Paysera payment gateway plugin for node.js
Install this package as a npm dependency:
npm install paysera-nodejs --save
First, require this package in your script:
var Paysera = require('paysera-nodejs');
Then, Initialize Paysera module with default parameters:
var options = {
projectid: 'X',
sign_password: 'Y',
accepturl: 'http://myaccept.url',
cancelurl: 'http://mycancel.url',
callbackurl: 'http://mycallback.url',
test: 0,
...
};
var paysera = new Paysera(options);
Finally, build and redirect to url with these available parameters:
var params = {
orderid: 123,
p_email: 'customer@email.com',
amount: 100,
currency: 'EUR',
...
};
var urlToGo = paysera.buildRequestUrl(params);
// Redirect to urlToGo...
Check if callback from paysera is valid:
var request = { data: ..., ss1: ... }; // the request data you got from paysera callback
var isValid = paysera.checkCallback(request);
if (isValid) {
// Since callback seems valid decode callback data
var order = paysera.decode(request.data);
// Your code ... to update order status
// Don't forget to return "OK" as the response.
}
All available parameters from callback are specified in paysera specification
If any problems occur please feel free to contact support@paysera.com