Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Config.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
16  const KEY_ENVIRONMENT = 'environment';
17  const KEY_ACTIVE = 'active';
18  const KEY_MERCHANT_ID = 'merchant_id';
19  const KEY_MERCHANT_ACCOUNT_ID = 'merchant_account_id';
20  const KEY_PUBLIC_KEY = 'public_key';
21  const KEY_PRIVATE_KEY = 'private_key';
22  const KEY_COUNTRY_CREDIT_CARD = 'countrycreditcard';
23  const KEY_CC_TYPES = 'cctypes';
24  const KEY_CC_TYPES_BRAINTREE_MAPPER = 'cctypes_braintree_mapper';
25  const KEY_SDK_URL = 'sdk_url';
26  const KEY_USE_CVV = 'useccv';
27  const KEY_VERIFY_3DSECURE = 'verify_3dsecure';
28  const KEY_THRESHOLD_AMOUNT = 'threshold_amount';
29  const KEY_VERIFY_ALLOW_SPECIFIC = 'verify_all_countries';
30  const KEY_VERIFY_SPECIFIC = 'verify_specific_countries';
31  const VALUE_3DSECURE_ALL = 0;
32  const CODE_3DSECURE = 'three_d_secure';
33  const KEY_KOUNT_MERCHANT_ID = 'kount_id';
34  const FRAUD_PROTECTION = 'fraudprotection';
35 
39  private $serializer;
40 
49  public function __construct(
50  ScopeConfigInterface $scopeConfig,
51  $methodCode = null,
52  $pathPattern = self::DEFAULT_PATH_PATTERN,
53  Json $serializer = null
54  ) {
55  parent::__construct($scopeConfig, $methodCode, $pathPattern);
56  $this->serializer = $serializer ?: \Magento\Framework\App\ObjectManager::getInstance()
57  ->get(Json::class);
58  }
59 
64  private static $dynamicDescriptorKeys = [
65  'name', 'phone', 'url'
66  ];
67 
75  {
76  $countryCardTypes = $this->getValue(self::KEY_COUNTRY_CREDIT_CARD, $storeId);
77  if (!$countryCardTypes) {
78  return [];
79  }
80  $countryCardTypes = $this->serializer->unserialize($countryCardTypes);
81  return is_array($countryCardTypes) ? $countryCardTypes : [];
82  }
83 
90  public function getAvailableCardTypes($storeId = null)
91  {
92  $ccTypes = $this->getValue(self::KEY_CC_TYPES, $storeId);
93 
94  return !empty($ccTypes) ? explode(',', $ccTypes) : [];
95  }
96 
102  public function getCcTypesMapper()
103  {
104  $result = json_decode(
105  $this->getValue(self::KEY_CC_TYPES_BRAINTREE_MAPPER),
106  true
107  );
108 
109  return is_array($result) ? $result : [];
110  }
111 
119  public function getCountryAvailableCardTypes($country, $storeId = null)
120  {
122 
123  return (!empty($types[$country])) ? $types[$country] : [];
124  }
125 
132  public function isCvvEnabled($storeId = null)
133  {
134  return (bool) $this->getValue(self::KEY_USE_CVV, $storeId);
135  }
136 
143  public function isVerify3DSecure($storeId = null)
144  {
145  return (bool) $this->getValue(self::KEY_VERIFY_3DSECURE, $storeId);
146  }
147 
154  public function getThresholdAmount($storeId = null)
155  {
156  return (double) $this->getValue(self::KEY_THRESHOLD_AMOUNT, $storeId);
157  }
158 
165  public function get3DSecureSpecificCountries($storeId = null)
166  {
167  if ((int) $this->getValue(self::KEY_VERIFY_ALLOW_SPECIFIC, $storeId) == self::VALUE_3DSECURE_ALL) {
168  return [];
169  }
170 
171  return explode(',', $this->getValue(self::KEY_VERIFY_SPECIFIC, $storeId));
172  }
173 
181  public function getEnvironment($storeId = null)
182  {
183  return $this->getValue(Config::KEY_ENVIRONMENT, $storeId);
184  }
185 
192  public function getKountMerchantId($storeId = null)
193  {
195  }
196 
203  public function getMerchantId($storeId = null)
204  {
205  return $this->getValue(Config::KEY_MERCHANT_ID, $storeId);
206  }
207 
214  public function getMerchantAccountId($storeId = null)
215  {
216  return $this->getValue(self::KEY_MERCHANT_ACCOUNT_ID, $storeId);
217  }
218 
222  public function getSdkUrl()
223  {
224  return $this->getValue(Config::KEY_SDK_URL);
225  }
226 
233  public function hasFraudProtection($storeId = null)
234  {
235  return (bool) $this->getValue(Config::FRAUD_PROTECTION, $storeId);
236  }
237 
244  public function isActive($storeId = null)
245  {
246  return (bool) $this->getValue(self::KEY_ACTIVE, $storeId);
247  }
248 
255  public function getDynamicDescriptors($storeId = null)
256  {
257  $values = [];
258  foreach (self::$dynamicDescriptorKeys as $key) {
259  $value = $this->getValue('descriptor_' . $key, $storeId);
260  if (!empty($value)) {
261  $values[$key] = $value;
262  }
263  }
264  return $values;
265  }
266 }
$pathPattern
$values
Definition: options.phtml:88
$value
Definition: gender.phtml:16
getValue($field, $storeId=null)
Definition: Config.php:83
get3DSecureSpecificCountries($storeId=null)
Definition: Config.php:165
__construct(ScopeConfigInterface $scopeConfig, $methodCode=null, $pathPattern=self::DEFAULT_PATH_PATTERN, Json $serializer=null)
Definition: Config.php:49
getCountrySpecificCardTypeConfig($storeId=null)
Definition: Config.php:74
getCountryAvailableCardTypes($country, $storeId=null)
Definition: Config.php:119