跳到主要内容

付款请求

以下指南解释了如何在商户应用程序中应用相应的源代码来形成付款请求参数并将其发送到 PayMaster 以进行定期付款。

第 1 步:图书馆

商户必须在商户应用程序中包含 PayMaster 商户插件 (MPI) Java 库 PayMaster.jar

第 2 步:导入

对于定期付款,商户应将以下内容导入商户代码:

  • 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 variable for Payment Master Properties - 1st Parameter = File Path, 2nd Parameter = File Name
PropertiesReader propertiesReader = new PropertiesReader("./PayMasterProperties/", "CCPayment.properties");

// Declare variable for Payment Master Entity
PayMasterEntity paymentRequestEntity = new PayMasterEntity();

// Get all the parameter values from the user side and set them into Payment Master Entity
paymentRequestEntity.setter("PaymentID", "C04");
paymentRequestEntity.setter("MerchRefNo", "merchant-refNo-0001");
paymentRequestEntity.setter("CurrCode", "458");
paymentRequestEntity.setter("TxnAmt", "1.00");
paymentRequestEntity.setter("ExpTxnAmt", "2");
paymentRequestEntity.setter("ECI", "12");
paymentRequestEntity.setter("CardNo", "8853010000095323");
paymentRequestEntity.setter("TokenFlag", "Y");
paymentRequestEntity.setter("POSEnvFlag", "R");
paymentRequestEntity.setter("MerchUserID", "guest");
paymentRequestEntity.setter("ExpiryYear", "20");
paymentRequestEntity.setter("ExpiryMth", "12");
paymentRequestEntity.setter("TokenShrtName", "testcard");

// 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 recurring payment
String initialUrl = "https://xxx.finexusgroup.com/upp/faces/ccpayment.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 步: 生成付款消息

一旦分配了所有强制值,商家就会调用PaymentRequestMessageBuilder来生成重复的paymentMessage

第 7 步:将付款消息发送至 PayMaster 网关

paymentMessage 将用于将付款请求发送到 PayMaster 网关以实现定期付款功能。

请参阅付款响应了解PayMaster商户插件(MPI)支持的安全控制。