我已经设置了 PayPal 沙箱帐户并创建了一个按钮并将其放入 HTML 中。当我使用 IPN 模拟器测试所有内容时,它工作得很好,但是当通过 PayPal 按钮(沙盒模式)进行购买时,什么也没有发生。这是按钮代码
<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>
这是 ipn 脚本(适用于 ipn 模拟器)
$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 = 'something@hotmail.com';
$subject = 'Something';
$headers = 'From:noreply@something.com' . "\r\n";
$message = 'bla bla bla';
mail($to, $subject, $message, $headers);
}
我已经在我的账户中启用了 IPN,并且我已经正确设置了通知 url 问候