Payment Response
The following guideline provides an explanation on how to integrate and utilize 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, 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.MessageResponseBuilder.PaymentResponseMessageBuilder
Step 3 : Source Code
import com.PayMaster.Entities.PayMasterEntity;
import com.PayMaster.PropertiesReader.PropertiesReader;
import com.PayMaster.MessageResponseBuilder.PaymentResponseMessageBuilder;
// Declare a variable for PayMaster Properties - 1st Parameter = File Path, 2nd Parameter = File Name
PropertiesReader propertiesReader = new PropertiesReader("./PayMasterProperties/", "CardPayment.properties");
// Declare a variable for PayMaster Entity
PayMasterEntity paymentResponseEntity = new PayMasterEntity();
// Get the response message from PayMaster and set it into PayMaster Entity
paymentResponseEntity.setter("ResponseMessage", responseMessage);
// Call PaymentResponseMessageBuilder to parse the response message
PaymentResponseMessageBuilder paymentResponseMessageBuilder = new PaymentResponseMessageBuilder();
paymentResponseMessageBuilder.buildCardPaymentResponseMessage(paymentResponseEntity, propertiesReader);
// Retrieve values from PayMaster Response Entity
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");
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 Using Setter
The merchant must set the response message returned by PayMaster Gateway using the setter method: paymentResponseEntity.setter("ResponseMessage", "<response message returned by PayMaster Gateway>");
Step 6 : Parse and Assign Values into PayMaster Response Entity
The merchant should call the CardPaymentResponseMessageBuilder
to parse the response message and assign the values to the PayMaster Response Entity.
Refer to Reversal 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.
- The getter function is used to retrieve values and 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, 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.MessageResponseBuilder
Step 3 : Source Code
using com.PayMaster.Entities;
using com.PayMaster.Properties;
using com.PayMaster.MessageResponseBuilder;
// 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 ccPaymentResponseEntity = new PayMasterEntity();
// Set the response message received from PayMaster into the PayMaster Entity
ccPaymentResponseEntity.setter("ResponseMessage", responseMessage);
// Call PaymentResponseMessageBuilder to parse the response message
PaymentResponseMessageBuilder cardPaymentResponseMessageBuilder = new PaymentResponseMessageBuilder();
cardPaymentResponseMessageBuilder.buildCardPaymentResponseMessage(ccPaymentResponseEntity, propertiesReader);
// Retrieve values from PayMaster Response Entity
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");
Step 4 : Indicate PayMaster Properties File Location
The merchant must specify the location of the PayMaster Properties File using the PropertiesReader
.
Step 5 : Assign Response Message into Payment Response Entity
The merchant must assign the response message received from the PayMaster Gateway to the PayMaster Response Entity using: ccPaymentResponseEntity.setter("ResponseMessage", "<response message returned by PayMaster Gateway>");
Step 6 : Parse and Assign Values into PayMaster Response Entity
The merchant should call the CardPaymentResponseMessageBuilder
to parse the response message and assign the values to the PayMaster Response Entity.
Refer to Reversal 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, in the merchant application.
Step 2 : Merchant Code
For reversal payments, the merchant shall import the following components into the code:
PropertiesReader
- to read the properties files.PayMasterEntity
- to assign all the acceptable values for PayMaster reversal payment.PaymentResponseMessageBuilder
- to generate the PayMaster reversal 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;
// Locate the absolute path of PayMaster.phar
$basePath = 'phar://<absolute path of PayMaster.phar>/paymaster/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>/paymaster", "CCPayment.ini");
// Declare variable for PayMaster Entity
$paymentResponseEntity = new PayMasterEntity();
// Set the response message received from PayMaster into the PayMaster Entity
$paymentResponseEntity->setter("ResponseMessage", $responseMessage);
// Call PaymentResponseMessageBuilder to parse the response message
$paymentResponseMessageBuilder = new PaymentResponseMessageBuilder();
$paymentResponseMessageBuilder->buildCardPaymentResponseMessage($paymentResponseEntity, $propertiesReader);
// Retrieve values from PayMaster Response Entity
$MerchantID = $paymentResponseEntity->getter("MerchantID");
$MerchRefNo = $paymentResponseEntity->getter("MerchRefNo");
$TxnStatus = $paymentResponseEntity->getter("TxnStatus");
$SHAlgorithmType = $paymentResponseEntity->getter("SHAlgorithmType");
$SHValue = $paymentResponseEntity->getter("SHValue");
?>
Step 4 : Locate the Absolute Path of PayMaster.phar
The merchant must locate the absolute path of PayMaster.phar to define the $basePath
in the source code.
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 Response Message into Payment Response Entity
The merchant must assign the response message received from the PayMaster Gateway to the PayMaster Response Entity using: $paymentResponseEntity->setter("ResponseMessage", "<response message returned by PayMaster Gateway>");
Step 7 : Parse and Assign Values into PayMaster Response Entity
The merchant should call the PaymentResponseMessageBuilder
to parse the response message and assign the values to the PayMaster Response Entity.
Refer to Reversal 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, which accepts one parameter: $paymentResponseEntity->getter("parameter name");
- The
TxnStatus
should be 00 andTxnStatDetCde
should be 0000. - 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 the PayMaster Merchant Plug-In (MPI) Python packages in the merchant application.
Step 2 : Import
For reversal payments, the merchant shall include the following modules in the code:
PropertiesReader
– to read the properties files.PayMasterEntity
– to assign all the acceptable values for PayMaster reversal payment.PaymentResponseMessageBuilder
– to generate the PayMaster reversal payment response message.
Step 3 : Source Code Example
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
propertiesReader = PropertiesReader("PayMasterProperties/", "CCPayment.properties")
# Declare variable for Payment Master Entity
ccPaymentResponseEntity = PayMasterEntity()
# Set the response message received from PayMaster into the PayMaster Entity
ccPaymentResponseEntity.setter("ResponseMessage", responseMessage)
# Call Payment Response Message Builder to parse and set values
cardPaymentResponseMessageBuilder = PaymentResponseMessageBuilder()
cardPaymentResponseMessageBuilder.buildCardPaymentResponseMessage(ccPaymentResponseEntity, propertiesReader)
# Retrieve values from PayMaster Response Entity
MerchantID = ccPaymentResponseEntity.getter("MerchantID")
MerchRefNo = ccPaymentResponseEntity.getter("MerchRefNo")
TxnStatus = ccPaymentResponseEntity.getter("TxnStatus")
SHAlgorithmType = ccPaymentResponseEntity.getter("SHAlgorithmType")
SHValue = ccPaymentResponseEntity.getter("SHValue")
Step 4 : Indicate PayMaster Properties File Location
The merchant must specify the location of the PayMaster Properties File using the PropertiesReader
.
Step 5 : Assign Response Message into Payment Response Entity
The merchant must assign the response message received from PayMaster to the PayMaster Response Entity using: ccPaymentResponseEntity.setter("ResponseMessage", "<response message returned by PayMaster Gateway>")
Step 6 : Parse and Assign Values into PayMaster Response Entity
The merchant should call the PaymentResponseMessageBuilder
to parse the response message and assign the values to the PayMaster Response Entity.
Refer to Reversal 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: value = 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 in the merchant application.
Step 2 : Functions
MERCH_CardPaymentResponse()
- This function should be used in the merchant's response page for reversal payments. It retrieves the response parameters returned from the PayMaster Gateway and returns the results required by the merchant.
Step 3 : Source Code Example
var paymaster = require('./js/PayMaster.min.js');
module.exports = function (app) {
app.get('/UPPPayment', (req, res) => {
// Load PayMaster Properties File
paymaster.PropertiesReader('./properties/', 'CCPayment.properties');
// Retrieve the response parameters
payment.MERCH_CardPaymentResponse(req, paymaster.propDetails, function(err, response, result) {
if (err) {
throw err;
}
if (response) {
// Check if transaction status detail code is valid
if (paymaster.getter('TxnStatDetCde') === "0000") {
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');
// Handle response values here
// to do ...
}
}
});
});
}
Step 4 : Indicate PayMaster Properties File Location
The merchant must specify the location of the PayMaster Properties File using the PropertiesReader
.
Step 5 : Retrieve Values from PayMaster Response Entity
The merchant can retrieve values from the PayMaster Response Entity using the getter function, which accepts one parameter: var value = paymaster.getter('parameter name');
Refer to Reversal Payment Parameters for the fields supported by the PayMaster Merchant Plug-In (MPI).
Ensure that the value of TxnStatDetCde
is not equal to 5015, as this represents an invalid secure hash value.