Reputation: 1411
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 urlencode
d), 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?
Upvotes: 10
Views: 13783
Reputation: 11
I also solved similar issue with removing paypal cookies. Problem was with changing sandbox account clientId/secret in the same browser.
Upvotes: 1
Reputation: 1411
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.
Upvotes: 32