php Magento-Payment-Helper-Data类(方法)实例源码

下面列出了php Magento-Payment-Helper-Data 类(方法)源码代码实例,从而了解它的用法。

作者:pradeep-wagent    项目:magento   
/**
  * 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();
 }

作者:aies    项目:magento   
/**
  * 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;
 }

作者:whoopl    项目:magento2-testin   
/**
  * 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;
 }

作者:pradeep-wagent    项目:magento   
/**
  * 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;
 }

作者:nja7    项目:magento   
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());
 }

作者:wirecar    项目:magento2-wc   
/**
  * @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);
     }
 }

作者:pradeep-wagent    项目:magento   
/**
  * С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;
 }

作者:pradeep-wagent    项目:magento   
/**
  * @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));
 }

作者:Doabilit    项目:magento2de   
/**
  * @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;
 }

作者:nja7    项目:magento   
/**
  * 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
             }
         }
     }
 }

作者:Doabilit    项目:magento2de   
/**
  * @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());
 }

作者:nja7    项目:magento   
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]);
 }

作者:PayFas    项目:mod-magento_   
/**
  * 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;
 }

作者:tozwier    项目:magento2_payup   
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());
 }

作者:shabbirvividad    项目:magento   
/**
  * 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');
 }

作者:pradeep-wagent    项目:magento   
/**
  * Get options
  *
  * @return array
  */
 public function toOptionArray()
 {
     if ($this->options === null) {
         $this->options = $this->paymentHelper->getPaymentMethodList(true, true);
     }
     return $this->options;
 }

作者:kidaa3    项目:magento2-platforms   
/**
  * @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);
     }
 }

作者:aies    项目:magento   
/**
  * @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()));
 }

作者:vkerkhof    项目:magento2-plugi   
/**
  * @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);
     }
 }

作者:kidaa3    项目:magento2-platforms   
/**
  * @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);
     }
 }


问题


面经


文章

微信
公众号

扫码关注公众号