交易后从PayPal获取信息 [英] Get information from PayPal after a transaction

查看:137
本文介绍了交易后从PayPal获取信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的网站上创建一个简单的交易,在完成该人的交易之后,我希望贝宝将用户重定向到我网站上的某个地方,并且我希望贝宝向我提供详细信息,以便可以使用PHP进行解析并通过电子邮件将购买链接发送给他们.我不确定notify_url是做什么的?谢谢

I want to create a simple transaction on my Web Site where after the person's transaction completes, I want paypal to redirect the user to go to a place on my site and I want PayPal to provide me with details so I can use PHP to parse it and email them the link to their purchase. I'm not sure what notify_url does? Thanks

推荐答案

PayPal的工作方式如下:

PayPal works like this:

您有一个带有购买"按钮的表格.单击该按钮后,它会将信息(产品,价格,您的帐户名等)发送到PayPal.

You have a form with a "buy" button. When that is clicked, it sends information (product, price, your account name, etc) to PayPal.

然后,买方同意付款给您,交易完成后,贝宝(PayPal)向您的通知URL发送一个"IPN"(即时付款通知)-它向该URL发送POST数据供您的服务器处理.您回复PayPal,询问他们是否发送了POST数据(而不是冒名顶替者),然后如果他们回答这是真实交易,则可以将产品发布给客户.请注意,当您的买家仍在PayPal网站上时,所有这些操作都会在后台发生.

The buyer then agrees to pay you and when the transaction is completed, PayPal send an "IPN" (instant payment notification) to your notify URL - it sends POST data to that URL for your server to process. You reply to PayPal to ask if they sent the POST data (rather than an imposter) and if they then answer that it is a real transaction, you can release the product to the customer. Note that this all happens in the background while your buyer is still "at" the PayPal website.

最后一个可选阶段是,贝宝将买家带回到您的网站.在这种情况下,他们将买方发送回您的返回" URL,并且他们可以(可选)再次传递交易数据(他们称为此PDT).然后,您可以再次与Paypal确认这是否是有效交易,并在那时提供下载等.

There is a final optional stage, which is that PayPal returns the buyer to your website. In this case, they send the buyer back to your "return" url, and they can (optionally) pass back the transaction data again, (they call this PDT). And you can again check with Paypal if this is a valid transaction and provide a download etc at that point.

没人能解释的最困难的一点是 buyer 不会重定向到您的通知URL.也就是说,您网站的通知URL的访问者"是PayPal,而不是买家,因此在您的买家会话中不会发生这种情况.如果您希望在此过程的三个部分中持续进行会话,则需要创建一种在表单中跟踪买方的方法,然后将其传递给自定义"表单字段中的PayPal.该数据将在IPN和PDT数据中传递回给您,您可以使用它与原始用户会话重新建立连接.

The most difficult bit that nobody explains is that the buyer doesn't get redirected to your notify URL. i.e. the "visitor" to your website's notify URL is PayPal, not the buyer, so this doesn't happen as part of your buyer's session. If you wish to persist a session across the three parts of this process, then you need to create a means of tracking the buyer in your form, and pass that to PayPal in a field of the form called "custom". This data is passed back to you in the IPN and PDT data, and you can use this to re-establish a connection with the original user session.

您确实需要同时实现IPN和PDT-如果IPN电子邮件失败,则您将PDT作为备份.而且,如果用户在重定向到您的PDT页面之前关闭了Web浏览器,那么您已经发送了IPN电子邮件作为备份.

You really need to implement both IPN and PDT - if the IPN email fails then you have PDT as a backup. And if the user closes their web browser before they are redirected back to your PDT page, then you have sent an IPN email as a backup.

搜索IPN和PDT,您会发现很多信息. PayPal 也包含完整的文档和示例脚本.

Search on IPN and PDT and you'll find quite a lot of information. PayPal also have full documentation and example scripts.

这篇关于交易后从PayPal获取信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆