123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Braintree\Block;
- use Magento\Braintree\Model\Ui\ConfigProvider;
- use Magento\Checkout\Model\ConfigProviderInterface;
- use Magento\Framework\View\Element\Template;
- use Magento\Framework\View\Element\Template\Context;
- /**
- * Class Payment
- *
- * @api
- * @since 100.1.0
- */
- class Payment extends Template
- {
- /**
- * @var ConfigProviderInterface
- */
- private $config;
- /**
- * Constructor
- *
- * @param Context $context
- * @param ConfigProviderInterface $config
- * @param array $data
- */
- public function __construct(
- Context $context,
- ConfigProviderInterface $config,
- array $data = []
- ) {
- parent::__construct($context, $data);
- $this->config = $config;
- }
- /**
- * @return string
- * @since 100.1.0
- */
- public function getPaymentConfig()
- {
- $payment = $this->config->getConfig()['payment'];
- $config = $payment[$this->getCode()];
- $config['code'] = $this->getCode();
- $config['clientTokenUrl'] = $this->_urlBuilder->getUrl(
- 'braintree/payment/getClientToken',
- ['_secure' => true]
- );
- return json_encode($config, JSON_UNESCAPED_SLASHES);
- }
- /**
- * @return string
- * @since 100.1.0
- */
- public function getCode()
- {
- return ConfigProvider::CODE;
- }
- }
|