Paypal 贝宝标准方法
对于我的项目,我一直在集成PayPal沙盒。对于标准方法,我使用了以下代码。但我无法从PayPal接收通知电话(通知url)。怎么了Paypal 贝宝标准方法,paypal,Paypal,对于我的项目,我一直在集成PayPal沙盒。对于标准方法,我使用了以下代码。但我无法从PayPal接收通知电话(通知url)。怎么了 <form id="form1" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" style="display:none;" accept-charset="utf-8"> <input type="hidden" name="business" va
<form id="form1" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" style="display:none;" accept-charset="utf-8">
<input type="hidden" name="business" value="test2_biz@gmail.com" />
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="paymentaction" value="sale" />
<input type="hidden" name="item_name_1" value="lap" />
<input type="hidden" name="amount_1" value="1" />
<input type="hidden" name="quantity_1" value="1" />
<input type="hidden" name="first_name" value="1" /><!--customer first name -->
<input type="hidden" name="last_name" value="1" /><!--customer last name -->
<input type="hidden" name="address1" value="1" /><!--customer address 1 name -->
<input type="hidden" name="address2" value="1" /><!--customer add2 name -->
<input type="hidden" name="email" value="dfd@rr.ee" /><!--customer email name -->
<input type="hidden" name="city" value="1" /><!--customer city name -->
<input type="hidden" name="state" value="1" /><!--customer state name -->
<input type="hidden" name="country" value="1" /><!--customer country name -->
<input type="hidden" name="zip" value="1" /><!--customer zip name -->
<input type="hidden" name="currency_code" value="USD" /><!--currrecy in which payment u need-->
<input type="hidden" name="upload" value="1" /><!--paypal parameter-->
<input type="hidden" name="return" value="HOST_NAME/default/index/order-return" />
<input type="hidden" name="cancel_return" id="cancel_return" value="" />
<input type="hidden" name="notify_url" id="notify_url" value="HOST_NAME/default/index/notify-url/order/222">
<input type="submit" value="submit">
</form>
> p>我在评论中写到,您应该有一个正确的IPN侦听器,用于对贝宝进行消息验证,以考虑调用您的URL取得成功。
下面是一个基本侦听器的粗略示例:
<?php
function validateIpnMessage() {
$ch = curl_init('https://www.sandbox.paypal.com/cgi-bin/webscr');
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, "cmd=_notify-validate&".http_build_query($_POST));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_FORBID_REUSE, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: Close'));
if( !curl_errno($ch)) {
$res = curl_exec($ch);
curl_close($ch);
if ($res === "VERIFIED") {
return TRUE;
}
}
return FALSE;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST)) {
if(validateIpnMessage()) {
// THE MESSAGE IS VALIDATED
// REST OF YOUR CODE GOES HERE
}
}
?>
您是否确保在您的配置文件中启用了IPN?
无论如何,我建议您首先通过手动测试来检查侦听器URL是否工作
使用IPN测试工具(在您的帐户中的“测试工具”下提供,网址为是的,我看到您添加了它。但是您是否手动检查了您的URL是否有效。您可以使用沙盒帐户中的工具轻松完成此操作,它位于左侧菜单上的“测试工具”链接下。请查看。我正在使用沙盒帐户。我已在paypal表单中添加了notify_URL。因此,我认为nk不需要在配置文件中启用IPN。我已手动测试了notify url。它正在工作。根据您的建议,我已使用IPN测试工具进行了测试。但我收到了此错误。“IPN传递失败。无法连接到指定的url。请验证url并重试。”\您的侦听器脚本有问题。如果您能在此处发布代码,将有助于发现问题。感谢您的回复。侦听器脚本中没有任何内容。我刚刚在该url中发送了一封邮件。您可以检查paypal的沙盒-侦听器url是否正常工作。是否有人可以在沙盒中检查此问题?此问题为o最近发生。我收到了前5到6次付款的回复。谢谢。