This commit is contained in:
Hamza Aleghwairyeen
2024-04-17 00:54:01 +03:00
parent 24b3804045
commit d450ad0f93
7 changed files with 236 additions and 78 deletions

View File

@@ -517,6 +517,14 @@ class MyTranslation extends Translations {
'اربح 300 جنيه ! كل 300 نقطة تمنحك 300 جنيه. اذهب واستفد من نقاطك!',
'the 300 points equal 300 L.E':
'الـ 300 نقطة تساوي 30 جنيه بالنسبة لك ',
'The payment was not approved. Please try again.':
'لم يتم الموافقة على الدفع. الرجاء المحاولة مرة أخرى.',
'Payment Failed': 'فشل الدفع',
'Error': 'خطأ',
'An error occurred during the payment process.':
'حدث خطأ أثناء عملية الدفع.',
'The payment was approved.': 'تمت الموافقة على الدفع.',
'Payment Successful': 'نجح الدفع',
'No ride found yet': '‏لا يوجد طلبات متوفرة حاليا',
'Accept Order': "‏اقبل الطلب",
'reject your order.': "رفض طلبك.",
@@ -609,7 +617,7 @@ class MyTranslation extends Translations {
'insert amount': "إدراج المبلغ",
'You can buy Points to let you online\nby this list below':
"يمكنك شراء النقاط للبقاء على وضع الاتصال\nمن خلال القائمة أدناه",
'Create Wallet to recive your money': "إنشاء محفظة لاستلام أموالك",
'Create Wallet to receive your money': "إنشاء محفظة لاستلام أموالك",
'Enter your feedback here': "أدخل تعليقاتك هنا",
'Please enter your feedback.': "الرجاء إدخال تعليقاتك.",
'Feedback': "تعليق",

View File

@@ -23,18 +23,19 @@ class PassengerWalletHistoryController extends GetxController {
print(archive);
isLoading = false;
update();
} else {}
Get.defaultDialog(
barrierDismissible: false,
title: 'No wallet record found'.tr,
titleStyle: AppStyle.title,
middleText: '',
confirm: MyElevatedButton(
title: 'OK'.tr,
onPressed: () {
Get.back();
Get.back();
}));
} else {
Get.defaultDialog(
barrierDismissible: false,
title: 'No wallet record found'.tr,
titleStyle: AppStyle.title,
middleText: '',
confirm: MyElevatedButton(
title: 'OK'.tr,
onPressed: () {
Get.back();
Get.back();
}));
}
}
@override

View File

@@ -1,5 +1,7 @@
import 'dart:convert';
import 'package:SEFER/constant/api_key.dart';
import 'package:SEFER/constant/style.dart';
import 'package:SEFER/views/widgets/elevated_btn.dart';
import 'package:http/http.dart' as http;
import 'package:flutter/material.dart';
import 'package:flutter_paypal/flutter_paypal.dart';
@@ -260,7 +262,9 @@ class PaymentController extends GetxController {
"amount": {
//sb-opsju26682403@personal.example.com
"total": '$selectedAmount',
"currency": "USD",
"currency": box.read(BoxName.countryCode) == 'Egypt'
? 'EGP'
: "JOD",
"details": {
"subtotal": '$selectedAmount',
"shipping": '0',
@@ -459,36 +463,125 @@ class PaymentController extends GetxController {
}
Future<void> payWithPayMob(
BuildContext context, String amount, currency) async {
BuildContext context, String amount, currency, Function method) async {
String newAmount = (double.parse(amount) * 100).toStringAsFixed(2);
try {
final PaymobResponse? response = await PaymobPayment.instance.pay(
context: context,
currency: currency, //"EGP",
amountInCents: amount, // 19.00 EGP
onPayment: (PaymobResponse response) {
print('Success: ${response.success}');
print('Transaction ID: ${response.transactionID}');
print('Response Code: ${response.responseCode}');
// print('Message: ${response.message}');
},
);
bool isAvailable = await LocalAuthentication().isDeviceSupported();
if (isAvailable) {
// Authenticate the user
bool didAuthenticate = await LocalAuthentication().authenticate(
localizedReason: 'Use Touch ID or Face ID to confirm payment',
);
if (didAuthenticate) {
final PaymobResponse? response = await PaymobPayment.instance.pay(
context: context,
currency: currency, //"EGP",
amountInCents: newAmount, // 19.00 EGP
onPayment: (PaymobResponse response) {
print('Success: ${response.success}');
print('Transaction ID: ${response.transactionID}');
print('Response Code: ${response.responseCode}');
// print('Message: ${response.message}');
},
);
if (response!.responseCode == 'APPROVED') {
Get.defaultDialog(
title: 'Payment Successful',
content: const Text('The payment was approved.'),
);
if (response!.responseCode == 'APPROVED') {
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,
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();
},
),
);
}
} else {
// Authentication failed, handle accordingly
print('Authentication failed');
}
} else {
Get.defaultDialog(
title: 'Payment Failed',
content:
const Text('The payment was not approved. Please try again.'),
final PaymobResponse? response = await PaymobPayment.instance.pay(
context: context,
currency: currency, //"EGP",
amountInCents: newAmount, // 19.00 EGP
onPayment: (PaymobResponse response) {
// print('Success: ${response.success}');
// print('Transaction ID: ${response.transactionID}');
// print('Response Code: ${response.responseCode}');
// print('Message: ${response.message}');
},
);
if (response!.responseCode == 'APPROVED') {
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,
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(
title: 'Error',
content: const Text('An error occurred during the payment process.'),
title: 'Error'.tr,
content: Text(
'An error occurred during the payment process.'.tr,
style: AppStyle.title,
),
);
rethrow;
}