1.0.6 • Published 6 years ago

sdk-paypal v1.0.6

Weekly downloads
3
License
ISC
Repository
github
Last release
6 years ago

Installation

npm install --save sdk-paypal

require module

const PayPal = require('sdk-paypal');

Merchant Documentation:

Init

const PaypalMerchant = new Paypal.Merchant({
    mode: "sandbox",
    client_id: 'Ac-AXyglk7AeZCL3fbR8ovtCh1A-3t2EKVqjTvag2lLSQ8Rxm7B7aIVromgHGj0DiiPdxQdJdPEiXeOu',
    client_secret: 'EGs3jRM6VCuNllsDfbExDlTgHQ2md3_8Ywg97ThBCmBrJg9kHJv-YNOLRk1VZhkiQx6X9JgU7_eF7BaT',
    callback: {
        error: 'https://error.com',
        success: 'https://success.com'
    }
}, {debug: false});

Create payment

PaypalMerchant
    .getOrderId({
        amount: 1,
        currency: 'USD',
        description: 'MIT SDK NODE TEST'
    })
    .then(res => {
        return PaypalMerchant.createPaymet(res)
    })
    .then(console.log)
    .catch((error) => {
        console.error('Create Error,', error);
    });

Browse function:

function payment(param) {
    var method = param.method || "post";
    var form = document.createElement("form");
    form.setAttribute("method", param.method);
    form.setAttribute("action", param.url);
    for (var key in param.data) {
        if (param.data.hasOwnProperty(key)) {
            var hiddenField = document.createElement("input");
            hiddenField.setAttribute("type", "hidden");
            hiddenField.setAttribute("name", key);
            hiddenField.setAttribute("value", param.data[key]);

            form.appendChild(hiddenField);
        }
    }
    document.body.appendChild(form);
    form.submit();
}
1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago