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.
- Java
- .Net
- PHP
- Python
- Node.js
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).
Step 1 : Library
The merchant should include the PayMaster Merchant Plug-In (MPI) .NET library, PayMaster.dll, in their application.
Step 2 : Namespace
For reversal payments, 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 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 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 reversal 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 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 ccPaymentMessage
.
Step 7 : Send the Payment Message to the PayMaster Gateway
The ccPaymentMessage
will be used to send to the PayMaster Gateway for the reversal payment function.
Refer to Payment Response for security controls supported by PayMaster Merchant Plug-In (MPI).
Step 1 : Library
The merchant should include the PayMaster Merchant Plug-In (MPI) PHP library, PayMaster.phar, in their application.
Step 2 : Import
For reversal payments, the merchant should import the following into their code:
PropertiesReader
– to read the properties files.PayMasterEntity
– to assign all the acceptable values for PayMaster reversal payment.PaymentRequestMessageBuilder
– to generate the PayMaster reversal 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;
// 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 reversal 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 and set it as the basePath
in the source code (see 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 accepts two parameters:
setter(parameterName, parameterValue)
.
Refer to Reversal Payment Parameters for the fields supported by the PayMaster Merchant Plug-In (MPI).
**Step 7 : Generate Payment Message **
Once all mandatory values are assigned, the merchant should call the PaymentRequestMessageBuilder
to generate the reversal paymentMessage
.
**Step 8 : Send Payment Message to 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).
Step 1 : Packages
The merchant should set up and include the PayMaster Merchant Plug-In (MPI) Python packages in their application.
Step 2 : Import
For reversal payments, the merchant should include the following in their code:
PropertiesReader
– to read the properties files.PayMasterEntity
– to assign all the acceptable values for PayMaster reversal payment.PaymentRequestMessageBuilder
- to generate the PayMaster reversal 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
# Declare variable for PayMaster Properties - 1st Parameter = File Path, 2nd Parameter = File Name
properties_reader = PropertiesReader("PayMasterProperties/", "CCPayment.properties")
# Declare variable for PayMaster Entity
cc_payment_request_entity = PayMasterEntity()
# Get all the parameter values from the user side and set them into PayMaster Entity
cc_payment_request_entity.setter("PaymentID", "C04")
cc_payment_request_entity.setter("ECI", "12")
cc_payment_request_entity.setter("MerchRefNo", "merchant-refNo-0001")
cc_payment_request_entity.setter("TxnDtTm", "")
cc_payment_request_entity.setter("CurrCode", "458")
cc_payment_request_entity.setter("TxnAmt", "1.00")
cc_payment_request_entity.setter("ExpTxnAmt", "2")
cc_payment_request_entity.setter("CardNo", "8853010000095323")
cc_payment_request_entity.setter("ExpiryYear", "20")
cc_payment_request_entity.setter("ExpiryMth", "12")
cc_payment_request_entity.setter("TokenFlag", "Y")
cc_payment_request_entity.setter("MerchUserID", "guest")
cc_payment_request_entity.setter("TokenShrtName", "testcard")
# Call Payment Master Payment Request Message Builder to generate the message
cc_message_builder = PaymentRequestMessageBuilder()
cc_payment_message = cc_message_builder.buildPaymentRequestMessage(cc_payment_request_entity, properties_reader)
# POST request to PayMaster Gateway for reversal payment
initial_url = "https://xxx.finexusgroup.com/upp/faces/ccpayment.xhtml?" + cc_payment_message
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 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 ccPaymentMessage
.
Step 7 : Send the Payment Message to the PayMaster Gateway
The ccPaymentMessage
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).
Step 1 : Library
The merchant should set up and include the PayMaster Merchant Plug-In (MPI) Node.js library in their application.
Step 2 : Source Code
var paymaster = require('./js/PayMaster.min.js');
module.exports = function (app) {
app.post('/CCPayment', (req, res) => {
// Initialize the PayMaster PropertiesReader with the file path and name
paymaster.PropertiesReader('./properties/', 'CCPayment.properties');
// Set all required parameters using the setter function
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 payment request message
payment.MERCH_CardPaymentRequest(paymaster.PaymentRequestEntity, paymaster.propDetails, function(err, response, result) {
if (err) {
throw err;
}
if (response) {
const initialUrl = "https://xxx.finexusgroup.com/upp/faces/ccpayment.xhtml?" + result;
// Function to send a POST request to the PayMaster Gateway
async function sendPostRequest() {
try {
const response = await axios.post(initialUrl);
const finalUrl = response.request.res.responseUrl;
// Handle the final URL or further actions
.....
} catch (error) {
console.error('Error sending POST request:', error);
}
}
sendPostRequest();
}
});
});
}
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 Reversal 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 reversal payment request message.
Step 6 : Send the Payment Message to PayMaster
The payment message 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).