4/17/1
This commit is contained in:
@@ -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': "تعليق",
|
||||
|
||||
@@ -23,7 +23,7 @@ class PassengerWalletHistoryController extends GetxController {
|
||||
print(archive);
|
||||
isLoading = false;
|
||||
update();
|
||||
} else {}
|
||||
} else {
|
||||
Get.defaultDialog(
|
||||
barrierDismissible: false,
|
||||
title: 'No wallet record found'.tr,
|
||||
@@ -36,6 +36,7 @@ class PassengerWalletHistoryController extends GetxController {
|
||||
Get.back();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
|
||||
@@ -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,12 +463,20 @@ 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 {
|
||||
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: amount, // 19.00 EGP
|
||||
amountInCents: newAmount, // 19.00 EGP
|
||||
onPayment: (PaymobResponse response) {
|
||||
print('Success: ${response.success}');
|
||||
print('Transaction ID: ${response.transactionID}');
|
||||
@@ -475,20 +487,101 @@ class PaymentController extends GetxController {
|
||||
|
||||
if (response!.responseCode == 'APPROVED') {
|
||||
Get.defaultDialog(
|
||||
title: 'Payment Successful',
|
||||
content: const Text('The payment was approved.'),
|
||||
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(
|
||||
title: 'Payment Failed',
|
||||
content:
|
||||
const Text('The payment was not approved. Please try again.'),
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ GetBuilder<MapPassengerController> leftMainMenuIcons() {
|
||||
child: IconButton(
|
||||
onPressed: () async {
|
||||
// await PaymobManager().payWithPayMob(100, 'EGP');
|
||||
await Get.find<PaymentController>()
|
||||
.payWithPayMob(context, '11', 'EGP');
|
||||
// await Get.find<PaymentController>()
|
||||
// .payWithPayMob(context, '1100', 'EGP');
|
||||
// Initiates a payment with a card using the FlutterPaymob instance
|
||||
|
||||
// NotificationController()
|
||||
@@ -150,8 +150,8 @@ class PaymobPackage extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
await Get.find<PaymentController>()
|
||||
.payWithPayMob(context, '11', 'EGP');
|
||||
// await Get.find<PaymentController>()
|
||||
// .payWithPayMob(context, '11', 'EGP');
|
||||
},
|
||||
child: Container(
|
||||
width: 50,
|
||||
|
||||
@@ -53,14 +53,18 @@ class PassengerWalletDialoge extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Radio(
|
||||
value: 10,
|
||||
value: box.read(BoxName.countryCode) == 'Egypt'
|
||||
? 100
|
||||
: 10,
|
||||
groupValue: controller.selectedAmount,
|
||||
onChanged: (value) {
|
||||
controller.updateSelectedAmount(value as int);
|
||||
},
|
||||
),
|
||||
Text(
|
||||
'10\$ and get 3% discount'.tr,
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? '100 ${'LE'.tr}'.tr
|
||||
: '10\$ and get 3% discount',
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
@@ -73,7 +77,10 @@ class PassengerWalletDialoge extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Radio(
|
||||
value: 20,
|
||||
value:
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? 200
|
||||
: 20,
|
||||
groupValue: controller.selectedAmount,
|
||||
onChanged: (value) {
|
||||
controller
|
||||
@@ -81,7 +88,9 @@ class PassengerWalletDialoge extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
Text(
|
||||
'20\$ and get 4% discount'.tr,
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? '200 ${'LE'.tr} '.tr
|
||||
: '20 ${'JOD'.tr}'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
@@ -93,7 +102,10 @@ class PassengerWalletDialoge extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Radio(
|
||||
value: 40,
|
||||
value:
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? 400
|
||||
: 40,
|
||||
groupValue: controller.selectedAmount,
|
||||
onChanged: (value) {
|
||||
controller
|
||||
@@ -101,7 +113,9 @@ class PassengerWalletDialoge extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
Text(
|
||||
'40\$ and get 6% discount'.tr,
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? '400 ${'LE'.tr} '.tr
|
||||
: '40 ${'JOD'.tr}'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
@@ -113,7 +127,10 @@ class PassengerWalletDialoge extends StatelessWidget {
|
||||
child: Row(
|
||||
children: [
|
||||
Radio(
|
||||
value: 100,
|
||||
value:
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? 1000
|
||||
: 50,
|
||||
groupValue: controller.selectedAmount,
|
||||
onChanged: (value) {
|
||||
controller
|
||||
@@ -121,7 +138,9 @@ class PassengerWalletDialoge extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
Text(
|
||||
'100\$ and get 9% discount'.tr,
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? '1000 ${'LE'.tr} '.tr
|
||||
: '50 ${'JOD'.tr}'.tr,
|
||||
style: AppStyle.title,
|
||||
),
|
||||
],
|
||||
@@ -141,14 +160,37 @@ class PassengerWalletDialoge extends StatelessWidget {
|
||||
}
|
||||
},
|
||||
),
|
||||
MyElevatedButton(
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? MyElevatedButton(
|
||||
title: 'Pay with Credit Card'.tr,
|
||||
onPressed: () {
|
||||
if (controller.selectedAmount != 0) {
|
||||
controller.payWithPayMob(
|
||||
context,
|
||||
controller.selectedAmount
|
||||
.toString(), // Convert int to double
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? 'EGP'
|
||||
: 'JOD', () async {
|
||||
await controller.addPassengerWallet();
|
||||
controller.changePromoSheetDialogue();
|
||||
await controller.getPassengerWallet();
|
||||
});
|
||||
} else {
|
||||
Toast.show(
|
||||
context,
|
||||
'You will choose one of above !'.tr,
|
||||
AppColor.redColor);
|
||||
}
|
||||
})
|
||||
: MyElevatedButton(
|
||||
title: 'Pay with Credit Card'.tr,
|
||||
onPressed: () {
|
||||
if (controller.selectedAmount != 0) {
|
||||
controller.makePaymentStripe(
|
||||
controller.selectedAmount!
|
||||
.toDouble(), // Convert int to double
|
||||
box.read(BoxName.countryCode) != 'Egypt'.tr
|
||||
box.read(BoxName.countryCode) != 'Egypt'
|
||||
? 'EGP'
|
||||
: 'USD', () {
|
||||
controller.addPassengerWallet();
|
||||
|
||||
@@ -27,11 +27,25 @@ class PointsCaptain extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () async {
|
||||
await paymentController.makePaymentStripe(pricePoint,
|
||||
box.read(BoxName.countryCode) == 'Egypt'
|
||||
? await paymentController.payWithPayMob(
|
||||
context,
|
||||
pricePoint.toStringAsFixed(2),
|
||||
box.read(BoxName.countryCode) == 'Egypt' ? 'EGP' : 'JOD',
|
||||
() async {
|
||||
await captainWalletController.addDriverPayment(
|
||||
'visa', pricePoint);
|
||||
await captainWalletController.addDriverWallet(
|
||||
'visa', countPoint);
|
||||
await captainWalletController.getCaptainWalletFromBuyPoints();
|
||||
})
|
||||
: await paymentController.makePaymentStripe(pricePoint,
|
||||
box.read(BoxName.countryCode) == 'Jordan' ? 'jod' : 'egp',
|
||||
() async {
|
||||
await captainWalletController.addDriverPayment('visa', pricePoint);
|
||||
await captainWalletController.addDriverWallet('visa', countPoint);
|
||||
await captainWalletController.addDriverPayment(
|
||||
'visa', pricePoint);
|
||||
await captainWalletController.addDriverWallet(
|
||||
'visa', countPoint);
|
||||
await captainWalletController.getCaptainWalletFromBuyPoints();
|
||||
});
|
||||
},
|
||||
|
||||
@@ -350,7 +350,7 @@ class WalletCaptain extends StatelessWidget {
|
||||
children: [
|
||||
MyElevatedButton(
|
||||
title:
|
||||
'Create Wallet to recive your money',
|
||||
'Create Wallet to receive your money',
|
||||
onPressed: () async {
|
||||
PaymentController paymentController =
|
||||
Get.find<PaymentController>();
|
||||
|
||||
Reference in New Issue
Block a user