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

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

Closed
loicginoux opened this issue May 17, 2023 · 5 comments
Closed

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

loicginoux opened this issue May 17, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@loicginoux
Copy link
Contributor

loicginoux commented May 17, 2023

When running solidus stripe master branch locally:

  • I add 50$ of store credits
  • I order for 30$ of products
  • so the total to be paid is 0 because everything is taken from the store credits.
  • The Stripe checkout form in the frontend checkout display an error
IntegrationError: Invalid value for elements.create(): `amount` must be greater than 0

Which seems legit as Stripe probably does not allow a payment for an amout of 0.

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
Copy link
Contributor

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

@loicginoux
Copy link
Contributor Author

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
Copy link
Contributor

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: solidusio/solidus_starter_frontend#348

solidus_starter_frontend.348.mov

Our long-term plan is detailed here: solidusio/solidus_starter_frontend#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
Copy link
Contributor Author

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:

  • order total: 50$
  • user's store credits: 49.70$

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
Copy link
Contributor

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: #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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants