123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <?php
- /**
- * Copyright © Magento, Inc. All rights reserved.
- * See COPYING.txt for license details.
- */
- namespace Magento\Braintree\Gateway\Config\PayPal;
- use Magento\Framework\App\Config\ScopeConfigInterface;
- use Magento\Payment\Model\CcConfig;
- /**
- * Class Config
- */
- class Config extends \Magento\Payment\Gateway\Config\Config
- {
- const KEY_ACTIVE = 'active';
- const KEY_TITLE = 'title';
- const KEY_DISPLAY_ON_SHOPPING_CART = 'display_on_shopping_cart';
- const KEY_ALLOW_TO_EDIT_SHIPPING_ADDRESS = 'allow_shipping_address_override';
- const KEY_MERCHANT_NAME_OVERRIDE = 'merchant_name_override';
- const KEY_REQUIRE_BILLING_ADDRESS = 'require_billing_address';
- /**
- * @var CcConfig
- */
- private $ccConfig;
- /**
- * @var array
- */
- private $icon = [];
- /**
- * Initialize dependencies.
- *
- * @param ScopeConfigInterface $scopeConfig
- * @param CcConfig $ccConfig
- * @param null $methodCode
- * @param string $pathPattern
- */
- public function __construct(
- ScopeConfigInterface $scopeConfig,
- CcConfig $ccConfig,
- $methodCode = null,
- $pathPattern = self::DEFAULT_PATH_PATTERN
- ) {
- parent::__construct($scopeConfig, $methodCode, $pathPattern);
- $this->ccConfig = $ccConfig;
- }
- /**
- * Get Payment configuration status
- *
- * @return bool
- */
- public function isActive()
- {
- return (bool) $this->getValue(self::KEY_ACTIVE);
- }
- /**
- * @return bool
- */
- public function isDisplayShoppingCart()
- {
- return (bool) $this->getValue(self::KEY_DISPLAY_ON_SHOPPING_CART);
- }
- /**
- * Is shipping address can be editable on PayPal side
- *
- * @return bool
- */
- public function isAllowToEditShippingAddress()
- {
- return (bool) $this->getValue(self::KEY_ALLOW_TO_EDIT_SHIPPING_ADDRESS);
- }
- /**
- * Get merchant name to display in PayPal popup
- *
- * @return string
- */
- public function getMerchantName()
- {
- return $this->getValue(self::KEY_MERCHANT_NAME_OVERRIDE);
- }
- /**
- * Is billing address can be required
- *
- * @return string
- */
- public function isRequiredBillingAddress()
- {
- return $this->getValue(self::KEY_REQUIRE_BILLING_ADDRESS);
- }
- /**
- * Get title of payment
- *
- * @return string
- */
- public function getTitle()
- {
- return $this->getValue(self::KEY_TITLE);
- }
- /**
- * Is need to skip order review
- * @return bool
- */
- public function isSkipOrderReview()
- {
- return (bool) $this->getValue('skip_order_review');
- }
- /**
- * Get PayPal icon
- * @return array
- */
- public function getPayPalIcon()
- {
- if (empty($this->icon)) {
- $asset = $this->ccConfig->createAsset('Magento_Braintree::images/paypal.png');
- list($width, $height) = getimagesize($asset->getSourceFile());
- $this->icon = [
- 'url' => $asset->getUrl(),
- 'width' => $width,
- 'height' => $height
- ];
- }
- return $this->icon;
- }
- }
|