Skip to main content

Payment Request

take note

The reversal function for QR Payment is available for ** Duitnow ** and ** Alipay+ **. Please refer to the Important Notes.

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

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

// Set values into PayMaster Entity
paymentRequestEntity.set("PaymentID", "C15");
paymentRequestEntity.set("MerchRefNo", "merchant-refNo-0001");
paymentRequestEntity.set("CurrCode", "458");
paymentRequestEntity.set("TxnAmt", "1.00");
paymentRequestEntity.set("ExpTxnAmt", "2");

// Call 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
String initialUrl = "https://xxx.finexusgroup.com/upp/faces/reversal0400.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 must assign values to the PayMasterRequestEntity. The code must include all mandatory fields as specified in the sample code. Use the setter function to assign values, the function 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, call the PaymentRequestMessageBuilder to generate the reversal payment message (paymentMessage).

Step 7 : Send the Payment Message to the PayMaster Gateway

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

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