solidusio / solidus_stripe

💳 Integrate Solidus with Stripe
https://stripe.com
BSD 3-Clause "New" or "Revised" License
36 stars 62 forks source link

Error displaying stripe form when store credits > order.total #307

Closed loicginoux closed 1 year ago

loicginoux commented 1 year ago

When running solidus stripe master branch locally:

Screenshot 2023-05-17 at 10 16 06

Expected behavior

it should probably not display the payment forms at all. just "save and continue"

additional notes Everything works fine when store credit amount < order total. for example with an order total of 94$ and 50$ store credit, the payment workflow looks good Screenshot 2023-05-17 at 10 29 06

rainerdema commented 1 year ago

Hey @loicginoux, we plan to address this issue in the Solidus Starter Frontend, you can track our progress here https://github.com/solidusio/solidus_starter_frontend/issues/345. I'll make sure to keep you updated as soon as we have a fix released.

loicginoux commented 1 year ago

FYI and because i guess it affects default solidus stripe behaviour. We realised the issue is more difficult because you can have the issue is the amount is 0 < amount < 0.50$. https://stripe.com/docs/api/charges/object#charge_object-amount So even with an amount of few cents you will also have an issue on Stripe. For now our plan is to block orders when total amount is below 50 cents, but your solution might be different...

rainerdema commented 1 year ago

FYI and because i guess it affects default solidus stripe behaviour. We realised the issue is more difficult because you can have the issue is the amount is 0 < amount < 0.50$. https://stripe.com/docs/api/charges/object#charge_object-amount So even with an amount of few cents you will also have an issue on Stripe. For now our plan is to block orders when total amount is below 50 cents, but your solution might be different...

Hey @loicginoux, thanks for mentioning this 🙏

Yes, We initially considered this issue and, as a result, our initial plan is to simply not render the available payment methods if store credits entirely cover the order. This way, there will be no interaction with Stripe, and the order will be completed using only the store credits. This is a short-term solution, which you can see in this dedicated PR: https://github.com/solidusio/solidus_starter_frontend/pull/348

https://github.com/solidusio/solidus_stripe/assets/19948291/1bfaa5fd-6b99-4fe8-89b6-aae97cf5885c


Our long-term plan is detailed here: https://github.com/solidusio/solidus_starter_frontend/issues/346 Essentially, the ultimate goal is to treat store credits as a full-fledged payment method that can be managed by the customer during the payment step.


I'm closing this issue as the current setup with this change in the solidus_starter_frontend ensures functionality even with orders fully covered by store credits.

Please let me know if you encounter any other issues or if there are scenarios that you think are not covered by this change.

loicginoux commented 1 year ago

Sorry @rainerdema , if I see your code, you always talk about fully covered by store credit. The case I am talking about is different I and don't see it included in your spec nor in the PR.
if you have for example:

so the remaining to pay is 0.30$. the method covered_by_store_credit? will return false so you will try to display the Stripe form, but at one point you will have an error from Stripe in the line of

Stripe::InvalidRequestError - Amount must be at least €0.50 eur

Did I miss something ? is it correctly covered somewhere in specs ?

rainerdema commented 1 year ago

Did I miss something ?

No, your explanation makes perfect sense now. My apologies for not understanding your point earlier. This use case was not considered, and I thank you for bringing it to light.

is it correctly covered somewhere in specs ?

Currently, there are no specs or logic to cover this behavior in the codebase.

With the recent fix, we were able to handle the scenario where an order is fully covered by store credits. However, this doesn't apply to the situation where store credits almost fully cover an order, leaving a balance insufficient for completing a payment through Stripe.

In a store with a single currency and Stripe as the only payment method, this would certainly be a patchable bug. But in our case, this situation will require more investigation and work due to the different minimum amounts for currencies other than USD, and the fact that this behavior is only valid for certain payment methods, like Stripe.

I've opened an issue to start a discussion and brainstorm for this specific problem: https://github.com/solidusio/solidus_stripe/issues/311 In the coming days, I'll try to figure out if it's possible to create some sort of workaround that could be easily implemented until this issue is resolved.