Skip to main content

Payment Request

The following guideline explains how to apply the corresponding source code in the merchant's application to form and send the payment request parameters to PayMaster for reversal payment processing.

Step 1 : Library

The merchant should include the PayMaster Merchant Plug-In (MPI) Java library, PayMaster.jar, into their application.

Step 2 : Import

For reversal payments, the merchant should import the following into their code:

  • com.PayMaster.Entities.PayMasterEntity
  • com.PayMaster.PropertiesReader.PropertiesReader
  • com.PayMaster.MessageRequestBuilder.PaymentRequestMessageBuilder

Step 3 : Source Code

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();

Step 4 : Indicate PayMaster Properties File Location

The merchant must specify the location of the PayMaster Properties File using the PropertiesReader.

Step 5 : Assign Values to the Payment Request Entity

The merchant should assign values to the PayMaster Request Entity. The merchant's code must include all the fields as stated in the sample code, as they are mandatory.

  • The setter function is used to assign values, and it accepts two parameters: setter(parameter name, parameter value).

Refer to Reversal Payment Parameters for the fields supported by the PayMaster Merchant Plug-In (MPI).

Step 6 : Generate the Payment Message

Once all mandatory values are assigned, the merchant should call the PaymentRequestMessageBuilder to generate the reversal paymentMessage.

Step 7 : Send the Payment Message to the PayMaster Gateway

The paymentMessage will be sent to the PayMaster Gateway for the reversal payment function.

Refer to Payment Response for security controls supported by PayMaster Merchant Plug-In (MPI).