跳到主要内容

付款请求

以下指南介绍了如何在商户应用程序中应用相应的源代码,形成付款请求参数并将其发送给 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 a variable for PayMaster Properties - 1st Parameter = File Path, 2nd Parameter = File Name
PropertiesReader propertiesReader = new PropertiesReader("./PayMasterProperties/", "CCPayment.properties");

// Declare a variable for PayMaster Entity
PayMasterEntity paymentRequestEntity = new PayMasterEntity();

// Get all the parameter values from the user side and set them into PayMaster 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 PayMaster Gateway for reversal 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)支持的安全控制。