-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix StoreCredit with multiple currencies #2183
Fix StoreCredit with multiple currencies #2183
Conversation
No functionality changes.
- StoreCredits can only be used with orders of the same currency. - Summing up amounts of different currencies gives a meaningless number.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes total sense to me
This will replace `User#total_available_store_credit`.
This fixes this scenario: - Joe gets $5 USD in store credit - Joe starts an order in JPY - Joe starts checking out and `Spree::Order#add_store_credit_payments` applies Joe's $5 store credit as ¥5 (which is around $0.05 currently) - Joe continues checkout and tries to complete his order but the payment auth/capture fails when Solidus realizes the store credit currency doesn't match the order currency. Joe cannot check out because he has no way to prevent Solidus from trying to apply his store credit.
To fix potential currency problems when a User has store credits that don't match the currency of their current Order.
4debea7
to
249eb35
Compare
And the corresponding User#display_total_available_store_credit
249eb35
to
4dfb51f
Compare
We can now have multiples of these.
FYI: I force-pushed after Thomas's review to fix some specs and add some specs. No code changes except for the last minor commit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me too, thanks for following through jordan.
Please see individual commits.
High level overview:
It took some effort to not attempt a refactor of a bunch of the scary or weird-looking StoreCredit code I noticed while working on this.