This NodeJS module is a library for working with the Paypal Express Checkout API.
The library consists of two classes:
A low-level class for dealing with NVP requests to the Paypal API. Can be used for any API request.
A higher-level class for common payment operations. Performs all the response parsing and request formatting needed for each operation.
Run this npm command to install (not working yet):
npm install paypal-express
var PaypalExpress = require('./paypal-express').PaypalExpress;
var paypal = new PaypalExpress(<API username>, <API password>, <API signature>);
paypal.useSandbox(true);
paypal.beginInstantPayment({
'RETURNURL': '',
'CANCELURL': '',
'PAYMENTREQUEST_0_AMT': 1, //Payment amount
//More request parameters
}, function(err, data) {
if (err) {
console.error(err);
}
if (data) {
var token = data.token;
var payment_url = data.payment_url;
//Redirect to payment_url
}
});
List of allowed parameters for SetExpressCheckout
var NVPRequest = require('./paypal-express').NVPRequest;
var request = new NVPRequest(<API username>, <API password>, <API signature>);
request.useSandbox(true);
request.makeRequest({
'METHOD': '<API method>',
//Any API method, and any parameter (see Paypal documentation)
}, function(err, data) {
if (err) {
console.error(err);
}
var qs = require('querystring');
var response = qs.parse(data.toString());
if (response.ACK == 'Success') {
console.log('Success!');
}
});