Process IPNs
An IPN (Instant Payment Notification), also referred to as a postback or callback, provides essential transaction details after a payment event. The information it contains includes payment status, transaction amount, currency, customer details, and any metadata you attached to the original request.
For the full IPN structure, validation algorithm, and retry policy, see IPN reference.
Determine the transaction outcome
There are two options to determine whether a transaction was successful or failed.
Option 1: Run IPN-handling code in PHP
A payment.code of 0 always indicates a successful transaction. Any other value indicates a decline, except the partial approval codes 1001 and 1002 described below.
payment.code is sent as an integer, so a strict comparison with 0 is safe.
The following PHP example automates this check:
$ipn = json_decode(file_get_contents('php://input'));
if ($ipn->payment->code === 0) {
// save success
} else {
// codes 1001 and 1002 are partial approvals, see "Decide what to do with an IPN"
// save decline
}If the transaction is unsuccessful, you will see a specific decline code, instead of 0 and the respective code description.
For example:
"code": 5013,
"description": "Invalid amount"See Issuer decline codes & Merchant Advice Codes and Gateway decline codes for the full list of codes.
Option 2: Inspect mode and status manually
In the IPN, look for payment.mode and payment.status:
modeindicates the payment type:saleorauth.statusindicates the outcome:success,fail, orpending.
For example, a successful sale looks like this:
"mode": "sale",
"status": "success"Also, check if code=0 which indicates a successful transaction.
Decide what to do with an IPN
One endpoint receives all IPN types. Use payment.action, payment.status and payment.code to tell them apart.
| IPN | Meaning | Typical handling |
|---|---|---|
action: charge, status: success, code: 0 | Payment or rebill approved | Check the amount and currency, then fulfil the order |
action: charge, status: confirmed | Bank transfer confirmed by the bank | Same as success |
action: charge, status: success or confirmed, code: 1001 or 1002 | Partial approval of a bank transfer: the customer paid less or more | Compare payment.amount with the order and apply your own policy |
action: charge, status: fail | Payment or rebill declined; code holds the decline code | Leave the order unpaid; check the decline code before retrying |
action: charge, status: pending | Payment still in progress | Wait for the next IPN |
action: credit, status: success | Refund, partial refund, void or payout; mode tells which | Record it and reverse the order according to your policy |
action: chargeback | Chargeback; mode holds the stage | Record it and review the order |
action: alert | Dispute or fraud alert (Ethoca, Verifi, RDR and others); mode tells which | Record it and review the order |
No payment object, subscription.status: canceled | Subscription canceled | Stop renewals on your side |
Always compare payment.amount and payment.currency with the amount you expect before fulfilling an order. The x-signature header confirms the sender, the transaction ID and the status; it does not cover the amount.
For details on codes 1001 and 1002, see Partial approvals.
Acknowledge the IPN
Respond with HTTP 200, 201, or 202 once the IPN has been either processed or saved to durable storage (a database table or a persistent queue). The gateway does not re-send an IPN that was acknowledged, so anything that is lost after your 2xx response cannot be recovered through retries.
- If you cannot process or save the IPN (for example, the order is not found yet or the database is unavailable), respond with a
5xxstatus. The gateway will retry according to the retry schedule. - Updating the order status is normally fast enough to do before responding. Move only slow work, such as sending emails or generating files, to a background job.
- The same IPN can be delivered more than once. Treat an IPN as a duplicate only if you have already processed the same
transactionIdwith the samestatussuccessfully. - IPNs for events you do not use (for example, subscription events if you sell one-time products) should still be acknowledged with
2xx.
Example IPN payload
The following is an example of a declined card payment delivered over IPN:
{
"payment": {
"code": 5082,
"description": "Negative online CAM, dCVV, iCVV, CVV, or CAVV results or Offline PIN authentication interrupted",
"action": "charge",
"mode": "sale",
"status": "fail",
"codeCategory": 3,
"amount": 12.09,
"currency": "USD",
"orderId": "2525616924",
"transactionId": "718641118",
"descriptor": "TRO***029",
"source": {
"method": "card",
"number": "518868****7707",
"paymentAccountId": "1ac7f157-a334-4276-ae52-67f7e70e96c4",
"brand": "mastercard",
"expirationMonth": "**",
"expirationYear": "**",
"disabled": false,
"bankName": "BENDIGO AND ADELAIDE BANK, LTD.",
"bankCountry": "AUS"
},
"apiPaymentSource": "paymentAccountId",
"timestamp": {
"dateTime": "2025-10-21 11:50:34",
"timezone": "+02:00",
"unixTime": 1761040234
},
"vat": {
"amount": 0,
"amountUsd": 0
}
},
"consumer": {
"id": "151925232",
"email": "lc***[email protected]",
"firstName": "Lachlan",
"lastName": "C",
"country": "AUS",
"state": "NSW",
"zip": "***"
},
"metadata": {
"orderId": "6***1"
}
}Updated 5 days ago
