简体   繁体   中英

Paypal sandbox: this transaction is invalid

I am trying to integrate paypal express checkout(test) with no luck. Not sure what i am doing wrong. I have followed the documentation but i get "This transaction is invalid. Please return to the recipient's website to complete your transaction using their regular checkout flow." when i try to redirect to the browser to the sandbox login page.

<form method=post action=https://api-3t.sandbox.paypal.com/nvp>
    <input type=hidden name=USER value=j***-1_api1.g*******s.com.au>
    <input type=hidden name=PWD value=Q8P*******U6>
    <input type=hidden name=SIGNATURE value=AFc************fH>
    <input type=hidden name=VERSION value=124.0>
    <input type=hidden name=PAYMENTREQUEST_0_PAYMENTACTION
        value=Sale>
    <input name=PAYMENTREQUEST_0_AMT value=19.95>
    <input type=hidden name=RETURNURL
        value=http://localhost/moes/paypal_complete.php>
    <input type=hidden name=CANCELURL
        value=http://localhost/moes/paypal_complete.php>
    <input type=submit name=METHOD id="submit_paypal" value=SetExpressCheckout>
</form>

have also tried this on my site live in case localhost is causing the troubles, but still the same.

The ACK response i get back is success:

TOKEN=EC-83V63085L7957480A
TIMESTAMP=20150901T14:14:08Z
CORRELATIONID=ffb632c840981
ACK=Success
VERSION=124.0
BUILD=000000 

But when i use the redirectURL in the documentation with the token i get the invalid transcation error.

https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&TOKEN=EC-83V63085L7957480A

I am logged into developer.paypal.com when i try it, still every time is an invalid transaction.

the URL of the invalid transaction:

//http://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_flow&SESSION=xa6gvld5X3qDZhYbt7pnz6rWMCzBdIFvAREoxohX4E5zH_3ydrzEQBnpQFW&dispatch=50a222a57771920b6a3d7b606239e4d529b525e0b7e69bf0224adecfb0124e9b61f737ba21b0819803370655d2811b9456e01fe893c80ec2

ideas?

You can get sample Express Checkout Code from the PayPal Wizard: PayPal Express Checkout Code Wizard

<form action='expresscheckout.php' METHOD='POST'>
<input type='image' name='submit' src='https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif' border='0' align='top' alt='Check out with PayPal'/>
</form>

You will need to download the expresscheckout.php and the paypalfunctions.php files from the PayPal Code Wizard. Typically your PayPal API Signature goes in a separate php file. The paypalfunctions.php on the code wizard has the API credentials stored.

The below snippet is from the paypal.php file and it is the portion of the code for the sandbox endpoints.

    if ($SandboxFlag == true) 
{ 
    $API_Endpoint = "https://api-3t.sandbox.paypal.com/nvp";
    $PAYPAL_URL = "https://www.sandbox.paypal.com/webscr&cmd=_express-checkout&token=";
}

Also with Express Checkout you need to call Mark Express Checkout which is normally done in one of your PHP files.

You can get the complete php code from the code wizard.

Here is more documentation on Express Checkout from the PayPal Developer Site.

For anyone else reading this, i found that if i changed the redirectURL from:

https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&TOKEN=

to:

https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&useraction=commit&token=

It redirects to the paypal(sandbox) log-in page as intended without error.

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM