Paypal 不会向 IPN 发送沙盒交易数据

Paypal won't send sandbox transaction data to IPN

我今天花了 9 个小时使用 Paypal,但我遇到了一个找不到解决方案的问题。

我正在使用 Paypal Javascript Buttons github 脚本为简单的 Buy Now 交易创建动态页面生成按钮。

按钮示例输出由 PHP 生成(也是动态的)并且看起来像这样(具有沙盒详细信息):

  <script src='https://site-addr/includes/js/paypal-button.min.js?merchant=siteemail-facilitator@gmail.com'
data-callback='https://site-addr/account/listener.php'
data-tax='0' 
data-env='sandbox' 
data-shipping='0' 
data-currency='GBP' 
data-amount='1.00'
data-quantity='1' 
data-custom='y$BdA/7xN2S/fzRq8X9p4pFOmzYBpia/u7sWsAcWN/4w9NZVXduaUzu'
data-number='20165'
data-size='Large'
data-locale='UK'
data-host='www.sandbox.paypal.com'
data-type='button'
data-cancel_return='https://site-addr/account/basket.php'
data-return='https://site-addr/account/complete.php'
data-name='Site Name Tickets' 
data-button='buynow' 
async='async'></script>

这会生成一个非常好的简单点击表单,用于通过 Paypal 界面进行购买。

与此同时,我已经下载了 IPN listener from the Paypal Github 并根据需要更新了详细信息,还下载了 cacert.pem 文件 from here.

我有 运行 Paypal IPN simulator 通过我的 listener.php 文件给了我正确的结果 ,给出了完整数据的正确提要VERIFIED 每次我 运行 测试。

问题

但是,当我 运行 使用上述详细信息购买沙盒时,购买 运行 是正确的,但我的 IPN 侦听器没有收到任何反馈,我的 sandbox Transaction notifications。但是我 DO 获取有关沙盒 Paypal 帐户的详细信息,表明购买成功并且购买已完成。

我尝试过的事情

我阅读了很多 Paypals 文档,发现他们提供清晰简洁的指南以通过 Paypal 设置任何内容的方法,非常令人担忧。我已经阅读了他们文档的大约 40 页,包括从 Stack Overflow 中找到各种有用的帖子(Paypal directly reference 提供有用的解决方案,而不是提供他们自己的解决方案)。

尝试失败的解决方案:

但是上面的替换data-callback不起作用。交易似乎仍然成功,但没有记录交易或 IPN 数据。


进一步考虑

我相信你们中的一些人会说,我应该使用 SDK 下载来做这种事情,但是 SDK 的范围很大,我的需求相对简单,Paypal 文档离开了需要设计的东西太多了。此外,他们(在一系列 Paypal github 存款中)正在使用 MySQL_ 示例代码请求以及 addslashes 和其他 的请求过时了。

另外值得注意的是,虽然 Javascript 按钮生成器的 Paypal 文档接受帐户电子邮件或帐户代码,但提供帐户代码会导致严重错误并阻止处理付款(真实或沙盒) .

再加上在文档中只找到零碎的指导信息和"loops",所以我在一个主题上,它说"oh if you want to find out how to do this, follow this link",然后按照link 它是为非开发人员(在开发人员门户上)编写的更冗长的文本,然后 link 到另一个文本块,然后 link 回到开始的文本。

抱歉,这变成了 Paypal 抱怨,但我想尽可能避免使用庞大的 SDK 系统来进行直接发送和接收数据操作。


有解决此问题的有用示例吗?


最后说明: 上个月我在 Stripe 上制作了一个支付系统,它做的事情完全一样,花了四个小时并且运行良好。

(我不能在这里使用 Stripe,因为客户有一个现有的 Paypal 帐户并且不会更改)。

Solution:

With the help from David Nguyens answer below, I found the issue in my case was that I had set up the IPN and enabled the IPN and given the correct address for it, but this was on the Live account rather than the sandbox account, despite only setting up the sandbox account after all the details on the live one had been applied.

Paypals Live and Sandbox profiles are entirely mutually exclusive and sandbox creation will not import any data from the live account it is associated with.

在 Paypal 上进一步解决问题

  • 调查 Sandbox Paypal 上的 IPN 日志以查看数据发送到什么以及发送到哪里,链接是 production URL and sandbox URL
  • 检查状态代码,如果您收到 5xx 类型错误 - 调试您的脚本
  • 这应该告诉您 IPN 发送到哪里,如果不是应该检查的地方:
    • ipn URL 中的按钮
    • 配置文件中的 ipn URL 被覆盖