Ejemplo n.º 1
0
 /**
  * Add payment info block to layout
  *
  * @return $this
  */
 protected function _prepareLayout()
 {
     if ($info = $this->getPaymentInfo()) {
         $this->setChild($this->_getInfoBlockName(), $this->_paymentData->getInfoBlock($info, $this->getLayout()));
     }
     return parent::_prepareLayout();
 }
Ejemplo n.º 2
0
 /**
  * Get options
  *
  * @return array
  */
 public function toOptionArray()
 {
     if ($this->options === null) {
         $this->options = $this->paymentHelper->getPaymentMethodList(true, true);
     }
     return $this->options;
 }
 /**
  * @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);
     }
 }
Ejemplo n.º 4
0
 /**
  * Set payment
  *
  * @param Info $payment
  * @return $this
  */
 public function setPayment($payment)
 {
     $paymentInfoBlock = $this->_paymentData->getInfoBlock($payment);
     $this->setChild('info', $paymentInfoBlock);
     $this->setData('payment', $payment);
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * @return void
  */
 protected function _prepareLayout()
 {
     if ($headBlock = $this->getLayout()->getBlock('head')) {
         $headBlock->setTitle(__('Order # %1', $this->getOrder()->getRealOrderId()));
     }
     $this->setChild('payment_info', $this->_paymentHelper->getInfoBlock($this->getOrder()->getPayment()));
 }
Ejemplo n.º 6
0
 /**
  * @param PaymentHelper $paymentHelper
  * @param Escaper $escaper
  */
 public function __construct(PaymentHelper $paymentHelper, Escaper $escaper)
 {
     $this->escaper = $escaper;
     foreach ($this->methodCodes as $code) {
         $this->methods[$code] = $paymentHelper->getMethodInstance($code);
     }
 }
Ejemplo n.º 7
0
 /**
  * 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;
 }
 /**
  * @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);
     }
 }
Ejemplo n.º 9
0
 /**
  * @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);
 }
Ejemplo n.º 10
0
 /**
  * Retrieve available billing agreement methods
  *
  * @param null|string|bool|int|\Magento\Store\Model\Store $store
  * @param \Magento\Quote\Model\Quote|null $quote
  * @return MethodInterface[]
  */
 public function getBillingAgreementMethods($store = null, $quote = null)
 {
     $result = [];
     foreach ($this->_paymentData->getStoreMethods($store, $quote) as $method) {
         if ($method instanceof MethodInterface) {
             $result[] = $method;
         }
     }
     return $result;
 }
Ejemplo n.º 11
0
 /**
  * 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 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;
 }
Ejemplo n.º 13
0
 public function testGetTransactionUrlTest()
 {
     $this->prepare();
     $expected = 'https://test.url';
     $methodInstance = $this->getMockBuilder('Magento\\Payment\\Model\\MethodInterface')->getMockForAbstractClass();
     $methodInstance->expects($this->exactly(2))->method('getConfigData')->willReturnMap([['sandbox_flag', null, true], ['cgi_url_test_mode', null, $expected]]);
     $this->paymentDataMock->expects($this->exactly(2))->method('getMethodInstance')->willReturn($methodInstance);
     $block = new \Magento\Paypal\Block\Payflow\Link\Iframe($this->contextMock, $this->orderFactoryMock, $this->checkoutSessionMock, $this->hssHelperMock, $this->paymentDataMock);
     $this->assertEquals($expected, $block->getTransactionUrl());
 }
Ejemplo n.º 14
0
 /**
  * @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);
     }
 }
Ejemplo n.º 15
0
 /**
  * @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);
     }
 }
Ejemplo n.º 16
0
 /**
  * С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;
 }
 /**
  * @dataProvider methodAvailabilityDataProvider
  * @param bool $availability
  */
 public function testIsMethodQuoteAvailableWithQuoteMethodNotAvailable($availability)
 {
     $quote = $this->getMockBuilder('Magento\\Quote\\Model\\Quote')->disableOriginalConstructor()->setMethods([])->getMock();
     $isInCatalog = false;
     $paymentCode = 'code';
     $methodInstanceMock = $this->getMockBuilder('Magento\\Payment\\Model\\Method\\AbstractMethod')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->sessionMock->expects($this->once())->method('getQuote')->will($this->returnValue($quote));
     $this->paymentHelperMock->expects($this->once())->method('getMethodInstance')->with($paymentCode)->will($this->returnValue($methodInstanceMock));
     $methodInstanceMock->expects($this->once())->method('isAvailable')->with($quote)->will($this->returnValue($availability));
     $this->assertEquals($availability, $this->checkoutValidator->isMethodQuoteAvailable($paymentCode, $isInCatalog));
 }
 /**
  * @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 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;
     }
 }
Ejemplo n.º 20
0
 /**
  * @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 = [];
     foreach ($this->paymentHelper->getStoreMethods($store, $quote) as $method) {
         if ($this->_canUseMethod($method, $quote)) {
             $method->setInfoInstance($quote->getPayment());
             $methods[] = $method;
         }
     }
     return $methods;
 }
Ejemplo n.º 21
0
 /**
  * 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
             }
         }
     }
 }
 /**
  * @param int $customerId
  * @param bool $vaultEnabled
  * @dataProvider customerIdProvider
  */
 public function testGetConfig($customerId, $vaultEnabled)
 {
     $storeId = 1;
     $vaultPaymentCode = 'vault_payment';
     $expectedConfiguration = ['vault' => [$vaultPaymentCode => ['is_enabled' => $vaultEnabled]]];
     $this->session->expects(static::once())->method('getCustomerId')->willReturn($customerId);
     $this->storeManager->expects(static::exactly(2))->method('getStore')->willReturn($this->store);
     $this->store->expects(static::exactly(2))->method('getId')->willReturn($storeId);
     $this->paymentDataHelper->expects(static::once())->method('getStoreMethods')->with($storeId)->willReturn([$this->vaultPayment]);
     $this->vaultPayment->expects(static::once())->method('getCode')->willReturn($vaultPaymentCode);
     $this->vaultPayment->expects($customerId !== null ? static::once() : static::never())->method('isActive')->with($storeId)->willReturn($vaultEnabled);
     static::assertEquals($expectedConfiguration, $this->vaultConfigProvider->getConfig());
 }
Ejemplo n.º 23
0
 public function testPrepareDataSource()
 {
     $itemName = 'itemName';
     $oldItemValue = 'oldItemValue';
     $newItemValue = 'newItemValue';
     $dataSource = ['data' => ['items' => [[$itemName => $oldItemValue]]]];
     $payment = $this->getMockForAbstractClass('Magento\\Payment\\Model\\MethodInterface');
     $payment->expects($this->once())->method('getTitle')->willReturn($newItemValue);
     $this->paymentHelper->expects($this->once())->method('getMethodInstance')->with($oldItemValue)->willReturn($payment);
     $this->model->setData('name', $itemName);
     $this->model->prepareDataSource($dataSource);
     $this->assertEquals($newItemValue, $dataSource['data']['items'][0][$itemName]);
 }
Ejemplo n.º 24
0
 /**
  * Retrieve available billing agreement methods
  *
  * @param null|string|bool|int|\Magento\Store\Model\Store $store
  * @param \Magento\Quote\Model\Quote|null $quote
  *
  * @return MethodInterface[]
  */
 public function getBillingAgreementMethods($store = null, $quote = null)
 {
     $pre = __METHOD__ . " : ";
     $this->_logger->debug($pre . 'bof');
     $result = [];
     foreach ($this->_paymentData->getStoreMethods($store, $quote) as $method) {
         if ($method instanceof MethodInterface) {
             $result[] = $method;
         }
     }
     $this->_logger->debug($pre . 'eof | result : ', $result);
     return $result;
 }
Ejemplo n.º 25
0
 /**
  * @param \Magento\Sales\Model\Quote $quote
  * @return \Magento\Payment\Model\MethodInterface[]
  */
 public function getAvailableMethods(\Magento\Sales\Model\Quote $quote = null)
 {
     $store = $quote ? $quote->getStoreId() : null;
     $methods = array();
     $specification = $this->methodSpecificationFactory->create(array(AbstractMethod::CHECK_ZERO_TOTAL));
     foreach ($this->paymentHelper->getStoreMethods($store, $quote) as $method) {
         if ($this->_canUseMethod($method, $quote) && $specification->isApplicable($method, $quote)) {
             $method->setInfoInstance($quote->getPayment());
             $methods[] = $method;
         }
     }
     return $methods;
 }
Ejemplo n.º 26
0
 /**
  * @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;
 }
Ejemplo n.º 27
0
 public function testGetConfigAvailable()
 {
     $redirectUrl = 'http://redirect.url';
     $paytypes = ['paytypes'];
     $expectedConfig = ['payment' => ['orbaPayupl' => ['redirectUrl' => $redirectUrl, 'paytypes' => $paytypes]]];
     $paymentMethodMock = $this->getPaymentMethodMock();
     $paymentMethodMock->expects($this->once())->method('isAvailable')->willReturn(true);
     $paymentMethodMock->expects($this->once())->method('getCheckoutRedirectUrl')->willReturn($redirectUrl);
     $this->paymentHelper->expects($this->once())->method('getMethodInstance')->with($this->equalTo('orba_payupl'))->willReturn($paymentMethodMock);
     $quote = $this->getMockBuilder(\Magento\Quote\Api\Data\CartInterface::class)->getMock();
     $this->checkoutSession->expects($this->once())->method('getQuote')->willReturn($quote);
     $this->paytypeHelper->expects($this->once())->method('getAllForQuote')->with($this->equalTo($quote))->willReturn($paytypes);
     $this->assertEquals($expectedConfig, $this->model->getConfig());
 }
Ejemplo n.º 28
0
 /**
  * @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);
 }
Ejemplo n.º 29
0
 /**
  * @param $method1 array
  * @param $method2 array
  *
  * @dataProvider getSortMethodsDataProvider
  */
 public function testSortMethods($method1, $method2)
 {
     $this->_initialConfig->expects($this->once())->method('getData')->will($this->returnValue(array(\Magento\Payment\Helper\Data::XML_PATH_PAYMENT_METHODS => array('method1' => $method1, 'method2 ' => $method2))));
     $this->_scopeConfig->expects($this->any())->method('getValue')->will($this->returnValue('Magento\\Payment\\Model\\Method\\AbstractMethod'));
     $methodInstanceMock1 = $this->getMock('Magento\\Framework\\Object', array('isAvailable', 'getConfigData'), array(), '', false);
     $methodInstanceMock1->expects($this->any())->method('isAvailable')->will($this->returnValue(true));
     $methodInstanceMock1->expects($this->any())->method('getConfigData')->will($this->returnValue($method1['sort_order']));
     $methodInstanceMock2 = $this->getMock('Magento\\Framework\\Object', array('isAvailable', 'getConfigData'), array(), '', false);
     $methodInstanceMock2->expects($this->any())->method('isAvailable')->will($this->returnValue(true));
     $methodInstanceMock2->expects($this->any())->method('getConfigData')->will($this->returnValue($method2['sort_order']));
     $this->_methodFactory->expects($this->at(0))->method('create')->will($this->returnValue($methodInstanceMock1));
     $this->_methodFactory->expects($this->at(1))->method('create')->will($this->returnValue($methodInstanceMock2));
     $sortedMethods = $this->_helper->getStoreMethods();
     $this->assertTrue(array_shift($sortedMethods)->getSortOrder() < array_shift($sortedMethods)->getSortOrder());
 }
Ejemplo n.º 30
0
 /**
  * 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');
 }