config = $config; $this->subjectReader = $subjectReader; } /** * @inheritdoc */ public function build(array $buildSubject) { $result = []; $paymentDO = $this->subjectReader->readPayment($buildSubject); $amount = $this->formatPrice($this->subjectReader->readAmount($buildSubject)); if ($this->is3DSecureEnabled($paymentDO->getOrder(), $amount)) { $result['options'][Config::CODE_3DSECURE] = ['required' => true]; } return $result; } /** * Check if 3d secure is enabled * @param OrderAdapterInterface $order * @param float $amount * @return bool */ private function is3DSecureEnabled(OrderAdapterInterface $order, $amount) { $storeId = $order->getStoreId(); if (!$this->config->isVerify3DSecure($storeId) || $amount < $this->config->getThresholdAmount($storeId) ) { return false; } $billingAddress = $order->getBillingAddress(); $specificCounties = $this->config->get3DSecureSpecificCountries($storeId); if (!empty($specificCounties) && !in_array($billingAddress->getCountryId(), $specificCounties)) { return false; } return true; } }