Skip to content

Commit

Permalink
bug #273 [Payment] fix cancel payment (oallain)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.5 branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | 1.5
| Bug fix?        | yes
| New feature?    | no
| Related tickets | replace #249

If the order already has a payment in the "new" status, then the Sylius orderPaymentProcessor must not be processed, otherwise a new payment in the "cart" status will be created, which will cause errors (2 payments in order ...).

Before : 
![image](https://user-images.githubusercontent.com/6593252/215053880-97319618-b24e-4a10-8281-15b71d494912.png)

After :
![image](https://user-images.githubusercontent.com/6593252/215054517-63061d73-37d3-4644-b16c-f57867a7e7d0.png)


Commits
-------

e068f7c fix cancel payment
  • Loading branch information
GSadee authored Jan 18, 2024
2 parents 8f63d74 + e068f7c commit 65c1dca
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 65c1dca

Please sign in to comment.