예제 #1
0
 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);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function createPayment(OrderInterface $order)
 {
     $payment = $this->paymentRepository->createNew();
     $payment->setCurrency($order->getCurrency());
     $payment->setAmount($order->getTotal());
     $order->addPayment($payment);
     return $payment;
 }
예제 #3
0
 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);
 }
예제 #4
0
 function it_sets_not_started_payments_as_cancelled_while_creating_payment($paymentManager, $paymentFactory, OrderInterface $order, PaymentInterface $existingPayment, PaymentInterface $payment)
 {
     $existingPayment->getState()->willReturn('new');
     $order->getPayments()->willReturn(array($existingPayment))->shouldBeCalled();
     $existingPayment->setState('cancelled')->shouldBeCalled();
     $paymentManager->flush()->shouldBeCalled();
     $order->getCurrency()->willReturn('EUR')->shouldBeCalled();
     $order->getTotal()->willReturn(100)->shouldBeCalled();
     $paymentFactory->createNew()->willReturn($payment)->shouldBeCalled();
     $payment->setCurrency('EUR')->shouldBeCalled();
     $payment->setAmount(100)->shouldBeCalled();
     $order->addPayment($payment)->shouldBeCalled();
     $this->createPayment($order)->shouldReturn($payment);
 }
 function it_does_not_add_a_new_payment_if_the_order_is_cancelled(OrderInterface $order)
 {
     $order->getState()->willReturn(OrderInterface::STATE_CANCELLED);
     $order->addPayment(Argument::any())->shouldNotBeCalled();
     $this->process($order);
 }
예제 #6
0
 /**
  * {@inheritdoc}
  */
 public function processOrderPayments(OrderInterface $order)
 {
     /** @var $payment PaymentInterface */
     $payment = $this->paymentFactory->createWithAmountAndCurrency($order->getTotal(), $order->getCurrency());
     $order->addPayment($payment);
 }