PayPal IPN 脚本,不会在数据库中插入数据
所以我会描述一个小问题 -
1) 我得到了 PayPal IPN 脚本,如果经过验证,它会在数据库中插入数据,否则会向我发送电子邮件。
2)我用PayPal沙盒测试工具测试了脚本,我只需要插入链接,它会自动检查它是否正常工作,并且它插入了数据,所以它正在工作。 但现在问题开始了 -
3)之后我尝试使用PayPal沙盒测试帐户对其进行测试。我创建了两个测试 PayPal 帐户 - 卖方和买方。
4) 为卖家配置所有内容并创建一个按钮(PayPal 技术支持配置按钮和 IPN 链接一切正常)。
5)所以我在homeapge中插入按钮,并尝试使用测试帐户付款。
6) 登录,付款,没有回到主页,但数据库中没有插入任何数据,也没有发送电子邮件到我的邮箱。
7) 我没有进入卖家帐户 PayPal 历史记录,它显示我从 IPN 脚本中获得了一份历史记录,该历史记录已成功发送且具有 200 HTTP(这意味着一切正常!)。
8) 我的买家帐户中的资金已发送至卖家帐户。
看起来一切都很顺利,除了 paypal 没有做 IPN 脚本内的任何事情,所以也许你可以帮我出点主意?我尝试联系 PayPal 技术支持,他们确认一切都应该没问题!
希望你能帮我解决这个问题!
谨致问候,
瓦尔特斯
So I'll describe a little bit problem -
1) I got PayPal IPN script, with features if is verified, it inserts data in database otherwise it sends email to me.
2) I tested the script with PayPal Sandbox Test Tools, where I just need to insert link and it automatically check's if it is working, and it inserted data, so it's working.
But now problem starts -
3) After that I tried to test it with PayPal Sandbox Test accounts. I created two test PayPal accounts - Seller and Buyer.
4) Configured everything for Seller and created a button (PayPal Technical support configured everything was ok with button and IPN link).
5) So I inserted the button in homeapge, and tried to pay with test accounts.
6) Logged in, payed and wen't back to homepage, but no data was inserted in database eather no email was sent to my mail.
7) I wen't to Seller account PayPal History, and it showed that I got one history from IPN script, that was succesfully sent and with 200 HTTP (this means everything was OK!).
8) Money from my buyer account was sent to seller account.
It seems that everything worked great, except, paypal didn't do anything that was inside IPN script, so maybe you could help me with ideas? I tried contacting PayPal technical support, and they confirmed that everything should be okay!
Hope you can help me with this problem!
Best regards,
Valters
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里没有简单的答案,因此我将帮助您提供一些有关如何具体调试此场景的说明。
首先,要注意不同的付款状态。 PayPal 有“待处理”状态,以及我相信的一些“已验证”或“已确认”状态(现在不记得确切的术语)。 IPN 模拟器和买家测试帐户可能会生成两种不同类型的付款,从而导致两种不同的状态,因此请首先检查这一点。如果它们不相同,请找出处理非工作付款状态的代码中的问题。
如果做不到这一点,...
听起来这不是一个必然与 PayPal 及其 IPN 有关的问题,而是与您的 PHP 脚本在执行过程中的某个时刻有关。换句话说,听起来您的 PHP 脚本在某些时候要么遇到了导致脚本崩溃的 PHP 错误,要么遇到了一些行为错误。
由于 IPN 模拟器一切正常,因此可能只是特定类型的测试用例导致了错误; IPN 模拟器的工作方式和买家帐户的设置方式之间的一些非常微小的差异可能会触发代码的不同部分执行...
看看您的服务器上是否有一个 error_log 文件,位于与您的 IPN 脚本。如果是这样,请向上打开它并向下滚动到最近的错误。这只是当脚本遇到错误时输出到屏幕的错误日志;显然,您在这里使用 IPN,因此 PayPal 是会“看到”输出到屏幕的错误的客户端(但他们的 IPN 系统无论如何都不会关注它),所以您看到这一点的唯一方法输出就是通过这个error_log或者写一些调试代码。
如果 error_log 不够,并且您确实需要编写一些调试代码,则应该在 IPN 回调脚本中添加一些代码,这些代码将在脚本中以一定的时间间隔将一些输出写入文本文件。这样,您就可以准确判断脚本崩溃的位置(如果崩溃的话)。如果事实证明脚本根本没有崩溃,那么编写一些代码来输出 SQL 查询。
实际上,弄清楚这个问题的最快方法可能就是这样做:编写一些调试代码将 SQL 查询输出到文件中。结果将为您提供有关问题所在的重要线索:您的脚本是否崩溃,或者您的代码是否从查询发生的地方分支(没有文件输出),查询本身是否有问题(很可能是案例),或者......好吧,几乎是这两种情况之一。
祝你好运!
There's no easy answer here, so I'll help you with some instructions on how specifically to debug this scenario.
First of all, pay attention to the different payment statuses. PayPal has a "pending" status, as well as I believe some "verified" or "confirmed" statuses (can't remember the exact terminology right now). The IPN simulator and the buyer test account could be generating two different types of payments, resulting in two different statuses, so check that first. If they're not identical, find what's wrong in your code that's handling the non-working payment status.
Failing that, ...
Sounds like it's not an issue necessarily having anything to do with PayPal and its IPN, but with your PHP script at some point in execution. In other words, it sounds like your PHP script is, at some point, either encountering a PHP error that's crashing the script or encountering some behavioral bug.
Because everything's working fine with the IPN simulator, it could be that just a specific type of test case is causing the error; some very minor difference in how the IPN simulator works and how a buyer account is set up could be triggering different parts of your code to execute...
Take a look and see if you have an error_log file on your server in the same directory as your IPN script. If so, open that up and scroll down to the most recent errors. This is just a log of the errors that get output to the screen when your script encounters an error; obviously, you're working with IPN here, so PayPal is the client who would "see" the errors being output to the screen (but their IPN system doesn't pay any attention to it anyway), so your only way to see that output is through this error_log or to write some debugging code.
If the error_log doesn't suffice and you do need to write some debugging code, you should add some code to your IPN callback script that will write some output to a text file at certain intervals in the script. That way, you can tell exactly where the script is crashing (if it IS crashing). If it turns out the script doesn't appear to be crashing at all, then write some code to output your SQL query.
Actually, the fastest way to get to the bottom of this would probably be just to do that: write some debugging code to output your SQL query to a file. The result will give you a big clue on what's going wrong: whether your script is crashing or if your code is branching away from wherever that query takes place (no file output), whether something's wrong with the query itself (could very likely be the case), or... well, pretty much one of those two cases.
Good luck!