config = $config; $this->adapterFactory = $adapterFactory; $this->session = $session; } /** * Retrieve assoc array of checkout configuration * * @return array */ public function getConfig() { $storeId = $this->session->getStoreId(); return [ 'payment' => [ self::CODE => [ 'isActive' => $this->config->isActive($storeId), 'clientToken' => $this->getClientToken(), 'ccTypesMapper' => $this->config->getCcTypesMapper(), 'sdkUrl' => $this->config->getSdkUrl(), 'countrySpecificCardTypes' => $this->config->getCountrySpecificCardTypeConfig($storeId), 'availableCardTypes' => $this->config->getAvailableCardTypes($storeId), 'useCvv' => $this->config->isCvvEnabled($storeId), 'environment' => $this->config->getEnvironment($storeId), 'kountMerchantId' => $this->config->getKountMerchantId($storeId), 'hasFraudProtection' => $this->config->hasFraudProtection($storeId), 'merchantId' => $this->config->getMerchantId($storeId), 'ccVaultCode' => self::CC_VAULT_CODE, ], Config::CODE_3DSECURE => [ 'enabled' => $this->config->isVerify3DSecure($storeId), 'thresholdAmount' => $this->config->getThresholdAmount($storeId), 'specificCountries' => $this->config->get3DSecureSpecificCountries($storeId), ], ], ]; } /** * Generate a new client token if necessary * @return string */ public function getClientToken() { if (empty($this->clientToken)) { $params = []; $storeId = $this->session->getStoreId(); $merchantAccountId = $this->config->getMerchantAccountId($storeId); if (!empty($merchantAccountId)) { $params[PaymentDataBuilder::MERCHANT_ACCOUNT_ID] = $merchantAccountId; } $this->clientToken = $this->adapterFactory->create($storeId) ->generate($params); } return $this->clientToken; } }