Payment Request
The reversal function for QR Payment is available for ** Duitnow ** and ** Alipay+ **. Please refer to the Important Notes.
- 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 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).
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 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 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 parameter values into PayMaster Entity
paymentRequestEntity.Setter("PaymentID", "C15");
paymentRequestEntity.Setter("MerchRefNo", "merchant-refNo-0001");
paymentRequestEntity.Setter("CurrCode", "458");
paymentRequestEntity.Setter("TxnAmt", "1.00");
paymentRequestEntity.Setter("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;
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 PayMasterEntity. 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 sent 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).
Step 1 : Library
Merchant shall include PayMaster Merchant Plug-In (MPI) PHP library PayMaster.phar into the merchant 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
<?php
use com\PayMaster\Entities\PayMasterEntity;
use com\PayMaster\PropertiesReader\PropertiesReader;
use com\PayMaster\MessageRequestBuilder\PaymentRequestMessageBuilder;
use com\PayMaster\Import\ImportFile;
// Merchant must 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();
// Set parameter values into PayMaster Entity
$paymentRequestEntity->setter('PaymentID', 'C15');
$paymentRequestEntity->setter('MerchRefNo', 'merchant-refNo-0001');
$paymentRequestEntity->setter('CurrCode', '458');
$paymentRequestEntity->setter('TxnAmt', '1022.00');
$paymentRequestEntity->setter('ExpTxnAmt', '2');
// Call Payment Request Message Builder to generate the message
$paymentRequestMessageBuilder = new PaymentRequestMessageBuilder();
$paymentMessage = $paymentRequestMessageBuilder->buildPaymentRequestMessage($paymentRequestEntity, $propertiesReader);
// POST request to PayMaster Gateway for reversal
$initialUrl = "https://xxx.finexusgroup.com/upp/faces/reversal0400.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 use it 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 PayMasterEntity. 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)
.
- The
MerchRefNo
is obtained from the payment that needs to be reversed.
Refer to Reversal Payment Parameters for the fields supported by the PayMaster Merchant Plug-In (MPI).
Step 7 : Generate Reversal
Once all mandatory values are assigned, call the PaymentRequestMessageBuilder
to generate the reversal paymentMessage
.
Step 8 : Send Reversal Message to PayMaster Gateway
The paymentMessage
will be sent 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).
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 reversal 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 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
import requests
# Declare variable for PayMaster Properties - 1st Parameter = File Path, 2nd Parameter = File Name
propertiesReader = PropertiesReader("PayMasterProperties/", "CCPayment.properties")
# Declare variable for PayMaster Entity
paymentRequestEntity = PayMasterEntity()
# Set parameter values into PayMaster Entity
paymentRequestEntity.setter("PaymentID", "C15")
paymentRequestEntity.setter("MerchRefNo", "merchant-refNo-0001")
paymentRequestEntity.setter("CurrCode", "458")
paymentRequestEntity.setter("TxnAmt", "1.00")
paymentRequestEntity.setter("ExpTxnAmt", "2")
# Call Payment Request Message Builder to generate the message
messageBuilder = PaymentRequestMessageBuilder()
paymentMessage = messageBuilder.buildPaymentRequestMessage(paymentRequestEntity, propertiesReader)
# POST request to PayMaster Gateway for reversal
initial_url = "https://xxx.finexusgroup.com/upp/faces/reversal0400.xhtml?" + paymentMessage
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 PayMasterEntity. 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
OOnce all mandatory values are assigned, 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 QR Reversal Completion 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('/CCPayment', async (req, res) => {
try {
// Initialize PropertiesReader
paymaster.PropertiesReader('./properties/', 'CCPayment.properties');
// Set parameters for Payment Request Entity
paymaster.setter('PaymentID', 'C15');
paymaster.setter('MerchRefNo', 'merchant-refNo-0001');
paymaster.setter('CurrCode', '458');
paymaster.setter('TxnAmt', '1.00');
paymaster.setter('ExpTxnAmt', '2');
// Generate payment request message
paymaster.MERCH_CardPaymentRequest(paymaster.PaymentRequestEntity, paymaster.propDetails, async function(err, response, result) {
if (err) {
throw err;
}
if (response) {
const initialUrl = "https://xxx.finexusgroup.com/upp/faces/reversal0400.xhtml?" + result;
try {
const response = await axios.post(initialUrl);
const finalUrl = response.request.res.responseUrl;
// Handle final URL or response as needed
res.send({ finalUrl: finalUrl });
} catch (error) {
console.error('Error sending POST request:', error);
res.status(500).send('Error sending POST request');
}
}
});
} catch (error) {
console.error('Error processing payment:', 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 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 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 QR Reversal Completion Response for security controls supported by PayMaster Merchant Plug-In (MPI).