/** * @param PaymentHelper $paymentHelper */ public function __construct(PaymentHelper $paymentHelper) { $this->paymentHelper = $paymentHelper; foreach ($this->methodCodes as $code) { $this->methods[$code] = $this->paymentHelper->getMethodInstance($code); } }
/** * @param PaymentHelper $paymentHelper * @param UrlInterface $urlBuilder */ public function __construct(PaymentHelper $paymentHelper, UrlInterface $urlBuilder) { $this->paymentHelper = $paymentHelper; $this->urlBuilder = $urlBuilder; foreach ($this->methodCodes as $code) { $this->methods[$code] = $this->paymentHelper->getMethodInstance($code); } }
/** * Retrieve payment method instance * * @return \Magento\Payment\Model\MethodInterface */ public function getPaymentMethodInstance() { if ($this->_paymentMethodInstance === null) { $this->_paymentMethodInstance = $this->_paymentData->getMethodInstance($this->getMethodCode()); $this->_paymentMethodInstance->setStore($this->getStoreId()); } return $this->_paymentMethodInstance; }
/** * Return option array * * @return array */ public function toOptionArray() { $result = array(); foreach ($this->paymentHelper->getPaymentMethods() as $code => $data) { if ($this->specification->isSatisfiedBy($code)) { $result[$code] = isset($data['title']) ? $data['title'] : $this->paymentHelper->getMethodInstance($code)->getTitle(); } } return $result; }
/** * @param \Wirecard\CheckoutPage\Helper\Data $helper * @param \Magento\Payment\Helper\Data $paymentHelper * @param \Magento\Framework\Escaper $escaper * @param \Magento\Framework\View\Asset\Repository $assetRepo * */ public function __construct(\Wirecard\CheckoutPage\Helper\Data $helper, \Magento\Payment\Helper\Data $paymentHelper, \Magento\Framework\Escaper $escaper, \Magento\Framework\View\Asset\Repository $assetRepo) { $this->_dataHelper = $helper; $this->paymentHelper = $paymentHelper; $this->escaper = $escaper; $this->assetRepo = $assetRepo; foreach ($this->methodCodes as $code) { $this->methods[$code] = $this->paymentHelper->getMethodInstance($code); } }
/** * @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); } }
/** * Сhecks payment method and quote availability * * @param string $paymentCode * @param bool $isInCatalog * @return bool */ public function isMethodQuoteAvailable($paymentCode, $isInCatalog) { $quote = $isInCatalog ? null : $this->_checkoutSession->getQuote(); // check payment method availability /** @var \Magento\Payment\Model\Method\AbstractMethod $methodInstance */ $methodInstance = $this->_paymentData->getMethodInstance($paymentCode); if (!$methodInstance->isAvailable($quote)) { return false; } return true; }
/** * Prepare Data Source * * @param array $dataSource * @return void */ public function prepareDataSource(array &$dataSource) { if (isset($dataSource['data']['items'])) { foreach ($dataSource['data']['items'] as &$item) { try { $item[$this->getData('name')] = $this->paymentHelper->getMethodInstance($item[$this->getData('name')])->getTitle(); } catch (\UnexpectedValueException $exception) { //Displaying payment code (with no changes) if payment method is not available in system } } } }
/** * @inheritdoc */ public function getConfig() { /** * @var $payment Payupl */ $config = []; $payment = $this->paymentHelper->getMethodInstance(Payupl::CODE); if ($payment->isAvailable()) { $redirectUrl = $payment->getCheckoutRedirectUrl(); $quote = $this->checkoutSession->getQuote(); $config = ['payment' => ['orbaPayupl' => ['redirectUrl' => $redirectUrl, 'paytypes' => $this->paytypeHelper->getAllForQuote($quote)]]]; } return $config; }
/** * @param ConfigFactory $configFactory * @param ResolverInterface $localeResolver * @param CurrentCustomer $currentCustomer * @param PayfastHelper $paymentHelper * @param PaymentHelper $paymentHelper */ public function __construct(\Psr\Log\LoggerInterface $logger, ConfigFactory $configFactory, ResolverInterface $localeResolver, CurrentCustomer $currentCustomer, PayfastHelper $payfastHelper, PaymentHelper $paymentHelper) { $this->_logger = $logger; $pre = __METHOD__ . ' : '; $this->_logger->debug($pre . 'bof'); $this->localeResolver = $localeResolver; $this->config = $configFactory->create(); $this->currentCustomer = $currentCustomer; $this->payfastHelper = $payfastHelper; $this->paymentHelper = $paymentHelper; foreach ($this->methodCodes as $code) { $this->methods[$code] = $this->paymentHelper->getMethodInstance($code); } $this->_logger->debug($pre . 'eof and this methods has : ', $this->methods); }
/** * Return payment method instance * * @return ManagerInterface */ protected function getManager() { if (!$this->_manager) { $this->_manager = $this->_managerFactory->create(array('paymentMethod' => $this->_paymentData->getMethodInstance($this->getMethodCode()))); } return $this->_manager; }
/** * @param CcConfig $ccConfig * @param PaymentHelper $paymentHelper * @param array $methodCodes */ public function __construct(CcConfig $ccConfig, PaymentHelper $paymentHelper, array $methodCodes = []) { $this->ccConfig = $ccConfig; foreach ($methodCodes as $code) { $this->methods[$code] = $paymentHelper->getMethodInstance($code); } }
/** * Retrieve payment method model object * * @return \Magento\Payment\Model\MethodInterface * @throws \Magento\Framework\Exception\LocalizedException */ public function getMethodInstance() { if (!$this->hasMethodInstance()) { if (!$this->getMethod()) { throw new \Magento\Framework\Exception\LocalizedException(__('The payment method you requested is not available.')); } try { $instance = $this->_paymentData->getMethodInstance($this->getMethod()); } catch (\UnexpectedValueException $e) { $instance = $this->_paymentData->getMethodInstance(Method\Substitution::CODE); } $instance->setInfoInstance($this); $this->setMethodInstance($instance); } return $this->_getData('method_instance'); }
/** * @param Repository $assetRepo * @param RequestInterface $request * @param UrlInterface $urlBuilder * @param LoggerInterface $logger * @param PaymentHelper $paymentHelper * @param string $methodCode */ public function __construct(Repository $assetRepo, RequestInterface $request, UrlInterface $urlBuilder, LoggerInterface $logger, PaymentHelper $paymentHelper, $methodCode) { $this->assetRepo = $assetRepo; $this->request = $request; $this->urlBuilder = $urlBuilder; $this->logger = $logger; $this->methodCode = $methodCode; $this->method = $paymentHelper->getMethodInstance($methodCode); }
/** * @param PaymentHelper $paymentHelper * @param Escaper $escaper */ public function __construct(PaymentHelper $paymentHelper, \Magento\Framework\View\Element\Context $context, \Smart2Pay\GlobalPay\Model\ConfiguredMethodsFactory $configuredMethodsFactory) { $this->_configuredMethodFactory = $configuredMethodsFactory; //$this->escaper = $escaper; $this->_request = $context->getRequest(); $this->_assetRepo = $context->getAssetRepository(); foreach ($this->methodCodes as $code) { $this->methods[$code] = $paymentHelper->getMethodInstance($code); } }
public function execute() { try { $order = $this->_getCheckoutSession()->getLastRealOrder(); $method = $order->getPayment()->getMethod(); $methodInstance = $this->_paymentHelper->getMethodInstance($method); if ($methodInstance instanceof \Paynl\Payment\Model\Paymentmethod\Paymentmethod) { $redirectUrl = $methodInstance->startTransaction($order, $this->_url); $this->_redirect($redirectUrl); } else { throw new Error('Method is not a paynl payment method'); } } catch (\Exception $e) { $this->messageManager->addException($e, __('Something went wrong, please try again later')); $this->_logger->critical($e); $this->_getCheckoutSession()->restoreQuote(); $this->_redirect('checkout/cart'); } }
/** * Сhecks payment method and quote availability * * @param string $paymentCode * @return bool */ public function isMethodAvailable($paymentCode) { // check payment method availability /** @var \Magento\Payment\Model\Method\AbstractMethod $methodInstance */ $methodInstance = $this->_paymentData->getMethodInstance($paymentCode); if (!$methodInstance || !$methodInstance->isAvailable()) { return false; } return true; }
/** * @param PaymentHelper $paymentHelper */ public function __construct(\Magento\Framework\App\Action\Context $context, PaymentHelper $paymentHelper, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\View\Asset\Repository $assetRepo) { $this->_request = $context->getRequest(); $this->methodInstance = $paymentHelper->getMethodInstance($this->methodCode); $this->_scopeConfig = $scopeConfig; $this->_checkoutSession = $checkoutSession; $this->_storeManager = $storeManager; $this->_assetRepo = $assetRepo; $this->_context = $context; }
/** * @param PaymentHelper $paymentHelper * @param Escaper $escaper * @param string[] $methodCodes * @throws LocalizedException */ public function __construct(PaymentHelper $paymentHelper, Escaper $escaper, array $methodCodes = array()) { $this->escaper = $escaper; $this->methodCodes = $methodCodes; foreach ($this->methodCodes as $code) { $method = $paymentHelper->getMethodInstance($code); if (!$method instanceof CheckoutConfigInterface) { throw new LocalizedException(__("%1 class doesn't implement \\Fontis\\Australia\\Model\\Payment\\CheckoutConfigInterface", $method)); } $this->methods[$code] = $method; } }
/** * @param \Magento\Framework\Model\Context $context * @param \Magento\Checkout\Model\Session $session * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param PaymentHelper $paymentHelper * @param \Adyen\Payment\Helper\Data $adyenHelper */ public function __construct(\Magento\Framework\Model\Context $context, \Magento\Checkout\Model\Session $session, \Magento\Store\Model\StoreManagerInterface $storeManager, PaymentHelper $paymentHelper, \Magento\Framework\Locale\ResolverInterface $localeResolver, \Magento\Framework\App\Config\ScopeConfigInterface $config, \Adyen\Payment\Helper\Data $adyenHelper, \Adyen\Payment\Logger\AdyenLogger $adyenLogger) { $this->_appState = $context->getAppState(); $this->_session = $session; $this->_storeManager = $storeManager; $this->_paymentHelper = $paymentHelper; $this->_localeResolver = $localeResolver; $this->_config = $config; $this->_adyenHelper = $adyenHelper; $this->_adyenLogger = $adyenLogger; foreach ($this->methodCodes as $code) { $this->methods[$code] = $this->_paymentHelper->getMethodInstance($code); } }
/** * @param \Magento\Quote\Api\Data\CartInterface $quote * @return \Magento\Payment\Model\MethodInterface[] * @api */ public function getAvailableMethods(\Magento\Quote\Api\Data\CartInterface $quote = null) { $store = $quote ? $quote->getStoreId() : null; $methods = []; $isFreeAdded = false; foreach ($this->paymentHelper->getStoreMethods($store, $quote) as $method) { if ($this->_canUseMethod($method, $quote)) { $method->setInfoInstance($quote->getPayment()); $methods[] = $method; if ($method->getCode() == Free::PAYMENT_METHOD_FREE_CODE) { $isFreeAdded = true; } } } if (!$isFreeAdded) { /** @var \Magento\Payment\Model\Method\Free $freeMethod */ $freeMethod = $this->paymentHelper->getMethodInstance(Free::PAYMENT_METHOD_FREE_CODE); if ($freeMethod->isAvailableInConfig()) { $freeMethod->setInfoInstance($quote->getPayment()); $methods[] = $freeMethod; } } return $methods; }
/** * Retrieve payment method model object * * @return MethodInterface * @throws \Magento\Framework\Model\Exception */ public function getMethodInstance() { if (!$this->hasMethodInstance()) { if ($this->getMethod()) { $instance = $this->_paymentData->getMethodInstance($this->getMethod()); if (!$instance) { $instance = $this->_paymentData->getMethodInstance(Method\Substitution::CODE); } $instance->setInfoInstance($this); $this->setMethodInstance($instance); return $instance; } throw new \Magento\Framework\Model\Exception(__('The payment method you requested is not available.')); } return $this->_getData('method_instance'); }
/** * @return \Magento\Framework\View\Element\AbstractBlock */ protected function _beforeToHtml() { $result = parent::_beforeToHtml(); $isInCatalog = $this->getIsInCatalogProduct(); if (!$this->_shortcutValidator->validate($this->_paymentMethodCode, $isInCatalog)) { $this->_shouldRender = false; return $result; } /** @var \Magento\Paypal\Model\Express $method */ $method = $this->_paymentData->getMethodInstance($this->_bmlMethodCode); if (!$method->isAvailable()) { $this->_shouldRender = false; return $result; } $this->setShortcutHtmlId($this->_mathRandom->getUniqueHash('ec_shortcut_bml_'))->setCheckoutUrl($this->getUrl($this->_startAction))->setImageUrl(self::SHORTCUT_IMAGE)->setAdditionalLinkImage(['href' => 'https://www.securecheckout.billmelater.com/paycapture-content/' . 'fetch?hash=AU826TU8&content=/bmlweb/ppwpsiw.html', 'src' => 'https://www.paypalobjects.com/webstatic/en_US/btn/btn_bml_text.png']); return $result; }
public function getFormAction() { return $this->_paymentData->getMethodInstance($this->_paymentMethodCode)->getUrl(); }
/** * @param PaymentHelper $paymentHelper */ public function __construct(PaymentHelper $paymentHelper, \Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\View\Asset\Repository $assetRepo) { $this->methodInstance = $paymentHelper->getMethodInstance($this->methodCode); $this->_storeManager = $storeManager; $this->_assetRepo = $assetRepo; }
/** * PaymentConfigProvider constructor. * @param PaymentHelper $helper */ public function __construct(PaymentHelper $helper) { $this->method = $helper->getMethodInstance(self::PAYMENT_METHOD_PAGSEGURO_CODE); }
/** * @param PaymentHelper $paymentHelper * @param Escaper $escaper */ public function __construct(PaymentHelper $paymentHelper, Escaper $escaper) { $this->escaper = $escaper; $this->method = $paymentHelper->getMethodInstance($this->methodCode); }
/** * @param \Magento\Payment\Helper\Data $paymentHelper * @param \Magento\Framework\Escaper $escaper */ public function __construct(\Magento\Payment\Helper\Data $paymentHelper, \Magento\Framework\Escaper $escaper) { $this->escaper = $escaper; $this->method = $paymentHelper->getMethodInstance($this->methodCode); }
/** * @expectedException \UnexpectedValueException */ public function testGetMethodInstanceWithException() { $this->scopeConfig->expects($this->once())->method('getValue')->willReturn(null); $this->helper->getMethodInstance('code'); }
/** * @param string $code * @param string $class * @param string $methodInstance * @dataProvider getMethodInstanceDataProvider */ public function testGetMethodInstance($code, $class, $methodInstance) { $this->_scopeConfig->expects($this->once())->method('getValue')->will($this->returnValue($class)); $this->_methodFactory->expects($this->any())->method('create')->with($class)->will($this->returnValue($methodInstance)); $this->assertEquals($methodInstance, $this->_helper->getMethodInstance($code)); }