25-3/8/1
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -137,8 +137,7 @@ class PaymobManager extends GetxController {
|
||||
EncryptionHelper.instance.decryptData(box.read(BoxName.nameDriver)),
|
||||
"last_name": EncryptionHelper.instance
|
||||
.decryptData(box.read(BoxName.lastNameDriver)),
|
||||
"email": EncryptionHelper.instance
|
||||
.decryptData(box.read(BoxName.emailDriver)),
|
||||
"email": (box.read(BoxName.emailDriver)),
|
||||
"phone_number": EncryptionHelper.instance
|
||||
.decryptData(box.read(BoxName.phoneDriver)),
|
||||
"apartment": "NA",
|
||||
|
||||
@@ -224,8 +224,7 @@ class PaymobBillingData {
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"email":
|
||||
EncryptionHelper.instance.decryptData(box.read(BoxName.emailDriver)),
|
||||
"email": (box.read(BoxName.emailDriver)),
|
||||
"first_name": box.read(BoxName.nameDriver),
|
||||
"last_name": box.read(BoxName.nameDriver),
|
||||
"phone_number":
|
||||
|
||||
@@ -267,8 +267,7 @@ class PaymobBillingDataWallet {
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
"email":
|
||||
EncryptionHelper.instance.decryptData(box.read(BoxName.emailDriver)),
|
||||
"email": (box.read(BoxName.emailDriver)),
|
||||
"first_name": box.read(BoxName.name) ?? box.read(BoxName.nameDriver),
|
||||
"last_name": box.read(BoxName.name) ?? box.read(BoxName.nameDriver),
|
||||
"phone_number": (box.read(BoxName.phoneWallet)),
|
||||
|
||||
Reference in New Issue
Block a user