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  'YY' => 'Y',
36  'NY' => 'A',
37  'YN' => 'Z',
38  'NN' => 'N'
39  ];
40 
48  public function getCode(OrderPaymentInterface $orderPayment)
49  {
50  if ($orderPayment->getMethod() !== Config::METHOD_PAYFLOWPRO) {
51  throw new \InvalidArgumentException(
52  'The "' . $orderPayment->getMethod() . '" does not supported by Payflow AVS mapper.'
53  );
54  }
55 
56  $additionalInfo = $orderPayment->getAdditionalInformation();
57  if (empty($additionalInfo[Info::PAYPAL_AVSADDR]) ||
58  empty($additionalInfo[Info::PAYPAL_AVSZIP])
59  ) {
60  return self::$unavailableCode;
61  }
62 
63  $streetCode = $additionalInfo[Info::PAYPAL_AVSADDR];
64  $zipCode = $additionalInfo[Info::PAYPAL_AVSZIP];
65  $key = $zipCode . $streetCode;
66 
67  return isset(self::$avsMap[$key]) ? self::$avsMap[$key] : self::$unavailableCode;
68  }
69 }
getCode(OrderPaymentInterface $orderPayment)