/** * Set payment method info to quote payment * * @param array $payment * @return \Magento\Multishipping\Model\Checkout\Type\Multishipping * @throws \Magento\Framework\Exception\LocalizedException */ public function setPaymentMethod($payment) { if (!isset($payment['method'])) { throw new \Magento\Framework\Exception\LocalizedException(__('A payment method is not defined.')); } if (!$this->paymentSpecification->isSatisfiedBy($payment['method'])) { throw new \Magento\Framework\Exception\LocalizedException(__('The requested payment method is not available for multishipping.')); } $quote = $this->getQuote(); $quote->getPayment()->importData($payment); // shipping totals may be affected by payment method if (!$quote->isVirtual() && $quote->getShippingAddress()) { $quote->getShippingAddress()->setCollectShippingRates(true); $quote->setTotalsCollectedFlag(false)->collectTotals(); } $this->quoteRepository->save($quote); return $this; }
/** * Check payment method model * * @param \Magento\Payment\Model\Method\AbstractMethod|null $method * @return bool */ protected function _canUseMethod($method) { return $method && $this->paymentSpecification->isSatisfiedBy($method->getCode()) && parent::_canUseMethod($method); }