/** * 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; }
/** * 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(); } }
/** * 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'); }
/** * 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; }
/** * 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; }
/** * 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(); }