Skip to main content

Payment Request

The following guideline provides an explanation of how to apply the corresponding source code in a merchant's application to form and send the payment request parameters to PayMaster for recurring payments.

Step 1 : Library

The merchant must include the PayMaster Merchant Plug-In (MPI) Java library, PayMaster.jar, in the merchant application.

Step 2 : Import

For recurring payments, the merchant shall import the following into the merchant 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 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();

Step 4 : Indicate PayMaster Properties File Location

The merchant must indicate where the PayMaster Properties File is located using PropertiesReader.

Step 5: Assign Value to Payment Request Entity

The merchant must 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 the function accepts two parameters: setter(parameter name, parameter value).

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

Step 6 : Generate the Payment Message

Once all the mandatory values are assigned, the merchant calls the PaymentRequestMessageBuilder to generate the recurring paymentMessage.

Step 7 : Send the Payment Message to the PayMaster Gateway

The paymentMessage will be used to send the payment request to the PayMaster Gateway for the recurring payment function.

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