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

@ -8,6 +8,12 @@
<true/>
<key>com.apple.developer.healthkit.access</key>
<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>
<true/>
<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_TAMARA_OPT = '/api/orders/paymentoptions/tamara';
// var BASE_URL = 'http://10.20.200.111:1010/';
// var BASE_URL = 'https://uat.hmgwebservices.com/';
var BASE_URL = 'https://hmgwebservices.com/';
var BASE_URL = 'https://uat.hmgwebservices.com/';
// var BASE_URL = 'https://hmgwebservices.com/';
// var BASE_URL = 'https://orash.cloudsolutions.com.sa/';
// var BASE_URL = 'https://vidauat.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
var getPayFortProjectDetails = "Services/PayFort_Serv.svc/REST/GetPayFortProjectDetails";
var addPayFortApplePayResponse = "Services/PayFort_Serv.svc/REST/AddResponse";
var payFortEnvironment = FortEnvironment.test;
var applePayMerchantId = "merchant.com.hmgwebservices.uat";

@ -35,6 +35,24 @@ class ApplePayInsertRequest {
String sessionID;
bool isDentalAllowedBackend;
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(
{this.clientRequestID,
@ -72,7 +90,18 @@ class ApplePayInsertRequest {
this.generalid,
this.sessionID,
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) {
clientRequestID = json['ClientRequestID'];
@ -151,6 +180,17 @@ class ApplePayInsertRequest {
data['SessionID'] = this.sessionID;
data['isDentalAllowedBackend'] = this.isDentalAllowedBackend;
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;
}
}

@ -17,6 +17,7 @@ import 'package:diplomaticquarterapp/pages/base/base_view.dart';
import 'package:diplomaticquarterapp/routes.dart';
import 'package:diplomaticquarterapp/services/appointment_services/GetDoctorsList.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/theme/colors.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 'new_text_Field.dart';
class ConfirmPaymentPage extends StatefulWidget {
final AdvanceModel advanceModel;
final PatientInfoAndMobileNumber patientInfoAndMobileNumber;
@ -228,6 +228,14 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
LiveCareService service = new LiveCareService();
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.clinicID = 0;
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.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 {
GifLoaderDialogUtils.hideDialog(context);
// GifLoaderDialogUtils.hideDialog(context);
await context.read<PayfortViewModel>().initiateApplePayWithPayfort(
customerName: projectViewModel.authenticatedUserObject.user.firstName + " " + projectViewModel.authenticatedUserObject.user.lastName,
customerEmail: projectViewModel.authenticatedUserObject.user.emailAddress,
orderDescription: "Advance Payment",
orderAmount: double.parse(widget.advanceModel.amount),
merchantReference: transID,
onFailed: (failureResult) {
payfortProjectDetailsRespModel: payfortProjectDetailsRespModel,
onFailed: (failureResult) async {
log("failureResult: ${failureResult.toString()}");
},
onSuccess: (successResult) {
onSuccess: (successResult) async {
log("Payfort: ${successResult.responseMessage}");
await context.read<PayfortViewModel>().addPayfortApplePayResponse(result: successResult);
checkPaymentStatus(AppoitmentAllHistoryResultList());
},
projectId: widget.advanceModel.hospitalsModel.iD,
// projectId: 95,
serviceTypeEnum: ServiceTypeEnum.advancePayment,
);
}).catchError((err) {
print(err);
if (context = null) GifLoaderDialogUtils.hideDialog(context);
GifLoaderDialogUtils.hideDialog(context);
AppToast.showErrorToast(message: err);
});
} else {
@ -309,72 +327,7 @@ class _ConfirmPaymentPageState extends State<ConfirmPaymentPage> {
);
}
// startApplePay() {
// 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);
});
}
void addPayFortApplePayResponse() {}
String getApplePayPaymentType(dynamic paymentMethod) {
switch (paymentMethod) {

@ -7,8 +7,9 @@ class PayfortProjectDetailsRespModel {
int servID;
String shaRequest;
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) {
accessCode = json['AccessCode'];

@ -39,6 +39,44 @@ class PayfortService extends BaseService {
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 {
var response = await post(
Uri.parse(payFortEnvironment.paymentApi),
@ -83,6 +121,26 @@ class PayfortService extends BaseService {
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({
SucceededCallback onSucceeded,
FailedCallback onFailed,

@ -19,6 +19,11 @@ class PayfortViewModel extends ChangeNotifier {
PayfortProjectDetailsRespModel payfortProjectDetailsRespModel = PayfortProjectDetailsRespModel();
try {
payfortProjectDetailsRespModel = await _payfortService.getPayfortConfigurations(serviceId: serviceId, projectId: projectId);
String signature =
await _payfortService.getPayfortSignature(payfortProjectDetailsRespModel.accessCode, payfortProjectDetailsRespModel.merchantIdentifier, payfortProjectDetailsRespModel.shaRequest);
payfortProjectDetailsRespModel.signature = signature;
return payfortProjectDetailsRespModel;
} on Exception catch (e, 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({
String customerName,
String customerEmail,
String orderDescription,
String merchantReference,
double orderAmount,
PayfortProjectDetailsRespModel payfortProjectDetailsRespModel,
SucceededCallback onSuccess,
FailedCallback onFailed,
ServiceTypeEnum serviceTypeEnum,
int projectId,
}) async {
GifLoaderDialogUtils.showMyDialog(AppGlobal.context);
PayfortProjectDetailsRespModel payfortProjectDetailsRespModel = await getProjectDetailsForPayfort(projectId: projectId, serviceId: serviceTypeEnum.getIdFromServiceEnum());
if (payfortProjectDetailsRespModel == null) {
GifLoaderDialogUtils.hideDialog(AppGlobal.context);
return;
}
// GifLoaderDialogUtils.showMyDialog(AppGlobal.context);
// PayfortProjectDetailsRespModel payfortProjectDetailsRespModel = await getProjectDetailsForPayfort(projectId: projectId, serviceId: serviceTypeEnum.getIdFromServiceEnum());
//
// if (payfortProjectDetailsRespModel == null) {
// GifLoaderDialogUtils.hideDialog(AppGlobal.context);
// return;
// }
try {
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 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

Loading…
Cancel
Save