Paypal 中的 IPN 与 PDT

发布于 2024-09-01 10:29:35 字数 485 浏览 1 评论 0原文

我在选择 PayPal 的即时付款通知 (IPN) 和付款数据传输 (PDT) 时遇到一些困难。

基本上,用户在我的网站上购买一次性产品,通过 PayPal 付款,然后返回我的网站。我了解 IPN 的工作原理,但我现在发现,我可能能够使用 PDT 更轻松地触发成功购买后发生的各种操作,因为数据会立即返回(而不是需要单独的侦听器) 。

然而,PayPal 的 PDT 文档包含这样一条神秘的文字:“PDT 不适用于信用卡或 Express Checkout 交易。” ...但我找不到有关该主题的任何进一步内容。

  1. 信用卡真的不适合与 PDT 一起使用吗?我想要的不仅仅是一句话。

  2. 这是否意味着用户必须拥有/创建 PayPal 帐户才能付款?

  3. 这是否意味着,如果我想允许用户直接使用其 PayPal 帐户和/或信用卡付款,我必须实施 IPN?

有经历过这种情况的好心人可以透露一下吗?

I'm having some trouble choosing between PayPal's Instant Payment Notification (IPN) and Payment Data Transfer (PDT).

Basically, users buy a one-off product on my site, pay on PayPal, and return to my site. I understand how IPN works but I'm now seeing that I might be able to trigger the various actions that take place after a successful purchase more easily with PDT, as the data gets returned there and then (as opposed to needing a separate listener).

However, PayPal's PDT documentation contains this cryptic line: "PDT is not meant to be used with credit card or Express Checkout transactions." ... but I can't find anything further whatsoever on the topic.

  1. Are credit cards REALLY not meant to be used with PDT? I would like more than a sentence.

  2. Does that mean that a user must have/create a PayPal account to pay?

  3. Does it mean that if I want to allow users to pay with their PayPal accounts AND/OR with credit cards directly, I must implement IPN?

Could anyone who's gone through this kindly shed some light?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

药祭#氼 2024-09-08 10:29:35

PDT 和 IPN 的 API 类似。主要区别在于您收到通知的时间。出于这个原因,我建议同时实施两者。

  • 通过 PDT,您可以立即收到通知,并可以执行所需的任何其他处理并向用户显示确认页面。
  • 通过 IPN,即使用户的计算机在向您发送 PDT 之前发生爆炸,您也能保证收到付款已收到的通知。

实施两者并获得两全其美的效果。但如果您只做其中一项,IPN 是可靠的。

一个问题是:如果您同时实施这两项,那么您的付款有可能会被处理两次。请注意确保不会发生这种情况。我编写的应用程序处理 PDT 和 IPN 的方式几乎相同(后端部分相同),并且该代码会在数据库中获取每个 Web 用户的锁定,因此,如果同一用户尝试多次提交完全相同的付款,只能处理一次。一旦处理完毕,该过程的结果将被重新用于任何后续处理它的尝试。

编辑
还有一件事:IPN 比 PDT 携带更多信息。您可以从 IPN 收到许多不同的消息,例如退款通知等,因此您确实应该实施它。


PayPal 的 PDT 系统将订单确认发送到使用 PayPal 支付标准的商家网站,并让他们验证此信息。然后,此类站点可以在“订单确认”页面中本地显示此数据。

何时使用 PDT?

IPN 提供与上述相同的功能。那么,什么时候应该选择PDT而不是IPN呢?

通过 PDT,当客户完成付款时,您的网站会立即收到通知。然而,对于 IPN,客户完成付款的时间与您的站点收到此事件通知的时间之间存在重大滞后。

因此,如果您的网站包含需要立即付款通知的功能,请使用 PDT。

例如,考虑一家数字音乐商店。借助 PDT,该商店可以让客户立即下载他们购买的商品,因为 PDT 会立即发送订单确认。对于 IPN,不可能立即履行订单。

IPN

PDT 的优点有一个主要缺点:它发送订单确认一次且仅一次。因此,当 PDT 发送确认时,您的站点必须正在运行;否则,它将永远不会收到该消息。

相比之下,使用 IPN,实际上可以保证订单确认的送达,因为 IPN 会重新发送确认,直到您的站点确认收到为止。因此,PayPal 建议您实施 IPN 而不是 PDT。

IPN 的另一个优点是它发送多种类型的通知,而 PDT 只发送订单确认。因此,使用 IPN,您的网站可以接收退款通知和订单确认等内容。
注意:如果您的网站必须立即收到付款通知,您可以同时实施 IPN 和 PDT。但是,如果您这样做,您的网站每次销售都会收到两份订单确认信息。因此,您必须小心地仅对给定确认消息的一份副本采取行动(例如运送产品)。

此处的文档

The APIs for PDT and IPN are similar. The main difference is when you receive the notification. For that reason I would recommend implementing both.

  • With PDT you get the notification instantly and can do any additional processing required and show the user a confirmation page.
  • With IPN you are guaranteed to be notified that the payment was received even if the user's computer explodes before it can send you the PDT.

Implement both and get the best of both worlds. But if you're only doing one, IPN is the reliable one.

One catch: if you implement both then there's a chance your payments could be processed twice. Take care to ensure that doesn't happen. The application I wrote handles the PDT and IPN almost identically (the backend part is the same) and that code acquires a per-web-user lock in the database, so that if the same user tries to submit the exact same payment multiple times it can only be processed once. Once processed the result of that process is re-used for any subsequent attempts to process it.

Edit
One more thing: IPN carries more information than PDT. There are lots of different messages that you can receive from IPN, such as chargeback notification, etc, and thus you really should implement it.


PayPal's PDT system sends order confirmations to merchant sites that use PayPal Payments Standard and lets them authenticate this information. Such sites can then display this data locally in an "order confirmation" page.

When to Use PDT?

IPN provides the same capabilities described above. So, when should you choose PDT instead of IPN?

With PDT, your site is notified immediately when a customer completes payment. With IPN, however, there is a material lag between the time a customer completes payment and the time your site receives notification of this event.

So, use PDT if your site includes a feature that requires immediate payment notification.

For example, consider a digital music store. With PDT, this store can let customers download their purchases right away since PDT sends order confirmations immediately. With IPN, such immediate order fulfillment is not possible.

Advantages of IPN

PDT has a a major weakness: it sends order confirmations once and only once. As a result, when PDT sends a confirmation, your site must be running; otherwise, it will never receive the message.

With IPN, in contrast, delivery of order confirmations is virtually guaranteed since IPN resends a confirmation until your site acknowledges receipt. For this reason, PayPal recommends that you implement IPN rather than PDT.

Another advantage of IPN is that it sends many types of notifications, while PDT sends just order confirmations. So, using IPN, your site can receive, for example, chargeback notifications as well as order confirmations.
Note: If your site must be notified of payments immediately, you can implement both IPN and PDT. However, if you do, your site will receive two order confirmations for each sale. As a result, you must be careful to take action (say, ship a product) on just one copy of a given confirmation message.

Documentation Here

辞旧 2024-09-08 10:29:35

回复 1. PDT 旨在与网站付款自动返回功能一起使用。向卖家付款后,自动退货会重定向到 PDT 网站。遗憾的是,该功能无法与 PayPal 帐户可选功能(用于启用信用卡付款)一起使用。以下是 PayPal 的注释:“如果您已开启 自动返回并选择启用 PayPal 帐户 对于新用户可选,新用户不会自动返回您的网站,但会提供返回选项。用户可以选择返回您的网站(PDT 步骤)或留在 PayPal 网站。总而言之,当通过信用卡付款时,如果用户不点击“返回商店链接”,则可以跳过 PDT 步骤。

回复 2. 您可以选择允许哪些付款方式,这取决于您。如果您想允许在没有 PayPal 帐户的情况下付款,您可以启用 帐户可选。如果您只想允许拥有 PayPal 帐户的用户,请禁用该功能。可能还有更多选择。

回复 3. 在您的情况下,您需要在成功购买后触发操作。推荐的方法是实施 IPN。 PDT 并不适用于所有情况,并且不保证消息传递。以下是涵盖该主题的文档的链接PDT 与 IPN

Re 1. PDT is meant to use with Auto Return for Website Payments feature. Auto Return redirects to PDT site after paying money to seller. Unfortunately it's not possible to use that feature along with PayPal Account Optional - used to enable Credit Card payment. Here is note from PayPal: 'If you have turned on Auto Return and have chosen to turn on PayPal Account Optional for new users, a new user will not be automatically directed back to your website, but will be given the option to return.'. User will have an option to go back to your site(PDT step) or stay on PayPal site. To sum it up when paying by Credit Card user can skip PDT step if user will not click 'return to store link'.

Re 2. It is up to you what paying options do you want to allow. If you want to allow paying without a PayPal Account you can enable Account Optional. If you want to allow only users with PayPal accounts disable that feature. There might be more options.

Re 3. In your case you need to trigger action after successful purchase. Recommended way would be to implement IPN. PDT doesn't work for all cases and doesn't guarantee message delivery. Here is link to doc covering that topic PDT vs IPN.

千と千尋 2024-09-08 10:29:35

这是一个老问题,但我的简单答案是 - 为什么不同时使用 PDT 和 IPN?它们可以很好地用于卡交易。

PDT可以向您的网站提供即时的交易状态,您可以在其中快速查看支付成功或失败的状态,并向用户提供适当的消息。

同时,您可以在后台等待IPN的全面验证。收到后,您可以使用它来进一步更新您的数据库并处理订单。

您可以按照我发现的分步指南进行操作,该指南非常清晰且有用 - 并且在 2018 年仍然有效。

https://www.codexworld.com/paypal-standard- payment-gateway-integration-php/

This is an old question, but my simple answer would be - Why not use both PDT and IPN? They will work fine for card transactions.

PDT can provide the immediate transaction status to your website, where you can quickly check the payment success or failure status and provide the user with appropriate message.

Meanwhile, you can await the full verification from IPN in the background. Once received, you can use this to further update your DB and process the order.

You can follow this step-by-step guide which I found to be very clear and helpful - and it's still valid in 2018.

https://www.codexworld.com/paypal-standard-payment-gateway-integration-php/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文