Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
ConfigProvider Class Reference
Inheritance diagram for ConfigProvider:
ConfigProviderInterface

Public Member Functions

 __construct (Config $config, BraintreeAdapterFactory $adapterFactory, SessionManagerInterface $session)
 
 getConfig ()
 
 getClientToken ()
 

Data Fields

const CODE = 'braintree'
 
const CC_VAULT_CODE = 'braintree_cc_vault'
 

Detailed Description

Class ConfigProvider

Definition at line 17 of file ConfigProvider.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( Config  $config,
BraintreeAdapterFactory  $adapterFactory,
SessionManagerInterface  $session 
)

Constructor

Parameters
Config$config
BraintreeAdapterFactory$adapterFactory
SessionManagerInterface$session

Definition at line 50 of file ConfigProvider.php.

54  {
55  $this->config = $config;
56  $this->adapterFactory = $adapterFactory;
57  $this->session = $session;
58  }

Member Function Documentation

◆ getClientToken()

getClientToken ( )

Generate a new client token if necessary

Returns
string

Definition at line 97 of file ConfigProvider.php.

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  }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18

◆ getConfig()

getConfig ( )

Retrieve assoc array of checkout configuration

Returns
array

Implements ConfigProviderInterface.

Definition at line 65 of file ConfigProvider.php.

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  }

Field Documentation

◆ CC_VAULT_CODE

const CC_VAULT_CODE = 'braintree_cc_vault'

Definition at line 21 of file ConfigProvider.php.

◆ CODE

const CODE = 'braintree'

Definition at line 19 of file ConfigProvider.php.


The documentation for this class was generated from the following file: