4. Confirm the payment
function processResponse(req, res, next) {
// This will vary depending on your bank
// and may also change so please check any emails you
// receive from Paycorp that contain setup instructions
const BASE_URL = 'https://sampath.paycorp.lk/webinterface/qw/confirm';
// This is the your private auth token. It must
// never be used in the browser, only on your secure server
const AUTH_TOKEN = '7c0c1c98-0f1e-4da9-9e93-1d4939d9282f';
// First submit the payment complete request, NOTE: empty body,
// only needs URL params
axios.post(`${BASE_URL}?csrfToken=${reqId}&authToken=${AUTH_TOKEN}`, {})
.then(function (response) {
// The response data will be in x-www-form-urlencode format
// Convert x-www-form-urlencode to simple object
const respData = querystring.parse(response.data);
// and add req ID if you wish
respData.reqid = req.query.reqid;
// Show the user a receipt page
res.render('payment-response', {
title: 'Payment Response',
data: respData
});
// FURTHER PROCESSING OF THE PAYMENT.........
})
.catch(function (error) {
console.log('ERROR:', error);
next(createError(error.response.status, error.response.statusText));
});
}Last updated