ConfigProvider.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Braintree\Model\Ui\PayPal;
  7. use Magento\Braintree\Gateway\Config\PayPal\Config;
  8. use Magento\Checkout\Model\ConfigProviderInterface;
  9. use Magento\Framework\Locale\ResolverInterface;
  10. /**
  11. * Class ConfigProvider
  12. */
  13. class ConfigProvider implements ConfigProviderInterface
  14. {
  15. const PAYPAL_CODE = 'braintree_paypal';
  16. const PAYPAL_VAULT_CODE = 'braintree_paypal_vault';
  17. /**
  18. * @var Config
  19. */
  20. private $config;
  21. /**
  22. * @var ResolverInterface
  23. */
  24. private $resolver;
  25. /**
  26. * Initialize dependencies.
  27. *
  28. * @param Config $config
  29. * @param ResolverInterface $resolver
  30. */
  31. public function __construct(Config $config, ResolverInterface $resolver)
  32. {
  33. $this->config = $config;
  34. $this->resolver = $resolver;
  35. }
  36. /**
  37. * Retrieve assoc array of checkout configuration
  38. *
  39. * @return array
  40. */
  41. public function getConfig()
  42. {
  43. $requireBillingAddressAll = \Magento\Paypal\Model\Config::REQUIRE_BILLING_ADDRESS_ALL;
  44. return [
  45. 'payment' => [
  46. self::PAYPAL_CODE => [
  47. 'isActive' => $this->config->isActive(),
  48. 'title' => $this->config->getTitle(),
  49. 'isAllowShippingAddressOverride' => $this->config->isAllowToEditShippingAddress(),
  50. 'merchantName' => $this->config->getMerchantName(),
  51. 'locale' => $this->resolver->getLocale(),
  52. 'paymentAcceptanceMarkSrc' =>
  53. 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/pp-acceptance-medium.png',
  54. 'vaultCode' => self::PAYPAL_VAULT_CODE,
  55. 'skipOrderReview' => $this->config->isSkipOrderReview(),
  56. 'paymentIcon' => $this->config->getPayPalIcon(),
  57. 'isRequiredBillingAddress' =>
  58. (int)$this->config->isRequiredBillingAddress() === $requireBillingAddressAll
  59. ]
  60. ]
  61. ];
  62. }
  63. }