approval_url

node v8.16.2
version: 8.0.0
endpointsharetweet
exports.endpoint = function(req, res) { var paypal = require('paypal-rest-sdk'); var request = require("request"); var access_token; paypal.configure({ 'mode': 'sandbox', //sandbox or live 'client_id': 'AfAFm3DIcNzNsPhpPg2Qx15ty5DzG8mQRd9UutyYaxRfJZRYGrA_KaLD3I2M2xQ94xE0_uvduj3-zGNH', 'client_secret': 'EEzIANWMYt_fr3MUsr_UbPfUrtISMn0rViYNLqKVvXrbap3P_CtqyFBT7p-9Oj9HFSeYs3l_BUFdKei6' }); paypal.generateToken(function(error, token) { if (error) throw new Error(error); var options = { method: 'POST', url: 'https://api.sandbox.paypal.com/v1/billing-agreements/agreement-tokens', headers: { 'cache-control': 'no-cache', Authorization: token, 'Content-Type': 'application/json' }, body: { description: 'Billing Agreement', payer: { payment_method: 'PAYPAL' }, plan: { type: 'MERCHANT_INITIATED_BILLING_SINGLE_AGREEMENT', merchant_preferences: { return_url: 'cctexample://return', cancel_url: 'cctexample://return', accepted_pymt_type: 'INSTANT', skip_shipping_address: true, immutable_shipping_address: false } } }, json: true }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); res.end(body.links[0].href); }); }); }
Loading…

no comments

    sign in to comment