paypal-ec icon indicating copy to clipboard operation
paypal-ec copied to clipboard

do_payment [Error: Invalid token.]

Open neutron92 opened this issue 7 years ago • 0 comments

var cred = {
                    username: 'mhamedhafsia06-facilitator_....',
                    password: 'hdfjgfj....',
                    signature: 'asdfasdf....'
                };

                var opts = {
                    sandbox: true,
                    version: '92.0'
                };
                var ec = new PayPalEC(cred, opts);
                console.log("ec", ec);
                var params = {
                    returnUrl: 'http://localhost:3000/confirm',
                    cancelUrl: 'http://localhost:3000/cancel',
                    SOLUTIONTYPE: 'sole',
                    PAYMENTREQUEST_0_AMT: '0.5',
                    PAYMENTREQUEST_0_DESC: 'Something',
                    PAYMENTREQUEST_0_CURRENCYCODE: 'USD',
                    PAYMENTREQUEST_0_PAYMENTACTION: 'Sale',
                };
                console.log("params", params);
                ec.set(params, function(err, data) {
                    console.log("set");
                    console.log("");
                    console.log("errset", err);
                    console.log("data", data);
                    console.log("-------------------------");
                    console.log("");
                    // data[ 'PAYMENTURL' ] is the payment url which
                    // you should redirect your user to
                });

                // NOTE: you must set another `params` with the token
                // you just get from PayPal
                ec.get_details(params, function(err, data) {
                    // data contains all the payment details, let your
                    // user confirm this information
                    console.log("get_details");
                    console.log("");
                    console.log("get_details", err);
                    console.log("data2", data);
                    console.log("********************");
                    console.log("");
                });

                // NOTE: set the `params` to contain both the token
                // and all the payment information
                ec.do_payment(params, function(err, data) {
                    console.log("do_payment");
                    console.log("");
                    // really charge the user for the payment
                    console.log("do_payment", err);
                    console.log("data3", data);
                    console.log("////////////////////");
                    console.log("");
                });

in do_payment i got [Error: Invalid token.]

but in set i go

 data { TOKEN: 'EC-2M99668096436354T',
I20170331-17:29:55.814(1)?   TIMESTAMP: '2017-03-31T16:29:55Z',
I20170331-17:29:55.814(1)?   CORRELATIONID: '5b0e35b666c43',
I20170331-17:29:55.814(1)?   ACK: 'Success',
I20170331-17:29:55.814(1)?   VERSION: '92.0',
I20170331-17:29:55.814(1)?   BUILD: '31674279',
I20170331-17:29:55.814(1)?   PAYMENTURL: 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-2M99668096436354T' }

neutron92 avatar Mar 31 '17 16:03 neutron92