通知 PayPal 的 URL [英] Notify URL of PayPal
问题描述
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?
推荐答案
PayPal 通过所谓的 IPN 将数据返回到您的站点.它实际上只是对您指定的 URL 的回调.您可以通过变量 notify_url 设置此 URL,您可以将其发送给 PayPal.
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.
示例:
<input name="notify_url" value="http://yourdomain.com/notify_url.php" type="hidden">
上例中的 notify_url.php 在付款完成时从 PayPal 接收一些 POST 变量,即使客户从未返回您的网站.
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.
一些重要的变量 PayPal 返回的是:
Some of the important variables returned by PayPal is:
- mc_gross
- 发票
- settle_amount
- protection_eligibility
- 地址状态
- payer_id
- 税
- address_street
- 付款日期
- 付款状态
- 字符集
- address_zip
- mc_shipping
- mc_handling
- 名字
- mc_fee
- address_country_code
- exchange_rate
- 地址名称
- notify_version
- settle_currency
- 自定义
- payer_status
- 业务
- address_country
- address_city
- verify_sign
- payer_email
- txn_id
- 付款类型
如果您设置它,将返回发票.它可以用作您自己的订单 ID/交易 ID.
invoice is returned if you set it. It can be used as your own order-id/transaction-id.
txn_id 由 PayPal 生成,是他们自己的交易 ID.
txn_id is generated by PayPal and it is their own id for the transaction.
如果您自己添加商品,PayPal 还会返回 num_cart_items、item_name1 (item_name2, item_name3)、quantity1 (quantity2,quantity3) 等.
If you add items yourself you will PayPal also returns num_cart_items, item_name1 (item_name2, item_name3), quantity1 (quantity2, quantity3) and such.
当然,您仍然有问题要解决,如何检查所有这些数据并将其连接到您自己数据库中的客户,您可能拥有该数据库.
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.
我所做的是在我将客户发送到 PayPal 之前保存一个临时订单",其中包含发票 ID,与我发送给 PayPal 作为发票的 ID 相同.这样我的 notify_url.php 页面就可以检查我的数据库中的发票 ID 并比较订单/付款.
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.
这篇关于通知 PayPal 的 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!