Paypal started to return from sandbox this URL:
http://www.url.com/en/order/201807035911&success=true&paymentId=PAY-3VW434721W751862GLO563ZQ?token=EC-1CD5257354412893B&PayerID=AZDJ2H9PDTOYY
A question mark in the middle of URL ( .. 63ZQ**?**token=E ..). The URL configurated in the PHP SDK is:
$successUrl = "http://www.url.com/en/order/201807035911&success=true";
I can get through _GET paymentId without a problem, but can't access the token and PayerID because of the question mark.
I have no idea how to solve it in a smart way. I tried even .htaccess, that doesn't work at all (I don't get even the paymentId parameter):
RewriteRule ^(.*)/order/(.*)&success=(.*)&paymentId=(.*)?token=(.*)&PayerID=(.*) overview.php?jazyk=$1&id=$2&success=$3&paymentId=PAY-$4&token=$5&PayerID=$6 [L]
With this .htaccess I use for my website I can get paymentID, but not the rest.
RewriteRule ^(.*)/order/(.*) overview.php?jazyk=$1&id=$2 [L]
How can I access the token and PayerID parameters?
I'd check if the configured postback URL is correct. It appears to have an &
without a ?
preceding it to mark the beginning of the query string.
"http://www.url.com/en/order/201807035911&success=true"
You don't need to add success=true
manually, since the status will be provided in the request's query string. Try setting it to just:
"http://www.url.com/en/order/201807035911"
You can grab the URL, get the stuff on the right of the ?
and use parse_str() to get the other values.
If you already have your full URL you can skip the $_SERVER['REQUEST_URI']
in the first step.
// your URL
$url = $_SERVER['REQUEST_URI'] ;
// split it on the '?'
$urlParts = explode('?',$url) ;
// grab the variables and put them in $rightOfTheQuestionMark
parse_str($urlParts[1],$rightOfTheQuestionMark) ;
What you want is now in the array $rightOfTheQuestionMark