Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canceling an unpaid order results in an error #59

Open
sinkgregor opened this issue Aug 14, 2024 · 1 comment
Open

Canceling an unpaid order results in an error #59

sinkgregor opened this issue Aug 14, 2024 · 1 comment
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@sinkgregor
Copy link

Hello,

We have encountered an error. When we cancel an order for a customer in the administration, we receive an error indicating that the payment cannot be canceled because the payment is already expired.

The error:

[2024-08-13T12:02:15.944658+02:00] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Messenger\Exception\HandlerFailedException: "Handling "FluxSE\SyliusPayumStripePlugin\Command\CancelPayment" failed: Request Cancel{model: ArrayObject} is not supported. Make sure the gateway supports the requests and there is an action which supports this request (The method returns true). There may be a bug, so look for a related issue on the issue tracker." at DoctrineTransactionMiddleware.php line 42 {"exception":"[object] (Symfony\Component\Messenger\Exception\HandlerFailedException(code: 0): Handling "FluxSE\SyliusPayumStripePlugin\Command\CancelPayment" failed: Request Cancel{model: ArrayObject} is not supported. Make sure the gateway supports the requests and there is an action which supports this request (The method returns true). There may be a bug, so look for a related issue on the issue tracker. at /var/www/project/vendor/symfony/doctrine-bridge/Messenger/DoctrineTransactionMiddleware.php:42)\n[previous exception] [object] (Payum\Core\Exception\RequestNotSupportedException(code: 0): Request Cancel{model: ArrayObject} is not supported. Make sure the gateway supports the requests and there is an action which supports this request (The method returns true). There may be a bug, so look for a related issue on the issue tracker. at /var/www/project/vendor/payum/payum/src/Payum/Core/Exception/RequestNotSupportedException.php:57)"} []

Steps to replicate:

  1. Create a new order.
  2. Initiate payment, but do not complete it.
  3. Cancel the order in the administration.

Possible Solution:
This could be resolved if the CancelOrderProcessor does not attempt to cancel the payment if the payment is in the state new, or if the CancelPaymentHandler checks whether the transaction is already expired.

This issue interferes with canceling orders because when the cancellation fails, the order is also not canceled, as the transaction is rolled back.

@Prometee
Copy link
Member

Prometee commented Aug 14, 2024

Hello @sinkgregor!

I'm aware of this issue but frankly I postponed to fix it due to lack of time right now.
However it can be easily ignored by sending the CancelPayment command to an async task with this config :

# config/packages/messenger.yaml
framework:
    messenger:
        routing:
            'FluxSE\SyliusPayumStripePlugin\Command\CancelPayment': main
            'FluxSE\SyliusPayumStripePlugin\Command\CaptureAuthorizedPayment': main
            'FluxSE\SyliusPayumStripePlugin\Command\RefundPayment': main

It is far from perfect but can allow you to wait for the fix.

What you suggested is one way to fix this issue, if you can submit a PR I would be glad to review it and help you doing so.

@Prometee Prometee added bug Something isn't working good first issue Good for newcomers labels Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants