Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
PaymentVerificationFactory.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Signifyd\Model;
7 
12 
18 {
22  private $config;
23 
27  private $objectManager;
28 
32  private $avsDefaultAdapter;
33 
37  private $cvvDefaultAdapter;
38 
45  public function __construct(
46  ObjectManagerInterface $objectManager,
47  ConfigInterface $config,
48  PaymentVerificationInterface $avsDefaultAdapter,
49  PaymentVerificationInterface $cvvDefaultAdapter
50  ) {
51  $this->config = $config;
52  $this->objectManager = $objectManager;
53  $this->avsDefaultAdapter = $avsDefaultAdapter;
54  $this->cvvDefaultAdapter = $cvvDefaultAdapter;
55  }
56 
65  public function createPaymentCvv($paymentCode)
66  {
67  return $this->create($this->cvvDefaultAdapter, $paymentCode, 'cvv_ems_adapter');
68  }
69 
78  public function createPaymentAvs($paymentCode)
79  {
80  return $this->create($this->avsDefaultAdapter, $paymentCode, 'avs_ems_adapter');
81  }
82 
94  private function create(PaymentVerificationInterface $defaultAdapter, $paymentCode, $configKey)
95  {
96  $this->config->setMethodCode($paymentCode);
97  $verificationClass = $this->config->getValue($configKey);
98  if ($verificationClass === null) {
99  return $defaultAdapter;
100  }
101  $mapper = $this->objectManager->create($verificationClass);
102  if (!$mapper instanceof PaymentVerificationInterface) {
103  throw new ConfigurationMismatchException(
104  __('%1 must implement %2', $verificationClass, PaymentVerificationInterface::class)
105  );
106  }
107  return $mapper;
108  }
109 }
$objectManager
Definition: bootstrap.php:17
$config
Definition: fraud_order.php:17
__()
Definition: __.php:13
__construct(ObjectManagerInterface $objectManager, ConfigInterface $config, PaymentVerificationInterface $avsDefaultAdapter, PaymentVerificationInterface $cvvDefaultAdapter)