This repository has been archived by the owner on Jul 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 674
Require payment recreate when payment price is wrong #892
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
orzechdev
force-pushed
the
fix/payment-recreate
branch
from
September 9, 2020 14:09
c7ceba2
to
1f8f42c
Compare
orzechdev
requested review from
krzysztofwolski,
dominik-zeglen and
AlicjaSzu
September 9, 2020 16:10
krzysztofwolski
suggested changes
Sep 10, 2020
src/@next/utils/core.ts
Outdated
export const checkIfShippingRequiredForProducts = (items?: IItems) => | ||
items?.some(({ variant }) => variant.product?.productType.isShippingRequired); | ||
|
||
export const checkIfCheckoutPriceEqualPaymentPrice = ( |
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.
If you want to test it you have to mock the whole payment object and total price. I see 2 solutions:
- Prefereble, easier to implement: Don't we have util for comparing prices?
If not, I would suggest creating utils/money.ts file with such function (having all utils in one file leads to one, too long file with too broad scope - nightmare to work with).
Also, unit tests for such function is a must. - Function
isCheckoutFullyPaid
which takes Checkout as an argument and performs needed checks. Thats more to mock, but could be easier to use in checkout views.
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.
I have created isPriceEqual util
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.
Another way to do it could be to update the available shipping methods when the cart is updated, then check the id of the available shipping methods against the id of the chosen shipping method in the checkout router.
krzysztofwolski
approved these changes
Sep 10, 2020
dominik-zeglen
approved these changes
Sep 10, 2020
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I want to merge this change because... it
/checkout/shipping
and user was not redirected to other possible stepScreenshots
Pull Request Checklist
Test Environment Config
API_URI=https://master.staging.saleor.rocks/graphql/