function it_does_not_set_order_payment_if_it_cannot_be_provided(OrderInterface $order, OrderPaymentProviderInterface $orderPaymentProvider)
 {
     $order->getState()->willReturn(OrderInterface::STATE_CART);
     $order->getLastPayment(PaymentInterface::STATE_CART)->willReturn(null);
     $orderPaymentProvider->provideOrderPayment($order, PaymentInterface::STATE_CART)->willThrow(NotProvidedOrderPaymentException::class);
     $order->addPayment(Argument::any())->shouldNotBeCalled();
     $this->process($order);
 }
 /**
  * {@inheritdoc}
  */
 public function process(BaseOrderInterface $order)
 {
     /** @var OrderInterface $order */
     Assert::isInstanceOf($order, OrderInterface::class);
     if (OrderInterface::STATE_CANCELLED === $order->getState()) {
         return;
     }
     $lastPayment = $order->getLastPayment($this->targetState);
     if (null !== $lastPayment) {
         $lastPayment->setCurrencyCode($order->getCurrencyCode());
         $lastPayment->setAmount($order->getTotal());
         return;
     }
     try {
         $newPayment = $this->orderPaymentProvider->provideOrderPayment($order, $this->targetState);
         $order->addPayment($newPayment);
     } catch (NotProvidedOrderPaymentException $exception) {
         return;
     }
 }