Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PayPal Express Checkout always shows user "This transaction has expired." page, but no API error

I'm trying to set up a simple payment sequence with PayPal's Express Checkout. My SetExpressCheckout call seems to work fine, I get ACK=Success and a token. When I redirect the user to PayPal using that token, though, it always displays a screen to them saying:

This transaction has expired. Please return to the recipient's website to complete your transaction using their regular checkout flow.

Your session has ended

We're sorry, but your session has ended. Your account hasn't been charged. Please go back to the merchant's site and check out again with PayPal.

Just to clarify, I don't get any error codes from the SetExpressCheckout API call, but the token always seems to be expired. I've tried redirecting to nonsense tokens, but that generates a different page. It seems that I am both receiving a valid token and redirecting to it correctly, but it has always expired in the 1-2 seconds that that takes.

Details of an example request:

What I'm sending in the initial SetExpressCheckout request:

Array
(
    [PAYMENTACTION] => Sale
    [useraction] => commit
    [RETURNURL] => xxxx
    [CANCELURL] => xxxxx
    [PAYMENTREQUEST_0_AMT] => 49.00
    [PAYMENTREQUEST_0_SHIPPINGAMT] => 0
    [PAYMENTREQUEST_0_CURRENCYCODE] => USD
    [PAYMENTREQUEST_0_ITEMAMT] => 49.00
    [L_PAYMENTREQUEST_0_NAME0] => xxxxx
    [L_PAYMENTREQUEST_0_DESC0] => xxxxx
    [L_PAYMENTREQUEST_0_NUMBER0] => xxxxx
    [L_PAYMENTREQUEST_0_AMT0] => 49
    [L_PAYMENTREQUEST_0_QTY0] => 1
    [METHOD] => SetExpressCheckout
    [VERSION] => 74.0
    [USER] => xxxxx
    [PWD] => xxxxx
    [SIGNATURE] => xxxxx
)

Curl_getinfo about the request:

Array
(
    [url] => https://api-3t.sandbox.paypal.com/nvp
    [content_type] => text/plain; charset=utf-8
    [http_code] => 200
    [header_size] => 255
    [request_size] => 798
    [filetime] => -1
    [ssl_verify_result] => 0
    [redirect_count] => 0
    [total_time] => 1.139
    [namelookup_time] => 0
    [connect_time] => 0.187
    [pretransfer_time] => 0.64
    [size_upload] => 660
    [size_download] => 136
    [speed_download] => 119
    [speed_upload] => 579
    [download_content_length] => 136
    [upload_content_length] => 660
    [starttransfer_time] => 1.139
    [redirect_time] => 0
    [certinfo] => Array
        (
        )

    [primary_ip] => 23.4.59.42
    [primary_port] => 443
    [local_ip] => 192.168.0.102
    [local_port] => 63049
    [redirect_url] => 
)

What I get back from PayPal via curl:

Array
(
    [TOKEN] => EC-59031295261754641
    [TIMESTAMP] => 2014-01-20T10:12:27Z
    [CORRELATIONID] => 84d3d68cbd574
    [ACK] => Success
    [VERSION] => 74.0
    [BUILD] => 9285531
)

I'm then redirecting the user to the relevant URL for that token (with the token urlencoded), in this case:

https://www.paypal.com/webscr?cmd=_express-checkout&useraction=commit&token=EC-59031295261754641

That all seems fine to me, but when I redirect to that URL, it always shows the 'transaction has expired screen'.

Could anyone point out what I'm doing wrong?

like image 388
MHG Avatar asked Jan 20 '14 10:01

MHG


People also ask

Is PayPal Express checkout deprecated?

PayPal has deprecated PayPal Express payment. Existing forms with PayPal Express will still work, but we highly recommend switching to/using our newest PayPal integrations, such as the following: Paypal Checkout.

How do I activate Express checkout on PayPal?

Click the Store feature. Click Checkout Settings. Click the Checkout Settings tab to set up your Store payment information. Click Activate to activate your Paypal Express checkout.

How do I disable PayPal Express checkout?

You can find this setting under Theme Settings > Cart. Note: this workaround only works when using the Page cart type. Once the additional checkout buttons are enabled we can apply a CSS snippet to hide those buttons on the cart page, effectively removing the express buttons from all parts of your checkout experience.

What does PayPal Express checkout mean?

PayPal Checkout, formerly known as PayPal Express Checkout, is a tool made for online sellers. It allows customers to buy goods or services easily, without the need to input their shipping and billing details. This ensures that the customer's personal and payment information is transmitted securely to the merchant.


2 Answers

The problem was that it was in Sandbox mode, and the redirection should be made to

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

Rather than the URL shown above.

This is shown on Page 36 of the Express Checkout integration guide.

like image 156
MHG Avatar answered Nov 05 '22 11:11

MHG


I also solved similar issue with removing paypal cookies. Problem was with changing sandbox account clientId/secret in the same browser.

like image 39
minXak Avatar answered Nov 05 '22 11:11

minXak