Failure codes
Read Pay.com's failure code, the network's raw response code, and the processor's own code for a declined or failed transaction.
A declined or failed transaction carries up to three codes for the same decline: Pay.com's failure code, the response code from the network or acquirer, and the processor's own code. Build your logic on Pay.com's code, which is the same for every acquirer. Use the other two to troubleshoot with your acquirer or processor.
The codes
Each code answers a different question.
| Code | Field | What it is |
|---|---|---|
| Failure code | failure_code, and decline_code in the 400 error | Pay.com's code for the reason, such as insufficient_funds. See Error codes. |
| Raw response code | underlying_network_details.<network>.raw_response_code | The response code from the network or acquirer, such as 51. See Raw response codes. |
| Processor code | underlying_processing_details.failure_code and failure_message | The processor's own decline code and message. See Processor codes. |
| Merchant advice code | underlying_network_details.<network>.advice_code | Whether and when to retry. See Merchant advice codes. |
A declined Mastercard charge, retrieved after the decline:
{
"id": "chrg_685125114794084352",
"resource": "charge",
"status": "failed",
"failure_code": "insufficient_funds",
"failure_message": "Insufficient Funds",
"underlying_network_details": {
"network": "mastercard",
"mastercard": {
"raw_response_code": "51",
"advice_code": "24"
}
},
"underlying_processing_details": {
"failure_code": "51",
"failure_message": "Insufficient funds"
}
}How Pay.com sets the failure code
Pay.com maps the acquirer's response code to a failure code, by card network
first, then by payment method. A code with no mapping becomes
generic_decline. failure_code is set only for a declined, blocked, or
failed transaction, and is null otherwise.
Some failure codes are Pay.com's own decisions, not the issuer's, for example
cancelled_by_risk when a risk rule blocks the payment, or
authentication_failure when 3D Secure fails. These have no raw response code.
failure_message describes the reason. Log it, and show customers your own
message for each failure code. See Handle declines.
Where to find the codes
The codes are on the transaction wherever you read it:
- The
400error: a declined charge, hold, capture, refund, or payout returnsdecline_code, which is the failure code, andmessage, which is the failure message. The error also hasunderlying_network_details,underlying_processing_details, andretry_attempts. See Declines. - The object: retrieve the charge, hold, refund, or payout by ID.
- Events:
charge.failed,hold.failed,refund.failed,payout.failed, andpayment_attempt.failedcarry the object with its codes. - Retry attempts: each attempt in
retry_attemptshas its own failure code and raw codes. See Attempts and retries. - Reports: the transaction reconciliation report and
GET /v1/reconciliation/transactionshavefailure_code.
Raw response codes
raw_response_code is the response code from the network or the acquirer, for
example 51 (insufficient funds) or 05 (do not honor) in the ISO 8583 codes
that most card networks use. It's set on approvals too, usually as 00.
It isn't always a network code. Some acquirers return their own codes in this field. Pay.com leaves it out when Pay.com declined the payment itself, for example after a risk rule or a timeout.
Use the raw code with your acquirer, and to apply the networks' retry rules. Visa, for example, forbids retries after some response codes and limits retries after the others. See Card network retry limits.
Processor codes
underlying_processing_details.failure_code and failure_message are the
processor's own code and message for the decline, as the processor sent them.
They're set when the processor returns a code, and only when processor details
are enabled on your account. Contact your Pay.com account team to enable them.
Codes in routing and retries
Fallback rules, the soft decline loop, network token fallback, and the account billing updater all match Pay.com's failure codes, not raw codes. Only codes marked Fallbackable in the error codes table can trigger a fallback. See Fallbacks and retries.
Next steps
- Error codes: Every failure code, and which ones can trigger a fallback.
- Handle errors: Branch on the status, type, and code of an error.
- Decline codes: The most common decline codes, and what to do for each.