ConfigProvider.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\AuthorizenetAcceptjs\Model\Ui;
  8. use Magento\AuthorizenetAcceptjs\Gateway\Config;
  9. use Magento\Checkout\Model\ConfigProviderInterface;
  10. use Magento\Quote\Api\Data\CartInterface;
  11. /**
  12. * Retrieves config needed for checkout
  13. */
  14. class ConfigProvider implements ConfigProviderInterface
  15. {
  16. /**
  17. * @var Config
  18. */
  19. private $config;
  20. /**
  21. * @var CartInterface
  22. */
  23. private $cart;
  24. /**
  25. * @param Config $config
  26. * @param CartInterface $cart
  27. */
  28. public function __construct(Config $config, CartInterface $cart)
  29. {
  30. $this->config = $config;
  31. $this->cart = $cart;
  32. }
  33. /**
  34. * Retrieve assoc array of checkout configuration
  35. *
  36. * @return array
  37. */
  38. public function getConfig()
  39. {
  40. $storeId = $this->cart->getStoreId();
  41. return [
  42. 'payment' => [
  43. Config::METHOD => [
  44. 'clientKey' => $this->config->getClientKey($storeId),
  45. 'apiLoginID' => $this->config->getLoginId($storeId),
  46. 'environment' => $this->config->getEnvironment($storeId),
  47. 'useCvv' => $this->config->isCvvEnabled($storeId),
  48. ]
  49. ]
  50. ];
  51. }
  52. }