Search code examples
paypal-ipnpaypal-adaptive-payments

PayPal IPN parameters contain two status fields. Which should I use?


I'm using the PayPal Adaptive Payments API. I have a script that receives the IPN postback when a payment is made. In this script I need to perform validation, including checking that the status of the payment is COMPLETED, as specified by the documentation:

Confirm that the "payment_status" is "Completed," since IPNs are also sent for other results such as "Pending" or "Failed"

The documentation hasn't been updated for Adaptive Payments which use different parameters (not payment_status). The parameters I receive are documented here and there are two status fields:

status
The status of the payment. Possible values are:

CREATED – The payment request was received; funds will be transferred once the payment is approved
COMPLETED – The payment was successful
INCOMPLETE – Some transfers succeeded and some failed for a parallel payment or, for a delayed chained payment, secondary receivers have not been paid
ERROR – The payment failed and all attempted transfers failed or all completed transfers were successfully reversed
REVERSALERROR – One or more transfers failed when attempting to reverse a payment
PROCESSING – The payment is in progress
PENDING – The payment is awaiting processing

and

transaction[n].status
The transaction status, where [n] is a number from 0 to 5. For simple single-receiver payments, this number will be 0. Numbers larger than 0 indicate the payment to a particular receiver in chained and parallel payments.

Possible values are:

Completed
Pending
Refunded

Simply put, I don't know which one I should be using. The payment status or the transaction status?

(I'd place my bets on transaction status but then I don't know what the purpose of the payment status is when you have more than one transaction in a request (when using chained payments, for example). Then again, the payment status has more possible values, so perhaps that's the "overall" status and should be used.)


Solution

  • You would want to look at transaction[n].status, and this would be an array. This is because with adaptive payments, a single transaction can be split into multiple transactions to different merchants.

    The status is just saying that the api call went through and completed successfully. It was processed. The transaction[n].status tells you what the status is of each transaction in that call.