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:

  • mode indicates the payment type: sale or auth.
  • status indicates the outcome: success, fail, or pending.

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.

IPNMeaningTypical handling
action: charge, status: success, code: 0Payment or rebill approvedCheck the amount and currency, then fulfil the order
action: charge, status: confirmedBank transfer confirmed by the bankSame as success
action: charge, status: success or confirmed, code: 1001 or 1002Partial approval of a bank transfer: the customer paid less or moreCompare payment.amount with the order and apply your own policy
action: charge, status: failPayment or rebill declined; code holds the decline codeLeave the order unpaid; check the decline code before retrying
action: charge, status: pendingPayment still in progressWait for the next IPN
action: credit, status: successRefund, partial refund, void or payout; mode tells whichRecord it and reverse the order according to your policy
action: chargebackChargeback; mode holds the stageRecord it and review the order
action: alertDispute or fraud alert (Ethoca, Verifi, RDR and others); mode tells whichRecord it and review the order
No payment object, subscription.status: canceledSubscription canceledStop 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 5xx status. 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 transactionId with the same status successfully.
  • 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"
  }
}


Did this page help you?