dev_3.3_faiz_payfort
haroon amjad 10 months ago
parent 704c0bbbc6
commit 52b3c196d6

@ -8,6 +8,12 @@
<true/> <true/>
<key>com.apple.developer.healthkit.access</key> <key>com.apple.developer.healthkit.access</key>
<array/> <array/>
<key>com.apple.developer.in-app-payments</key>
<array>
<string>merchant.com.hmgwebsersives</string>
<string>merchant.com.hmgwebservices.uat</string>
<string>merchant.com.hmgwebservices</string>
</array>
<key>com.apple.developer.networking.HotspotConfiguration</key> <key>com.apple.developer.networking.HotspotConfiguration</key>
<true/> <true/>
<key>com.apple.developer.networking.wifi-info</key> <key>com.apple.developer.networking.wifi-info</key>

@ -21,8 +21,8 @@ var PACKAGES_ORDERS = '/api/orders';
var PACKAGES_ORDER_HISTORY = '/api/orders/items'; var PACKAGES_ORDER_HISTORY = '/api/orders/items';
var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara'; var PACKAGES_TAMARA_OPT = '/api/orders/paymentoptions/tamara';
// var BASE_URL = 'http://10.20.200.111:1010/'; // var BASE_URL = 'http://10.20.200.111:1010/';
// var BASE_URL = 'https://uat.hmgwebservices.com/'; var BASE_URL = 'https://uat.hmgwebservices.com/';
var BASE_URL = 'https://hmgwebservices.com/'; // var BASE_URL = 'https://hmgwebservices.com/';
// var BASE_URL = 'https://orash.cloudsolutions.com.sa/'; // var BASE_URL = 'https://orash.cloudsolutions.com.sa/';
// var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/'; // var BASE_URL = 'https://vidauat.cloudsolutions.com.sa/';
// var BASE_URL = 'https://vidamergeuat.cloudsolutions.com.sa/'; // var BASE_URL = 'https://vidamergeuat.cloudsolutions.com.sa/';
@ -625,6 +625,7 @@ var CONVERT_PATIENT_TO_CASH = 'Services/Doctors.svc/REST/deActivateInsuranceComp
//PAYFORT //PAYFORT
var getPayFortProjectDetails = "Services/PayFort_Serv.svc/REST/GetPayFortProjectDetails"; var getPayFortProjectDetails = "Services/PayFort_Serv.svc/REST/GetPayFortProjectDetails";
var addPayFortApplePayResponse = "Services/PayFort_Serv.svc/REST/AddResponse";
var payFortEnvironment = FortEnvironment.test; var payFortEnvironment = FortEnvironment.test;
var applePayMerchantId = "merchant.com.hmgwebservices.uat"; var applePayMerchantId = "merchant.com.hmgwebservices.uat";

@ -35,6 +35,24 @@ class ApplePayInsertRequest {
String sessionID; String sessionID;
bool isDentalAllowedBackend; bool isDentalAllowedBackend;
int deviceTypeID; int deviceTypeID;
bool isMobSDK;
String merchantReference;
String merchantIdentifier;
String commandType;
String signature;
String accessCode;
String shaRequestPhrase;
String shaResponsePhrase;
String returnURL;
// IsMobSDK ==> bool
// Merchant_Reference ==> string
// Merchant_Identifier ==> string
// CommandType ==> string
// Signature ==> string
// Access_code ==> string
// SHA_RequestPhase ==> string
// SHA_ResponsePhase ==> string
ApplePayInsertRequest( ApplePayInsertRequest(
{this.clientRequestID, {this.clientRequestID,
@ -72,7 +90,18 @@ class ApplePayInsertRequest {
this.generalid, this.generalid,
this.sessionID, this.sessionID,
this.isDentalAllowedBackend, this.isDentalAllowedBackend,
this.deviceTypeID}); this.deviceTypeID,
this.isMobSDK,
this.merchantReference,
this.merchantIdentifier,
this.commandType,
this.signature,
this.accessCode,
this.shaRequestPhrase,
this.shaResponsePhrase,
this.returnURL,
});
ApplePayInsertRequest.fromJson(Map<String, dynamic> json) { ApplePayInsertRequest.fromJson(Map<String, dynamic> json) {
clientRequestID = json['ClientRequestID']; clientRequestID = json['ClientRequestID'];
@ -151,6 +180,17 @@ class ApplePayInsertRequest {
data['SessionID'] = this.sessionID; data['SessionID'] = this.sessionID;
data['isDentalAllowedBackend'] = this.isDentalAllowedBackend; data['isDentalAllowedBackend'] = this.isDentalAllowedBackend;
data['DeviceTypeID'] = this.deviceTypeID; data['DeviceTypeID'] = this.deviceTypeID;
data['IsMobSDK'] = this.isMobSDK;
data['Merchant_Reference'] = this.merchantReference;
data['Merchant_Identifier'] = this.merchantIdentifier;
data['CommandType'] = this.commandType;
data['Signature'] = this.signature;
data['Access_code'] = this.accessCode;
data['SHA_RequestPhase'] = this.shaRequestPhrase;
data['SHA_ResponsePhase'] = this.shaResponsePhrase;
data['ReturnURL'] = this.returnURL;
return data; return data;
} }
} }

@ -17,6 +17,7 @@ import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/routes.dart'; import 'package:diplomaticquarterapp/routes.dart';
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart'; import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.dart';
import 'package:diplomaticquarterapp/services/livecare_services/livecare_provider.dart'; import 'package:diplomaticquarterapp/services/livecare_services/livecare_provider.dart';
import 'package:diplomaticquarterapp/services/payfort_services/payfort_project_details_resp_model.dart';
import 'package:diplomaticquarterapp/services/payfort_services/payfort_view_model.dart'; import 'package:diplomaticquarterapp/services/payfort_services/payfort_view_model.dart';
import 'package:diplomaticquarterapp/theme/colors.dart'; import 'package:diplomaticquarterapp/theme/colors.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart'; import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';
@ -33,7 +34,6 @@ import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'new_text_Field.dart'; import 'new_text_Field.dart';
class ConfirmPaymentPage extends StatefulWidget { class ConfirmPaymentPage extends StatefulWidget {
final AdvanceModel advanceModel; final AdvanceModel advanceModel;
final PatientInfoAndMobileNumber patientInfoAndMobileNumber; final PatientInfoAndMobileNumber patientInfoAndMobileNumber;
@ -218,7 +218,7 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
padding: EdgeInsets.all(20), padding: EdgeInsets.all(20),
child: DefaultButton( child: DefaultButton(
TranslationBase.of(context).confirm.toUpperCase(), TranslationBase.of(context).confirm.toUpperCase(),
() async { () async {
if (widget.advanceModel.fileNumber == projectViewModel.user.patientID.toString()) { if (widget.advanceModel.fileNumber == projectViewModel.user.patientID.toString()) {
if (widget.selectedPaymentMethod == "ApplePay") { if (widget.selectedPaymentMethod == "ApplePay") {
transID = Utils.getAdvancePaymentTransID(widget.advanceModel.hospitalsModel.iD, int.parse(widget.advanceModel.fileNumber)); transID = Utils.getAdvancePaymentTransID(widget.advanceModel.hospitalsModel.iD, int.parse(widget.advanceModel.fileNumber));
@ -228,6 +228,14 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
LiveCareService service = new LiveCareService(); LiveCareService service = new LiveCareService();
ApplePayInsertRequest applePayInsertRequest = new ApplePayInsertRequest(); ApplePayInsertRequest applePayInsertRequest = new ApplePayInsertRequest();
PayfortProjectDetailsRespModel payfortProjectDetailsRespModel;
await context
.read<PayfortViewModel>()
.getProjectDetailsForPayfort(projectId: widget.advanceModel.hospitalsModel.iD, serviceId: ServiceTypeEnum.advancePayment.getIdFromServiceEnum())
.then((value) {
payfortProjectDetailsRespModel = value;
});
applePayInsertRequest.clientRequestID = transID; applePayInsertRequest.clientRequestID = transID;
applePayInsertRequest.clinicID = 0; applePayInsertRequest.clinicID = 0;
applePayInsertRequest.currency = projectViewModel.authenticatedUserObject.user.outSA == 1 ? "AED" : "SAR"; applePayInsertRequest.currency = projectViewModel.authenticatedUserObject.user.outSA == 1 ? "AED" : "SAR";
@ -257,29 +265,39 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
applePayInsertRequest.backClickUrl = "http://hmg.com/Documents/success.html"; applePayInsertRequest.backClickUrl = "http://hmg.com/Documents/success.html";
applePayInsertRequest.paymentOption = "ApplePay"; applePayInsertRequest.paymentOption = "ApplePay";
applePayInsertRequest.isMobSDK = true;
applePayInsertRequest.merchantReference = transID;
applePayInsertRequest.merchantIdentifier = payfortProjectDetailsRespModel.merchantIdentifier;
applePayInsertRequest.commandType = "PURCHASE";
applePayInsertRequest.signature = payfortProjectDetailsRespModel.signature;
applePayInsertRequest.accessCode = payfortProjectDetailsRespModel.accessCode;
applePayInsertRequest.shaRequestPhrase = payfortProjectDetailsRespModel.shaRequest;
applePayInsertRequest.shaResponsePhrase = payfortProjectDetailsRespModel.shaResponse;
applePayInsertRequest.returnURL = "";
service.applePayInsertRequest(applePayInsertRequest, context).then((res) async { service.applePayInsertRequest(applePayInsertRequest, context).then((res) async {
GifLoaderDialogUtils.hideDialog(context); // GifLoaderDialogUtils.hideDialog(context);
await context.read<PayfortViewModel>().initiateApplePayWithPayfort( await context.read<PayfortViewModel>().initiateApplePayWithPayfort(
customerName: projectViewModel.authenticatedUserObject.user.firstName + " " + projectViewModel.authenticatedUserObject.user.lastName, customerName: projectViewModel.authenticatedUserObject.user.firstName + " " + projectViewModel.authenticatedUserObject.user.lastName,
customerEmail: projectViewModel.authenticatedUserObject.user.emailAddress, customerEmail: projectViewModel.authenticatedUserObject.user.emailAddress,
orderDescription: "Advance Payment", orderDescription: "Advance Payment",
orderAmount: double.parse(widget.advanceModel.amount), orderAmount: double.parse(widget.advanceModel.amount),
merchantReference: transID, merchantReference: transID,
onFailed: (failureResult) { payfortProjectDetailsRespModel: payfortProjectDetailsRespModel,
log("failureResult: ${failureResult.toString()}"); onFailed: (failureResult) async {
log("failureResult: ${failureResult.toString()}");
}, },
onSuccess: (successResult) { onSuccess: (successResult) async {
log("Payfort: ${successResult.responseMessage}"); log("Payfort: ${successResult.responseMessage}");
checkPaymentStatus(AppoitmentAllHistoryResultList()); await context.read<PayfortViewModel>().addPayfortApplePayResponse(result: successResult);
}, checkPaymentStatus(AppoitmentAllHistoryResultList());
projectId: widget.advanceModel.hospitalsModel.iD, },
// projectId: 95, projectId: widget.advanceModel.hospitalsModel.iD,
serviceTypeEnum: ServiceTypeEnum.advancePayment, serviceTypeEnum: ServiceTypeEnum.advancePayment,
); );
}).catchError((err) { }).catchError((err) {
print(err); print(err);
if (context = null) GifLoaderDialogUtils.hideDialog(context); GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast(message: err); AppToast.showErrorToast(message: err);
}); });
} else { } else {
@ -309,72 +327,7 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
); );
} }
// startApplePay() { void addPayFortApplePayResponse() {}
// ApplePayResponse applePayResponse;
// var _paymentItems = [
// PaymentItem(
// label: 'Total',
// amount: widget.advanceModel.amount,
// status: PaymentItemStatus.final_price,
// )
// ];
//
// _payClient.userCanPay(PayProvider.apple_pay).then((value) async {
// print(value);
// final result = await _payClient.showPaymentSelector(
// provider: PayProvider.apple_pay,
// paymentItems: _paymentItems,
// );
// print(result);
// applePayResponse = ApplePayResponse.fromJson(result);
// callPayfortApplePayAPI(applePayResponse);
// }).catchError((err) {
// print(err);
// });
// }
callPayfortApplePayAPI(ApplePayResponse applePayResponse) async {
DoctorsListService service = new DoctorsListService();
ApplePayRequest applePayRequest = new ApplePayRequest();
AppleHeader appleHeader = new AppleHeader();
ApplePaymentMethod applePaymentMethod = new ApplePaymentMethod();
applePayRequest.amount = widget.advanceModel.amount;
applePayRequest.currency = "SAR";
applePayRequest.language = projectViewModel.isArabic ? "ar" : "en";
applePayRequest.customername = projectViewModel.user.firstName;
applePayRequest.customerEmail = projectViewModel.user.emailAddress;
applePayRequest.orderdescription = "Advance Payment";
applePayRequest.liveServiceid = "";
applePayRequest.latitude = await this.sharedPref.getDouble(USER_LAT);
applePayRequest.longitude = await this.sharedPref.getDouble(USER_LONG);
applePayRequest.devicetoken = await sharedPref.getString(PUSH_TOKEN);
applePayRequest.clientrequestid = Utils.getAdvancePaymentTransID(widget.advanceModel.hospitalsModel.iD, int.parse(widget.advanceModel.fileNumber));
applePayRequest.projectid = widget.advanceModel.hospitalsModel.iD.toString();
applePayRequest.serviceid = "3";
applePayRequest.patientid = projectViewModel.user.patientID.toString();
applePayRequest.appleData = applePayResponse.token.data;
applePayRequest.appleSignature = applePayResponse.token.signature;
appleHeader.appleEphemeralPublicKey = applePayResponse.token.header.ephemeralPublicKey;
appleHeader.appleTransactionId = applePayResponse.token.header.transactionId;
appleHeader.applePublicKeyHash = applePayResponse.token.header.publicKeyHash;
applePaymentMethod.appleType = getApplePayPaymentType(applePayResponse.paymentMethod.type);
applePaymentMethod.appleNetwork = applePayResponse.paymentMethod.network;
applePaymentMethod.appleDisplayName = applePayResponse.paymentMethod.displayName;
applePayRequest.appleHeader = appleHeader;
applePayRequest.applePaymentMethod = applePaymentMethod;
service.callPayfortApplePayAPI(applePayRequest, context).then((res) {
print(res);
GifLoaderDialogUtils.hideDialog(context);
}).catchError((err) {
GifLoaderDialogUtils.hideDialog(context);
print(err);
// _showMyDialog(err, this.context);
});
}
String getApplePayPaymentType(dynamic paymentMethod) { String getApplePayPaymentType(dynamic paymentMethod) {
switch (paymentMethod) { switch (paymentMethod) {

@ -7,8 +7,9 @@ class PayfortProjectDetailsRespModel {
int servID; int servID;
String shaRequest; String shaRequest;
String shaResponse; String shaResponse;
String signature;
PayfortProjectDetailsRespModel({this.accessCode, this.integrationId, this.merchantIdentifier, this.projectID, this.projectName, this.servID, this.shaRequest, this.shaResponse}); PayfortProjectDetailsRespModel({this.accessCode, this.integrationId, this.merchantIdentifier, this.projectID, this.projectName, this.servID, this.shaRequest, this.shaResponse, this.signature});
PayfortProjectDetailsRespModel.fromJson(Map<String, dynamic> json) { PayfortProjectDetailsRespModel.fromJson(Map<String, dynamic> json) {
accessCode = json['AccessCode']; accessCode = json['AccessCode'];

@ -39,6 +39,44 @@ class PayfortService extends BaseService {
return payfortProjectDetailsRespModel; return payfortProjectDetailsRespModel;
} }
Future<void> addPayfortApplePayResponse({PayFortResult result}) async {
Map<String, dynamic> body = {
"Fort_id": result.fortId,
"CommandType": result.command,
"Amount": (num.parse(result.amount) / 100).toString(),
"Payment_Option": result.paymentOption,
"Customer_IP": result.customerIp,
"ECI": result.eci,
"Response_Message": result.responseMessage,
"Card_Number": result.cardNumber,
// "Card_Bin": result.ca,
"Status": result.status,
"Merchant_Ref": result.merchantReference,
// Installments_Number
// plan_code
// issuer_code
"Pat_Token": result.tokenName,
"IsRefund": false,
"RemmeberMe": false,
"Reconciliation_Reference": result.reconcilationReference,
"LanguageID": 1,
};
// PayfortProjectDetailsRespModel payfortProjectDetailsRespModel = PayfortProjectDetailsRespModel();
await baseAppClient.post(
addPayFortApplePayResponse,
onSuccess: (response, statusCode) async {
// payfortProjectDetailsRespModel = PayfortProjectDetailsRespModel.fromJson(response.isNotEmpty ? response.first : response);
},
onFailure: (String error, int statusCode) {
Utils.showErrorToast(error);
return null;
},
body: body,
isAllowAny: true,
);
}
Future<SdkTokenResponse> generateSdkSignatureFromAPI(SdkTokenRequest request) async { Future<SdkTokenResponse> generateSdkSignatureFromAPI(SdkTokenRequest request) async {
var response = await post( var response = await post(
Uri.parse(payFortEnvironment.paymentApi), Uri.parse(payFortEnvironment.paymentApi),
@ -83,6 +121,26 @@ class PayfortService extends BaseService {
return null; return null;
} }
Future<String> getPayfortSignature(
String applePayAccessCode,
String merchantIdentifier,
String applePayShaRequestPhrase,
) async {
String deviceId = await _payfort.getDeviceId();
SdkTokenRequest tokenRequest = SdkTokenRequest(
accessCode: applePayAccessCode,
deviceId: deviceId ?? '',
merchantIdentifier: merchantIdentifier,
);
String signature = await _payfort.generateSignature(
shaType: "SHA-256",
concatenatedString: tokenRequest.toConcatenatedString(applePayShaRequestPhrase),
);
return signature;
}
Future<void> paymentWithApplePay({ Future<void> paymentWithApplePay({
SucceededCallback onSucceeded, SucceededCallback onSucceeded,
FailedCallback onFailed, FailedCallback onFailed,

@ -15,10 +15,15 @@ class PayfortViewModel extends ChangeNotifier {
await _payfortService.initPayfortSDK(); await _payfortService.initPayfortSDK();
} }
Future<PayfortProjectDetailsRespModel> getProjectDetailsForPayfort({ int serviceId, int projectId}) async { Future<PayfortProjectDetailsRespModel> getProjectDetailsForPayfort({int serviceId, int projectId}) async {
PayfortProjectDetailsRespModel payfortProjectDetailsRespModel = PayfortProjectDetailsRespModel(); PayfortProjectDetailsRespModel payfortProjectDetailsRespModel = PayfortProjectDetailsRespModel();
try { try {
payfortProjectDetailsRespModel = await _payfortService.getPayfortConfigurations(serviceId: serviceId, projectId: projectId); payfortProjectDetailsRespModel = await _payfortService.getPayfortConfigurations(serviceId: serviceId, projectId: projectId);
String signature =
await _payfortService.getPayfortSignature(payfortProjectDetailsRespModel.accessCode, payfortProjectDetailsRespModel.merchantIdentifier, payfortProjectDetailsRespModel.shaRequest);
payfortProjectDetailsRespModel.signature = signature;
return payfortProjectDetailsRespModel; return payfortProjectDetailsRespModel;
} on Exception catch (e, s) { } on Exception catch (e, s) {
print(s); print(s);
@ -26,24 +31,34 @@ class PayfortViewModel extends ChangeNotifier {
} }
} }
Future<void> addPayfortApplePayResponse({PayFortResult result}) async {
try {
await _payfortService.addPayfortApplePayResponse(result: result);
} on Exception catch (e, s) {
print(s);
return null;
}
}
Future<void> initiateApplePayWithPayfort({ Future<void> initiateApplePayWithPayfort({
String customerName, String customerName,
String customerEmail, String customerEmail,
String orderDescription, String orderDescription,
String merchantReference, String merchantReference,
double orderAmount, double orderAmount,
SucceededCallback onSuccess, PayfortProjectDetailsRespModel payfortProjectDetailsRespModel,
FailedCallback onFailed, SucceededCallback onSuccess,
ServiceTypeEnum serviceTypeEnum, FailedCallback onFailed,
int projectId, ServiceTypeEnum serviceTypeEnum,
int projectId,
}) async { }) async {
GifLoaderDialogUtils.showMyDialog(AppGlobal.context); // GifLoaderDialogUtils.showMyDialog(AppGlobal.context);
PayfortProjectDetailsRespModel payfortProjectDetailsRespModel = await getProjectDetailsForPayfort(projectId: projectId, serviceId: serviceTypeEnum.getIdFromServiceEnum()); // PayfortProjectDetailsRespModel payfortProjectDetailsRespModel = await getProjectDetailsForPayfort(projectId: projectId, serviceId: serviceTypeEnum.getIdFromServiceEnum());
//
if (payfortProjectDetailsRespModel == null) { // if (payfortProjectDetailsRespModel == null) {
GifLoaderDialogUtils.hideDialog(AppGlobal.context); // GifLoaderDialogUtils.hideDialog(AppGlobal.context);
return; // return;
} // }
try { try {
await _payfortService.paymentWithApplePay( await _payfortService.paymentWithApplePay(

@ -40,9 +40,9 @@ class MyInAppBrowser extends InAppBrowser {
// static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWebLive/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL LIVE // static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWebLive/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL LIVE
static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWebLive/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL UAT static String APPLE_PAY_PAYFORT_URL = 'https://hmgwebservices.com/PayFortWebLive/PayFortApi/MakeApplePayRequest'; // Payfort Payment Gateway URL UAT
// static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWeb/pages/SendPayFortRequest.aspx'; // Payfort Payment Gateway URL UAT
static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE // static String SERVICE_URL = 'https://hmgwebservices.com/PayFortWebLive/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL LIVE
// static String SERVICE_URL = 'https://uat.hmgwebservices.com/payfortforvidaplus/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL UAT VIDA PLUS // static String SERVICE_URL = 'https://uat.hmgwebservices.com/payfortforvidaplus/pages/SendPayFortRequest.aspx'; //Payfort Payment Gateway URL UAT VIDA PLUS

Loading…
Cancel
Save