Skip to content

trainerbill/paypal-payflow-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

paypal-payflow-sdk

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

Setup

git clone https://github.com/trainerbill/paypal-payflow-sdk.git
cd paypal-payflow-sdk
npm install

Examples

node samples/DirectPayments/sale.js
node samples/DirectPayments/refund.js

Usage

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();
    }
});

Running Tests

All Tests and Build

grunt

All Tests

mocha --recursive -t 60000

One Test

mocha -t 60000 test/src/Directpayments/sale.js

Contribution

If you would like to contribute, please fork the repo and send in a pull request. Please run grunt before submitting.

About

NodeJS SDK for PayFlow

Resources

Stars

Watchers

Forks

Packages

No packages published