This SDK is provided "AS-IS" with no warranty. YOU (the developer) would need to ensure that your code works well with your own platform, and that you are handling data securely
git clone https://github.com/trainerbill/paypal-payflow-sdk.git
cd paypal-payflow-sdk
npm install
node samples/DirectPayments/sale.js
node samples/DirectPayments/refund.js
Require SDK
var payflow = require('paypal-payflow-sdk');
Configure SDK
payflow.configure({
"host": "pilot-payflowpro.paypal.com",
"port": "443",
"credentials": {
"PARTNER": "",
"VENDOR": "",
"USER": "",
"PWD": ""
}
});
Use Helper to get Models
var sale = payflow.getModel('sale');
Exchange Data with model
var data = {
ACCT: "4716792779006088",
EXPDATE: "1118",
CVV2: "111",
AMT: "100"
};
sale.exchangeData(data);
Validate the data based on the model
sale.validateData();
Execute API Call. Send in parameters from helper model
payflow.execute(sale.getParameters(), function(err, data) {
if (err) {
console.log(err.message);
res.writeHead(500, { 'Content-Type': 'application/json' });
res.write(JSON.stringify({message: err.message}));
res.end();
}
else {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.write(JSON.stringify(data));
res.end();
}
});
You can also do a straight execute without using helper functions
var data = {
TRXTYPE: "S",
TENDER: "C",
ACCT: "4556209654007209",
EXPDATE: "1118",
CVV2: "111",
AMT: "100"
};
payflow.execute(data, function(err, data) {
if (err) {
console.log(err.message);
res.writeHead(500, { 'Content-Type': 'application/json' });
res.write(JSON.stringify({message: err.message}));
res.end();
}
else {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.write(JSON.stringify(data));
res.end();
}
});
All Tests and Build
grunt
All Tests
mocha --recursive -t 60000
One Test
mocha -t 60000 test/src/Directpayments/sale.js
If you would like to contribute, please fork the repo and send in a pull request. Please run grunt before submitting.