Reputation:
If I send an IPN from here https://developer.paypal.com/developer/ipnSimulator/ it works fine.
If I make a payment directly from my site using a PayPal sandbox account and a PayPal standard button, the IPN listener doesn't pick anything up. Here's the PayPal button on my site (note that it does link to PayPal's sandbox and the notify_url is specified correctly):
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="no_shipping" value="1">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="business" value="[email protected]">
<input type="hidden" name="item_number" value="21-2360-4" id="itemNumber">
<input type="hidden" name="item_name" value="Listing Fee">
<input type="hidden" name="return" value="https://www.com/Market">
<input type="hidden" name="cancel_return" value="https://www.com/Seller">
<input type="hidden" name="amount" value="10" id="amount">
<input type="hidden" name="notify_url" value="https://www.com/IPN">
<p><button type="submit" id="sellButton">Pay fee and list</button></p>
</form>
Here's my IPN listener code which works fine for IPNs made from the PayPal IPN simulator page but not for sandbox payments made using the form above (note it is also listening to PayPal's sandbox):
if($_SERVER['REQUEST_METHOD'] != 'POST'){
exit();
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://ipnpb.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=_notify-validate&" . http_build_query($_POST));
$response = curl_exec($ch);
curl_close($ch);
if($response == "VERIFIED"){
// Successful purchase code.
}
Any clues as to why it doesn't pick up the IPN would be much appreciated.
Upvotes: 1
Views: 1104
Reputation: 236
Modified Info Log into the recipient Paypal account and setup IPN
Steps Profile -> Profile and Settings -> My selling tools -> Instant payment notifications -> update
Click "Choose IPN settings"
Set the "Notification URL" field to what you have on "notify_url" in the HTML form.
Choose "Recieve IPN Messages"
Save
Note: If you check IPN history, it may come up as Queued. This seems to be a Sandbox glitch or maybe its handling many requests and has a long queue. You can try a live payment with a small value (e.g $1). See here: Paypal IPN Status - Queued
now irrelevant---
This should be a comment but I don't have the clearance to make comments.
You have <button name="submit">Purchase with PayPal</button>
That should be <button type="submit">Purchase with PayPal</button>
Please provide the full Paypal html code within the <form></form>
tags.
Upvotes: 1