Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AVSResponse.php
Go to the documentation of this file.
1 <?php
7 
11 
16 {
22  const AVSADDR = 'avsaddr';
23 
29  const AVSZIP = 'avszip';
30 
41  const IAVS = 'iavs';
42 
44  const RESPONSE_YES = 'y';
45 
46  const RESPONSE_NO = 'n';
47 
52  const CONFIG_ON = 1;
53 
54  const CONFIG_OFF = 0;
58  protected $avsCheck = [
59  'avsaddr' => 'avs_street',
60  'avszip' => 'avs_zip',
61  ];
62 
66  protected $errorsMessages = [
67  'avs_street' => 'AVS address does not match.',
68  'avs_zip' => 'AVS zip does not match.',
69  ];
70 
78  public function validate(DataObject $response, Transparent $transparentModel)
79  {
80  $config = $transparentModel->getConfig();
81  foreach ($this->avsCheck as $fieldName => $settingName) {
82  if ($config->getValue($settingName) == static::CONFIG_ON
83  && strtolower((string) $response->getData($fieldName)) === static::RESPONSE_NO
84  ) {
85  $response->setRespmsg($this->errorsMessages[$settingName]);
86  return false;
87  }
88  }
89 
90  return true;
91  }
92 }
$response
Definition: 404.php:11
$config
Definition: fraud_order.php:17
validate(DataObject $response, Transparent $transparentModel)
Definition: AVSResponse.php:78