Tamara payment flow done

pull/75/head
haroon amjad 4 weeks ago
parent 30eb8bf5de
commit d220be7283

@ -727,7 +727,7 @@ const FAMILY_FILES= 'Services/Authentication.svc/REST/GetAllSharedRecordsByStatu
class ApiConsts { class ApiConsts {
static const maxSmallScreen = 660; 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 // static String baseUrl = 'https://uat.hmgwebservices.com/'; // HIS API URL UAT
@ -745,6 +745,7 @@ class ApiConsts {
static String TAMARA_URL = "https://mdlaboratories.com/tamaralive/Home/Checkout"; static String TAMARA_URL = "https://mdlaboratories.com/tamaralive/Home/Checkout";
static String GET_TAMARA_INSTALLMENTS_URL = "https://mdlaboratories.com/tamaralive/Home/GetInstallments"; static String GET_TAMARA_INSTALLMENTS_URL = "https://mdlaboratories.com/tamaralive/Home/GetInstallments";
static String GET_TAMARA_PAYMENT_STATUS = 'https://mdlaboratories.com/tamaralive/api/OnlineTamara/order_status?orderid=';
// static String GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments"; // static String GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments";
@ -760,6 +761,7 @@ class ApiConsts {
SERVICE_URL = "https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx"; SERVICE_URL = "https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx";
TAMARA_URL = "https://mdlaboratories.com/tamaralive/Home/Checkout"; TAMARA_URL = "https://mdlaboratories.com/tamaralive/Home/Checkout";
GET_TAMARA_INSTALLMENTS_URL = "https://mdlaboratories.com/tamaralive/Home/GetInstallments"; GET_TAMARA_INSTALLMENTS_URL = "https://mdlaboratories.com/tamaralive/Home/GetInstallments";
GET_TAMARA_PAYMENT_STATUS = 'https://mdlaboratories.com/tamaralive/api/OnlineTamara/order_status?orderid=';
break; break;
case AppEnvironmentTypeEnum.dev: case AppEnvironmentTypeEnum.dev:
baseUrl = "https://uat.hmgwebservices.com/"; baseUrl = "https://uat.hmgwebservices.com/";
@ -768,6 +770,7 @@ class ApiConsts {
SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx';
TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout"; TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout";
GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments"; GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments";
GET_TAMARA_PAYMENT_STATUS = 'https://epharmacy.hmg.com/tamara/api/OnlineTamara/order_status?orderid=';
break; break;
case AppEnvironmentTypeEnum.uat: case AppEnvironmentTypeEnum.uat:
baseUrl = "https://uat.hmgwebservices.com/"; baseUrl = "https://uat.hmgwebservices.com/";
@ -776,6 +779,7 @@ class ApiConsts {
SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx';
TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout"; TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout";
GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments"; GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments";
GET_TAMARA_PAYMENT_STATUS = 'https://epharmacy.hmg.com/tamara/api/OnlineTamara/order_status?orderid=';
break; break;
case AppEnvironmentTypeEnum.preProd: case AppEnvironmentTypeEnum.preProd:
@ -785,6 +789,7 @@ class ApiConsts {
SERVICE_URL = "https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx"; SERVICE_URL = "https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx";
TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout"; TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout";
GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments"; GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments";
GET_TAMARA_PAYMENT_STATUS = 'https://epharmacy.hmg.com/tamara/api/OnlineTamara/order_status?orderid=';
break; break;
case AppEnvironmentTypeEnum.qa: case AppEnvironmentTypeEnum.qa:
baseUrl = "https://uat.hmgwebservices.com/"; baseUrl = "https://uat.hmgwebservices.com/";
@ -793,6 +798,7 @@ class ApiConsts {
SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx';
TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout"; TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout";
GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments"; GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments";
GET_TAMARA_PAYMENT_STATUS = 'https://epharmacy.hmg.com/tamara/api/OnlineTamara/order_status?orderid=';
break; break;
case AppEnvironmentTypeEnum.staging: case AppEnvironmentTypeEnum.staging:
baseUrl = "https://uat.hmgwebservices.com/"; baseUrl = "https://uat.hmgwebservices.com/";
@ -801,6 +807,7 @@ class ApiConsts {
SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx';
TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout"; TAMARA_URL = "https://epharmacy.hmg.com/tamara/Home/Checkout";
GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments"; GET_TAMARA_INSTALLMENTS_URL = "https://epharmacy.hmg.com/tamara/Home/getinstallments";
GET_TAMARA_PAYMENT_STATUS = 'https://epharmacy.hmg.com/tamara/api/OnlineTamara/order_status?orderid=';
break; break;
} }
} }

@ -18,6 +18,13 @@ abstract class PayfortRepo {
Future<Either<Failure, GenericApiModel<SdkTokenResponse>>> generateSdkSignatureFromAPI({required SdkTokenRequest tokenRequest}); Future<Either<Failure, GenericApiModel<SdkTokenResponse>>> generateSdkSignatureFromAPI({required SdkTokenRequest tokenRequest});
Future<Either<Failure, GenericApiModel<PayfortCheckPaymentStatusResponseModel>>> checkPaymentStatus({required String transactionID}); Future<Either<Failure, GenericApiModel<PayfortCheckPaymentStatusResponseModel>>> checkPaymentStatus({required String transactionID});
Future<Either<Failure, GenericApiModel<dynamic>>> checkTamaraPaymentStatus({required String transactionID});
Future<Either<Failure, GenericApiModel<dynamic>>> markAppointmentAsTamaraPaid({required int projectID, required int appointmentNo});
Future<Either<Failure, GenericApiModel<dynamic>>> updateTamaraRequestStatus(
{required String responseMessage, required String status, required String clientRequestID, required String tamaraOrderID});
} }
class PayfortRepoImp implements PayfortRepo { class PayfortRepoImp implements PayfortRepo {
@ -147,4 +154,100 @@ class PayfortRepoImp implements PayfortRepo {
return Left(UnknownFailure(e.toString())); return Left(UnknownFailure(e.toString()));
} }
} }
@override
Future<Either<Failure, GenericApiModel>> checkTamaraPaymentStatus({required String transactionID}) async {
try {
GenericApiModel<dynamic>? apiResponse;
Failure? failure;
await apiClient.get(
'${ApiConsts.GET_TAMARA_PAYMENT_STATUS}$transactionID',
isExternal: true,
isAllowAny: true,
onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType;
},
onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
apiResponse = GenericApiModel<dynamic>(
messageStatus: messageStatus,
statusCode: statusCode,
errorMessage: null,
data: response,
);
} catch (e) {
failure = DataParsingFailure(e.toString());
}
},
);
if (failure != null) return Left(failure!);
if (apiResponse == null) return Left(ServerFailure("Unknown error"));
return Right(apiResponse!);
} catch (e) {
return Left(UnknownFailure(e.toString()));
}
}
@override
Future<Either<Failure, GenericApiModel>> updateTamaraRequestStatus({required String responseMessage, required String status, required String clientRequestID, required String tamaraOrderID}) async {
Map<String, dynamic> body = {
"Response_Message": responseMessage,
"ClientRequestID": clientRequestID,
"Status": status,
"FortID": tamaraOrderID, // Tamara order ID
"LanguageID": 1,
"Installments_Number": 3,
};
try {
GenericApiModel<dynamic>? apiResponse;
Failure? failure;
await apiClient.post(UPDATE_TAMARA_STATUS, body: body, onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType;
}, onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
apiResponse = GenericApiModel<dynamic>(
messageStatus: messageStatus,
statusCode: statusCode,
errorMessage: null,
data: response,
);
} catch (e) {
failure = DataParsingFailure(e.toString());
}
}, isAllowAny: true, isPaymentServices: true);
if (failure != null) return Left(failure!);
if (apiResponse == null) return Left(ServerFailure("Unknown error"));
return Right(apiResponse!);
} catch (e) {
return Left(UnknownFailure(e.toString()));
}
}
@override
Future<Either<Failure, GenericApiModel>> markAppointmentAsTamaraPaid({required int projectID, required int appointmentNo}) async {
Map<String, dynamic> body = {"ProjectID": projectID, "AppointmentNo": appointmentNo, "LanguageID": 1};
try {
GenericApiModel<dynamic>? apiResponse;
Failure? failure;
await apiClient.post(MARK_APPOINTMENT_TAMARA_STATUS, body: body, onFailure: (error, statusCode, {messageStatus, failureType}) {
failure = failureType;
}, onSuccess: (response, statusCode, {messageStatus, errorMessage}) {
try {
apiResponse = GenericApiModel<dynamic>(
messageStatus: messageStatus,
statusCode: statusCode,
errorMessage: null,
data: response,
);
} catch (e) {
failure = DataParsingFailure(e.toString());
}
}, isAllowAny: true, isPaymentServices: true);
if (failure != null) return Left(failure!);
if (apiResponse == null) return Left(ServerFailure("Unknown error"));
return Right(apiResponse!);
} catch (e) {
return Left(UnknownFailure(e.toString()));
}
}
} }

@ -94,6 +94,40 @@ class PayfortViewModel extends ChangeNotifier {
); );
} }
Future<void> checkTamaraPaymentStatus({required String transactionID, Function(dynamic)? onSuccess, Function(String)? onError}) async {
final result = await payfortRepo.checkTamaraPaymentStatus(transactionID: transactionID);
result.fold(
(failure) async {
onError!(failure.message);
},
(apiResponse) {
print(apiResponse.data);
if (onSuccess != null) {
onSuccess(apiResponse);
}
// }
},
);
}
Future<void> updateTamaraRequestStatus(
{required String responseMessage, required String status, required String clientRequestID, required String tamaraOrderID, Function(dynamic)? onSuccess, Function(String)? onError}) async {
final result = await payfortRepo.updateTamaraRequestStatus(responseMessage: responseMessage, status: status, clientRequestID: clientRequestID, tamaraOrderID: tamaraOrderID);
result.fold(
(failure) async {
onError!(failure.message);
},
(apiResponse) {
print(apiResponse.data);
if (onSuccess != null) {
onSuccess(apiResponse);
}
},
);
}
Future<SdkTokenResponse?> _generateSdkResponse({ Future<SdkTokenResponse?> _generateSdkResponse({
String? applePayAccessCode, String? applePayAccessCode,
String? merchantIdentifier, String? merchantIdentifier,
@ -199,4 +233,20 @@ class PayfortViewModel extends ChangeNotifier {
onFailed!(e.toString() as PayFortFailureResult); onFailed!(e.toString() as PayFortFailureResult);
} }
} }
Future<void> markAppointmentAsTamaraPaid({required int projectID, required int appointmentNo, Function(dynamic)? onSuccess, Function(String)? onError}) async {
final result = await payfortRepo.markAppointmentAsTamaraPaid(projectID: projectID, appointmentNo: appointmentNo);
result.fold(
(failure) async {
onError!(failure.message);
},
(apiResponse) {
print(apiResponse.data);
if (onSuccess != null) {
onSuccess(apiResponse);
}
},
);
}
} }

@ -52,6 +52,8 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
String transID = ""; String transID = "";
bool isShowTamara = false; bool isShowTamara = false;
String tamaraPaymentStatus = "";
String tamaraOrderID = "";
@override @override
void initState() { void initState() {
@ -117,7 +119,7 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
Transform.flip( Transform.flip(
flipX: appState.isArabic() ? true : false, flipX: appState.isArabic() ? true : false,
child: Utils.buildSvgWithAssets( child: Utils.buildSvgWithAssets(
icon: AppAssets.forward_arrow_icon, icon: AppAssets.forward_arrow_icon_small,
iconColor: AppColors.blackColor, iconColor: AppColors.blackColor,
width: 18.h, width: 18.h,
height: 13.h, height: 13.h,
@ -159,7 +161,7 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
Transform.flip( Transform.flip(
flipX: appState.isArabic() ? true : false, flipX: appState.isArabic() ? true : false,
child: Utils.buildSvgWithAssets( child: Utils.buildSvgWithAssets(
icon: AppAssets.forward_arrow_icon, icon: AppAssets.forward_arrow_icon_small,
iconColor: AppColors.blackColor, iconColor: AppColors.blackColor,
width: 18.h, width: 18.h,
height: 13.h, height: 13.h,
@ -196,18 +198,18 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
Transform.flip( Transform.flip(
flipX: appState.isArabic() ? true : false, flipX: appState.isArabic() ? true : false,
child: Utils.buildSvgWithAssets( child: Utils.buildSvgWithAssets(
icon: AppAssets.forward_arrow_icon, icon: AppAssets.forward_arrow_icon_small,
iconColor: AppColors.blackColor, iconColor: AppColors.blackColor,
width: 18.h, width: 18.h,
height: 13.h, height: 13.h,
fit: BoxFit.contain, fit: BoxFit.contain,
).toShimmer2(isShow: myAppointmentsVM.isAppointmentPatientShareLoading), ).toShimmer2(isShow: myAppointmentsVM.isAppointmentPatientShareLoading),
), ),
], ],
).paddingSymmetrical(16.h, 16.h), ).paddingSymmetrical(16.h, 16.h),
).paddingSymmetrical(24.h, 0.h).onPress(() { ).paddingSymmetrical(24.h, 0.h).onPress(() {
selectedPaymentMethod = "TAMARA"; selectedPaymentMethod = "TAMARA";
openPaymentURL("tamara"); openPaymentURL("tamara");
}) })
: SizedBox.shrink(), : SizedBox.shrink(),
], ],
@ -328,12 +330,12 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
if (selectedPaymentMethod == "tamara") { if (selectedPaymentMethod == "tamara") {
if (Platform.isAndroid) { if (Platform.isAndroid) {
Uri uri = new Uri.dataFromString(url); Uri uri = new Uri.dataFromString(url);
// tamaraPaymentStatus = uri.queryParameters['status']!; tamaraPaymentStatus = uri.queryParameters['status']!;
// tamaraOrderID = uri.queryParameters['AuthorizePaymentId']!; tamaraOrderID = uri.queryParameters['AuthorizePaymentId']!;
} else { } else {
Uri uri = new Uri.dataFromString(url); Uri uri = new Uri.dataFromString(url);
// tamaraPaymentStatus = uri.queryParameters['paymentStatus']!; tamaraPaymentStatus = uri.queryParameters['paymentStatus']!;
// tamaraOrderID = uri.queryParameters['orderId']!; tamaraOrderID = uri.queryParameters['orderId']!;
} }
} }
@ -359,95 +361,155 @@ class _AppointmentPaymentPageState extends State<AppointmentPaymentPage> {
} }
onBrowserExit(bool isPaymentMade) async { onBrowserExit(bool isPaymentMade) async {
print("onBrowserExit Called!!!!"); checkPaymentStatus();
if (selectedPaymentMethod == "TAMARA") {
// checkTamaraPaymentStatus(transID!, appo);
// if (tamaraPaymentStatus != null && tamaraPaymentStatus.toLowerCase() == "approved") {
// updateTamaraRequestStatus("success", "14", Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), tamaraOrderID, num.parse(selectedInstallments), appo);
// } else {
// updateTamaraRequestStatus("Failed", "00", Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), tamaraOrderID, num.parse(selectedInstallments), appo);
// }
} else {
checkPaymentStatus();
// checkPaymentStatus(appo);
}
} }
void checkPaymentStatus() async { void checkPaymentStatus() async {
LoaderBottomSheet.showLoader(); LoaderBottomSheet.showLoader(loadingText: "Checking payment status, Please wait...".needTranslation);
await payfortViewModel.checkPaymentStatus( if (selectedPaymentMethod == "TAMARA") {
transactionID: transID, await payfortViewModel.checkTamaraPaymentStatus(
onSuccess: (apiResponse) async { transactionID: transID,
print(apiResponse.data); onSuccess: (apiResponse) async {
if (payfortViewModel.payfortCheckPaymentStatusResponseModel!.responseMessage!.toLowerCase() == "success") { if (apiResponse.data["status"].toString().toLowerCase() == "success") {
await myAppointmentsViewModel.createAdvancePayment( tamaraOrderID = apiResponse.data["tamara_order_id"].toString();
paymentMethodName: selectedPaymentMethod, await payfortViewModel.updateTamaraRequestStatus(responseMessage: "success", status: "14", clientRequestID: transID, tamaraOrderID: tamaraOrderID);
projectID: widget.patientAppointmentHistoryResponseModel.projectID, await payfortViewModel.markAppointmentAsTamaraPaid(
clinicID: widget.patientAppointmentHistoryResponseModel.clinicID, projectID: widget.patientAppointmentHistoryResponseModel.projectID, appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo);
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(), await myAppointmentsViewModel.addAdvanceNumberRequest(
payedAmount: payfortViewModel.payfortCheckPaymentStatusResponseModel!.amount!, advanceNumber: "Tamara-Advance-0000",
paymentReference: payfortViewModel.payfortCheckPaymentStatusResponseModel!.fortId!, paymentReference: tamaraOrderID,
patientID: appState.getAuthenticatedUser()!.patientId.toString(), appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
patientType: appState.getAuthenticatedUser()!.patientType!, onSuccess: (value) async {
onSuccess: (value) async { if (widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment!) {
print(value); //TODO: Implement LiveCare Check-In API Call
await myAppointmentsViewModel.addAdvanceNumberRequest( await myAppointmentsViewModel.insertLiveCareVIDARequest(
advanceNumber: Utils.isVidaPlusProject(widget.patientAppointmentHistoryResponseModel.projectID) clientRequestID: tamaraOrderID,
? value.data['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString() patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel,
: value.data['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(), onSuccess: (apiResponse) {
paymentReference: payfortViewModel.payfortCheckPaymentStatusResponseModel!.fortId!, Future.delayed(Duration(milliseconds: 500), () {
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(), LoaderBottomSheet.hideLoader();
onSuccess: (value) async { Navigator.pushAndRemoveUntil(
if (widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment!) { context,
//TODO: Implement LiveCare Check-In API Call CustomPageRoute(
await myAppointmentsViewModel.insertLiveCareVIDARequest( page: LandingNavigation(),
clientRequestID: transID, ),
patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel, (r) => false);
onSuccess: (apiResponse) { });
Future.delayed(Duration(milliseconds: 500), () { },
LoaderBottomSheet.hideLoader(); onError: (error) {});
Navigator.pushAndRemoveUntil( } else {
context, await myAppointmentsViewModel.generateAppointmentQR(
CustomPageRoute( clinicID: widget.patientAppointmentHistoryResponseModel.clinicID,
page: LandingNavigation(), projectID: widget.patientAppointmentHistoryResponseModel.projectID,
), appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
(r) => false); isFollowUp: myAppointmentsViewModel.patientAppointmentShareResponseModel!.isFollowup!,
}); onSuccess: (apiResponse) {
}, Future.delayed(Duration(milliseconds: 500), () {
onError: (error) {}); LoaderBottomSheet.hideLoader();
} else { Navigator.pushAndRemoveUntil(
await myAppointmentsViewModel.generateAppointmentQR( context,
clinicID: widget.patientAppointmentHistoryResponseModel.clinicID, CustomPageRoute(
projectID: widget.patientAppointmentHistoryResponseModel.projectID, page: LandingNavigation(),
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(), ),
isFollowUp: myAppointmentsViewModel.patientAppointmentShareResponseModel!.isFollowup!, (r) => false);
onSuccess: (apiResponse) { });
Future.delayed(Duration(milliseconds: 500), () { });
LoaderBottomSheet.hideLoader(); }
Navigator.pushAndRemoveUntil( });
context, } else {
CustomPageRoute( await payfortViewModel.updateTamaraRequestStatus(responseMessage: "Failed", status: "00", clientRequestID: transID, tamaraOrderID: tamaraOrderID);
page: LandingNavigation(), LoaderBottomSheet.hideLoader();
), showCommonBottomSheetWithoutHeight(
(r) => false); context,
// Navigator.of(context).push( child: Utils.getErrorWidget(loadingText: "Payment Failed! Please try again.".needTranslation),
// CustomPageRoute(page: MyAppointmentsPage()), callBackFunc: () {},
// ); isFullScreen: false,
}); isCloseButtonVisible: true,
}); );
} }
}); },
}); onError: (err) {
} else { LoaderBottomSheet.hideLoader();
showCommonBottomSheetWithoutHeight( showCommonBottomSheetWithoutHeight(
context, context,
child: Utils.getErrorWidget(loadingText: "Payment Failed! Please try again.".needTranslation), child: Utils.getErrorWidget(loadingText: err),
callBackFunc: () {}, callBackFunc: () {},
isFullScreen: false, isFullScreen: false,
isCloseButtonVisible: true, isCloseButtonVisible: true,
); );
} });
}); } else {
await payfortViewModel.checkPaymentStatus(
transactionID: transID,
onSuccess: (apiResponse) async {
print(apiResponse.data);
if (payfortViewModel.payfortCheckPaymentStatusResponseModel!.responseMessage!.toLowerCase() == "success") {
await myAppointmentsViewModel.createAdvancePayment(
paymentMethodName: selectedPaymentMethod,
projectID: widget.patientAppointmentHistoryResponseModel.projectID,
clinicID: widget.patientAppointmentHistoryResponseModel.clinicID,
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
payedAmount: payfortViewModel.payfortCheckPaymentStatusResponseModel!.amount!,
paymentReference: payfortViewModel.payfortCheckPaymentStatusResponseModel!.fortId!,
patientID: appState.getAuthenticatedUser()!.patientId.toString(),
patientType: appState.getAuthenticatedUser()!.patientType!,
onSuccess: (value) async {
print(value);
await myAppointmentsViewModel.addAdvanceNumberRequest(
advanceNumber: Utils.isVidaPlusProject(widget.patientAppointmentHistoryResponseModel.projectID)
? value.data['OnlineCheckInAppointments'][0]['AdvanceNumber_VP'].toString()
: value.data['OnlineCheckInAppointments'][0]['AdvanceNumber'].toString(),
paymentReference: payfortViewModel.payfortCheckPaymentStatusResponseModel!.fortId!,
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
onSuccess: (value) async {
if (widget.patientAppointmentHistoryResponseModel.isLiveCareAppointment!) {
//TODO: Implement LiveCare Check-In API Call
await myAppointmentsViewModel.insertLiveCareVIDARequest(
clientRequestID: transID,
patientAppointmentHistoryResponseModel: widget.patientAppointmentHistoryResponseModel,
onSuccess: (apiResponse) {
Future.delayed(Duration(milliseconds: 500), () {
LoaderBottomSheet.hideLoader();
Navigator.pushAndRemoveUntil(
context,
CustomPageRoute(
page: LandingNavigation(),
),
(r) => false);
});
},
onError: (error) {});
} else {
await myAppointmentsViewModel.generateAppointmentQR(
clinicID: widget.patientAppointmentHistoryResponseModel.clinicID,
projectID: widget.patientAppointmentHistoryResponseModel.projectID,
appointmentNo: widget.patientAppointmentHistoryResponseModel.appointmentNo.toString(),
isFollowUp: myAppointmentsViewModel.patientAppointmentShareResponseModel!.isFollowup!,
onSuccess: (apiResponse) {
Future.delayed(Duration(milliseconds: 500), () {
LoaderBottomSheet.hideLoader();
Navigator.pushAndRemoveUntil(
context,
CustomPageRoute(
page: LandingNavigation(),
),
(r) => false);
});
});
}
});
});
} else {
showCommonBottomSheetWithoutHeight(
context,
child: Utils.getErrorWidget(loadingText: "Payment Failed! Please try again.".needTranslation),
callBackFunc: () {},
isFullScreen: false,
isCloseButtonVisible: true,
);
}
});
}
} }
openPaymentURL(String paymentMethod) { openPaymentURL(String paymentMethod) {

@ -124,7 +124,7 @@ class AppointmentCheckinBottomSheet extends StatelessWidget {
Transform.flip( Transform.flip(
flipX: appState.isArabic() ? true : false, flipX: appState.isArabic() ? true : false,
child: Utils.buildSvgWithAssets( child: Utils.buildSvgWithAssets(
icon: AppAssets.forward_arrow_icon, icon: AppAssets.forward_arrow_icon_small,
iconColor: AppColors.blackColor, iconColor: AppColors.blackColor,
width: 18.h, width: 18.h,
height: 13.h, height: 13.h,

@ -57,6 +57,8 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
String transID = ""; String transID = "";
bool isShowTamara = false; bool isShowTamara = false;
String tamaraPaymentStatus = "";
String tamaraOrderID = "";
@override @override
void initState() { void initState() {
@ -319,15 +321,15 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
print("onBrowserLoadStart"); print("onBrowserLoadStart");
print(url); print(url);
if (selectedPaymentMethod == "tamara") { if (selectedPaymentMethod == "TAMARA") {
if (Platform.isAndroid) { if (Platform.isAndroid) {
Uri uri = new Uri.dataFromString(url); Uri uri = new Uri.dataFromString(url);
// tamaraPaymentStatus = uri.queryParameters['status']!; tamaraPaymentStatus = uri.queryParameters['status']!;
// tamaraOrderID = uri.queryParameters['AuthorizePaymentId']!; tamaraOrderID = uri.queryParameters['AuthorizePaymentId']!;
} else { } else {
Uri uri = new Uri.dataFromString(url); Uri uri = new Uri.dataFromString(url);
// tamaraPaymentStatus = uri.queryParameters['paymentStatus']!; tamaraPaymentStatus = uri.queryParameters['paymentStatus']!;
// tamaraOrderID = uri.queryParameters['orderId']!; tamaraOrderID = uri.queryParameters['orderId']!;
} }
} }
@ -353,61 +355,107 @@ class _ImmediateLiveCarePaymentPageState extends State<ImmediateLiveCarePaymentP
} }
onBrowserExit(bool isPaymentMade) async { onBrowserExit(bool isPaymentMade) async {
print("onBrowserExit Called!!!!"); debugPrint("onBrowserExit Called!!!!");
if (selectedPaymentMethod == "TAMARA") { checkPaymentStatus();
// checkTamaraPaymentStatus(transID!, appo);
// if (tamaraPaymentStatus != null && tamaraPaymentStatus.toLowerCase() == "approved") {
// updateTamaraRequestStatus("success", "14", Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), tamaraOrderID, num.parse(selectedInstallments), appo);
// } else {
// updateTamaraRequestStatus("Failed", "00", Utils.getAppointmentTransID(appo.projectID, appo.clinicID, appo.appointmentNo), tamaraOrderID, num.parse(selectedInstallments), appo);
// }
} else {
checkPaymentStatus();
// checkPaymentStatus(appo);
}
} }
void checkPaymentStatus() async { void checkPaymentStatus() async {
LoaderBottomSheet.showLoader(loadingText: "Checking payment status, Please wait...".needTranslation); LoaderBottomSheet.showLoader(loadingText: "Checking payment status, Please wait...".needTranslation);
await payfortViewModel.checkPaymentStatus(
transactionID: transID, if (selectedPaymentMethod == "TAMARA") {
onSuccess: (apiResponse) async { await payfortViewModel.checkTamaraPaymentStatus(
debugPrint(apiResponse.data.toString()); transactionID: transID,
if (payfortViewModel.payfortCheckPaymentStatusResponseModel!.responseMessage!.toLowerCase() == "success") { onSuccess: (apiResponse) async {
await immediateLiveCareViewModel.addNewCallRequestForImmediateLiveCare(transID); if (apiResponse.data["status"].toString().toLowerCase() == "success") {
await immediateLiveCareViewModel.getPatientLiveCareHistory(); tamaraOrderID = apiResponse.data["tamara_order_id"].toString();
LoaderBottomSheet.hideLoader(); await payfortViewModel.updateTamaraRequestStatus(responseMessage: "success", status: "14", clientRequestID: transID, tamaraOrderID: tamaraOrderID);
if (immediateLiveCareViewModel.patientHasPendingLiveCareRequest) { await immediateLiveCareViewModel.addNewCallRequestForImmediateLiveCare(transID);
Navigator.pushAndRemoveUntil( await immediateLiveCareViewModel.getPatientLiveCareHistory();
context, LoaderBottomSheet.hideLoader();
if (immediateLiveCareViewModel.patientHasPendingLiveCareRequest) {
Navigator.pushAndRemoveUntil(
context,
CustomPageRoute(
page: LandingNavigation(),
),
(r) => false);
Navigator.of(context).push(
CustomPageRoute( CustomPageRoute(
page: LandingNavigation(), page: ImmediateLiveCarePendingRequestPage(),
), ),
(r) => false); );
Navigator.of(context).push( } else {
CustomPageRoute( showCommonBottomSheetWithoutHeight(
page: ImmediateLiveCarePendingRequestPage(), context,
), child: Utils.getErrorWidget(loadingText: "Unknown error occurred...".needTranslation),
); callBackFunc: () {},
isFullScreen: false,
isCloseButtonVisible: true,
);
}
} else { } else {
await payfortViewModel.updateTamaraRequestStatus(responseMessage: "Failed", status: "00", clientRequestID: transID, tamaraOrderID: tamaraOrderID);
LoaderBottomSheet.hideLoader();
showCommonBottomSheetWithoutHeight( showCommonBottomSheetWithoutHeight(
context, context,
child: Utils.getErrorWidget(loadingText: "Unknown error occurred...".needTranslation), child: Utils.getErrorWidget(loadingText: "Payment Failed! Please try again.".needTranslation),
callBackFunc: () {}, callBackFunc: () {},
isFullScreen: false, isFullScreen: false,
isCloseButtonVisible: true, isCloseButtonVisible: true,
); );
} }
} else { },
onError: (err) {
LoaderBottomSheet.hideLoader();
showCommonBottomSheetWithoutHeight( showCommonBottomSheetWithoutHeight(
context, context,
child: Utils.getErrorWidget(loadingText: "Payment Failed! Please try again.".needTranslation), child: Utils.getErrorWidget(loadingText: err),
callBackFunc: () {}, callBackFunc: () {},
isFullScreen: false, isFullScreen: false,
isCloseButtonVisible: true, isCloseButtonVisible: true,
); );
} });
}); } else {
await payfortViewModel.checkPaymentStatus(
transactionID: transID,
onSuccess: (apiResponse) async {
debugPrint(apiResponse.data.toString());
if (payfortViewModel.payfortCheckPaymentStatusResponseModel!.responseMessage!.toLowerCase() == "success") {
await immediateLiveCareViewModel.addNewCallRequestForImmediateLiveCare(transID);
await immediateLiveCareViewModel.getPatientLiveCareHistory();
LoaderBottomSheet.hideLoader();
if (immediateLiveCareViewModel.patientHasPendingLiveCareRequest) {
Navigator.pushAndRemoveUntil(
context,
CustomPageRoute(
page: LandingNavigation(),
),
(r) => false);
Navigator.of(context).push(
CustomPageRoute(
page: ImmediateLiveCarePendingRequestPage(),
),
);
} else {
showCommonBottomSheetWithoutHeight(
context,
child: Utils.getErrorWidget(loadingText: "Unknown error occurred...".needTranslation),
callBackFunc: () {},
isFullScreen: false,
isCloseButtonVisible: true,
);
}
} else {
showCommonBottomSheetWithoutHeight(
context,
child: Utils.getErrorWidget(loadingText: "Payment Failed! Please try again.".needTranslation),
callBackFunc: () {},
isFullScreen: false,
isCloseButtonVisible: true,
);
}
});
}
} }
openPaymentURL(String paymentMethod) { openPaymentURL(String paymentMethod) {

Loading…
Cancel
Save