coreHelper = $coreHelper; $this->config = $config; $this->url = $url; $this->categoryExclusionHelper = $categoryExclusionHelper; } /** * @return string */ public function getConfig() { $config = [ 'widgetUrl' => $this->coreHelper->getWidgetUrl(), 'merchantId' => $this->coreHelper->getMerchantId(), 'clientId' => $this->coreHelper->getClientId(), 'isPwaEnabled' => $this->coreHelper->isPaymentButtonEnabled(), 'isLwaEnabled' => $this->coreHelper->isLoginButtonEnabled(), 'isSandboxEnabled' => $this->coreHelper->isSandboxEnabled(), 'chargeOnOrder' => $this->sanitizePaymentAction(), 'authorizationMode' => $this->coreHelper->getAuthorizationMode(), 'displayLanguage' => $this->coreHelper->getButtonDisplayLanguage(), 'buttonTypePwa' => $this->coreHelper->getButtonTypePwa(), 'buttonTypeLwa' => $this->coreHelper->getButtonTypeLwa(), 'buttonColor' => $this->coreHelper->getButtonColor(), 'buttonSize' => $this->coreHelper->getButtonSize(), 'redirectUrl' => $this->coreHelper->getRedirectUrl(), 'loginPostUrl' => $this->url->getLoginPostUrl(), 'customerLoginPageUrl' => $this->url->getLoginUrl(), 'sandboxSimulationOptions' => [], 'loginScope' => $this->coreHelper->getLoginScope(), 'allowAmLoginLoading' => $this->coreHelper->allowAmLoginLoading(), 'isEuPaymentRegion' => $this->coreHelper->isEuPaymentRegion(), 'presentmentCurrency' => $this->config->getPresentmentCurrency(), 'oAuthHashRedirectUrl' => $this->coreHelper->getOAuthRedirectUrl(), 'isQuoteDirty' => $this->categoryExclusionHelper->isQuoteDirty(), 'region' => $this->coreHelper->getRegion(), 'useMultiCurrency' => $this->config->useMultiCurrency() ]; if ($this->coreHelper->isSandboxEnabled()) { $config['sandboxSimulationOptions'] = $this->transformSandboxSimulationOptions(); } return $config; } /** * @return bool */ public function isBadgeEnabled() { return ($this->coreHelper->isPwaEnabled()); } /** * @return bool */ public function isExtensionEnabled() { return ($this->coreHelper->isPwaEnabled() || $this->coreHelper->isLwaEnabled()); } /** * @return bool */ public function sanitizePaymentAction() { return ($this->coreHelper->getPaymentAction() === 'authorize_capture'); } /** * @return array */ public function transformSandboxSimulationOptions() { $sandboxSimulationOptions = $this->coreHelper->getSandboxSimulationOptions(); $output = []; foreach ($sandboxSimulationOptions as $key => $value) { $output[] = [ 'labelText' => $value, 'simulationValue' => $key, ]; } return $output; } }