100

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?

yairchu
  • 21,122
  • 7
  • 65
  • 104
Tom
  • 28,567
  • 26
  • 84
  • 120
  • I found a web page that really explains this better. [PayPal PDT and IPN: How does it work?][1] [1]: http://webmasters.stackexchange.com/questions/21634/paypal-pdt-and-ipn-how-does-it-work – Ananize Scott Dec 04 '12 at 13:00
  • Regarding question 2, there is a `PayPal Account Optional` setting under `My selling preferences > Website preferences` which you can turn on to not force you customers to create/have a PayPal account, ie. pay by credit/debit card. – kaiyaq Dec 16 '14 at 23:12

3 Answers3

113

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

Rafael
  • 6,646
  • 13
  • 29
  • 43
Mr. Shiny and New 安宇
  • 13,596
  • 6
  • 41
  • 64
  • 2
    Thanks, I see. So basically, link the database updates to IPN (as it will always get processed) and link user confirmations only to PDT (such as checking whether the payment has been processed by IPN on a pending page, for example) .... ? – Tom May 14 '10 at 19:03
  • 3
    @Tom: My implementation is: When either a PDT or an IPN comes in, read the parameters and try to process the payment. The processor A) blocks out other simultaneous processing (for that user) and B) checks to see if it's been processed already. After processing is done, with IPN you are finished, with PDT you show the user a confirmation page or receipt page or whatever. Both the PDT side and IPN side can work properly if the other side is down, but you get good reliability from having both. A fairly high % of users don't click through before the IPN arrives. – Mr. Shiny and New 安宇 May 14 '10 at 19:29
  • @Tom: Also, since the back-end implementation for PDT is so similar to IPN you may as well do them both, it's practically free. – Mr. Shiny and New 安宇 May 14 '10 at 19:30
  • 1
    I found an official doc releated to this question https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNPDTAnAlternativetoIPN/ – HungYuHei Feb 02 '15 at 07:12
  • 2
    IPN takes up to 4 days to answer... it sucks – Toskan May 25 '16 at 01:33
  • Don't use ampersand character in the custom field. You'll only get the first segment returned. We're able to replicate the issue intermittently. – Joseph Persie Mar 21 '17 at 03:48
  • Thanks for your answer. Sometimes IPN takes lots of time to notify. – Chinmay235 Jan 03 '20 at 06:14
1

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.

jan salawa
  • 1,168
  • 1
  • 7
  • 25
0

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/

Sol
  • 851
  • 8
  • 16