Skip to main content

Overview

This page provides comprehensive information about transaction response codes, AVS (Address Verification System) codes, and CVV (Card Verification Value) response codes returned by the payment gateway.
Understanding response codes is essential for proper error handling and transaction management.

Transaction Response Format

All transaction responses are returned in query string format:
response=1&responsetext=SUCCESS&transactionid=123456789&amount=99.99

Response Code

The response variable indicates the overall transaction result:
CodeStatusDescriptionAction
1ApprovedTransaction successfulComplete order
2DeclinedTransaction declinedRequest alternative payment
3ErrorProcessing error occurredReview error details, retry if appropriate

Response Text

The responsetext variable provides a human-readable description:
Common approval messages:
Response TextMeaning
SUCCESSStandard approval
APPROVEDTransaction approved
HONOR WITH IDApproved, ID required
PARTIAL APPROVALPartially approved (amount_authorized < requested)

AVS Response Codes

Address Verification System (AVS) compares billing address with issuer records:

Standard AVS Codes

CodeDescriptionRecommendation
XExact match - Address and 9-digit ZIP✅ Accept
YExact match - Address and 5-digit ZIP✅ Accept
AAddress match only⚠️ Review
W9-digit ZIP match only⚠️ Review
Z5-digit ZIP match only⚠️ Review
NNo match⛔ Decline/Review
UAddress unavailable⚠️ Review
RRetry - System unavailable🔄 Retry
EAVS error⚠️ Review
SService not supported- N/A
GGlobal non-verifiable- N/A

International AVS Codes

CodeDescriptionRecommendation
BStreet match, postal code not verified⚠️ Review
CStreet and postal code not verified⚠️ Review
DStreet and postal code match (international)✅ Accept
IAddress information not verified⚠️ Review
MStreet and postal code match (international)✅ Accept
PPostal code match, street not verified⚠️ Review
Configure AVS rules based on your risk tolerance. Overly strict rules may decline legitimate transactions.

CVV Response Codes

Card Verification Value (CVV) response codes:
CodeDescriptionRecommendation
MCVV match✅ Accept
NCVV does not match⛔ Decline
PNot processed⚠️ Review
SCVV should be on card but was not indicated⚠️ Review
UIssuer not certified or not provided⚠️ Review
XNo response from card association⚠️ Review
Always request CVV for card-not-present transactions to reduce fraud and improve approval rates.

Handling Response Codes

Decision Flow

1

Check Response Code

First, check the response variable
if ($result['response'] == '1') {
    // Approved
} elseif ($result['response'] == '2') {
    // Declined
} else {
    // Error
}
2

Verify AVS

For approved transactions, check AVS
$acceptable_avs = ['X', 'Y', 'A', 'Z', 'W'];
if (in_array($result['avsresponse'], $acceptable_avs)) {
    // AVS acceptable
}
3

Verify CVV

Check CVV response
if ($result['cvvresponse'] == 'M') {
    // CVV match
} else {
    // CVV mismatch - flag for review
}
4

Take Action

Process accordingly based on all checks

Implementation Example

<?php
function handleTransactionResponse($result) {
    // Check primary response
    if ($result['response'] != '1') {
        if ($result['response'] == '2') {
            // Declined
            return [
                'success' => false,
                'message' => 'Payment declined: ' . $result['responsetext'],
                'retry' => in_array($result['responsetext'], ['CALL FOR AUTHORIZATION'])
            ];
        } else {
            // Error
            return [
                'success' => false,
                'message' => 'Payment error: ' . $result['responsetext'],
                'retry' => true
            ];
        }
    }

    // Transaction approved - check AVS
    $avs_acceptable = ['X', 'Y', 'A', 'Z', 'W', 'D', 'M'];
    $avs_match = in_array($result['avsresponse'], $avs_acceptable);

    // Check CVV
    $cvv_match = ($result['cvvresponse'] == 'M');

    // Fraud score check
    $needs_review = !$avs_match || !$cvv_match;

    if ($needs_review) {
        // Flag for manual review
        flagForReview($result['transactionid'], [
            'avs' => $result['avsresponse'],
            'cvv' => $result['cvvresponse']
        ]);
    }

    return [
        'success' => true,
        'transaction_id' => $result['transactionid'],
        'needs_review' => $needs_review,
        'message' => 'Payment successful'
    ];
}
?>

Partial Approvals

Some transactions may be partially approved:
response=1
responsetext=PARTIAL APPROVAL
amount_authorized=50.00
partial_payment_balance=49.99
Response Variables:
  • amount_authorized - Approved amount (less than requested)
  • partial_payment_balance - Remaining balance
Handling:
if ($result['responsetext'] == 'PARTIAL APPROVAL') {
    $approved = $result['amount_authorized'];
    $remaining = $result['partial_payment_balance'];

    // Option 1: Accept partial amount
    completeOrderWithPartial($approved);

    // Option 2: Request additional payment
    requestAdditionalPayment($remaining);

    // Option 3: Void and request full amount elsewhere
    voidTransaction($result['transactionid']);
    requestFullPayment($originalAmount);
}

EMV Response Codes

For EMV chip transactions:
CodeDescription
00Approved
01Refer to card issuer
03Invalid merchant
04Pick up card
05Do not honor
12Invalid transaction
13Invalid amount
14Invalid card number
51Insufficient funds
54Expired card
55Incorrect PIN
57Transaction not permitted
58Transaction not permitted to terminal
61Exceeds withdrawal amount limit
62Restricted card
63Security violation
65Exceeds withdrawal frequency limit

ACH Return Codes

Common ACH return codes:
CodeDescriptionType
R01Insufficient FundsNSF
R02Account ClosedAccount
R03No Account/Unable to LocateAccount
R04Invalid Account NumberAccount
R05Unauthorized Debit to Consumer AccountAuthorization
R06Returned per ODFI RequestAuthorization
R07Authorization RevokedAuthorization
R08Payment StoppedStop Payment
R09Uncollected FundsNSF
R10Customer Advises Not AuthorizedAuthorization
R11Check Truncation Entry ReturnEntry
R12Account Sold to Another DFIAccount
R13Invalid ACH Routing NumberRouting
R14Representative Payee DeceasedAccount
R15Beneficiary DeceasedAccount
R16Account FrozenAccount
R20Non-Transaction AccountAccount
R29Corporate Customer Advises Not AuthorizedAuthorization
Certain ACH return codes (R01, R09) allow retry after 30 days. Others (R02, R03, R04) should not be retried.

Chargeback Reason Codes

Visa Reason Codes

CodeDescriptionCategory
10.1EMV Liability Shift Counterfeit FraudFraud
10.2EMV Liability Shift Non-Counterfeit FraudFraud
10.3Other Fraud - Card Present EnvironmentFraud
10.4Other Fraud - Card Absent EnvironmentFraud
10.5Visa Fraud Monitoring ProgramFraud
11.1Card Recovery BulletinAuthorization
11.2Declined AuthorizationAuthorization
11.3No AuthorizationAuthorization
12.1Late PresentmentProcessing
12.2Incorrect Transaction CodeProcessing
12.3Incorrect CurrencyProcessing
12.4Incorrect Account NumberProcessing
12.5Incorrect AmountProcessing
13.1Merchandise Not ReceivedConsumer Dispute
13.2Cancelled RecurringConsumer Dispute
13.3Not as DescribedConsumer Dispute

Mastercard Reason Codes

CodeDescriptionCategory
4837No Cardholder AuthorizationFraud
4840Fraudulent Processing of TransactionFraud
4841Cancelled Recurring TransactionConsumer Dispute
4842Late PresentmentProcessing
4853Cardholder DisputeConsumer Dispute
4854Cardholder Dispute (US Region Only)Consumer Dispute
4855Non-Receipt of MerchandiseConsumer Dispute
4859Services Not RenderedConsumer Dispute
4860Credit Not ProcessedConsumer Dispute

Testing Response Codes

Test Card Numbers

Card NumberAVS ResponseCVV ResponseResult
4111111111111111XMApproved
4000000000000002NNDeclined (AVS/CVV fail)
4000000000000010YMApproved
4000000000000028--Declined (Insufficient Funds)
4000000000000036--Declined (Do Not Honor)
4000000000000044--Declined (Expired Card)

Test Amounts

Use specific amounts to trigger responses:
AmountResponse
x.00Approved
x.01Declined
x.02Error
x.05Approved with AVS=N
x.10Partial approval ($50.00)

Best Practices

Log All Responses

Store complete response data for troubleshooting and compliance

Display User-Friendly Messages

Translate technical codes to customer-friendly language

Implement Fraud Rules

Configure AVS/CVV rules based on your risk profile

Handle Retries Gracefully

Implement appropriate retry logic for specific errors

Error Message Examples

Convert technical responses to customer-friendly messages:
function getCustomerMessage($responsetext) {
    $messages = [
        'DECLINE' => 'Your card was declined. Please use a different payment method.',
        'INSUFFICIENT FUNDS' => 'Your card has insufficient funds. Please use a different card.',
        'INVALID CARD NUMBER' => 'The card number you entered is invalid. Please check and try again.',
        'CARD EXPIRED' => 'Your card has expired. Please use a different card.',
        'DO NOT HONOR' => 'Your card was declined. Please contact your bank or use a different card.',
        'CALL FOR AUTHORIZATION' => 'Please contact your card issuer to authorize this transaction.',
    ];

    return $messages[$responsetext] ?? 'Payment processing failed. Please try again or use a different payment method.';
}

Next Steps