@@ -273,4 +273,70 @@ public static function validateSecurityCode(string $security_code, CreditCardTyp
273273 return TRUE ;
274274 }
275275
276+ /**
277+ * Gets all available AVS response code meanings.
278+ *
279+ * @return array
280+ * The AVS response code meanings.
281+ *
282+ * @see https://developer.paypal.com/docs/nvp-soap-api/AVSResponseCodes/#avs-error-response-codes
283+ */
284+ public static function getAvsResponseCodeMeanings () : array {
285+ // AVS codes for Visa, MasterCard, Discover, and American Express.
286+ $ standard_codes = [
287+ 'A ' => new TranslatableMarkup ('Address ' ),
288+ 'B ' => new TranslatableMarkup ('International "A" ' ),
289+ 'C ' => new TranslatableMarkup ('International "N" ' ),
290+ 'D ' => new TranslatableMarkup ('International "X" ' ),
291+ 'E ' => new TranslatableMarkup ('Not allowed for MOTO (Internet/Phone) transactions ' ),
292+ 'F ' => new TranslatableMarkup ('UK-specific "X" ' ),
293+ 'G ' => new TranslatableMarkup ('Global Unavailable ' ),
294+ 'I ' => new TranslatableMarkup ('International Unavailable ' ),
295+ 'M ' => new TranslatableMarkup ('Address ' ),
296+ 'N ' => new TranslatableMarkup ('No ' ),
297+ 'P ' => new TranslatableMarkup ('Postal (International "Z") ' ),
298+ 'R ' => new TranslatableMarkup ('Retry ' ),
299+ 'S ' => new TranslatableMarkup ('AVS not Supported ' ),
300+ 'U ' => new TranslatableMarkup ('Unavailable ' ),
301+ 'W ' => new TranslatableMarkup ('Whole ZIP ' ),
302+ 'X ' => new TranslatableMarkup ('Exact match ' ),
303+ 'Y ' => new TranslatableMarkup ('Yes ' ),
304+ 'Z ' => new TranslatableMarkup ('ZIP ' ),
305+ ];
306+
307+ // Additional codes for American Express.
308+ $ amex_codes = [
309+ 'A ' => new TranslatableMarkup ('Card holder address only correct. ' ),
310+ 'D ' => new TranslatableMarkup ('Card holder name incorrect, postal code matches. ' ),
311+ 'E ' => new TranslatableMarkup ('Card holder name incorrect, address and postal code match. ' ),
312+ 'F ' => new TranslatableMarkup ('Card holder name incorrect, address matches. ' ),
313+ 'K ' => new TranslatableMarkup ('Card holder name matches. ' ),
314+ 'L ' => new TranslatableMarkup ('Card holder name and postal code match. ' ),
315+ 'M ' => new TranslatableMarkup ('Card holder name, address and postal code match. ' ),
316+ 'N ' => new TranslatableMarkup ('No, card holder address and postal code are both incorrect. ' ),
317+ 'O ' => new TranslatableMarkup ('Card holder name and address match. ' ),
318+ 'R ' => new TranslatableMarkup ('System unavailable; retry. ' ),
319+ 'S ' => new TranslatableMarkup ('AVS not supported. ' ),
320+ 'U ' => new TranslatableMarkup ('Information unavailable. ' ),
321+ 'W ' => new TranslatableMarkup ('No, card holder name, address and postal code are all incorrect. ' ),
322+ 'Y ' => new TranslatableMarkup ('Yes, card holder address and postal code are both correct. ' ),
323+ 'Z ' => new TranslatableMarkup ('Card holder postal code only correct. ' ),
324+ ] + $ standard_codes ;
325+
326+ return [
327+ 'visa ' => $ standard_codes ,
328+ 'mastercard ' => $ standard_codes ,
329+ 'amex ' => $ amex_codes ,
330+ 'discover ' => $ standard_codes ,
331+ 'maestro ' => [
332+ '0 ' => new TranslatableMarkup ('All the address information matched. ' ),
333+ '1 ' => new TranslatableMarkup ('None of the address information matched. ' ),
334+ '2 ' => new TranslatableMarkup ('Part of the address information matched. ' ),
335+ '3 ' => new TranslatableMarkup ('The merchant did not provide AVS information. Not processed. ' ),
336+ '4 ' => new TranslatableMarkup ('Address not checked, or acquirer had no response. Service not available. ' ),
337+ 'U ' => new TranslatableMarkup ('Address not checked, or acquirer had no response. Service not available. ' ),
338+ ],
339+ ];
340+ }
341+
276342}
0 commit comments