Speed up development with full-stack environments for every branch.

Learn More

Save a Credit Card using PayPal API [Node.js]

493 Runs 1349 Views 371 Copies
Saved

Saved

jkingyens 24

jkingyens
published 4 years ago

/* Copyright 2013 PayPal */
"use strict";

var paypal_api = require('paypal-rest-sdk');

var config_opts = {
    'host': 'api.sandbox.paypal.com',
    'port': '',
    'client_id': 'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM',
    'client_secret': 'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM'
};

var savedCard = {
    "type": "visa",
    "number": "4417119669820331",
    "expire_month": "11",
    "expire_year": "2019",
    "cvv2": "123",
    "first_name": "Joe",
    "last_name": "Shopper"
};

paypal_api.credit_card.create(savedCard, config_opts, function (get_err, get_res) {
    if (get_err) {
        throw get_res;
    }

    if (get_res) {
        console.log("Save Credit Card Response");
        console.log(JSON.stringify(get_res));
    }

});
Please login/signup to get access to the terminal.

Your session has timed out.

Dismiss (the page may not function properly).