Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigProvider.php
Go to the documentation of this file.
1 <?php
7 
13 
18 {
19  const CODE = 'braintree';
20 
21  const CC_VAULT_CODE = 'braintree_cc_vault';
22 
26  private $config;
27 
31  private $adapterFactory;
32 
36  private $clientToken = '';
37 
41  private $session;
42 
50  public function __construct(
51  Config $config,
52  BraintreeAdapterFactory $adapterFactory,
54  ) {
55  $this->config = $config;
56  $this->adapterFactory = $adapterFactory;
57  $this->session = $session;
58  }
59 
65  public function getConfig()
66  {
67  $storeId = $this->session->getStoreId();
68  return [
69  'payment' => [
70  self::CODE => [
71  'isActive' => $this->config->isActive($storeId),
72  'clientToken' => $this->getClientToken(),
73  'ccTypesMapper' => $this->config->getCcTypesMapper(),
74  'sdkUrl' => $this->config->getSdkUrl(),
75  'countrySpecificCardTypes' => $this->config->getCountrySpecificCardTypeConfig($storeId),
76  'availableCardTypes' => $this->config->getAvailableCardTypes($storeId),
77  'useCvv' => $this->config->isCvvEnabled($storeId),
78  'environment' => $this->config->getEnvironment($storeId),
79  'kountMerchantId' => $this->config->getKountMerchantId($storeId),
80  'hasFraudProtection' => $this->config->hasFraudProtection($storeId),
81  'merchantId' => $this->config->getMerchantId($storeId),
82  'ccVaultCode' => self::CC_VAULT_CODE,
83  ],
85  'enabled' => $this->config->isVerify3DSecure($storeId),
86  'thresholdAmount' => $this->config->getThresholdAmount($storeId),
87  'specificCountries' => $this->config->get3DSecureSpecificCountries($storeId),
88  ],
89  ],
90  ];
91  }
92 
97  public function getClientToken()
98  {
99  if (empty($this->clientToken)) {
100  $params = [];
101 
102  $storeId = $this->session->getStoreId();
103  $merchantAccountId = $this->config->getMerchantAccountId($storeId);
104  if (!empty($merchantAccountId)) {
105  $params[PaymentDataBuilder::MERCHANT_ACCOUNT_ID] = $merchantAccountId;
106  }
107 
108  $this->clientToken = $this->adapterFactory->create($storeId)
109  ->generate($params);
110  }
111 
112  return $this->clientToken;
113  }
114 }
$config
Definition: fraud_order.php:17
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18
__construct(Config $config, BraintreeAdapterFactory $adapterFactory, SessionManagerInterface $session)