php - 哪个是正确的 - PayPal 文档或他们的 PHP IPN 代码示例?

标签 php paypal paypal-ipn

根据 Paypal 的Implementing an IPN Listener文档中,IPN 监听器的正确事件顺序是:

  • 监听器收到通知
  • 监听器发送一个空的 HTTP 200 响应
  • 监听器将 cmd=_notify-validate 添加到它收到的通知上,并通过 POST 将其发送回 PayPal
  • PayPal 响应 VERIFIEDINVALID
  • 监听器适本地处理通知

但是,GitHub 上的示例代码(显然由 PayPal 提供)以不同的顺序做事:

  • 监听器收到通知
  • 监听器将 cmd=_notify-validate 添加到它收到的通知上,并通过 POST 将其发送回 PayPal
  • PayPal 响应 VERIFIEDINVALID
  • 监听器适本地处理通知
  • 监听器发送一个空的 HTTP 200 响应

示例代码是否正常工作?如果不是,为什么 PayPal 引用此代码作为示例?如果是这样,为什么 PayPal 的文档没有反射(reflect)正确的编码顺序? ...或者顺序无关紧要?

最佳答案

显然答案是“按哪个顺序完成并不重要”- 只要在超时窗口内收到响应即可。

当我在 https://www.paypal-techsupport.com/ 搜索“沙盒交易不发送 IPN”时,我发现隐藏在 PayPal 网站上的此信息是可能的答案之一。 :

How long is the IPN timeout length?

PayPal's Instant Payment Notification (IPN) system expects your web server to send an HTTP 200 response when the IPN is sent to your IPN script.

If your server doesn't respond after a certain amount of time, the IPN system then re-posts the IPN to your script.

The amount of time between each re-post doubles each time: 10 seconds, 20 seconds, 40 seconds, 80 seconds, and so on, up to a maximum of 24 hours. The IPN system stops re-posting when:

  • PayPal receives a basic HTTP "200 OK" response from your web server, or
  • When approximately four days have passed since the initial post.

请注意,如果您的 IPN 监听器花费超过 10 秒到达其响应 HTTP 200 结果的位置(如示例代码中所示),则您的操作非常错误: IPN 处理程序应该是一个非常快的过程,尽可能快地执行,尤其是如果您想处理大量流量。 p>

关于php - 哪个是正确的 - PayPal 文档或他们的 PHP IPN 代码示例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45072891/

相关文章:

php - 在类里面执行 SELECT 时无效的语句/准备

paypal - PayPal 的 "Processed"和 "Completed"PAYMENTSTATUS 有什么区别?

microsoft-metro - Paypal Windows8 Checkout SDK 是否支持循环支付?

paypal - 如何配置 Paypal 沙箱进行测试

django-paypal:IPN 请求始终无效

php - Paypal - 用 php 加密 buynow 动态结帐按钮

php - WHERE IN 语句返回 'where clause' 中的未知列

php - 面向对象风格 PHP 中的命名空间使用

php - Laravel 4 - 如何插入多个模型?

ruby-on-rails - 从 Paypal 获取 first_name(和其他信息)并使用 paypal-recurring gem 创建 Rails Devise 帐户