完成请求
本指南介绍了如何应用相应的源代码形成重定向链接中的强制支付请求参数,并将其发送给PayMaster进行支付完成处理。
- Java
- .Net
- PHP
- Python
- Node.js
第 1 步:图书馆
商户必须在商户应用程序中包含 PayMaster 商户插件 (MPI) Java 库 PayMaster.jar。
第 2 步:导入
对于 UPP 付款,商家应将以下内容导入其代码中:
com.PayMaster.Entities.PayMasterEntity
com.PayMaster.PropertiesReader.PropertiesReader
com.PayMaster.MessageRequestBuilder.PaymentRequestMessageBuilder
第 3 步:源代码
import com.PayMaster.Entities.PayMasterEntity;
import com.PayMaster.PropertiesReader.PropertiesReader;
import com.PayMaster.MessageRequestBuilder.PaymentRequestMessageBuilder;
// Declare a variable for Payment Master Properties - 1st Parameter = File Path, 2nd Parameter = File name
PropertiesReader propertiesReader = new PropertiesReader("./PayMasterProperties/", "CCPayment.properties");
// Declare a variable for Payment Master Entity
PayMasterEntity paymentRequestEntity = new PayMasterEntity();
// Get all the parameter values from the user side and set them into the Payment Master Entity
paymentRequestEntity.setter("PaymentID", "C13");
paymentRequestEntity.setter("MerchRefNo", "merchant-refNo-0001");
paymentRequestEntity.setter("CurrCode", "458");
paymentRequestEntity.setter("TxnAmt", "1.00");
paymentRequestEntity.setter("ExpTxnAmt", "2");
paymentRequestEntity.setter("CardNo", "8853010000095323");
// Call Payment Master Payment Request Message Builder to generate the message
PaymentRequestMessageBuilder messageBuilder = new PaymentRequestMessageBuilder();
String paymentMessage = messageBuilder.buildPaymentRequestMessage(paymentRequestEntity, propertiesReader);
// POST request to Payment Master Gateway for pre-authorization payment
String initialUrl = "https://xxx.finexusgroup.com/upp/faces/preauthcomplete.xhtml?" + paymentMessage;
HttpURLConnection connection = null;
URL url = new URL(initialUrl);
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
in.close();
String finalUrl = connection.getURL().toString();
第 4 步:指示 PayMaster 属性文件位置
商家必须使用PropertiesReader
指定 PayMaster 属性文件的位置。
第 5 步: 为付款请求实体分配值
商家应向 PayMaster 请求实体分配值。商家代码必须包含示例代码中所述的所有字段,因为它们是强制性的。
- setter函数用于赋值,它接受两个参数:
setter(参数名,参数值)
。
PayMaster商户插件(MPI)支持的字段请参考 预授权完成参数。
第 6 步:生成 UPP 付款
一旦分配了所有强制值,商家就会调用支 付请求消息生成器来生成 UPP 支付 – paymentMessage
。
第 7 步:将付款消息发送至 PayMaster 网关
paymentMessage
将用于发送到 PayMaster 网关以进行 UPP 付款。
请参阅 预授权完成响应了解PayMaster商户插件(MPI)支持的安全控制。
第 1 步:图书馆
商户必须在商户应用程序中包含 PayMaster 商户插件 (MPI) .NET 库 PayMaster.dll。
第 2 步:命名空间
对于 UPP 支付,商户应在商户代码中包含以下命名空间:
using com.PayMaster.Entities
using com.PayMaster.Properties
using com.PayMaster.MessageRequestBuilder
第 3 步:源代码
using com.PayMaster.Entities;
using com.PayMaster.Properties;
using com.PayMaster.MessageRequestBuilder;
// Declare a variable for Payment Master Properties - 1st Parameter = File Path, 2nd Parameter = File name
PropertiesReader propertiesReader = new PropertiesReader("./PayMasterProperties/", "CCPayment.properties");
// Declare a variable for Payment Master Entity
PayMasterEntity ccPaymentRequestEntity = new PayMasterEntity();
// Get all the parameter values from the user side and set them into the Payment Master Entity
ccPaymentRequestEntity.setter("PaymentID", "C13");
ccPaymentRequestEntity.setter("MerchRefNo", "merchant-refNo-0001");
ccPaymentRequestEntity.setter("CurrCode", "458");
ccPaymentRequestEntity.setter("TxnAmt", "1.00");
ccPaymentRequestEntity.setter("ExpTxnAmt", "2");
ccPaymentRequestEntity.setter("CardNo", "8853010000095XXX"); // Masked for security
// Call Payment Master Payment Request Message Builder to generate the message
PaymentRequestMessageBuilder ccMessageBuilder = new PaymentRequestMessageBuilder();
string ccPaymentMessage = ccMessageBuilder.buildPaymentRequestMessage(ccPaymentRequestEntity, propertiesReader);
// POST request to Payment Master Gateway for pre-authorization payment
string initialUrl = "https://xxx.finexusgroup.com/upp/faces/preauthcomplete.xhtml?" + ccPaymentMessage;
HttpClient httpClient = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, initialUrl);
HttpResponseMessage response = await httpClient.SendAsync(request);
Uri finalUrl = response.RequestMessage.RequestUri;