vendure-ecommerce / vendure

The commerce platform with customization in its DNA.
https://www.vendure.io
Other
5.69k stars 1.01k forks source link

Use a shop-api endpoint to get Mollie payment intent instead of addPaymentToOrder #1432

Closed martijnvdbrug closed 2 years ago

martijnvdbrug commented 2 years ago

Is your feature request related to a problem? Please describe. When using Mollie as paymentmethod, an order can get stuck in the PaymentAuthorized state as described here: https://github.com/vendure-ecommerce/vendure/issues/1330

Describe the solution you'd like Use a createMolliePaymentIntent or getMolliePaymentUrl endpoint to get the Mollie redirectUrl for an order payment, and add Mollie as paymentMethod to the order on callback from Mollie. Similar to the solution for Stripe described here: https://github.com/vendure-ecommerce/vendure/pull/1417

Describe alternatives you've considered Allow orders to stay in PaymentCreated state after addOrderToPayment has been called. Also described in #1330

Additional context How do we deal with this breaking change? Do we keep a hybrid solution where both addPaymentToOrder and the new endpoint exist?

Since there is no way to deprecate the addPaymentToOrder mutation for Mollie only, I suggest we don't go through the trouble of maintaining both solutions and just do the breaking change.

You can assign this issue to me.

michaelbromley commented 2 years ago

I would also vote to just do the break. I'll announce it in the blog post etc, but I think the impact will be small because the package is not yet widely adopted.

martijnvdbrug commented 2 years ago

@michaelbromley We have 2 ways of implementing this:

1. GraphQL query

A GraphQL query createMolliePaymentIntent which returns the redirectUrl. The client would need to redirect to Mollie for the payment.

:heavy_check_mark: This option is in line with the Stripe plugin. :heavy_check_mark: An error can be shown in the storefront when createPaymentIntent failed, because the redirect was retrieved via an AJAX call :x: Extra network call, so a bit slower and a slightly higher chance of failure

2. Rest + Redirect

A rest endpoint payWithMollie which does something like this:

const redirectUrl = await mollie.createPayment()
res.redirect(302, redirectUrl)

:heavy_check_mark: Saves 1 network call from the storefront. Less complexity on the storefront side :x: Cannot be done via AJAX call, so the user will leave the storefront, even when redirect creation fails.

I slightly favor option 1. What do you think?

michaelbromley commented 2 years ago

I'd go with option 1 too. Giving more control to the client at the slight expense of extra steps to implement I think is the better choice in the long-run.

martijnvdbrug commented 2 years ago

Closed by #1437