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.
- 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 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).
Step 1 : Library
The merchant shall include the PayMaster Merchant Plug-In (MPI) .Net library— PayMaster.dll into the merchant application.
Step 2 : Namespace
For recurring payments, the merchant shall use 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 PayMaster Properties - 1st Parameter = File Path, 2nd Parameter = File Name
PropertiesReader propertiesReader = new PropertiesReader("./PayMasterProperties/", "CCPayment.properties");
// Declare variable for PayMaster Entity
PayMasterEntity ccPaymentRequestEntity = new PayMasterEntity();
// Get all the parameter values from the user side and set them into PayMaster Entity
ccPaymentRequestEntity.setter("PaymentID", "C04");
ccPaymentRequestEntity.setter("ECI", "12");
ccPaymentRequestEntity.setter("MerchRefNo", "merchant-refNo-0001");
ccPaymentRequestEntity.setter("CurrCode", "458");
ccPaymentRequestEntity.setter("TxnAmt", "1.00");
ccPaymentRequestEntity.setter("ExpTxnAmt", "2");
ccPaymentRequestEntity.setter("CardNo", "8853010000095323");
ccPaymentRequestEntity.setter("ExpiryYear", "20");
ccPaymentRequestEntity.setter("ExpiryMth", "12");
ccPaymentRequestEntity.setter("TokenFlag", "Y");
ccPaymentRequestEntity.setter("MerchUserID", "guest");
ccPaymentRequestEntity.setter("TokenShrtName", "testcard");
// Call Payment Master Payment Request Message Builder to generate the message
PaymentRequestMessageBuilder ccMessageBuilder = new PaymentRequestMessageBuilder();
string ccPaymentMessage = ccMessageBuilder.buildPaymentRequestMessage(ccPaymentRequestEntity, propertiesReader);
// POST request to PayMaster Gateway for recurring payment
string initialUrl = "https://xxx.finexusgroup.com/upp/faces/ccpayment.xhtml?" + ccPaymentMessage;
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
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 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 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 ccPaymentMessage
.
Step 7 : Send the Payment Message to the PayMaster Gateway
The ccPaymentMessage
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).
Step 1 : Library
The merchant shall include the PayMaster Merchant Plug-In (MPI) PHP library – PayMaster.phar into the merchant application.
Step 2 : Import
For recurring payments, the merchant shall import the following into their code:
PropertiesReader
– to read the properties files.PayMasterEntity
– to assign all the acceptable values for PayMaster recurring payments.PaymentRequestMessageBuilder
– to generate the PayMaster recurring 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;
// Merchant to locate the absolute path of PayMaster.phar
$basePath = 'phar://<absolute path of PayMaster.phar>/';
include_once $basePath.'com/PayMaster/Import/ImportFile.php';
$import = new ImportFile();
$import->includeFile($basePath);
// Declare variable for PayMaster Properties - 1st Parameter = File Path, 2nd Parameter = File Name
$propertiesReader = new PropertiesReader();
$propertiesReader->PropertiesReader(<absolute path>, "CCPayment.ini");
// Declare variable for PayMaster Entity
$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("TokenShrtName", "testcard");
$paymentRequestEntity->setter("ExpiryYear", "20");
$paymentRequestEntity->setter("ExpiryMth", "12");
// Call Payment Master Payment Request Message Builder to generate the message
$paymentRequestMessageBuilder = new PaymentRequestMessageBuilder();
$paymentMessage = $paymentRequestMessageBuilder->buildPaymentRequestMessage($paymentRequestEntity, $propertiesReader);
// POST request to PayMaster Gateway for recurring payment
$initialUrl = "https://xxx.finexusgroup.com/upp/faces/ccpayment.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
The merchant must locate the absolute path of PayMaster.phar as the basePath
in the merchant's source code (line 7 in the example above).
Example:$basePath='phar://<absolute path of PayMaster.phar>/'
Step 5 : Indicate PayMaster Properties File Location
The merchant must specify the location of the PayMaster Properties File using the PropertiesReader
.
Step 6 : Assign Values to the 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 it 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 7 : Generate the Payment Message
Once all the mandatory values are assigned, the merchant calls the PaymentRequestMessageBuilder
to generate the recurring paymentMessage
.
Step 8 : Send the Payment Message to the PayMaster Gateway
The paymentMessage
will be sent to the PayMaster Gateway for the recurring payment function.
Refer to Payment Response for security controls supported by PayMaster Merchant Plug-In (MPI).
Step 1 : Packages
The merchant shall set up and include PayMaster Merchant Plug-In (MPI) Python packages into the merchant application.
Step 2 : Import
For recurring payments, the merchant shall include the following in their code:
PropertiesReader
– to read the properties files.PayMasterEntity
– to assign all the acceptable values for PayMaster Recurring payment.PaymentRequestMessageBuilder
- to generate the PayMaster Recurring 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 PayMaster Properties - 1st Parameter = File Name, 2nd Parameter = File Path
propertiesReader = PropertiesReader("CCPayment.properties", "PayMasterProperties/")
# Declare variable for PayMaster Entity
ccPaymentRequestEntity = PayMasterEntity()
# Get all the parameter values from the user side and set them into PayMaster Entity
ccPaymentRequestEntity.setter("PaymentID", "C04")
ccPaymentRequestEntity.setter("ECI", "12")
ccPaymentRequestEntity.setter("MerchRefNo", "merchant-refNo-0001")
ccPaymentRequestEntity.setter("TxnDtTm", "")
ccPaymentRequestEntity.setter("CurrCode", "458")
ccPaymentRequestEntity.setter("TxnAmt", "1.00")
ccPaymentRequestEntity.setter("ExpTxnAmt", "2")
ccPaymentRequestEntity.setter("CardNo", "8853010000095323")
ccPaymentRequestEntity.setter("ExpiryYear", "20")
ccPaymentRequestEntity.setter("ExpiryMth", "12")
ccPaymentRequestEntity.setter("TokenFlag", "Y")
ccPaymentRequestEntity.setter("MerchUserID", "guest")
ccPaymentRequestEntity.setter("TokenShrtName", "testcard")
# Call Payment Master Payment Request Message Builder to generate the message
ccMessageBuilder = PaymentRequestMessageBuilder()
ccPaymentMessage = ccMessageBuilder.buildPaymentRequestMessage(ccPaymentRequestEntity, propertiesReader)
# POST request to PayMaster Gateway for recurring payment
initial_url = "https://xxx.finexusgroup.com/upp/faces/ccpayment.xhtml?" + ccPaymentMessage
response = requests.post(initial_url)
final_url = response.url
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 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 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 ccPaymentMessage
.
Step 7 : Send the Payment Message to the PayMaster Gateway
The ccPaymentMessage
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).
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');
const axios = require('axios');
module.exports = function(app) {
app.post('/CCPayment', async (req, res) => {
// Indicate the PayMaster Properties File location
paymaster.PropertiesReader('./properties/', 'CCPayment.properties');
// Assign values into the Payment Request Entity
paymaster.setter('PaymentID', 'C04');
paymaster.setter('MerchRefNo', 'merchant-refNo-0001');
paymaster.setter('CurrCode', '458');
paymaster.setter('TxnAmt', '1.00');
paymaster.setter('ExpTxnAmt', '2');
paymaster.setter('ECI', '12');
paymaster.setter('CardNo', '8853010000095323');
paymaster.setter('TokenFlag', 'Y');
paymaster.setter('POSEnvFlag', 'R');
paymaster.setter('MerchUserID', 'guest');
paymaster.setter('ExpiryYear', '20');
paymaster.setter('ExpiryMth', '12');
paymaster.setter('TokenShrtName', 'testcard');
// Generate the request message
paymaster.MERCH_CardPaymentRequest(paymaster.PaymentRequestEntity, paymaster.propDetails, async (err, response, result) => {
if (err) {
throw err;
}
if (response) {
const initialUrl = "https://xxx.finexusgroup.com/upp/faces/ccpayment.xhtml?" + result;
try {
const response = await axios.post(initialUrl);
const finalUrl = response.request.res.responseUrl;
// Further processing with finalUrl if needed
res.send(finalUrl);
} catch (error) {
console.error('Error sending POST request:', error);
res.status(500).send('Error processing payment');
}
}
});
});
}
Step 3 : Indicate PayMaster Properties File Location
The merchant must specify the location of the PayMaster Properties File using the PropertiesReader
.
Step 4 : Assign Values to the 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 it 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 5 : Generate the Request Message
Use the MERCH_CardPaymentRequest()
function to generate the recurring payment request message.
Step 6 : Send the Payment Message to PayMaster
The payment message will be sent to the PayMaster Gateway for the recurring payment function.
Refer to Payment Response for security controls supported by PayMaster Merchant Plug-In (MPI).