/** * {@inheritdoc} */ public function toOptionArray() { /** @var \Magento\Paypal\Model\Config $configModel */ $configModel = $this->_configFactory->create(); $configModel->setMethod(\Magento\Paypal\Model\Config::METHOD_WPP_EXPRESS); return $configModel->getPaymentActions(); }
/** * Set template and redirect message * * @return null */ protected function _construct() { $this->_config = $this->_paypalConfigFactory->create()->setMethod($this->getMethodCode()); $mark = $this->_getMarkTemplate(); $mark->setPaymentAcceptanceMarkHref($this->_config->getPaymentMarkWhatIsPaypalUrl($this->_localeResolver))->setPaymentAcceptanceMarkSrc($this->_config->getPaymentMarkImageUrl($this->_localeResolver->getLocale())); // known issue: code above will render only static mark image $this->_initializeRedirectTemplateWithMark($mark); parent::_construct(); $this->setRedirectMessage(__('You will be redirected to the PayPal website.')); }
/** * Checks visibility of context (cart or product page) * * @param string $paymentCode Payment method code * @param bool $isInCatalog * @return bool */ public function isContextAvailable($paymentCode, $isInCatalog) { /** @var \Magento\Paypal\Model\Config $config */ $config = $this->_paypalConfigFactory->create(); $config->setMethod($paymentCode); // check visibility on cart or product page $context = $isInCatalog ? 'visible_on_product' : 'visible_on_cart'; if (!$config->getConfigValue($context)) { return false; } return true; }
/** * @return \Magento\Framework\View\Element\AbstractBlock */ protected function _beforeToHtml() { $result = parent::_beforeToHtml(); /** @var \Magento\Paypal\Model\Config $config */ $config = $this->_paypalConfigFactory->create(); $config->setMethod($this->_paymentMethodCode); $isInCatalog = $this->getIsInCatalogProduct(); if (!$this->_shortcutValidator->validate($this->_paymentMethodCode, $isInCatalog)) { $this->_shouldRender = false; return $result; } $quote = $isInCatalog || !$this->_checkoutSession ? null : $this->_checkoutSession->getQuote(); // set misc data $this->setShortcutHtmlId($this->_mathRandom->getUniqueHash('ec_shortcut_'))->setCheckoutUrl($this->getUrl($this->_startAction)); // use static image if in catalog if ($isInCatalog || null === $quote) { $this->setImageUrl($config->getExpressCheckoutShortcutImageUrl($this->_localeResolver->getLocale())); } else { /**@todo refactor checkout model. Move getCheckoutShortcutImageUrl to helper or separate model */ $parameters = ['params' => ['quote' => $quote, 'config' => $config]]; $checkoutModel = $this->_checkoutFactory->create($this->_checkoutType, $parameters); $this->setImageUrl($checkoutModel->getCheckoutShortcutImageUrl()); } // ask whether to create a billing agreement $customerId = $this->currentCustomer->getCustomerId(); // potential issue for caching if ($this->_paypalData->shouldAskToCreateBillingAgreement($config, $customerId)) { $this->setConfirmationUrl($this->getUrl($this->_startAction, [\Magento\Paypal\Model\Express\Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1])); $this->setConfirmationMessage(__('Would you like to sign a billing agreement to streamline further purchases with PayPal?')); } return $result; }
/** * @inheritdoc * @param ResolverInterface $localeResolver */ public function __construct(Context $context, ResolverInterface $localeResolver, ConfigFactory $configFactory, array $data = []) { parent::__construct($context, $data); $this->localeResolver = $localeResolver; $this->config = $configFactory->create(); $this->config->setMethod(Config::METHOD_EXPRESS); }
/** * @param CurrentCustomer $currentCustomer * @param Data $paypalData * @param ConfigFactory $paypalConfigFactory * @param UrlInterface $urlBuilder * @param Escaper $escaper */ public function __construct(CurrentCustomer $currentCustomer, Data $paypalData, ConfigFactory $paypalConfigFactory, UrlInterface $urlBuilder, Escaper $escaper) { $this->currentCustomer = $currentCustomer; $this->paypalData = $paypalData; $this->urlBuilder = $urlBuilder; $this->escaper = $escaper; $this->config = $paypalConfigFactory->create(); $this->config->setMethod(Config::METHOD_EXPRESS); }
/** * Get HTML representation of transaction id * * @param string $methodCode * @param string $txnId * @return string */ public function getHtmlTransactionId($methodCode, $txnId) { if (in_array($methodCode, $this->methodCodes)) { /** @var \Magento\Paypal\Model\Config $config */ $config = $this->configFactory->create()->setMethod($methodCode); $sandboxFlag = $config->getValue('sandboxFlag') ? 'sandbox' : ''; return sprintf(self::HTML_TRANSACTION_ID, $sandboxFlag, $txnId); } return $txnId; }
/** * @param ConfigFactory $configFactory * @param ResolverInterface $localeResolver * @param CurrentCustomer $currentCustomer * @param PaypalHelper $paypalHelper * @param PaymentHelper $paymentHelper */ public function __construct(ConfigFactory $configFactory, ResolverInterface $localeResolver, CurrentCustomer $currentCustomer, PaypalHelper $paypalHelper, PaymentHelper $paymentHelper) { $this->localeResolver = $localeResolver; $this->config = $configFactory->create(); $this->currentCustomer = $currentCustomer; $this->paypalHelper = $paypalHelper; $this->paymentHelper = $paymentHelper; foreach ($this->methodCodes as $code) { $this->methods[$code] = $this->paymentHelper->getMethodInstance($code); } }
/** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Paypal\Model\ConfigFactory $paypalConfigFactory * @param \Magento\Paypal\Model\Express\Checkout\Factory $checkoutFactory * @param \Magento\Framework\Math\Random $mathRandom * @param \Magento\Framework\Locale\ResolverInterface $localeResolver * @param ValidatorInterface $shortcutValidator * @param string $paymentMethodCode * @param string $startAction * @param string $checkoutType * @param string $alias * @param string $shortcutTemplate * @param \Magento\Checkout\Model\Session $checkoutSession * @param array $data * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct(\Magento\Framework\View\Element\Template\Context $context, \Magento\Paypal\Model\ConfigFactory $paypalConfigFactory, \Magento\Paypal\Model\Express\Checkout\Factory $checkoutFactory, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\Locale\ResolverInterface $localeResolver, ValidatorInterface $shortcutValidator, $paymentMethodCode, $startAction, $checkoutType, $alias, $shortcutTemplate, \Magento\Checkout\Model\Session $checkoutSession = null, array $data = []) { $this->_paypalConfigFactory = $paypalConfigFactory; $this->_checkoutSession = $checkoutSession; $this->_checkoutFactory = $checkoutFactory; $this->_mathRandom = $mathRandom; $this->_localeResolver = $localeResolver; $this->_shortcutValidator = $shortcutValidator; $this->_paymentMethodCode = $paymentMethodCode; $this->_startAction = $startAction; $this->_checkoutType = $checkoutType; $this->_alias = $alias; $this->setTemplate($shortcutTemplate); parent::__construct($context, $data); $this->config = $this->_paypalConfigFactory->create(); $this->config->setMethod($this->_paymentMethodCode); }
/** * {@inheritdoc} */ public function toOptionArray() { return $this->_configFactory->create()->getPaymentActions(); }
/** * {@inheritdoc} */ public function toOptionArray() { $result = array('' => __('No Logo')); $result += $this->_configFactory->create()->getAdditionalOptionsLogoTypes(); return $result; }
/** * {@inheritdoc} */ public function toOptionArray($isMultiselect = false) { $supported = $this->_configFactory->create()->getSupportedBuyerCountryCodes(); $options = $this->_countryCollectionFactory->create()->addCountryCodeFilter($supported, 'iso2')->loadData()->toOptionArray($isMultiselect ? false : __('--Please Select--')); return $options; }
/** * {@inheritdoc} */ public function toOptionArray() { return $this->_configFactory->create()->getRequireBillingAddressOptions(); }
/** * Return request object with basic information for gateway request * * @param \Magento\Framework\Object|Payment $payment * @return \Magento\Framework\Object */ protected function _buildBasicRequest(\Magento\Framework\Object $payment) { $request = new \Magento\Framework\Object(); /** @var \Magento\Paypal\Model\Config $config */ $config = $this->_configFactory->create(); $request->setUser($this->getConfigData('user'))->setVendor($this->getConfigData('vendor'))->setPartner($this->getConfigData('partner'))->setPwd($this->getConfigData('pwd'))->setVerbosity($this->getConfigData('verbosity'))->setData('BNCODE', $config->getBuildNotationCode())->setTender(self::TENDER_CC)->setRequestId($this->_generateRequestId()); return $request; }