2

I'm working with PayPal IPN and I have the following question: Is it possible, to have two IPN messages with the same txn_id and payment_status parameter?

For example:

  1. IPN: txn_id=4BB79227HY951745W&payment_status=pending
  2. IPN: txn_id=4BB79227HY951745W&payment_status=idontknowwhat
  3. IPN: tnx_id=4BB79227HY951745W&payment_status=pending
  4. IPN: txn_id=4BB79227HY951745W&payment_status=completed

So my question is basically that the txn_id and the payment_status together make the messages unique, or not?

Another example:

If I have an SQL query like:

SELECT * FROM transactions WHERE txn_id=4BB79227HY951745W AND payment_status=something

Can it returns with more than one rows? (If I don't store any messages re-sent by PayPal because of the lack of 200 OK response message or slow response time or anything like this.)

I read this thread before: PayPal IPN unique identifier . Here it sounds that these two parameters make the message unique, but i'm not sure.

Community
  • 1
  • 1
bazsibazsi
  • 121
  • 9
  • IMHO, it's not about "uniqueness" per se because IPN is a messaging service (on the **changing state** of a transaction). It even has "retries" as described in the [IPN Protocol](https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNIntro/#protocol_and_arch) which is discussed in the answer of the post you referenced/linked to. – EdSF Apr 04 '15 at 16:14
  • 1
    Thank you for your answer. I understand this, but I want to store everything related to a transaction, but I don't want to store anything more than once. So after I save transaction data into my DB somehow I have to know if a new IPN message is sent because something "changed" with that transaction or it just re-sent by PayPal IPN service for some reason. – bazsibazsi Apr 04 '15 at 16:26

1 Answers1

0

I think that the txn_id and payment_status alone are not enough to make the IPN unique. Since in your case you want to save every IPN related to a given transaction, you should also check the pending_reason value:

Let's say you have created a transaction using the Authorization - Capture model and Your transaction goes through Instant Payment Review (IPR). You'll have something like this as IPN:

IPN 1: TXN goes into UNDER REVIEW (IPR)

[payment_status] => Pending
[txn_id] => 0CD48848U16230847
[pending_reason] => paymentreview
[txn_type] => express_checkout
[auth_status] => Pending
[ipn_track_id] => 8c7559d39005

IPN 2: TXN has passed IPR (Note that the pending reason has changed!)

[payment_status] => Pending
[txn_id] => 0CD48848U16230847
[pending_reason] => authorization
[txn_type] => express_checkout
[auth_status] => Pending
[ipn_track_id] => 8c7559d39005
dickwan
  • 337
  • 4
  • 13
  • I've already solved this problem with db timestamps and other 'doublechecks' but what you say makes sense and answered my question. Accepted! – bazsibazsi Oct 04 '15 at 15:05