You are here

public static function CreditCard::getAvsResponseCodeMeanings in Commerce Core 8.2

Gets all available AVS response code meanings.

Return value

array The AVS response code meanings.

See also

https://developer.paypal.com/docs/nvp-soap-api/AVSResponseCodes/#avs-err...

2 calls to CreditCard::getAvsResponseCodeMeanings()
CreditCardTest::testGetAvsResponseCodeMeanings in modules/payment/tests/src/Unit/CreditCardTest.php
@covers ::getAvsResponseCodeMeanings
PaymentGatewayBase::buildAvsResponseCodeLabel in modules/payment/src/Plugin/Commerce/PaymentGateway/PaymentGatewayBase.php
Builds a label for the given AVS response code and card type.

File

modules/payment/src/CreditCard.php, line 284

Class

CreditCard
Provides logic for listing card types and validating card details.

Namespace

Drupal\commerce_payment

Code

public static function getAvsResponseCodeMeanings() : array {

  // AVS codes for Visa, MasterCard, Discover, and American Express.
  $standard_codes = [
    'A' => new TranslatableMarkup('Address'),
    'B' => new TranslatableMarkup('International "A"'),
    'C' => new TranslatableMarkup('International "N"'),
    'D' => new TranslatableMarkup('International "X"'),
    'E' => new TranslatableMarkup('Not allowed for MOTO (Internet/Phone) transactions'),
    'F' => new TranslatableMarkup('UK-specific "X"'),
    'G' => new TranslatableMarkup('Global Unavailable'),
    'I' => new TranslatableMarkup('International Unavailable'),
    'M' => new TranslatableMarkup('Address'),
    'N' => new TranslatableMarkup('No'),
    'P' => new TranslatableMarkup('Postal (International "Z")'),
    'R' => new TranslatableMarkup('Retry'),
    'S' => new TranslatableMarkup('AVS not Supported'),
    'U' => new TranslatableMarkup('Unavailable'),
    'W' => new TranslatableMarkup('Whole ZIP'),
    'X' => new TranslatableMarkup('Exact match'),
    'Y' => new TranslatableMarkup('Yes'),
    'Z' => new TranslatableMarkup('ZIP'),
  ];

  // Additional codes for American Express.
  $amex_codes = [
    'A' => new TranslatableMarkup('Card holder address only correct.'),
    'D' => new TranslatableMarkup('Card holder name incorrect, postal code matches.'),
    'E' => new TranslatableMarkup('Card holder name incorrect, address and postal code match.'),
    'F' => new TranslatableMarkup('Card holder name incorrect, address matches.'),
    'K' => new TranslatableMarkup('Card holder name matches.'),
    'L' => new TranslatableMarkup('Card holder name and postal code match.'),
    'M' => new TranslatableMarkup('Card holder name, address and postal code match.'),
    'N' => new TranslatableMarkup('No, card holder address and postal code are both incorrect.'),
    'O' => new TranslatableMarkup('Card holder name and address match.'),
    'R' => new TranslatableMarkup('System unavailable; retry.'),
    'S' => new TranslatableMarkup('AVS not supported.'),
    'U' => new TranslatableMarkup('Information unavailable.'),
    'W' => new TranslatableMarkup('No, card holder name, address and postal code are all incorrect.'),
    'Y' => new TranslatableMarkup('Yes, card holder address and postal code are both correct.'),
    'Z' => new TranslatableMarkup('Card holder postal code only correct.'),
  ] + $standard_codes;
  return [
    'visa' => $standard_codes,
    'mastercard' => $standard_codes,
    'amex' => $amex_codes,
    'discover' => $standard_codes,
    'maestro' => [
      '0' => new TranslatableMarkup('All the address information matched.'),
      '1' => new TranslatableMarkup('None of the address information matched.'),
      '2' => new TranslatableMarkup('Part of the address information matched.'),
      '3' => new TranslatableMarkup('The merchant did not provide AVS information. Not processed.'),
      '4' => new TranslatableMarkup('Address not checked, or acquirer had no response. Service not available.'),
      'U' => new TranslatableMarkup('Address not checked, or acquirer had no response. Service not available.'),
    ],
  ];
}