Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do_payment [Error: Invalid token.] #16

Open
neutron92 opened this issue Mar 31, 2017 · 0 comments
Open

do_payment [Error: Invalid token.] #16

neutron92 opened this issue Mar 31, 2017 · 0 comments

Comments

@neutron92
Copy link

neutron92 commented Mar 31, 2017

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' }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant