25-3/18/1

This commit is contained in:
Hamza-Ayed
2025-03-18 13:54:27 +03:00
parent 6e77dec65f
commit 153d2f64c0
1307 changed files with 9505 additions and 528 deletions

0
lib/controller/payment/driver_payment_controller.dart Normal file → Executable file
View File

158
lib/controller/payment/payment_controller.dart Normal file → Executable file
View File

@@ -56,7 +56,7 @@ class PaymentController extends GetxController {
isLoading = true;
update();
await CRUD().get(
await CRUD().getWallet(
link: AppLink.getWalletByPassenger,
payload: {'passenger_id': box.read(BoxName.passengerID)}).then((value) {
box.write(BoxName.passengerWalletTotal,
@@ -71,7 +71,7 @@ class PaymentController extends GetxController {
update();
// double sallaryAccountNowBeforeAdding =
// double.parse(box.read(BoxName.passengerWalletTotal).toString());
await CRUD().post(link: AppLink.addPassengersWallet, payload: {
await CRUD().postWallet(link: AppLink.addPassengersWallet, payload: {
'passenger_id': box.read(BoxName.passengerID).toString(),
'balance': selectedAmount.toString()
}).then((value) {
@@ -440,8 +440,11 @@ class PaymentController extends GetxController {
if (isAvailable) {
// Authenticate the user
bool didAuthenticate = await LocalAuthentication().authenticate(
localizedReason: 'Use Touch ID or Face ID to confirm payment',
);
localizedReason: 'Use Touch ID or Face ID to confirm payment',
options: AuthenticationOptions(
biometricOnly: true,
sensitiveTransaction: true,
));
if (didAuthenticate) {
final PaymobResponse? response = await PaymobPayment.instance.pay(
context: context,
@@ -490,73 +493,84 @@ class PaymentController extends GetxController {
);
}
} else {
Get.snackbar("Authentication Failed",
"Please enable Face ID or Fingerprint in your settings.");
// Authentication failed, handle accordingly
}
} else {
final PaymobResponse? response = await PaymobPayment.instance.pay(
context: context,
currency: currency, //"EGP",
amountInCents: newAmount, // 19.00 EGP
billingData: PaymobBillingData(),
onPayment: (PaymobResponse response) {},
);
if (response!.responseCode == 'APPROVED') {
Get.defaultDialog(
barrierDismissible: false,
title: 'Payment Successful'.tr,
titleStyle: AppStyle.title,
// backgroundColor: AppColor.greenColor,
content: Text(
'The payment was approved.'.tr,
style: AppStyle.title,
),
confirm: MyElevatedButton(
kolor: AppColor.greenColor,
title: 'OK'.tr,
onPressed: () async {
Get.back();
method();
},
),
);
} else {
Get.defaultDialog(
barrierDismissible: false,
// backgroundColor: AppColor.redColor,
title: 'Payment Failed'.tr,
content: Column(
children: [
IconButton(
onPressed: () {
Get.find<TextToSpeechController>().speakText(
'The payment was not approved. Please try again.'.tr,
);
},
icon: const Icon(Icons.headphones),
),
Text(
'The payment was not approved. Please try again.'.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
Text(
'${'The reason is'.tr} ${response.message!.tr}',
textAlign: TextAlign.center,
style: AppStyle.title.copyWith(color: AppColor.redColor),
),
],
),
confirm: MyElevatedButton(
title: 'OK'.tr,
kolor: AppColor.redColor,
onPressed: () async {
Get.back();
},
),
);
}
MyDialog().getDialog('Biometric Authentication'.tr,
'You should use Touch ID or Face ID to confirm payment'.tr, () {
Get.back();
});
// Authentication failed, handle accordingly
}
// else {
// final PaymobResponse? response = await PaymobPayment.instance.pay(
// context: context,
// currency: currency, //"EGP",
// amountInCents: newAmount, // 19.00 EGP
// billingData: PaymobBillingData(),
// onPayment: (PaymobResponse response) {},
// );
// if (response!.responseCode == 'APPROVED') {
// Get.defaultDialog(
// barrierDismissible: false,
// title: 'Payment Successful'.tr,
// titleStyle: AppStyle.title,
// // backgroundColor: AppColor.greenColor,
// content: Text(
// 'The payment was approved.'.tr,
// style: AppStyle.title,
// ),
// confirm: MyElevatedButton(
// kolor: AppColor.greenColor,
// title: 'OK'.tr,
// onPressed: () async {
// Get.back();
// method();
// },
// ),
// );
// } else {
// Get.defaultDialog(
// barrierDismissible: false,
// // backgroundColor: AppColor.redColor,
// title: 'Payment Failed'.tr,
// content: Column(
// children: [
// IconButton(
// onPressed: () {
// Get.find<TextToSpeechController>().speakText(
// 'The payment was not approved. Please try again.'.tr,
// );
// },
// icon: const Icon(Icons.headphones),
// ),
// Text(
// 'The payment was not approved. Please try again.'.tr,
// textAlign: TextAlign.center,
// style: AppStyle.title,
// ),
// Text(
// '${'The reason is'.tr} ${response.message!.tr}',
// textAlign: TextAlign.center,
// style: AppStyle.title.copyWith(color: AppColor.redColor),
// ),
// ],
// ),
// confirm: MyElevatedButton(
// title: 'OK'.tr,
// kolor: AppColor.redColor,
// onPressed: () async {
// Get.back();
// },
// ),
// );
// }
// }
} catch (e) {
Get.defaultDialog(
title: 'Error'.tr,
@@ -577,11 +591,11 @@ class PaymentController extends GetxController {
if (isAvailable) {
// Authenticate the user
bool didAuthenticate = await LocalAuthentication().authenticate(
localizedReason: 'Use Touch ID or Face ID to confirm payment',
options: const AuthenticationOptions(
biometricOnly: true, // Only biometrics (no fallback to PIN/pattern)
),
);
localizedReason: 'Use Touch ID or Face ID to confirm payment',
options: AuthenticationOptions(
biometricOnly: true,
sensitiveTransaction: true,
));
if (didAuthenticate) {
final PaymobResponseWallet? response =
await PaymobPaymentWallet.instance.pay(

0
lib/controller/payment/paymob.dart Normal file → Executable file
View File

0
lib/controller/payment/paymob/paymob_response.dart Normal file → Executable file
View File

0
lib/controller/payment/paymob/paymob_wallet.dart Normal file → Executable file
View File

0
lib/controller/payment/stripe.dart Normal file → Executable file
View File