Payment Request
The following guideline is to provide explanation on how to apply the corresponding source code in merchant website and application in order to form the payment request parameters which the merchant can have in the redirect link and send to PayMaster for QR payment processing.
- Java
- .Net
- PHP
- Python
- Node.js
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 QR payment, 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 Payment Master Properties - 1st Parameter = File Path, 2nd Parameter = File Name
PropertiesReader propertiesReader = new PropertiesReader("./PayMasterProperties/", "QRPayment.properties");
// Declare variable for Payment Master Entity
PayMasterEntity paymentRequestEntity = new PayMasterEntity();
// Set parameter values into Payment Master Entity
paymentRequestEntity.set("PaymentID", "Q03");
paymentRequestEntity.set("MerchRefNo", "merchant-refNo-0001");
paymentRequestEntity.set("CurrCode", "458");
paymentRequestEntity.set("TxnAmt", "1.00");
paymentRequestEntity.set("ExpTxnAmt", "2");
paymentRequestEntity.set("TerminalID", "200039XX");
paymentRequestEntity.set("PayloadInd", "12");
paymentRequestEntity.set("PANInd", "26");
paymentRequestEntity.set("CountryCode", "MY");
paymentRequestEntity.set("TxnFlag", "CP");
paymentRequestEntity.set("SndrID", "46654288XX893XXX");
paymentRequestEntity.set("SndrIDType", "2");
paymentRequestEntity.set("ExpiryYear", "27");
paymentRequestEntity.set("ExpiryMth", "12");
paymentRequestEntity.set("QRPayload", "00020201021226470014A00...");
// Generate the payment request message
PaymentRequestMessageBuilder messageBuilder = new PaymentRequestMessageBuilder();
String paymentMessage = messageBuilder.buildPaymentRequestMessage(paymentRequestEntity, propertiesReader);
// POST request to Payment Master Gateway for QR Payload
String initialUrl = "https://xxx.finexusgroup.com/upp/faces/qrPushPayment.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 PropertiesReader
.
Step 5 : Assign Values to the Payment Request Entity
Assign values to the PayMaster Request Entity. Ensure all fields as shown in the sample code are included, as they are mandatory. Use the setter function to assign values, the function accepts two parameters: setter(parameter name, parameter value)
.
Refer to QR Payment Parameters for the fields supported by the PayMaster Merchant Plug-In (MPI).
Step 6 : Generate Consumer Presented QR Payment
Once all mandatory values are assigned, call the PaymentRequestMessageBuilder
to generate the Consumer Presented QR Payment message (paymentMessage
).
Step 7 : Send the Payment Message to the PayMaster Gateway
Send the paymentMessage
to the PayMaster Gateway for the QR Payload.
Refer to QR Payment Response for security controls supported by PayMaster Merchant Plug-In (MPI).
Step 1 : Library
The merchant must include the PayMaster Merchant Plug-In (MPI) .NET library, PayMaster.dll, in the merchant application.
Step 2 : Namespace
For QR Payment, the merchant shall include the following namespaces in the merchant code:
using com.PayMaster.Entities
using com.PayMaster.Properties
using com.PayMaster.MessageRequestBuilder
Step 3 : Source Code
using com.PayMaster.Entities;
using com.PayMaster.Properties;
using com.PayMaster.MessageRequestBuilder;
// Declare variable for Payment Master Properties - 1st Parameter = File Path, 2nd Parameter = File Name
PropertiesReader propertiesReader = new PropertiesReader("./PayMasterProperties/", "QRPayment.properties");
// Declare variable for Payment Master Entity
PayMasterEntity qrPaymentRequestEntity = new PayMasterEntity();
// Set parameter values into Payment Master Entity
qrPaymentRequestEntity.setter("PaymentID", "Q03");
qrPaymentRequestEntity.setter("MerchRefNo", "merchant-refNo-0001");
qrPaymentRequestEntity.setter("CurrCode", "458");
qrPaymentRequestEntity.setter("TxnAmt", "1.00");
qrPaymentRequestEntity.setter("ExpTxnAmt", "2");
qrPaymentRequestEntity.setter("TerminalID", "200039XX");
qrPaymentRequestEntity.setter("PayloadInd", "12");
qrPaymentRequestEntity.setter("PANInd", "26");
qrPaymentRequestEntity.setter("CountryCode", "MY");
qrPaymentRequestEntity.setter("TxnFlag", "CP");
qrPaymentRequestEntity.setter("SndrID", "46654288XX893XXX");
qrPaymentRequestEntity.setter("SndrIDType", "2");
qrPaymentRequestEntity.setter("ExpiryYear", "27");
qrPaymentRequestEntity.setter("ExpiryMth", "12");
qrPaymentRequestEntity.setter("QRPayload", "00020201021226470014A00...");
// Generate the payment request message
PaymentRequestMessageBuilder qrMessageBuilder = new PaymentRequestMessageBuilder();
string qrPaymentMessage = qrMessageBuilder.buildPaymentRequestMessage(qrPaymentRequestEntity, propertiesReader);
// POST request to Payment Master Gateway for QR Payload
string initialUrl = "https://xxx.finexusgroup.com/upp/faces/qrPushPayment.xhtml?" + qrPaymentMessage;
HttpClient httpClient = new HttpClient();
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, initialUrl);
HttpResponseMessage response = await httpClient.SendAsync(request);
Uri finalUrl = response.RequestMessage.RequestUri;
Step 4 : Indicate PayMaster Properties File Location
Specify the location of the PayMaster Properties File using the PropertiesReader
.
Step 5 : Assign Values to the Payment Request Entity
Assign values to the PayMaster Request Entity. Ensure that all fields required by the sample code are included, as they are mandatory. Use the setter function to assign values, it accepts two parameters: setter(parameter name, parameter value)
.
Refer to QR Payment Parameters for the fields supported by the PayMaster Merchant Plug-In (MPI).
Step 6 : Generate Consumer Presented QR Payment
Once all mandatory values are assigned, call the PaymentRequestMessageBuilder
to generate the Consumer Presented QR Payment message (paymentMessage
).
Step 7 : Send the Payment Message to the PayMaster Gateway
Send the qrPaymentMessage
to the PayMaster Gateway for the QR Payload.
Refer to QR Payment Response for security controls supported by PayMaster Merchant Plug-In (MPI).
Step 1 : Library
The merchant must include the PayMaster Merchant Plug-In (MPI) PHP library, PayMaster.phar, in the merchant application.
Step 2 : Import
For QR payment, the merchant should import the following into their code:
PropertiesReader
- to read the properties files.PayMasterEntity
– to assign all the acceptable values for PayMaster QR payment.PaymentRequestMessageBuilder
– to generate the PayMaster QR payment request message.
Step 3 : Source Code
<?php
use com\PayMaster\Entities\PayMasterEntity;
use com\PayMaster\PropertiesReader\PropertiesReader;
use com\PayMaster\MessageRequestBuilder\PaymentRequestMessageBuilder;
use com\PayMaster\Import\ImportFile;
// Locate the absolute path of PayMaster.phar
$basePath = 'phar://<PayMaster.phar path>/';
include_once $basePath . 'com/PayMaster/Import/ImportFile.php';
$import = new ImportFile();
$import->includeFile($basePath);
// Declare variable for Payment Master Properties - 1st Parameter = File Path, 2nd Parameter = File Name
$propertiesReader = new PropertiesReader();
$propertiesReader->PropertiesReader("./PayMasterProperties/", "QRPayment.ini");
// Declare variable for Payment Master Entity
$paymentRequestEntity = new PayMasterEntity();
// Set parameter values into Payment Master Entity
$paymentRequestEntity->setter("PaymentID", "Q03");
$paymentRequestEntity->setter("MerchRefNo", "merchant-refNo-0001");
$paymentRequestEntity->setter("CurrCode", "458");
$paymentRequestEntity->setter("TxnAmt", "1.00");
$paymentRequestEntity->setter("ExpTxnAmt", "2");
$paymentRequestEntity->setter("TerminalID", "200039XX");
$paymentRequestEntity->setter("PayloadInd", "12");
$paymentRequestEntity->setter("PANInd", "26");
$paymentRequestEntity->setter("CountryCode", "MY");
$paymentRequestEntity->setter("TxnFlag", "CP");
$paymentRequestEntity->setter("SndrID", "46654288XX893XXX");
$paymentRequestEntity->setter("SndrIDType", "2");
$paymentRequestEntity->setter("ExpiryYear", "27");
$paymentRequestEntity->setter("ExpiryMth", "12");
$paymentRequestEntity->setter("QRPayload", "00020201021226470014A00...");
// Generate the payment request message
$paymentRequestMessageBuilder = new PaymentRequestMessageBuilder();
$paymentMessage = $paymentRequestMessageBuilder->buildPaymentRequestMessage($paymentRequestEntity, $propertiesReader);
// POST request to Payment Master Gateway for QR Payload
$initialUrl = "https://xxx.finexusgroup.com/upp/faces/qrPushPayment.xhtml?" . $paymentMessage;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $initialUrl);
curl_setopt($ch, CURLOPT_POST, 1);
$response = curl_exec($ch);
curl_close($ch);
$finalUrl = curl_getinfo($ch, CURLINFO_REDIRECT_URL);
exit();
?>
Step 4 : Locate the Absolute Path of PayMaster.phar
Specify the absolute path of PayMaster.phar in the basePath
variable in your PHP code.
Example:$basePath='phar://<absolute path of PayMaster.phar>/'
Step 5 : Indicate PayMaster Properties File Location
Specify the location of the PayMaster Properties File using the PropertiesReader
.
Step 6 : Assign Values to the Payment Request Entity
Assign values to the PayMaster Request Entity. Ensure that all fields as stated in the sample code are included, as they are mandatory. Use the setter function to assign values, the function accepts two parameters: setter(parameter name, parameter value)
.
Refer to QR Payment Parameters for the fields supported by the PayMaster Merchant Plug-In (MPI).
Step 7 : Generate Consumer Presented QR Payment
Once all mandatory values are assigned, call the PaymentRequestMessageBuilder
to generate the Consumer Presented QR Payment message (paymentMessage
).
Step 8 : Send the Payment Message to the PayMaster Gateway
Send the paymentMessage
to the PayMaster Gateway for the QR Payload.
Refer to QR Payment Response for security controls supported by PayMaster Merchant Plug-In (MPI).
Step 1 : Packages
The merchant must set up and include the PayMaster Merchant Plug-In (MPI) Python packages in the merchant application.
Step 2 : Import
For QR payment, the merchant shall include the following in their code:
PropertiesReader
– to read the properties files.PayMasterEntity
– to assign all the acceptable values for PayMaster QR payment.PaymentRequestMessageBuilder
- to generate the PayMaster QR Payment request message.
Step 3 : Source Code
from com.PayMaster.Entities.PayMasterEntity import PayMasterEntity
from com.PayMaster.PropertiesReader.PropertiesReader import PropertiesReader
from com.PayMaster.MessageRequestBuilder.PaymentRequestMessageBuilder import PaymentRequestMessageBuilder
import requests
# Declare variable for Payment Master Properties - 1st Parameter = File Path, 2nd Parameter = File Name
propertiesReader = PropertiesReader("PayMasterProperties/", "QRPayment.properties")
# Declare variable for Payment Master Entity
qrPaymentRequestEntity = PayMasterEntity()
# Set parameter values into Payment Master Entity
qrPaymentRequestEntity.setter("PaymentID", "Q03")
qrPaymentRequestEntity.setter("MerchRefNo", "merchant-refNo-0001")
qrPaymentRequestEntity.setter("CurrCode", "458")
qrPaymentRequestEntity.setter("TxnAmt", "1.00")
qrPaymentRequestEntity.setter("ExpTxnAmt", "2")
qrPaymentRequestEntity.setter("TerminalID", "200039XX")
qrPaymentRequestEntity.setter("PayloadInd", "12")
qrPaymentRequestEntity.setter("PANInd", "26")
qrPaymentRequestEntity.setter("CountryCode", "MY")
qrPaymentRequestEntity.setter("TxnFlag", "CP")
qrPaymentRequestEntity.setter("SndrID", "46654288XX893XXX")
qrPaymentRequestEntity.setter("SndrIDType", "2")
qrPaymentRequestEntity.setter("ExpiryYear", "27")
qrPaymentRequestEntity.setter("ExpiryMth", "12")
qrPaymentRequestEntity.setter("QRPayload", "00020201021226470014A00...")
# Generate the payment request message
qrMessageBuilder = PaymentRequestMessageBuilder()
qrPaymentMessage = qrMessageBuilder.buildPaymentRequestMessage(qrPaymentRequestEntity, propertiesReader)
# POST request to Payment Master Gateway for QR Payload
initial_url = "https://xxx.finexusgroup.com/upp/faces/qrPushPayment.xhtml?" + qrPaymentMessage
response = requests.post(initial_url)
final_url = response.url
Step 4 : Indicate PayMaster Properties File Location
Specify the location of the PayMaster Properties File using the PropertiesReader
.
Step 5 : Assign Values to the Payment Request Entity
Assign values to the PayMaster Request Entity. Ensure all fields as stated in the sample code are included, as they are mandatory. Use the setter function to assign values, it accepts two parameters: setter(parameter name, parameter value)
.
Refer to QR Payment Parameters for the fields supported by the PayMaster Merchant Plug-In (MPI).
Step 6 : Generate Consumer Presented QR Payment
Once all mandatory values are assigned, call the PaymentRequestMessageBuilder
to generate the Consumer Presented QR Payment message (paymentMessage
).
Step 7 : Send the Payment Message to the PayMaster Gateway
Send the qrPaymentMessage
to the PayMaster Gateway for the QR Payload.
Refer to QR Payment Response for security controls supported by PayMaster Merchant Plug-In (MPI).
Step 1 : Library
The merchant shall set up and include the PayMaster Merchant Plug-In (MPI) Node.js library into the merchant application.
Step 2 : Source Code
var paymaster = require('./js/PayMaster.min.js');
var axios = require('axios');
module.exports = function (app) {
app.post('/QRPayment', (req, res) => {
// Initialize PropertiesReader and set parameters
paymaster.PropertiesReader('./properties/', 'QRPayment.properties');
paymaster.setter('PaymentID', 'Q03');
paymaster.setter('MerchRefNo', 'merchant-refNo-0001');
paymaster.setter('CurrCode', '458');
paymaster.setter('TxnAmt', '1.00');
paymaster.setter('ExpTxnAmt', '2');
paymaster.setter('TerminalID', '200039XX');
paymaster.setter('PayloadInd', '12');
paymaster.setter('PANInd', '26');
paymaster.setter('CountryCode', 'MY');
paymaster.setter('TxnFlag', 'CP');
paymaster.setter('SndrID', '46654288XX893XXX');
paymaster.setter('SndrIDType', '2');
paymaster.setter('ExpiryYear', '27');
paymaster.setter('ExpiryMth', '12');
paymaster.setter('QRPayload', '00020201021226470014A00...');
// Generate payment request message
paymaster.MERCH_QRPaymentRequest(paymaster.PaymentRequestEntity, paymaster.propDetails, (err, response, result) => {
if (err) {
throw err;
}
if (response) {
const initialUrl = "https://xxx.finexusgroup.com/upp/faces/qrPushPayment.xhtml?" + result;
async function sendPostRequest() {
try {
const response = await axios.post(initialUrl);
const finalUrl = response.request.res.responseUrl;
res.json({ finalUrl });
} catch (error) {
res.status(500).send('Error sending request to PayMaster');
}
}
sendPostRequest();
}
});
});
}
Step 3 : Indicate PayMaster Properties File Location
Specify the location of the PayMaster Properties File using the PropertiesReader
.
Step 4 : Assign Values to the Payment Request Entity
Assign values to the PayMaster Request Entity. Ensure that all fields as stated in the sample code are included, as they are mandatory. Use the setter function to assign values, it accepts two parameters: setter(parameter name, parameter value)
.
Refer to QR Payment Parameters for the fields supported by the PayMaster Merchant Plug-In (MPI).
Step 5 : Generate the Request Message
Use the MERCH_QRPaymentRequest()
function to generate the payment request message.
Step 6 : Send the Payment Message to PayMaster
Send the payment message returned by the JavaScript to PayMaster for processing.
Refer to QR Payment Response for security controls supported by PayMaster Merchant Plug-In (MPI).