@ -94,13 +94,16 @@ class _OffersAndDiscountPaymentPageState extends State<OffersAndDiscountPaymentP
if ( selectedOffer = = null ) {
if ( selectedOffer = = null ) {
return Center (
return Center (
child: Column (
child: Container (
mainAxisAlignment: MainAxisAlignment . center ,
color: AppColors . bgScaffoldColor ,
children: [
child: Column (
Icon ( Icons . error_outline , size: 64. h , color: AppColors . errorColor ) ,
mainAxisAlignment: MainAxisAlignment . center ,
SizedBox ( height: 16. h ) ,
children: [
LocaleKeys . noDataAvailable . tr ( context: context ) . toText16 ( ) ,
Icon ( Icons . error_outline , size: 64. h , color: AppColors . errorColor ) ,
] ,
SizedBox ( height: 16. h ) ,
LocaleKeys . noDataAvailable . tr ( context: context ) . toText16 ( ) ,
] ,
) ,
) ,
) ,
) ;
) ;
}
}
@ -111,225 +114,240 @@ class _OffersAndDiscountPaymentPageState extends State<OffersAndDiscountPaymentP
child: CollapsingListView (
child: CollapsingListView (
title: " ${ LocaleKeys . offerAndPackages . tr ( context: context ) } ${ LocaleKeys . payment . tr ( context: context ) } " ,
title: " ${ LocaleKeys . offerAndPackages . tr ( context: context ) } ${ LocaleKeys . payment . tr ( context: context ) } " ,
child: SingleChildScrollView (
child: SingleChildScrollView (
child: Column (
child: Container (
crossAxisAlignment: CrossAxisAlignment . start ,
color: AppColors . bgScaffoldColor ,
children: [
child: Column (
SizedBox ( height: 24. h ) ,
crossAxisAlignment: CrossAxisAlignment . start ,
/ / Offer Summary Card
children: [
Container (
SizedBox ( height: 24. h ) ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
/ / Offer Summary Card
color: AppColors . whiteColor ,
Container (
borderRadius: 20. h ,
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
hasShadow: false ,
color: AppColors . whiteColor ,
) ,
borderRadius: 20. h ,
child: Column (
hasShadow: false ,
crossAxisAlignment: CrossAxisAlignment . start ,
) ,
children: [
child: Column (
( appState . getLanguageID ( ) = = 1 ? selectedOffer . nameAr : selectedOffer . name ) . toText18 ( isBold: true ) ,
crossAxisAlignment: CrossAxisAlignment . start ,
SizedBox ( height: 8. h ) ,
children: [
Row (
( appState . getLanguageID ( ) = = 1 ? selectedOffer . nameAr : selectedOffer . name ) . toText18 ( isBold: true ) ,
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
SizedBox ( height: 8. h ) ,
children: [
Row (
LocaleKeys . price . tr ( context: context ) . toText14 ( color: AppColors . greyTextColor ) ,
mainAxisAlignment: MainAxisAlignment . spaceBetween ,
" ${ selectedOffer . vatExclusivePrice } ${ selectedOffer . currency } " . toText16 ( isBold: true , color: AppColors . primaryRedColor ) ,
children: [
] ,
LocaleKeys . price . tr ( context: context ) . toText14 ( color: AppColors . greyTextColor ) ,
) ,
" ${ selectedOffer . vatExclusivePrice } ${ selectedOffer . currency } " . toText16 ( isBold: true , color: AppColors . primaryRedColor ) ,
] ,
] ,
) . paddingSymmetrical ( 16. h , 16. h ) ,
) . paddingSymmetrical ( 24. h , 0. h ) ,
SizedBox ( height: 24. h ) ,
LocaleKeys . selectPaymentMethod . tr ( context: context ) . toText18 ( isBold: true ) . paddingSymmetrical ( 24. h , 0. h ) ,
SizedBox ( height: 16. h ) ,
Container (
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . whiteColor ,
borderRadius: 20. h ,
hasShadow: false ,
) ,
child: Row (
mainAxisSize: MainAxisSize . max ,
children: [
Column (
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
Utils . buildImgWithAssets ( icon: AppAssets . mada , width: 72. h , height: 25. h , fit: BoxFit . contain ) ,
SizedBox ( height: 16. h ) ,
LocaleKeys . mada . tr ( context: context ) . toText16 ( isBold: true ) ,
] ,
) ,
SizedBox ( width: 8. h ) ,
const Spacer ( ) ,
Transform . flip (
flipX: appState . isArabic ( ) ,
child: Utils . buildSvgWithAssets (
icon: AppAssets . forward_arrow_icon ,
iconColor: AppColors . blackColor ,
width: 40. h ,
height: 40. h ,
fit: BoxFit . contain ,
) ,
) ,
) ,
] ,
] ,
) . paddingSymmetrical ( 16. h , 16. h ) ,
) . paddingSymmetrical ( 16.h , 16 .h ) ,
) . paddingSymmetrical ( 24. h , 0. h ) ,
) . paddingSymmetrical ( 24. h , 0. h ) . onPress ( ( ) async {
SizedBox ( height: 24. h ) ,
selectedPaymentMethod = " MADA " ;
LocaleKeys . selectPaymentMethod . tr ( context: context ) . toText18 ( isBold: true ) . paddingSymmetrical ( 24. h , 0. h ) ,
SizedBox ( height: 16. h ) ,
/ / Create order first to get order_ref
Container (
LoaderBottomSheet . showLoader ( loadingText: LocaleKeys . fetchingPaymentInformation . tr ( context: context ) ) ;
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
String ? orderRef = await createOrder ( ) ;
color: AppColors . whiteColor ,
borderRadius: 20. h ,
if ( orderRef = = null ) {
hasShadow: false ,
/ / Error already shown in createOrder
) ,
return ;
child: Row (
}
mainAxisSize: MainAxisSize . max ,
children: [
transID = orderRef ;
Column (
crossAxisAlignment: CrossAxisAlignment . start ,
if ( appState . isPaytabsEnabled ) {
children: [
LoaderBottomSheet . hideLoader ( ) ;
Utils . buildImgWithAssets ( icon: AppAssets . mada , width: 72. h , height: 25. h , fit: BoxFit . contain ) ,
paytabsViewModel . setPaymentConfiguration (
SizedBox ( height: 16. h ) ,
LocaleKeys . offerPayment . tr ( context: context ) ,
LocaleKeys . mada . tr ( context: context ) . toText16 ( isBold: true ) ,
getPaymentAmount ( ) ,
] ,
) ;
) ,
paytabsViewModel . startCardPayment ( onSuccess: ( PaytabsTransactionResponseModel transactionData ) async {
SizedBox ( width: 8. h ) ,
await completePaymentResult ( paymentStatus: " success " ) ;
const Spacer ( ) ,
} , onError: ( err ) {
Transform . flip (
showCommonBottomSheetWithoutHeight (
flipX: appState . isArabic ( ) ,
context ,
child: Utils . buildSvgWithAssets (
child: Utils . getErrorWidget ( loadingText: err . toString ( ) ) ,
icon: AppAssets . forward_arrow_icon ,
callBackFunc: ( ) { } ,
iconColor: AppColors . blackColor ,
isFullScreen: false ,
width: 40. h ,
isCloseButtonVisible: true ,
height: 40. h ,
) ;
fit: BoxFit . contain ,
} ) ;
) ,
} else {
) ,
if ( appState . isPayfortHostedPageEnabled ) {
] ,
await payfortViewModel . getPayfortConfigurations ( serviceId: ServiceTypeEnum . offerPayment . getIdFromServiceEnum ( ) , projectId: 0 , integrationId: 1 ) ;
) . paddingSymmetrical ( 16. h , 16. h ) ,
) . paddingSymmetrical ( 24. h , 0. h ) . onPress ( ( ) async {
payfortViewModel . initiatePaymentWithCard (
selectedPaymentMethod = " MADA " ;
transactionID: transID ,
fileNumber: appState . getAuthenticatedUser ( ) ! . patientId . toString ( ) ,
/ / Create order first to get order_ref
amount: getPaymentAmount ( ) . toString ( ) ,
LoaderBottomSheet . showLoader ( loadingText: LocaleKeys . fetchingPaymentInformation . tr ( context: context ) ) ;
onSucceeded: ( paymentResult ) async {
String ? orderRef = await createOrder ( ) ;
print ( " Payment Success Data: ${ paymentResult . toString ( ) } " ) ;
await completePaymentResult ( paymentStatus: " success " ) ;
if ( orderRef = = null ) {
} ,
/ / Error already shown in createOrder
onFailed: ( err ) {
return ;
print (" Payment Failed Data: ${ err . toString ( ) }" ) ;
}
showCommonBottomSheetWithoutHeight (
context ,
transID = orderRef ;
child: Utils . getErrorWidget ( loadingText: LocaleKeys . paymentFailedPleaseTryAgain . tr ( context: context ) ) ,
callBackFunc: ( ) { } ,
if ( appState . isPaytabsEnabled ) {
isFullScreen: false ,
LoaderBottomSheet . hideLoader ( ) ;
isCloseButtonVisible: true ,
paytabsViewModel . setPaymentConfiguration (
) ;
LocaleKeys . offerPayment . tr ( context: context ) ,
} ,
getPaymentAmount ( ) ,
) ;
) ;
paytabsViewModel . startCardPayment ( onSuccess: ( PaytabsTransactionResponseModel transactionData ) async {
await completePaymentResult ( paymentStatus: " success " ) ;
} , onError: ( err ) {
showCommonBottomSheetWithoutHeight (
context ,
child: Utils . getErrorWidget ( loadingText: err . toString ( ) ) ,
callBackFunc: ( ) { } ,
isFullScreen: false ,
isCloseButtonVisible: true ,
) ;
} ) ;
} else {
} else {
LoaderBottomSheet . hideLoader ( ) ;
if ( appState . isPayfortHostedPageEnabled ) {
openPaymentURL ( " mada " , getPaymentAmount ( ) ) ;
await payfortViewModel . getPayfortConfigurations ( serviceId: ServiceTypeEnum . offerPayment . getIdFromServiceEnum ( ) , projectId: 0 , integrationId: 1 ) ;
payfortViewModel . initiatePaymentWithCard (
" mada " ,
ServiceTypeEnum . offerPayment . getIdFromServiceEnum ( ) . toString ( ) ,
" false " ,
DateUtil . convertDateToString ( DateTime . now ( ) ) ,
" 0 " ,
" 0 " ,
transactionID: transID ,
fileNumber: appState . getAuthenticatedUser ( ) ! . patientId . toString ( ) ,
amount: getPaymentAmount ( ) . toString ( ) ,
onSucceeded: ( paymentResult ) async {
print ( " Payment Success Data: ${ paymentResult . toString ( ) } " ) ;
await completePaymentResult ( paymentStatus: " success " ) ;
} ,
onFailed: ( err ) {
print ( " Payment Failed Data: ${ err . toString ( ) } " ) ;
showCommonBottomSheetWithoutHeight (
context ,
child: Utils . getErrorWidget ( loadingText: LocaleKeys . paymentFailedPleaseTryAgain . tr ( context: context ) ) ,
callBackFunc: ( ) { } ,
isFullScreen: false ,
isCloseButtonVisible: true ,
) ;
} ,
) ;
} else {
LoaderBottomSheet . hideLoader ( ) ;
openPaymentURL ( " mada " , getPaymentAmount ( ) ) ;
}
}
}
}
} ) ,
} ) ,
SizedBox ( height: 16. h ) ,
SizedBox ( height: 16. h ) ,
Container (
Container (
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
decoration: RoundedRectangleBorder ( ) . toSmoothCornerDecoration (
color: AppColors . whiteColor ,
color: AppColors . whiteColor ,
borderRadius: 20. h ,
borderRadius: 20. h ,
hasShadow: false ,
hasShadow: false ,
) ,
) ,
child: Row (
child: Row (
mainAxisSize: MainAxisSize . max ,
mainAxisSize: MainAxisSize . max ,
children: [
children: [
Column (
Column (
crossAxisAlignment: CrossAxisAlignment . start ,
crossAxisAlignment: CrossAxisAlignment . start ,
children: [
children: [
Row (
Row (
children: [
children: [
Utils . buildImgWithAssets ( icon: AppAssets . visa , width: 50. h , height: 50. h ) ,
Utils . buildImgWithAssets ( icon: AppAssets . visa , width: 50. h , height: 50. h ) ,
SizedBox ( width: 8. h ) ,
SizedBox ( width: 8. h ) ,
Utils . buildImgWithAssets ( icon: AppAssets . mastercard , width: 40. h , height: 40. h , fit: BoxFit . contain ) ,
Utils . buildImgWithAssets ( icon: AppAssets . mastercard , width: 40. h , height: 40. h , fit: BoxFit . contain ) ,
] ,
] ,
) ,
SizedBox ( height: 16. h ) ,
LocaleKeys . visaOrMastercard . tr ( context: context ) . toText16 ( isBold: true ) ,
] ,
) ,
SizedBox ( width: 8. h ) ,
const Spacer ( ) ,
Transform . flip (
flipX: appState . isArabic ( ) ,
child: Utils . buildSvgWithAssets (
icon: AppAssets . forward_arrow_icon ,
iconColor: AppColors . blackColor ,
width: 40. h ,
height: 40. h ,
fit: BoxFit . contain ,
) ,
) ,
SizedBox ( height: 16. h ) ,
LocaleKeys . visaOrMastercard . tr ( context: context ) . toText16 ( isBold: true ) ,
] ,
) ,
SizedBox ( width: 8. h ) ,
const Spacer ( ) ,
Transform . flip (
flipX: appState . isArabic ( ) ,
child: Utils . buildSvgWithAssets (
icon: AppAssets . forward_arrow_icon ,
iconColor: AppColors . blackColor ,
width: 40. h ,
height: 40. h ,
fit: BoxFit . contain ,
) ,
) ,
) ,
] ,
] ,
) . paddingSymmetrical ( 16. h , 16. h ) ,
) . paddingSymmetrical ( 16. h , 16. h ) ,
) . paddingSymmetrical ( 24. h , 0. h ) . onPress ( ( ) async {
) . paddingSymmetrical ( 24. h , 0. h ) . onPress ( ( ) async {
selectedPaymentMethod = " VISA " ;
selectedPaymentMethod = " VISA " ;
/ / Create order first to get order_ref
/ / Create order first to get order_ref
LoaderBottomSheet . showLoader ( loadingText: LocaleKeys . fetchingPaymentInformation . tr ( context: context ) ) ;
LoaderBottomSheet . showLoader ( loadingText: LocaleKeys . fetchingPaymentInformation . tr ( context: context ) ) ;
String ? orderRef = await createOrder ( ) ;
String ? orderRef = await createOrder ( ) ;
if ( orderRef = = null ) {
if ( orderRef = = null ) {
/ / Error already shown in createOrder
/ / Error already shown in createOrder
return ;
return ;
}
}
transID = orderRef ;
transID = orderRef ;
if ( appState . isPaytabsEnabled ) {
if ( appState . isPaytabsEnabled ) {
LoaderBottomSheet . hideLoader ( ) ;
LoaderBottomSheet . hideLoader ( ) ;
paytabsViewModel . setPaymentConfiguration (
paytabsViewModel . setPaymentConfiguration (
LocaleKeys . offerPayment . tr ( context: context ) ,
LocaleKeys . offerPayment . tr ( context: context ) ,
getPaymentAmount ( ) ,
getPaymentAmount ( ) ,
) ;
paytabsViewModel . startCardPayment ( onSuccess: ( PaytabsTransactionResponseModel transactionData ) async {
await completePaymentResult ( paymentStatus: " success " ) ;
} , onError: ( err ) {
showCommonBottomSheetWithoutHeight (
context ,
child: Utils . getErrorWidget ( loadingText: err . toString ( ) ) ,
callBackFunc: ( ) { } ,
isFullScreen: false ,
isCloseButtonVisible: true ,
) ;
} ) ;
} else {
if ( appState . isPayfortHostedPageEnabled ) {
await payfortViewModel . getPayfortConfigurations ( serviceId: ServiceTypeEnum . offerPayment . getIdFromServiceEnum ( ) , projectId: 0 , integrationId: 1 ) ;
payfortViewModel . initiatePaymentWithCard (
transactionID: transID ,
fileNumber: appState . getAuthenticatedUser ( ) ! . patientId . toString ( ) ,
amount: getPaymentAmount ( ) . toString ( ) ,
onSucceeded: ( paymentResult ) async {
print ( " Payment Success Data: ${ paymentResult . toString ( ) } " ) ;
await completePaymentResult ( paymentStatus: " success " ) ;
} ,
onFailed: ( err ) {
print ( " Payment Failed Data: ${ err . toString ( ) } " ) ;
showCommonBottomSheetWithoutHeight (
context ,
child: Utils . getErrorWidget ( loadingText: LocaleKeys . paymentFailedPleaseTryAgain . tr ( context: context ) ) ,
callBackFunc: ( ) { } ,
isFullScreen: false ,
isCloseButtonVisible: true ,
) ;
} ,
) ;
) ;
paytabsViewModel . startCardPayment ( onSuccess: ( PaytabsTransactionResponseModel transactionData ) async {
await completePaymentResult ( paymentStatus: " success " ) ;
} , onError: ( err ) {
showCommonBottomSheetWithoutHeight (
context ,
child: Utils . getErrorWidget ( loadingText: err . toString ( ) ) ,
callBackFunc: ( ) { } ,
isFullScreen: false ,
isCloseButtonVisible: true ,
) ;
} ) ;
} else {
} else {
LoaderBottomSheet . hideLoader ( ) ;
if ( appState . isPayfortHostedPageEnabled ) {
openPaymentURL ( " visa " , getPaymentAmount ( ) ) ;
await payfortViewModel . getPayfortConfigurations ( serviceId: ServiceTypeEnum . offerPayment . getIdFromServiceEnum ( ) , projectId: 0 , integrationId: 1 ) ;
payfortViewModel . initiatePaymentWithCard (
transactionID: transID ,
" visa " ,
ServiceTypeEnum . offerPayment . getIdFromServiceEnum ( ) . toString ( ) ,
" false " ,
DateUtil . convertDateToString ( DateTime . now ( ) ) ,
" 0 " ,
" 0 " ,
fileNumber: appState . getAuthenticatedUser ( ) ! . patientId . toString ( ) ,
amount: getPaymentAmount ( ) . toString ( ) ,
onSucceeded: ( paymentResult ) async {
print ( " Payment Success Data: ${ paymentResult . toString ( ) } " ) ;
await completePaymentResult ( paymentStatus: " success " ) ;
} ,
onFailed: ( err ) {
print ( " Payment Failed Data: ${ err . toString ( ) } " ) ;
showCommonBottomSheetWithoutHeight (
context ,
child: Utils . getErrorWidget ( loadingText: LocaleKeys . paymentFailedPleaseTryAgain . tr ( context: context ) ) ,
callBackFunc: ( ) { } ,
isFullScreen: false ,
isCloseButtonVisible: true ,
) ;
} ,
) ;
} else {
LoaderBottomSheet . hideLoader ( ) ;
openPaymentURL ( " visa " , getPaymentAmount ( ) ) ;
}
}
}
}
} ) ,
} ) ,
] ,
] ,
) ,
) ,
) ,
) ,
) ,
) ,
) ,