示例#1
0
 /**
  * Method code setter
  *
  * @param string|MethodInterface $method
  * @return $this
  */
 public function setMethod($method)
 {
     if ($method instanceof MethodInterface) {
         $this->_methodCode = $method->getCode();
     } elseif (is_string($method)) {
         $this->_methodCode = $method;
     }
     return $this;
 }
示例#2
0
 /**
  * Payment method additional label part getter
  *
  * @param \Magento\Payment\Model\MethodInterface $method
  * @return string
  */
 public function getMethodLabelAfterHtml(\Magento\Payment\Model\MethodInterface $method)
 {
     $form = $this->getChildBlock('payment.method.' . $method->getCode());
     if ($form) {
         return $form->getMethodLabelAfterHtml();
     }
 }
示例#3
0
 /**
  * Check whether payment method is applicable to quote
  * Purposed to allow use in controllers some logic that was implemented in blocks only before
  *
  * @param MethodInterface $paymentMethod
  * @param \Magento\Quote\Model\Quote $quote
  * @return bool
  */
 public function isApplicable(MethodInterface $paymentMethod, Quote $quote)
 {
     return !($quote->getBaseGrandTotal() < 0.0001 && $paymentMethod->getCode() != 'free');
 }
示例#4
0
 /**
  * Retrieve payment method form html
  *
  * @param MethodInterface $method
  * @param LayoutInterface $layout
  * @return Form
  */
 public function getMethodFormBlock(MethodInterface $method, LayoutInterface $layout)
 {
     $block = $layout->createBlock($method->getFormBlockType(), $method->getCode());
     $block->setMethod($method);
     return $block;
 }
示例#5
0
 /**
  * Retrieve payment method form html
  *
  * @param \Magento\Payment\Model\MethodInterface $method
  * @return Form
  */
 public function getMethodFormBlock(\Magento\Payment\Model\MethodInterface $method)
 {
     $block = false;
     $blockType = $method->getFormBlockType();
     if ($this->_layout) {
         $block = $this->_layout->createBlock($blockType, $method->getCode());
         $block->setMethod($method);
     }
     return $block;
 }
示例#6
0
 /**
  * Convert quote payment object to payment data object
  *
  * @param \Magento\Payment\Model\MethodInterface $object
  * @return \Magento\Checkout\Service\V1\Data\Cart\PaymentMethod
  */
 public function toDataObject(\Magento\Payment\Model\MethodInterface $object)
 {
     $data = [QuotePaymentMethod::CODE => $object->getCode(), QuotePaymentMethod::TITLE => $object->getTitle()];
     return $this->builder->populateWithArray($data)->create();
 }