简体   繁体   中英

PayPal IPN simulator works fine but IPN not responding to sandbox payments

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="payments@www.com">
                    <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.

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 (eg $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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM