Hi everyone!
I posted a similar thread to the PP developer SE page, in case my issue is PP specific, but I'm thinking it's not, it's an issue with the code I've written, in which case, I need to ask you guys, so here I am 🙂
I'm trying to implement this very simple PayPal payment integration into my site's cart. The issue I'm having is that when the page should be pinging PP and checking the data, it instead sends the visitor to the PP developer home page. It looks like it might be because my querystring to be sent to PP sandbox is corrupted. Here's my querystring builder:
// Check if paypal request or response
if(!ISSET($_POST["txn_id"]) && !isset($_POST["txn_type"])){
$querystring = '';
// Firstly Append paypal account to querystring
$querystring .= "?business=".urlencode($site_email)."&";
// Append amount& currency (£) to quersytring so it cannot be edited in html
//The item name and amount can be brought in dynamically by querying the $_POST['item_number'] variable.
$querystring .= "item_name=".urlencode($coToken)."&";
$querystring .= "amount=".urlencode($coTotal)."&";
$querystring .= "lc=".urlencode('US')."&";
$querystring .= "currency_code=".urlencode('USD')."&";
// Append paypal return addresses
$querystring .= "return=".urlencode(stripslashes($return_url))."&";
$querystring .= "cancel_return=".urlencode(stripslashes($cancel_url))."&";
$querystring .= "notify_url=".urlencode($notify_url);
//echo urldecode($querystring);
header('location:https://www.sandbox.paypal.com/cgi-bin/webscr'.$querystring);
exit();
}
I decoded my querystring to make sure the data was correct and it seems Like it might be corrupt right after lc=US.
?business=site@email.com&item_name=9814992281458743510&amount=785&lc=US¤cy_code=USD&return=https://site.com/?action=invoice&successful&cancel_return=https://site.com/?action=invoice&cancelled¬ify_url=https://site.com/?action=payola
Where it should state "LC=US¤cy_code=USD", it instead states "lc=US¤cy_code=USD" and there's another illegal character further along at "notify_url".
Might this be the reason PayPal is sending me to the sandbox frontpage and not processing the purchase or should I be looking elsewhere in the code? If this is the issue, what am I doing wrong?
Thanks for your time!