付款响应
以下指南解释了如何在商户应用程序中集成和利用相应的源代码,从 PayMaster 返回的响应消息中检索支付响应参数。
- Java
- .Net
- PHP
- Python
- Node.js
第 1 步:图书馆
商户应在商户应用程序中包含 PayMaster 商户插件 (MPI) Java 库 PayMaster.jar。
第 2 步:导入
对于冲销付款,商家应将以下内容导入其代码中:
com.PayMaster.Entities.PayMasterEntity
com.PayMaster.PropertiesReader.PropertiesReader
com.PayMaster.MessageResponseBuilder.PaymentResponseMessageBuilder
第 3 步:源代码
import com.PayMaster.Entities.PayMasterEntity;
import com.PayMaster.PropertiesReader.PropertiesReader;
import com.PayMaster.MessageResponseBuilder.PaymentResponseMessageBuilder;
// Declare a variable for PayMaster Properties - 1st Parameter = File Path, 2nd Parameter = File Name
PropertiesReader propertiesReader = new PropertiesReader("./PayMasterProperties/", "CardPayment.properties");
// Declare a variable for PayMaster Entity
PayMasterEntity paymentResponseEntity = new PayMasterEntity();
// Get the response message from PayMaster and set it into PayMaster Entity
paymentResponseEntity.setter("ResponseMessage", responseMessage);
// Call PaymentResponseMessageBuilder to parse the response message
PaymentResponseMessageBuilder paymentResponseMessageBuilder = new PaymentResponseMessageBuilder();
paymentResponseMessageBuilder.buildCardPaymentResponseMessage(paymentResponseEntity, propertiesReader);
// Retrieve values from PayMaster Response Entity
String MerchantID = paymentResponseEntity.getter("MerchantID");
String MerchRefNo = paymentResponseEntity.getter("MerchRefNo");
String TxnStatus = paymentResponseEntity.getter("TxnStatus");
String SHAlgorithmType = paymentResponseEntity.getter("SHAlgorithmType");
String SHValue = paymentResponseEntity.getter("SHValue");
第 4 步:指示 PayMaster 属性文件位置
商家必须使用PropertiesReader
指定 PayMaster 属性文件的位置。
第 5 步:使用 Setter 设置响应消息
商户必须使用setter方法设置PayMaster网关返回的响应消息:paymentResponseEntity.setter("ResponseMessage", "<PayMaster网关返回的响应消息>");
第 6 步: 解析 PayMaster 响应实体并为其赋值
商户应调用 CardPaymentResponseMessageBuilder
来解析响应消息并将值分配给PayMaster响应实体。
PayMaster商户插件(MPI)支持的字段请参见 冲销支付参数。
第 7 步: 从 PayMaster 响应实体检索值
商家可以从 PayMaster 响应实体检索值。
- getter 函数用于检索值并接受一个参数:
getter(参数名称)
。
确保 TxnStatDetCde
的值不等于 5015,因为这表示无效的安全哈希值。
第 1 步:图书馆
商户应在商户应用程序中包含 PayMaster 商户插件 (MPI) .NET 库 PayMaster.dll。
第 2 步:命名空间
对于撤销付款,商户应在商户代码中包含以下命名空间:
using com.PayMaster.Entities
using com.PayMaster.Properties
using com.PayMaster.MessageResponseBuilder
第 3 步:源代码
using com.PayMaster.Entities;
using com.PayMaster.Properties;
using com.PayMaster.MessageResponseBuilder;
// 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 ccPaymentResponseEntity = new PayMasterEntity();
// Set the response message received from PayMaster into the PayMaster Entity
ccPaymentResponseEntity.setter("ResponseMessage", responseMessage);
// Call PaymentResponseMessageBuilder to parse the response message
PaymentResponseMessageBuilder cardPaymentResponseMessageBuilder = new PaymentResponseMessageBuilder();
cardPaymentResponseMessageBuilder.buildCardPaymentResponseMessage(ccPaymentResponseEntity, propertiesReader);
// Retrieve values from PayMaster Response Entity
string MerchantID = ccPaymentResponseEntity.getter("MerchantID");
string MerchRefNo = ccPaymentResponseEntity.getter("MerchRefNo");
string TxnStatus = ccPaymentResponseEntity.getter("TxnStatus");
string SHAlgorithmType = ccPaymentResponseEntity.getter("SHAlgorithmType");
string SHValue = ccPaymentResponseEntity.getter("SHValue");