Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
GetClientToken.php
Go to the documentation of this file.
1 <?php
7 
15 
19 class GetClientToken extends Action
20 {
21  const ADMIN_RESOURCE = 'Magento_Braintree::get_client_token';
22 
26  private $config;
27 
31  private $adapterFactory;
32 
36  private $quoteSession;
37 
44  public function __construct(
45  Context $context,
46  Config $config,
47  BraintreeAdapterFactory $adapterFactory,
48  Quote $quoteSession
49  ) {
50  parent::__construct($context);
51  $this->config = $config;
52  $this->adapterFactory = $adapterFactory;
53  $this->quoteSession = $quoteSession;
54  }
55 
59  public function execute()
60  {
61  $params = [];
62  $response = $this->resultFactory->create(ResultFactory::TYPE_JSON);
63 
64  $storeId = $this->quoteSession->getStoreId();
65  $merchantAccountId = $this->config->getMerchantAccountId($storeId);
66  if (!empty($merchantAccountId)) {
68  }
69 
70  $clientToken = $this->adapterFactory->create($storeId)
71  ->generate($params);
72  $response->setData(['clientToken' => $clientToken]);
73 
74  return $response;
75  }
76 }
__construct(Context $context, Config $config, BraintreeAdapterFactory $adapterFactory, Quote $quoteSession)
$response
Definition: 404.php:11
$config
Definition: fraud_order.php:17
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18