private function setInitialOrderStatus(OrderInterface $order) { if (false === $order->hasCurrentStatus()) { $paymentMethod = $order->getPaymentMethod(); $order->setCurrentStatus($paymentMethod->getPaymentPendingOrderStatus()); } }
public function createPaymentForOrder(OrderInterface $order) : PaymentInterface { $processor = $order->getPaymentMethod()->getProcessor(); /** @var PaymentInterface $payment */ $payment = $this->initResource(); $payment->setOrder($order); $payment->setState(PaymentInterface::PAYMENT_STATE_CREATED); $payment->setProcessor($processor); $this->createResource($payment, false); return $payment; }
/** * {@inheritdoc} */ public function visitOrder(OrderInterface $order) { if (false === $order->hasShippingMethod()) { $order->setPaymentMethod(null); return; } $shippingMethod = $order->getShippingMethod(); $paymentMethods = $shippingMethod->getPaymentMethods(); if (false === $order->hasPaymentMethod() || false === $paymentMethods->contains($order->getPaymentMethod())) { $order->setPaymentMethod($paymentMethods->first()); } }
/** * {@inheritdoc} */ public function visitOrder(OrderInterface $order) { $shippingMethod = $order->getShippingMethod(); $paymentMethods = $shippingMethod->getPaymentMethods(); if (false === $order->hasPaymentMethod() || false === $paymentMethods->contains($order->getPaymentMethod())) { $order->setPaymentMethod($paymentMethods->first()); } $modifier = $this->orderModifierProvider->getOrderModifier($order, 'payment_surcharge'); $modifier->setCurrency($order->getCurrency()); $modifier->setGrossAmount(0); $modifier->setNetAmount(0); $modifier->setTaxAmount(0); }
/** * @param OrderInterface $order * * @return \WellCommerce\Bundle\PaymentBundle\Processor\PaymentMethodProcessorInterface */ protected function getProcessor(OrderInterface $order) { $orderProcessor = $order->getPaymentMethod()->getProcessor(); $processors = $this->get('payment_method.processor.collection'); return $processors->get($orderProcessor); }