This commit is contained in:
Hamza-Ayed
2025-03-08 19:35:09 +03:00
parent d41314cfed
commit 5a4664ed67
30 changed files with 433 additions and 306 deletions

View File

@@ -11,6 +11,7 @@ import 'package:flutter_paypal/flutter_paypal.dart';
import 'package:flutter_stripe/flutter_stripe.dart';
import 'package:get/get.dart';
import 'package:local_auth/local_auth.dart';
import 'package:sefer_driver/views/widgets/mydialoug.dart';
import '../../constant/box_name.dart';
import '../../constant/colors.dart';
@@ -158,8 +159,7 @@ class PaymentController extends GetxController {
billingDetails: BillingDetails(
name: EncryptionHelper.instance
.decryptData(box.read(BoxName.nameDriver)),
email: EncryptionHelper.instance
.decryptData(box.read(BoxName.emailDriver)),
email: (box.read(BoxName.emailDriver)),
phone: EncryptionHelper.instance
.decryptData(box.read(BoxName.phoneDriver)),
address: Address(
@@ -578,6 +578,9 @@ class PaymentController extends GetxController {
// 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)
),
);
if (didAuthenticate) {
final PaymobResponseWallet? response =
@@ -589,32 +592,10 @@ class PaymentController extends GetxController {
billingData: PaymobBillingDataWallet(),
onPayment: (PaymobResponseWallet response) {},
);
// Log.print('message: ${response!.message}');
// Log.print('responseCode: ${response.responseCode}');
// Log.print('success: ${response.success}');
// Log.print('transactionID: ${response.transactionID}');
if (response!.success == true &&
response.message.toString() == 'Approved') {
// Log.print('transactionID wewer: ${response.transactionID}');
Toast.show(context, 'Payment Successful'.tr, AppColor.greenColor);
method();
// Get.defaultDialog(
// barrierDismissible: false,
// title: 'Payment Successful'.tr,
// titleStyle: AppStyle.title,
// content: Text(
// 'The payment was approved.'.tr,
// style: AppStyle.title,
// ),
// confirm: MyElevatedButton(
// title: 'OK'.tr,
// kolor: AppColor.greenColor,
// onPressed: () async {
// Get.back();
// method();
// },
// ),
// );
} else {
Get.defaultDialog(
barrierDismissible: false,
@@ -653,57 +634,64 @@ class PaymentController extends GetxController {
}
} else {
// Authentication failed, handle accordingly
MyDialog().getDialog('Authentication failed'.tr, ''.tr, () {
Get.back();
});
}
} else {
final PaymobResponse? response = await PaymobPayment.instance.pay(
context: context,
currency: currency, //"EGP",
amountInCents: newAmount, // 19.00 EGP
billingData: PaymobBillingData(),
onPayment: (PaymobResponse response) {},
);
MyDialog().getDialog('Biometric Authentication'.tr,
'You should use Touch ID or Face ID to confirm payment'.tr, () {
Get.back();
});
// 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') {
if (response!.responseCode == '200' && response.success == true) {
Toast.show(context, 'Payment Successful'.tr, AppColor.greenColor);
method();
// 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: Text(
'The payment was not approved. Please try again.'.tr,
textAlign: TextAlign.center,
style: AppStyle.title,
),
confirm: MyElevatedButton(
title: 'OK'.tr,
kolor: AppColor.redColor,
onPressed: () async {
Get.back();
},
),
);
}
// // if (response!.responseCode == 'APPROVED') {
// if (response!.responseCode == '200' && response.success == true) {
// Toast.show(context, 'Payment Successful'.tr, AppColor.greenColor);
// method();
// 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: Text(
// 'The payment was not approved. Please try again.'.tr,
// textAlign: TextAlign.center,
// style: AppStyle.title,
// ),
// confirm: MyElevatedButton(
// title: 'OK'.tr,
// kolor: AppColor.redColor,
// onPressed: () async {
// Get.back();
// },
// ),
// );
// }
}
} catch (e) {
Get.defaultDialog(