Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CvvEmsCodeMapper.php
Go to the documentation of this file.
1 <?php
7 
12 
21 {
27  private static $notProvidedCode = 'P';
28 
34  private static $cvvMap = [
35  'M' => 'M',
36  'N' => 'N',
37  'U' => 'P',
38  'I' => 'P',
39  'S' => 'S',
40  'A' => ''
41  ];
42 
50  public function getCode(OrderPaymentInterface $orderPayment)
51  {
52  if ($orderPayment->getMethod() !== ConfigProvider::CODE) {
53  throw new \InvalidArgumentException(
54  'The "' . $orderPayment->getMethod() . '" does not supported by Braintree CVV mapper.'
55  );
56  }
57 
58  $additionalInfo = $orderPayment->getAdditionalInformation();
59  if (empty($additionalInfo[PaymentDetailsHandler::CVV_RESPONSE_CODE])) {
60  return self::$notProvidedCode;
61  }
62 
63  $cvv = $additionalInfo[PaymentDetailsHandler::CVV_RESPONSE_CODE];
64  return isset(self::$cvvMap[$cvv]) ? self::$cvvMap[$cvv] : self::$notProvidedCode;
65  }
66 }
getCode(OrderPaymentInterface $orderPayment)