Payment Response
The following guideline explains how to apply the corresponding source code in the merchant's application to retrieve payment response parameters from the response message returned by PayMaster.
- Java
- .Net
- PHP
- Python
- Node.js
Step 1 : Library
The merchant shall include the PayMaster Merchant Plug-In (MPI) Java library – PayMaster.jar – into the merchant application.
Step 2 : Import
For recurring payments, the merchant shall import the following into their code:
com.PayMaster.Entities.PayMasterEntity
com.PayMaster.PropertiesReader.PropertiesReader
com.PayMaster.MessageResponseBuilder.PaymentResponseMessageBuilder
Step 3 : Source Code
import com.PayMaster.Entities.PayMasterEntity;
import com.PayMaster.PropertiesReader.PropertiesReader;
import com.PayMaster.MessageResponseBuilder.PaymentResponseMessageBuilder;
// Declare variable for PayMaster Properties - 1st Parameter = File Path, 2nd Parameter = File name
PropertiesReader propertiesReader = new PropertiesReader("./PayMasterProperties/", "CardPayment.properties");
// Declare variable for PayMaster Entity
PayMasterEntity paymentResponseEntity = new PayMasterEntity();
// Get response message from PayMaster and set into PayMaster Entity
paymentResponseEntity.setter("ResponseMessage", responseMessage);
// Call Payment Master Payment Response Message Builder to set value
PaymentResponseMessageBuilder paymentResponseMessageBuilder = new PaymentResponseMessageBuilder();
paymentResponseMessageBuilder.buildCardPaymentResponseMessage(paymentResponseEntity, propertiesReader);
String MerchantID = paymentResponseEntity.getter("MerchantID");
String MerchRefNo = paymentResponseEntity.getter("MerchRefNo");
String TxnStatus = paymentResponseEntity.getter("TxnStatus");
String SHAlgorithmType = paymentResponseEntity.getter("SHAlgorithmType");
String SHValue = paymentResponseEntity.getter("SHValue");
// Process retrieved values as needed
Step 4 : Indicate PayMaster Properties File Location
The merchant must specify the location of the PayMaster Properties File using PropertiesReader
.
Step 5 : Set Response Message
The merchant must indicate the response message returned by the PayMaster Gateway using setter(“ResponseMessage”,”<response message returned by PayMaster Gateway>”)
.
Step 6 : Assign Values into PayMaster Response Entity
The merchant calls the Card Payment Response Message Builder to process the response message and assign the values to the PayMaster Response Entity.
Refer to Recurring Payment Parameters for the fields supported by the PayMaster Merchant Plug-In (MPI).
Step 7 : Retrieve Values from PayMaster Response Entity
The merchant can retrieve values from the PayMaster Response Entity using the getter function, which accepts one parameter: getter(parameter name)
.
Ensure that the value of TxnStatDetCde
is not equal to 5015, as this represents an invalid secure hash value.
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 their code:
using com.PayMaster.Entities
using com.PayMaster.Properties
using com.PayMaster.MessageResponseBuilder
Step 3 : Source Code
using com.PayMaster.Entities;
using com.PayMaster.Properties;
using com.PayMaster.MessageResponseBuilder;
// 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 ccPaymentResponseEntity = new PayMasterEntity();
// Get response message from PayMaster and set into PayMaster Entity
ccPaymentResponseEntity.setter("ResponseMessage", responseMessage);
// Call Payment Master Payment Response Message Builder to set value
PaymentResponseMessageBuilder cardPaymentResponseMessageBuilder = new PaymentResponseMessageBuilder();
cardPaymentResponseMessageBuilder.buildCardPaymentResponseMessage(ccPaymentResponseEntity, propertiesReader);
string MerchantID = ccPaymentResponseEntity.getter("MerchantID");
string MerchRefNo = ccPaymentResponseEntity.getter("MerchRefNo");
string TxnStatus = ccPaymentResponseEntity.getter("TxnStatus");
string SHAlgorithmType = ccPaymentResponseEntity.getter("SHAlgorithmType");
string SHValue = ccPaymentResponseEntity.getter("SHValue");
// Process retrieved values as needed
Step 4 : Indicate PayMaster Properties File Location
The merchant must specify where the PayMaster Properties File is located using PropertiesReader
.
Step 5 : Assign Response Message into Payment Response Entity
The merchant must assign the response message received from PayMaster into the PayMasterEntity using: ccPaymentResponseEntity.setter("ResponseMessage", "<response message returned by PayMaster Gateway>");
Step 6 : Assign Values into PayMaster Response Entity
The merchant calls the Card Payment Response Message Builder to process the response message and assign the values into the PayMaster Response Entity.
Refer to Recurring Payment Parameters for the fields supported by the PayMaster Merchant Plug-In (MPI).
Step 7 : Retrieve Values from PayMaster Response Entity
The merchant can retrieve values from the PayMaster Response Entity using the getter function, which accepts one parameter: ccPaymentResponseEntity.getter("parameter name");
.
Ensure that the value of TxnStatDetCde
is not equal to 5015, as this represents an invalid secure hash value.
Step 1 : Library
The merchant shall include the PayMaster Merchant Plug-In (MPI) PHP library – PayMaster.phar – into the merchant application.
Step 2 : Merchant Code
For recurring payments, the merchant shall import the following into the merchant code:
PropertiesReader
- to read the properties files.PayMasterEntity
– to assign all the acceptable values for PayMaster Recurring payments.PaymentResponseMessageBuilder
– to generate the PayMaster Recurring payment response message.
Step 3 : Source Code
<?php
use com\PayMaster\Entities\PayMasterEntity;
use com\PayMaster\PropertiesReader\PropertiesReader;
use com\PayMaster\MessageResponseBuilder\PaymentResponseMessageBuilder;
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 Payment Master Properties - 1st Parameter = File Path, 2nd Parameter = File name
$propertiesReader = new PropertiesReader();
$propertiesReader->PropertiesReader(<absolute path> . "/paymaster", "CardPayment.ini");
// Declare variable for Payment Master Entity
$paymentResponseEntity = new PayMasterEntity();
// Get the response message from PayMaster and set it into Payment Master Entity
$paymentResponseEntity->setter("ResponseMessage", $responseMessage);
// Call Payment Master Payment Response Message Builder to process the response
$paymentResponseMessageBuilder = new PaymentResponseMessageBuilder();
$paymentResponseMessageBuilder->buildCardPaymentResponseMessage($paymentResponseEntity, $propertiesReader);
$MerchantID = $paymentResponseEntity->getter("MerchantID");
$MerchRefNo = $paymentResponseEntity->getter("MerchRefNo");
$TxnStatus = $paymentResponseEntity->getter("TxnStatus");
$SHAlgorithmType = $paymentResponseEntity->getter("SHAlgorithmType");
$SHValue = $paymentResponseEntity->getter("SHValue");
// Process retrieved values as needed
?>
Step 4 : Locate Absolute Path of PayMaster.phar
The merchant must determine the absolute path of PayMaster.phar and set it as the basePath in the merchant source code.
Example:$basePath=’phar://<absolute path of PayMaster.phar>/’
Step 5 : Indicate PayMaster Properties File Location
The merchant must specify where the PayMaster Properties File is located using the PropertiesReader
.
Step 6 : Assign Response Message into Payment Response Entity
The merchant assigns the response message received from PayMaster into the PayMasterEntity using: $paymentResponseEntity->setter("ResponseMessage", "<response message returned by PayMaster Gateway>");
Step 7 : Assign Values into PayMaster Response Entity
The merchant calls the PaymentResponseMessageBuilder
to process the response message and assign the values into the PayMaster Response Entity.
Refer to Recurring Payment Parameters for the fields supported by the PayMaster Merchant Plug-In (MPI).
Step 8 : Retrieve Values from PayMaster Response Entity
The merchant can retrieve values from the PayMaster Response Entity using the getter function: $paymentResponseEntity->getter("parameter name");
Ensure that the value of TxnStatDetCde
is not equal to 5015, as this represents an invalid secure hash value.
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 the merchant code:
PropertiesReader
– to read the properties files.PayMasterEntity
– to assign all the acceptable values for PayMaster recurring payments.PaymentResponseMessageBuilder
– to generate the PayMaster recurring payment response message.
Step 3 : Source Code
from com.PayMaster.Entities.PayMasterEntity import PayMasterEntity
from com.PayMaster.PropertiesReader.PropertiesReader import PropertiesReader
from com.PayMaster.MessageResponseBuilder.PaymentResponseMessageBuilder import PaymentResponseMessageBuilder
# Declare variable for Payment Master Properties - 1st Parameter = File Path, 2nd Parameter = File name
propertiesReader = PropertiesReader("CCPayment.properties", "PayMasterProperties/")
# Declare variable for Payment Master Entity
ccPaymentResponseEntity = PayMasterEntity()
# Get the response message from PayMaster and set it into Payment Master Entity
ccPaymentResponseEntity.setter("ResponseMessage", responseMessage)
# Call Payment Master Payment Response Message Builder to set values
cardPaymentResponseMessageBuilder = PaymentResponseMessageBuilder()
cardPaymentResponseMessageBuilder.buildCardPaymentResponseMessage(ccPaymentResponseEntity, propertiesReader)
# Retrieve values from Payment Master Response Entity
MerchantID = ccPaymentResponseEntity.getter("MerchantID")
MerchRefNo = ccPaymentResponseEntity.getter("MerchRefNo")
TxnStatus = ccPaymentResponseEntity.getter("TxnStatus")
SHAlgorithmType = ccPaymentResponseEntity.getter("SHAlgorithmType")
SHValue = ccPaymentResponseEntity.getter("SHValue")
# Process retrieved values as needed
Step 4 : Indicate PayMaster Properties File Location
The merchant must specify where the PayMaster Properties File is located using the PropertiesReader
.
Step 5 : Assign Response Message into Payment Response Entity
The merchant assigns the response message received from PayMaster into the PayMasterEntity using: ccPaymentResponseEntity.setter("ResponseMessage", "<response message returned by PayMaster Gateway>")
Step 6 : Assign Values into PayMaster Response Entity
The merchant calls the PaymentResponseMessageBuilder
to process the response message and assign the values into the PayMaster Response Entity.
Refer to Recurring Payment Parameters for the fields supported by the PayMaster Merchant Plug-In (MPI).
Step 7 : Retrieve Values from PayMaster Response Entity
The merchant retrieves values from the PayMaster Response Entity using the getter function: ccPaymentResponseEntity.getter("parameter name")
.
Ensure that the value of TxnStatDetCde
is not equal to 5015, as this represents an invalid secure hash value.
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 : Functions
MERCH_CardPaymentResponse()
- This function should run on the merchant's response page for recurring payments. It retrieves the response parameters returned from the PayMaster Gateway and returns the results required by the merchant.
Step 3 : Source Code
var paymaster = require('./js/PayMaster.min.js');
module.exports = function (app) {
app.get('/UPPPayment', (req, res) => {
// Set the location of the PayMaster Properties File
paymaster.PropertiesReader('./properties/', 'CCPayment.properties');
// Call MERCH_CardPaymentResponse function to handle the response
payment.MERCH_CardPaymentResponse(req, paymaster.propDetails, function (err, response, result) {
if (err) {
throw err;
}
if (response) {
if (paymaster.getter('TxnStatDetCde') === "0000") {
// Retrieve values from PayMaster Response Entity
var MerchantID = paymaster.getter('MerchantID');
var MerchRefNo = paymaster.getter('MerchRefNo');
var TxnStatus = paymaster.getter('TxnStatus');
var SHAlgorithmType = paymaster.getter('SHAlgorithmType');
var SHValue = paymaster.getter('SHValue');
// Process retrieved values as needed
// For example, send a response to the client
res.json({
MerchantID: MerchantID,
MerchRefNo: MerchRefNo,
TxnStatus: TxnStatus,
SHAlgorithmType: SHAlgorithmType,
SHValue: SHValue
});
} else {
// Handle other TxnStatDetCde values as needed
res.status(400).send('Transaction failed or secure hash is invalid.');
}
}
});
});
}
Step 4 : Indicate PayMaster Properties File Location
The merchant must specify where the PayMaster Properties File is located using the PropertiesReader
.
Refer to Recurring Payment Parameters for the fields supported by the PayMaster Merchant Plug-In (MPI).
Step 5 : Retrieve Values from PayMaster Response Entity
The merchant retrieves values from the PayMaster Response Entity using the getter function: paymaster.getter('parameter name')
Ensure that the value of TxnStatDetCde
is not equal to 5015, as this represents an invalid secure hash value.