I have set PayPal sandbox account and created a button and put it in HTML. When I test everything out with IPN simulator it works just fine, but when purchase is made through PayPal button (sandbox mode) nothing happens. Here is the button code
<form action="https://sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="NC4M3RU83QEDG">
<input type="image" src="https://www.sandbox.paypal.com/en_US/GB/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.sandbox.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
And here is the ipn script (works fine with ipn simulator)
$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") {
$to = '[email protected]';
$subject = 'Something';
$headers = 'From:[email protected]' . "\r\n";
$message = 'bla bla bla';
mail($to, $subject, $message, $headers);
}
I have enabled IPN in my acc and I have set notify url correctly Regards