|
|
|
|
@ -16,6 +16,8 @@ import 'package:hmg_patient_app_new/extensions/widget_extensions.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/habib_wallet/habib_wallet_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/payfort/models/apple_pay_request_insert_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/payfort/payfort_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/paytabs/models/paytabs_transaction_response_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/features/paytabs/paytabs_view_model.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/generated/locale_keys.g.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/services/navigation_service.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/widgets/appbar/collapsing_list_view.dart';
|
|
|
|
|
@ -35,6 +37,7 @@ class WalletPaymentConfirmPage extends StatefulWidget {
|
|
|
|
|
|
|
|
|
|
class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
|
|
|
|
|
late PayfortViewModel payfortViewModel;
|
|
|
|
|
late PayTabsViewModel paytabsViewModel;
|
|
|
|
|
late AppState appState;
|
|
|
|
|
late HabibWalletViewModel habibWalletVM;
|
|
|
|
|
|
|
|
|
|
@ -56,6 +59,7 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
|
|
|
|
|
appState = getIt.get<AppState>();
|
|
|
|
|
habibWalletVM = Provider.of<HabibWalletViewModel>(context, listen: false);
|
|
|
|
|
payfortViewModel = Provider.of<PayfortViewModel>(context, listen: false);
|
|
|
|
|
paytabsViewModel = Provider.of<PayTabsViewModel>(context, listen: false);
|
|
|
|
|
return Scaffold(
|
|
|
|
|
backgroundColor: AppColors.bgScaffoldColor,
|
|
|
|
|
body: Column(
|
|
|
|
|
@ -102,7 +106,66 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
|
|
|
|
|
).paddingSymmetrical(16.h, 16.h),
|
|
|
|
|
).paddingSymmetrical(24.h, 0.h).onPress(() {
|
|
|
|
|
selectedPaymentMethod = "MADA";
|
|
|
|
|
openPaymentURL("mada");
|
|
|
|
|
if (appState.isPaytabsEnabled) {
|
|
|
|
|
paytabsViewModel.setPaymentConfiguration("Advance Payment", habibWalletVM.walletRechargeAmount);
|
|
|
|
|
paytabsViewModel.startCardPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async {
|
|
|
|
|
LoaderBottomSheet.showLoader();
|
|
|
|
|
await habibWalletVM.HISCreateAdvancePayment(
|
|
|
|
|
paymentMethodName: selectedPaymentMethod,
|
|
|
|
|
paidAmount: habibWalletVM.walletRechargeAmount,
|
|
|
|
|
paymentReference: transactionData.transactionReference!,
|
|
|
|
|
patientID: habibWalletVM.fileNumber,
|
|
|
|
|
projectID: habibWalletVM.selectedHospital!.iD!,
|
|
|
|
|
depositorName: habibWalletVM.depositorName,
|
|
|
|
|
onSuccess: (value) async {
|
|
|
|
|
await habibWalletVM.addAdvanceNumberRequest(
|
|
|
|
|
advanceNumber: Utils.isVidaPlusProject(habibWalletVM.selectedHospital!.iD)
|
|
|
|
|
? value.data['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString()
|
|
|
|
|
: value.data['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
|
|
|
|
|
paymentReference: transactionData.transactionReference!,
|
|
|
|
|
onSuccess: (value) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
showCommonBottomSheetWithoutHeight(getIt.get<NavigationService>().navigatorKey.currentContext!, child: Utils.getSuccessWidget(loadingText: "Payment Successful!"),
|
|
|
|
|
callBackFunc: () {
|
|
|
|
|
habibWalletVM.initHabibWalletProvider();
|
|
|
|
|
habibWalletVM.getPatientBalanceAmount();
|
|
|
|
|
Navigator.of(getIt.get<NavigationService>().navigatorKey.currentContext!).pop();
|
|
|
|
|
Navigator.of(getIt.get<NavigationService>().navigatorKey.currentContext!).pop();
|
|
|
|
|
}, isFullScreen: false, isCloseButtonVisible: true, isAutoDismiss: true);
|
|
|
|
|
},
|
|
|
|
|
onError: (err) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: LocaleKeys.paymentFailedPleaseTryAgain.tr(context: context)),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onError: (err) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: err),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}, onError: (err) {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: err.toString()),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
openPaymentURL("mada");
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
SizedBox(height: 16.h),
|
|
|
|
|
Container(
|
|
|
|
|
@ -144,7 +207,66 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
|
|
|
|
|
).paddingSymmetrical(16.h, 16.h),
|
|
|
|
|
).paddingSymmetrical(24.h, 0.h).onPress(() {
|
|
|
|
|
selectedPaymentMethod = "VISA";
|
|
|
|
|
openPaymentURL("visa");
|
|
|
|
|
if (appState.isPaytabsEnabled) {
|
|
|
|
|
paytabsViewModel.setPaymentConfiguration("Advance Payment", habibWalletVM.walletRechargeAmount);
|
|
|
|
|
paytabsViewModel.startCardPayment(onSuccess: (PaytabsTransactionResponseModel transactionData) async {
|
|
|
|
|
LoaderBottomSheet.showLoader();
|
|
|
|
|
await habibWalletVM.HISCreateAdvancePayment(
|
|
|
|
|
paymentMethodName: selectedPaymentMethod,
|
|
|
|
|
paidAmount: habibWalletVM.walletRechargeAmount,
|
|
|
|
|
paymentReference: transactionData.transactionReference!,
|
|
|
|
|
patientID: habibWalletVM.fileNumber,
|
|
|
|
|
projectID: habibWalletVM.selectedHospital!.iD!,
|
|
|
|
|
depositorName: habibWalletVM.depositorName,
|
|
|
|
|
onSuccess: (value) async {
|
|
|
|
|
await habibWalletVM.addAdvanceNumberRequest(
|
|
|
|
|
advanceNumber: Utils.isVidaPlusProject(habibWalletVM.selectedHospital!.iD)
|
|
|
|
|
? value.data['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString()
|
|
|
|
|
: value.data['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
|
|
|
|
|
paymentReference: transactionData.transactionReference!,
|
|
|
|
|
onSuccess: (value) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
showCommonBottomSheetWithoutHeight(getIt.get<NavigationService>().navigatorKey.currentContext!, child: Utils.getSuccessWidget(loadingText: "Payment Successful!"),
|
|
|
|
|
callBackFunc: () {
|
|
|
|
|
habibWalletVM.initHabibWalletProvider();
|
|
|
|
|
habibWalletVM.getPatientBalanceAmount();
|
|
|
|
|
Navigator.of(getIt.get<NavigationService>().navigatorKey.currentContext!).pop();
|
|
|
|
|
Navigator.of(getIt.get<NavigationService>().navigatorKey.currentContext!).pop();
|
|
|
|
|
}, isFullScreen: false, isCloseButtonVisible: true, isAutoDismiss: true);
|
|
|
|
|
},
|
|
|
|
|
onError: (err) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: LocaleKeys.paymentFailedPleaseTryAgain.tr(context: context)),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onError: (err) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: err),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
}, onError: (err) {
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: err.toString()),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
openPaymentURL("visa");
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -197,9 +319,7 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
|
|
|
|
|
).paddingSymmetrical(24.h, 0.h),
|
|
|
|
|
SizedBox(height: 12.h),
|
|
|
|
|
Platform.isIOS
|
|
|
|
|
? Utils.buildSvgWithAssets(
|
|
|
|
|
icon: AppAssets.apple_pay_button,
|
|
|
|
|
width: 200.h, height: 56.h, fit: BoxFit.contain, applyThemeColor: false).paddingSymmetrical(24.h, 0.h).onPress(() {
|
|
|
|
|
? Utils.buildSvgWithAssets(icon: AppAssets.apple_pay_button, width: 200.h, height: 56.h, fit: BoxFit.contain, applyThemeColor: false).paddingSymmetrical(24.h, 0.h).onPress(() {
|
|
|
|
|
if (Utils.havePrivilege(103)) {
|
|
|
|
|
startApplePay();
|
|
|
|
|
} else {
|
|
|
|
|
@ -321,16 +441,12 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
|
|
|
|
|
onSuccess: (value) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
showCommonBottomSheetWithoutHeight(getIt.get<NavigationService>().navigatorKey.currentContext!, child: Utils.getSuccessWidget(loadingText: "Payment Successful!"),
|
|
|
|
|
callBackFunc: () {
|
|
|
|
|
habibWalletVM.initHabibWalletProvider();
|
|
|
|
|
habibWalletVM.getPatientBalanceAmount();
|
|
|
|
|
callBackFunc: () {
|
|
|
|
|
habibWalletVM.initHabibWalletProvider();
|
|
|
|
|
habibWalletVM.getPatientBalanceAmount();
|
|
|
|
|
Navigator.of(getIt.get<NavigationService>().navigatorKey.currentContext!).pop();
|
|
|
|
|
Navigator.of(getIt.get<NavigationService>().navigatorKey.currentContext!).pop();
|
|
|
|
|
},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
isAutoDismiss: true
|
|
|
|
|
);
|
|
|
|
|
}, isFullScreen: false, isCloseButtonVisible: true, isAutoDismiss: true);
|
|
|
|
|
},
|
|
|
|
|
onError: (err) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
@ -343,7 +459,16 @@ class _WalletPaymentConfirmPageState extends State<WalletPaymentConfirmPage> {
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
onError: (err) {});
|
|
|
|
|
onError: (err) {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
context,
|
|
|
|
|
child: Utils.getErrorWidget(loadingText: err),
|
|
|
|
|
callBackFunc: () {},
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
isCloseButtonVisible: true,
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
LoaderBottomSheet.hideLoader();
|
|
|
|
|
showCommonBottomSheetWithoutHeight(
|
|
|
|
|
|