通知 PayPal 的 URL
PayPal 成功返回我在创建“立即购买”按钮时指定的返回 URL。但现在我很困惑。 如何检索有关 PayPal 上发生的交易的详细信息?我还想在返回 URL 上设置一些数据库值。但我担心如果我的用户没有付费就导航到该 URL,他仍然会成为高级会员。我该如何避免这种情况?
PayPal successfully returns me the return URL that I specify while creating "buy now" button. But now I am confused. How do I retrieve details about the transaction that took place on PayPal? I also want to set some database values on the return URL. But I am afraid if my user navigates to that URL without paying, he will become a premium member nonetheless. How do I avoid this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
PayPal 通过他们所谓的 IPN 将数据返回到您的网站。它实际上只是对您指定的 URL 的回调。
您可以通过发送至 PayPal 的变量 notify_url 设置此 URL。
示例:
上例中的notify_url.php 在付款完成后从PayPal 接收一些POST 变量,即使客户从未返回您的网站。
返回了一些重要的变量 PayPal 的格式为:
如果设置,则返回 发票。它可以用作您自己的订单 ID/交易 ID。
txn_id 由 PayPal 生成,是他们自己的交易 ID。
如果您自己添加商品,PayPal 还会返回 num_cart_items、item_name1(item_name2、item_name3)、quantity1(quantity2、quantity3)等。
更多阅读请访问 https://cms.paypal .com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables
当然,您仍然有问题需要解决,如何检查所有这些数据并将其连接到您的客户您可能拥有自己的数据库。
我所做的是在将客户发送到 PayPal 之前保存临时“订单”,并提供发票 ID,该 ID 与我发送到 PayPal 作为发票的 ID 相同。这样我的notify_url.php页面可以检查我的数据库中的发票ID并比较订单/付款。
PayPal returns data back to your site via what they call IPN. Its really just a callback to a URL you specify.
You can set this URL via the variable notify_url you can send to PayPal.
Example:
The notify_url.php in the example above receives some POST variables from PayPal when the payment is completed, even if the customer never returns to your website.
Some of the important variables returned by PayPal is:
invoice is returned if you set it. It can be used as your own order-id/transaction-id.
txn_id is generated by PayPal and it is their own id for the transaction.
If you add items yourself you will PayPal also returns num_cart_items, item_name1 (item_name2, item_name3), quantity1 (quantity2, quantity3) and such.
More reading at https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables
Of course then you still have the problem to solve, how to check all this data and connect it to a customer in your own database, which you probably have.
What I do is to save a temporary "order" before I send the customer to PayPal with a invoice id, same id i send to PayPal as invoice. This way my notify_url.php page can check my database for a invoice id and compare the order/payment.