/** * {@inheritdoc} */ public function processOrderPayments(OrderInterface $order) { /** @var $payment PaymentInterface */ $payment = $this->paymentFactory->createWithAmountAndCurrency($order->getTotal(), $order->getCurrency()); $this->setPaymentMethodIfNeeded($order, $payment); $order->addPayment($payment); }
function it_processes_payment_for_given_order(PaymentFactoryInterface $paymentFactory, PaymentInterface $payment, OrderInterface $order) { $order->getTotal()->willReturn(1234); $order->getCurrency()->willReturn('EUR'); $paymentFactory->createWithAmountAndCurrency(1234, 'EUR')->willReturn($payment); $order->addPayment($payment)->shouldBeCalled(); $this->processOrderPayments($order); }
function it_does_not_set_payment_method_from_last_cancelled_payment_during_processing_if_new_payment_exists(PaymentFactoryInterface $paymentFactory, PaymentInterface $newPaymentReadyToPay, PaymentInterface $cancelledPayment, PaymentInterface $payment, OrderInterface $order) { $order->getTotal()->willReturn(1234); $order->getCurrency()->willReturn('EUR'); $order->getLastPayment(PaymentInterface::STATE_CANCELLED)->willReturn($cancelledPayment); $order->getLastPayment(PaymentInterface::STATE_NEW)->willReturn($newPaymentReadyToPay); $paymentFactory->createWithAmountAndCurrency(1234, 'EUR')->willReturn($payment); $payment->setMethod($cancelledPayment)->shouldNotBeCalled(); $order->addPayment($payment)->shouldBeCalled(); $this->processOrderPayments($order); }
/** * @Given /^the customer chose ("[^"]+" shipping method) (to "[^"]+") with ("[^"]+" payment)$/ */ public function theCustomerChoseShippingToWithPayment(ShippingMethodInterface $shippingMethod, AddressInterface $address, PaymentMethodInterface $paymentMethod) { /** @var OrderInterface $order */ $order = $this->sharedStorage->get('order'); $this->orderShipmentFactory->processOrderShipment($order); $order->getShipments()->first()->setMethod($shippingMethod); $payment = $this->paymentFactory->createWithAmountAndCurrency($order->getTotal(), $order->getCurrency()); $payment->setMethod($paymentMethod); $order->addPayment($payment); $order->setShippingAddress($address); $order->setBillingAddress($address); $this->objectManager->flush(); }
function it_adds_shipping_payment_and_addressing_info_to_an_order(AddressInterface $address, Collection $shipmentCollection, OrderInterface $order, OrderShipmentProcessorInterface $orderShipmentFactory, PaymentFactoryInterface $paymentFactory, PaymentInterface $payment, PaymentMethodInterface $paymentMethod, SharedStorageInterface $sharedStorage, ShipmentInterface $shipment, ShippingMethodInterface $shippingMethod, ObjectManager $objectManager) { $sharedStorage->get('order')->willReturn($order); $order->getCurrency()->willReturn('EUR'); $order->getTotal()->willReturn(1234); $order->getShipments()->willReturn($shipmentCollection); $shipmentCollection->first()->willReturn($shipment); $paymentFactory->createWithAmountAndCurrency(1234, 'EUR')->willReturn($payment); $order->setBillingAddress($address)->shouldBeCalled(); $order->setShippingAddress($address)->shouldBeCalled(); $order->addPayment($payment)->shouldBeCalled(); $payment->setMethod($paymentMethod)->shouldBeCalled(); $shipment->setMethod($shippingMethod)->shouldBeCalled(); $orderShipmentFactory->processOrderShipment($order)->shouldBeCalled(); $objectManager->flush()->shouldBeCalled(); $this->theCustomerChoseShippingToWithPayment($shippingMethod, $address, $paymentMethod); }