4/16/1
This commit is contained in:
@@ -7,6 +7,7 @@ import 'package:flutter_stripe/flutter_stripe.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:local_auth/local_auth.dart';
|
||||
import 'package:SEFER/controller/home/map_passenger_controller.dart';
|
||||
import 'package:paymob_payment/paymob_payment.dart';
|
||||
|
||||
import '../../constant/box_name.dart';
|
||||
import '../../constant/colors.dart';
|
||||
@@ -457,6 +458,42 @@ class PaymentController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> payWithPayMob(
|
||||
BuildContext context, String amount, currency) async {
|
||||
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}');
|
||||
},
|
||||
);
|
||||
|
||||
if (response!.responseCode == 'APPROVED') {
|
||||
Get.defaultDialog(
|
||||
title: 'Payment Successful',
|
||||
content: const Text('The payment was approved.'),
|
||||
);
|
||||
} else {
|
||||
Get.defaultDialog(
|
||||
title: 'Payment Failed',
|
||||
content:
|
||||
const Text('The payment was not approved. Please try again.'),
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
Get.defaultDialog(
|
||||
title: 'Error',
|
||||
content: const Text('An error occurred during the payment process.'),
|
||||
);
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void onInit() {
|
||||
timestamp = now.millisecondsSinceEpoch;
|
||||
|
||||
Reference in New Issue
Block a user