NodeJS SDK for payline.com API
This provides a very succinct SDK for the payline.com API. If you need additional Payline methods covered, feel free to contribute :-) Highly inspired from Django-Payline, thanks!
As promised (Bluebird based).
Where to find those f**** config strings? Well I've been there:
userId
is sent by email when you subscribe to Payline. joyfully named Vendor identifier or Merchant's Login elsewhere in their adminuserPass
is called access key and available in Settings > Change your access keycontractNumber
is related to a point of sale and a method of payment. So once you created a point of sale, head to method of payment and you will get a contract number after that. In the test mode, '1234567' seems to be accepted by default
npm install payline
var Payline = require('payline');
var payline = new Payline('<% userId %>', '<% userPass %>', '<% contractNumber %>');
payline.createWallet('wallet_0001', {
number: '4970101122334471',
type: 'CB',
expirationDate: '0117',
cvx: '123'
})
.then(function() {
// issue a 10€ order
return payline.makeWalletPayment('wallet_0001', 1000, Payline.CURRENCIES.EUR);
})
.then(function(result) {
console.log("Youpi! Transaction id: " + result.transactionId);
}, function(err) {
console.log("Wtf happened: " + err.shortMessage + ' - ' + err.longMessage);
});
payline.doWebPayment(123, 'A-PAY-TEST', '20/06/2015 20:21', 'http://www.wexample.com', 'http://v2.wexample.com')
.then(function (result) {
console.log("Youpla! Redirect to: " + result.redirectURL);
}, function (err) {
console.log("Wtf happened: " + err.shortMessage + ' - ' + err.longMessage);
});
See Usage to find those variables
You can override the wsdl bundled in this module by setting a 4th arg :
new Payline(userId, userPass, contractNumber, 'my file path or url')
Card object:
{ number, type, expirationDate, cvx }
Type: One of
CB
,AMEX
,VISA
(but abroad France only),MASTERCARD
(same) - cf page 148 of their doc
Note that amounts are in cents
Will try to issue a 1€ order (that will be cancelled right after the call is verified)
npm run watch
# this module is written in ES6 - so it has to be transpiled
# before being published to NPM. check the package.json prepublish script