Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AvsEmsCodeMapper.php
Go to the documentation of this file.
1 <?php
7 
12 
21 {
27  private static $unavailableCode = '';
28 
34  private static $avsMap = [
35  'MM' => 'Y',
36  'NM' => 'A',
37  'MN' => 'Z',
38  'NN' => 'N',
39  'UU' => 'U',
40  'II' => 'U',
41  'AA' => 'E'
42  ];
43 
51  public function getCode(OrderPaymentInterface $orderPayment)
52  {
53  if ($orderPayment->getMethod() !== ConfigProvider::CODE) {
54  throw new \InvalidArgumentException(
55  'The "' . $orderPayment->getMethod() . '" does not supported by Braintree AVS mapper.'
56  );
57  }
58 
59  $additionalInfo = $orderPayment->getAdditionalInformation();
60  if (empty($additionalInfo[PaymentDetailsHandler::AVS_POSTAL_RESPONSE_CODE]) ||
62  ) {
63  return self::$unavailableCode;
64  }
65 
66  $streetCode = $additionalInfo[PaymentDetailsHandler::AVS_STREET_ADDRESS_RESPONSE_CODE];
67  $zipCode = $additionalInfo[PaymentDetailsHandler::AVS_POSTAL_RESPONSE_CODE];
68  $key = $zipCode . $streetCode;
69  return isset(self::$avsMap[$key]) ? self::$avsMap[$key] : self::$unavailableCode;
70  }
71 }
getCode(OrderPaymentInterface $orderPayment)