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

Payment cancellation #1637

Closed
ashitikov opened this issue Jun 27, 2022 · 1 comment
Closed

Payment cancellation #1637

ashitikov opened this issue Jun 27, 2022 · 1 comment

Comments

@ashitikov
Copy link
Contributor

ashitikov commented Jun 27, 2022

Is your feature request related to a problem? Please describe.
Current implementation of 'cancel' payment state is like a dummy. I can cancel payment from any state, so its gonna be a problem if payment is in 'authorized' or 'settled' state and I click cancel in admin-ui. Literally we may lose payments, without any callback to payment provider.

Describe the solution you'd like
A new payment handler's method 'cancelPayment' which carefully handle this type of transition. In two-step scheme we could cancel payment transaction, which will unblock held funds, instead invoking a refund.

Describe alternatives you've considered
Handle this type of action as refund, but I guess there is a lot of side effects on order.

@michaelbromley
Hi,
I think you are right - currently it's just setting state to Cancelled and no side effects are happening. It should not really be possible to just cancel a settled payment - you'd also want to take the corresponding action with the payment provider like with "refund".

So I think basically I added this state way back when I implemented Payments but before actually having implemented a concrete provider integration, hence this rather impractical functionality.

@ashitikov
It's quite helpful in case of two-step payment flow
Transition authorized -> cancelled is possible in this case. Corresponding method cancelPayment should be called in payment handler in this case

@michaelbromley
yes, then we'd need to add a cancelPayment method to the handler API.

Slack thread: https://vendure-ecommerce.slack.com/archives/CKYMF0ZTJ/p1656319311851299

@michaelbromley michaelbromley added this to the v1.7 milestone Jul 1, 2022
@michaelbromley michaelbromley moved this to 📅 Planned in Vendure OS Roadmap Jul 1, 2022
@michaelbromley michaelbromley moved this from 📅 Planned to 🏗 In progress in Vendure OS Roadmap Aug 19, 2022
michaelbromley added a commit that referenced this issue Aug 22, 2022
Relates to #1637. This commit introduces a new function to the PaymentHandler as well as a new
`cancelPayment` mutation to the Admin API. Rather than directly transitioning the Payment state
to "Cancelled", the intention is that `cancelPayment` should be executed, which will run the
associated PaymentMethodHandler function (if defined).
@michaelbromley michaelbromley moved this from 🏗 In progress to 🔖 Ready in Vendure OS Roadmap Aug 22, 2022
@michaelbromley
Copy link
Member

@martijnvdbrug, @vrosa - the above commits introduce a new optional function to PaymentMethodHandlers, cancelPayment(). This is designed to allow you to cancel a "started but not yet completed" payment, which e.g. in Stripe probably corresponds to a payment intent, and in Mollie probably corresponds to an open payment which can still be cancelled.

Just giving you guys the heads up so that you can potentially incorporate this API into your own implementations once v1.7 is out, and if it proves beneficial, perhaps contribute the changes back to the payments-plugin versions of Stripe and Mollie handlers.

@michaelbromley michaelbromley moved this from 🔖 Ready to ✅ Done in Vendure OS Roadmap Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants