Skip to content

Commit

Permalink
fix cancel payment
Browse files Browse the repository at this point in the history
  • Loading branch information
oallain authored and NoResponseMate committed Jan 18, 2024
1 parent 8f63d74 commit e068f7c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/Controller/CancelLastPayPalPaymentAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ public function __invoke(Request $request): Response
$paymentStateMachine = $this->stateMachineFactory->get($payment, PaymentTransitions::GRAPH);
$paymentStateMachine->apply(PaymentTransitions::TRANSITION_CANCEL);

/** @var PaymentInterface $lastPayment */
$lastPayment = $order->getLastPayment();
if ($lastPayment->getState() === PaymentInterface::STATE_NEW) {
$this->objectManager->flush();

return new Response('', Response::HTTP_NO_CONTENT);
}

$this->orderPaymentProcessor->process($order);
$this->objectManager->flush();

Expand Down

0 comments on commit e068f7c

Please sign in to comment.