This commit is contained in:
Hamza-Ayed
2023-12-12 21:31:36 +03:00
parent ba90f96e77
commit 44505dd9ea
8 changed files with 216 additions and 170 deletions

View File

@@ -52,6 +52,8 @@ class HelpController extends GetxController {
});
if (res == "failure") {
// print(res);
isLoading = false;
update();
Get.defaultDialog(
title: 'There is no help Question here'.tr,
titleStyle: AppStyle.title,

View File

@@ -14,6 +14,7 @@ class CaptainWalletController extends GetxController {
final formKey = GlobalKey<FormState>();
String totalAmount = '0';
String totalPoints = '0';
Future getCaptainWalletFromRide() async {
isLoading = true;
update();
@@ -37,8 +38,14 @@ class CaptainWalletController extends GetxController {
payload: {'driverID': box.read(BoxName.driverID)},
);
walletDriverPointsDate = jsonDecode(res);
totalPoints =
walletDriverPointsDate['message'][0]['total_amount'].toString();
if (walletDriverPointsDate['message'][0]['driverID'].toString() ==
box.read(BoxName.driverID)) {
totalPoints =
walletDriverPointsDate['message'][0]['total_amount'].toString();
} else {
totalPoints = '0';
}
isLoading = false;
update();
}
@@ -64,10 +71,25 @@ class CaptainWalletController extends GetxController {
});
}
//check if account bank is created or not
Future checkAccountCaptainBank() async {
if (box.read(BoxName.accountIdStripeConnect).toString().isEmpty) {
var res = await CRUD().get(link: AppLink.getAccount, payload: {
'id': box.read(BoxName.driverID).toString(),
});
var d = jsonDecode(res);
if (d['status'] != 'failure') {
box.write(BoxName.accountIdStripeConnect,
d['message'][0]['accountBank'].toString());
}
}
}
@override
void onInit() {
getCaptainWalletFromRide();
getCaptainWalletFromBuyPoints();
checkAccountCaptainBank();
super.onInit();
}
}

View File

@@ -403,13 +403,24 @@ class PaymentController extends GetxController {
payload: body,
);
final responseData = jsonDecode(response);
print(responseData);
// print(responseData);
final accountId = responseData['id'];
box.write(BoxName.accountIdStripeConnect, accountId);
await updateCaptainAccountBank();
print('accountId = $accountId');
return accountId;
}
Future updateCaptainAccountBank() async {
var res = await CRUD().post(link: AppLink.updateAccountBank, payload: {
'id': box.read(BoxName.driverID),
'accountBank': box.read(BoxName.accountIdStripeConnect),
});
if (jsonDecode(res)['status'] == 'success') {
Get.snackbar('Account Updated', '');
}
}
Future<String> createTransactionToCaptain(
String amount, String account) async {
String url = 'https://api.stripe.com//v1/transfers';
@@ -427,7 +438,7 @@ class PaymentController extends GetxController {
final responseData = jsonDecode(response);
print(responseData);
final transactionId = responseData['id'];
box.write(BoxName.accountIdStripeConnect, transactionId);
print('transactionId = $transactionId');
return transactionId;
}