Offers And Discounts

offers_discounts
Aamir Muhammad 3 weeks ago
parent 90aaed84ed
commit 558a957101

@ -768,7 +768,7 @@
"viewTerms": "لعرض الشروط والأحكام",
"wantConnectHmgNetwork": "عزيزي العميل، لا يوجد وصول إلى الإنترنت، هل ترغب في الاتصال بشبكة مجموعة الحبيب الطبية لاستخدام تطبيقنا، تأكد من أنك في نطاق شبكة مجموعة الحبيب الطبية",
"failedToAccessHmgServices": "متصل بشبكة مجموعة الحبيب الطبية،\n\nلكن فشل في الوصول إلى خدمات مجموعة الحبيب الطبية",
"offerAndPackages": "عروض وباقات",
"offerAndPackages": "العروض و الباقات",
"offerAndPackagesDetails": "تتيح لك هذه الخدمة عرض جميع عروض مجموعة الحبيب الطبية:",
"invoiceNo": "رقم الفاتورة",
"invoiceDate": "تاريخ الفاتورة",
@ -1967,9 +1967,9 @@
"notAvailable": "غير متاح",
"hide": "إخفاء",
"paymentSuccessful": "تم الدفع بنجاح",
"typeAnyOffer": "اكتب أي عرض",
"validTill": "صالح حتى",
"buyNow": "اشتري الآن",
"typeAnyOffer": "ابحث عن العروض و الباقات",
"validTill": "صالح لغاية",
"buyNow": "اشترِ الآن",
"availableAt": "متاح في",
"includedServices": "الخدمات المشمولة",
"off": "خصم",
@ -1977,8 +1977,8 @@
"orderLabel": "الطلب",
"purchased": "تم الشراء",
"validUntil": "صالح حتى",
"viewOfferDetails": "عرض تفاصيل العرض",
"viewOrderDetails": "عرض تفاصيل الطلب",
"viewOfferDetails": "تفاصيل العرض",
"viewOrderDetails": "تفاصيل الطلب",
"hospitalNA": "المستشفى: غير متوفر",
"hospitalLabel": "المستشفى",
"showLess": "عرض أقل",
@ -2001,10 +2001,12 @@
"errorLoadingQRCode": "خطأ في تحميل رمز الاستجابة السريعة",
"noOfferDetailsAvailable": "لا توجد تفاصيل عرض متاحة",
"noImagesAvailable": "لا توجد صور متاحة",
"checkOutThisAmazingOffer": "تحقق من هذا العرض المذهل!",
"checkOutThisAmazingOffer": "تحقق من هذا العرض من مستشفى سلمان الحبيب",
"offerPayment": "دفع العرض",
"unableToCreateOrder": "غير قادر على إنشاء الطلب. معلومات العرض أو المستخدم مفقودة.",
"failedToCreateOrder": "فشل في إنشاء الطلب. يرجى المحاولة مرة أخرى.",
"unableToCompletePayment": "غير قادر على إكمال الدفع. معلومات الطلب مفقودة.",
"paymentConfirmationFailed": "تم تسجيل الدفع لكن التأكيد فشل. يرجى الاتصال بالدعم."
"paymentConfirmationFailed": "تم تسجيل الدفع لكن التأكيد فشل. يرجى الاتصال بالدعم.",
"offerAndPackageDetails": "تفاصيل العروض والباقات",
"myOrders": "طلباتي"
}

@ -1956,7 +1956,53 @@
"weeklyShift": "Weekly Shift",
"dayOff": "Off",
"hide": "Hide",
"paymentSuccessful": "Payment SuccessFul"
"paymentSuccessful": "Payment SuccessFul",
"typeAnyOffer": "Type any offer",
"validTill": "Valid till",
"buyNow": "Buy Now",
"availableAt": "Available at",
"includedServices": "Included Services",
"off": "OFF",
"failedToLoadOfferDetails": "Failed to load offer details",
"orderLabel": "Order",
"purchased": "Purchased",
"validUntil": "Valid until",
"viewOfferDetails": "View Offer Details",
"viewOrderDetails": "View Order Details",
"hospitalNA": "Hospital: N/A",
"hospitalLabel": "Hospital",
"showLess": "Show less",
"redeemed": "Redeemed",
"partiallyRedeemed": "Partially Redeemed",
"available": "Available",
"saveQRCode": "Save QR Code",
"voucherNo": "Voucher No",
"expiresOn": "Expires on",
"saveTheQRCode": "Save the QR Code",
"pleaseShowQRCodeInHospital": "Please save it to your device and show it in hospital to proceed.",
"voucherCodeCopied": "Voucher code copied to clipboard",
"qrCodeNotAvailableToShare": "QR Code not available to share",
"failedToShareQRCode": "Failed to share QR Code",
"failedToSaveQRCode": "Failed to save QR Code",
"qrCodeSavedSuccessfully": "QR Code Saved Successfully",
"qrCodeSavedToDevice": "Your QR code has been saved to your device",
"viewOrderHistory": "View Order History",
"qrCodeNotAvailable": "QR Code not available",
"errorLoadingQRCode": "Error loading QR Code",
"noOfferDetailsAvailable": "No offer details available",
"noImagesAvailable": "No images available",
"checkOutThisAmazingOffer": "Checkout this Offer From HMG",
"offerPayment": "Offer Payment",
"unableToCreateOrder": "Unable to create order. Missing offer or user information.",
"failedToCreateOrder": "Failed to create order. Please try again.",
"unableToCompletePayment": "Unable to complete payment. Missing order information.",
"paymentConfirmationFailed": "Payment recorded but confirmation failed. Please contact support.",
"offerAndPackageDetails": "Offers and Package Detail",
"myOrders": "My Orders"
}

@ -5,7 +5,7 @@ import 'package:hmg_patient_app_new/core/enums.dart';
class ApiConsts {
static const maxSmallScreen = 660;
static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.prod;
static AppEnvironmentTypeEnum appEnvironmentType = AppEnvironmentTypeEnum.uat;
// static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT

@ -543,32 +543,6 @@ class _LandingPageState extends State<LandingPage> {
).paddingSymmetrical(24.w, 0.h)
: SizedBox.shrink(),
// Offers And Discounts Carousel - Auto-scrolling from right to left
appState.isAuthenticated && appState.isEnabledOffersAndDiscountsCarousel
? Column(
children: [
SizedBox(height: 12.h),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
("${LocaleKeys.offers.tr(context: context)} & ${LocaleKeys.discount.tr(context: context)}").toText16(isBold: true),
Row(
children: [
LocaleKeys.viewAll.tr(context: context).toText14(color: AppColors.primaryRedColor, isBold: true),
SizedBox(width: 2.h),
Icon(Icons.arrow_forward_ios, color: AppColors.primaryRedColor, size: 14.h),
],
),
],
).paddingSymmetrical(24.h, 0.h).onPress(() {
Navigator.of(context).push(CustomPageRoute(page: OffersAndDiscountsPage()));
}),
SizedBox(height: 16.h),
OffersAndDiscountsCarousel().paddingSymmetrical(24.h, 0.h),
SizedBox(height: 18.h),
],
)
: SizedBox.shrink(),
appState.isAuthenticated
? Column(

@ -15,6 +15,7 @@ import 'package:hmg_patient_app_new/services/dialog_service.dart';
import 'package:hmg_patient_app_new/theme/colors.dart';
import 'package:hmg_patient_app_new/widgets/buttons/custom_button.dart';
import 'package:hmg_patient_app_new/widgets/common_bottom_sheet.dart';
import 'package:hmg_patient_app_new/widgets/loader/bottomsheet_loader.dart';
import 'package:hmg_patient_app_new/widgets/routes/custom_page_route.dart';
import 'package:provider/provider.dart';
import 'package:share_plus/share_plus.dart' hide Share;
@ -288,37 +289,47 @@ class _OfferAndDiscountsFullScreenSwiperPageState extends State<OfferAndDiscount
getIt<AuthenticationViewModel>().onLoginPressed();
});
} else {
// Ensure patient is authenticated (will re-authenticate if needed)
final isAuthenticated = await vm.ensureAuthenticated(
onSuccess: () {
// Authentication successful, continue
},
onError: (error) {
// Show error to user
showCommonBottomSheetWithoutHeight(
context,
child: Utils.getErrorWidget(loadingText: LocaleKeys.paymentFailedPleaseTryAgain.tr(context: context)),
callBackFunc: () {},
isFullScreen: false,
isCloseButtonVisible: true,
);
},
);
if (!isAuthenticated) {
return;
}
// Set the selected offer and navigate to payment page
if (vm.offerDetails != null) {
vm.setSelectedOffer(vm.offerDetails!);
Navigator.of(context).push(
CustomPageRoute(
page: OffersAndDiscountPaymentPage(),
),
// Show loader during authentication
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.pleaseWait.tr(context: context));
// Ensure patient is authenticated (will re-authenticate if needed)
final isAuthenticated = await vm.ensureAuthenticated(
onSuccess: () {
// Authentication successful, continue
},
onError: (error) {
// Hide loader on error
LoaderBottomSheet.hideLoader();
// Show error to user
showCommonBottomSheetWithoutHeight(
context,
child: Utils.getErrorWidget(loadingText: LocaleKeys.paymentFailedPleaseTryAgain.tr(context: context)),
callBackFunc: () {},
isFullScreen: false,
isCloseButtonVisible: true,
);
},
);
if (!isAuthenticated) {
// Hide loader if authentication failed
LoaderBottomSheet.hideLoader();
return;
}
// Hide loader on success
LoaderBottomSheet.hideLoader();
// Set the selected offer and navigate to payment page
if (vm.offerDetails != null) {
vm.setSelectedOffer(vm.offerDetails!);
Navigator.of(context).push(
CustomPageRoute(
page: OffersAndDiscountPaymentPage(),
),
);
}
}
}
},
backgroundColor: AppColors.primaryRedColor,
borderColor: AppColors.primaryRedColor,

@ -94,13 +94,16 @@ class _OffersAndDiscountPaymentPageState extends State<OffersAndDiscountPaymentP
if (selectedOffer == null) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(Icons.error_outline, size: 64.h, color: AppColors.errorColor),
SizedBox(height: 16.h),
LocaleKeys.noDataAvailable.tr(context: context).toText16(),
],
child: Container(
color: AppColors.bgScaffoldColor,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
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(
title: "${LocaleKeys.offerAndPackages.tr(context: context)} ${LocaleKeys.payment.tr(context: context)}",
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 24.h),
// Offer Summary Card
Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor,
borderRadius: 20.h,
hasShadow: false,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
(appState.getLanguageID() == 1 ? selectedOffer.nameAr : selectedOffer.name).toText18(isBold: true),
SizedBox(height: 8.h),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
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,
child: Container(
color: AppColors.bgScaffoldColor,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 24.h),
// Offer Summary Card
Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor,
borderRadius: 20.h,
hasShadow: false,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
(appState.getLanguageID() == 1 ? selectedOffer.nameAr : selectedOffer.name).toText18(isBold: true),
SizedBox(height: 8.h),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
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).onPress(() async {
selectedPaymentMethod = "MADA";
// Create order first to get order_ref
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.fetchingPaymentInformation.tr(context: context));
String? orderRef = await createOrder();
if (orderRef == null) {
// Error already shown in createOrder
return;
}
transID = orderRef;
if (appState.isPaytabsEnabled) {
LoaderBottomSheet.hideLoader();
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 {
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,
);
},
],
).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(24.h, 0.h).onPress(() async {
selectedPaymentMethod = "MADA";
// Create order first to get order_ref
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.fetchingPaymentInformation.tr(context: context));
String? orderRef = await createOrder();
if (orderRef == null) {
// Error already shown in createOrder
return;
}
transID = orderRef;
if (appState.isPaytabsEnabled) {
LoaderBottomSheet.hideLoader();
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 {
LoaderBottomSheet.hideLoader();
openPaymentURL("mada", getPaymentAmount());
if (appState.isPayfortHostedPageEnabled) {
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),
Container(
decoration: RoundedRectangleBorder().toSmoothCornerDecoration(
color: AppColors.whiteColor,
borderRadius: 20.h,
hasShadow: false,
),
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
Utils.buildImgWithAssets(icon: AppAssets.visa, width: 50.h, height: 50.h),
SizedBox(width: 8.h),
Utils.buildImgWithAssets(icon: AppAssets.mastercard, width: 40.h, height: 40.h, fit: BoxFit.contain),
],
}),
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: [
Row(
children: [
Utils.buildImgWithAssets(icon: AppAssets.visa, width: 50.h, height: 50.h),
SizedBox(width: 8.h),
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(24.h, 0.h).onPress(() async {
selectedPaymentMethod = "VISA";
// Create order first to get order_ref
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.fetchingPaymentInformation.tr(context: context));
String? orderRef = await createOrder();
if (orderRef == null) {
// Error already shown in createOrder
return;
}
transID = orderRef;
if (appState.isPaytabsEnabled) {
LoaderBottomSheet.hideLoader();
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 {
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,
);
},
],
).paddingSymmetrical(16.h, 16.h),
).paddingSymmetrical(24.h, 0.h).onPress(() async {
selectedPaymentMethod = "VISA";
// Create order first to get order_ref
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.fetchingPaymentInformation.tr(context: context));
String? orderRef = await createOrder();
if (orderRef == null) {
// Error already shown in createOrder
return;
}
transID = orderRef;
if (appState.isPaytabsEnabled) {
LoaderBottomSheet.hideLoader();
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 {
LoaderBottomSheet.hideLoader();
openPaymentURL("visa", getPaymentAmount());
if (appState.isPayfortHostedPageEnabled) {
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());
}
}
}
}),
],
}),
],
),
),
),
),

@ -133,12 +133,18 @@ class _OffersAndDiscountsDetailedPageState extends State<OffersAndDiscountsDetai
getIt<AuthenticationViewModel>().onLoginPressed();
});
} else {
// Show loader during authentication
LoaderBottomSheet.showLoader(loadingText: LocaleKeys.pleaseWait.tr(context: context));
// Ensure patient is authenticated (will re-authenticate if needed)
final isAuthenticated = await viewModel.ensureAuthenticated(
onSuccess: () {
// Authentication successful, continue
},
onError: (error) {
// Hide loader on error
LoaderBottomSheet.hideLoader();
// Show error to user
showCommonBottomSheetWithoutHeight(
context,
child: Utils.getErrorWidget(loadingText: LocaleKeys.paymentFailedPleaseTryAgain.tr(context: context)),
@ -150,8 +156,15 @@ class _OffersAndDiscountsDetailedPageState extends State<OffersAndDiscountsDetai
);
if (!isAuthenticated) {
// Hide loader if authentication failed
LoaderBottomSheet.hideLoader();
return;
}
// Hide loader on success
LoaderBottomSheet.hideLoader();
// Set the selected offer and navigate to payment page
viewModel.setSelectedOffer(viewModel.offerDetails!);
Navigator.of(context).push(
CustomPageRoute(
@ -359,10 +372,7 @@ class _OffersAndDiscountsDetailedPageState extends State<OffersAndDiscountsDetai
// Branches Section
if (offer.branches.isNotEmpty) ...[
LocaleKeys.availableAt.tr(context: context).toText18(
isBold: true,
weight: FontWeight.w700,
),
LocaleKeys.availableAt.tr(context: context).toText18(isBold: true, weight: FontWeight.w700),
SizedBox(height: 12.h),
Wrap(
spacing: 8.w,

Loading…
Cancel
Save