-
Notifications
You must be signed in to change notification settings - Fork 23
fix: remove tax fields from cart queries unless its prepare for completion #280
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
base: main
Are you sure you want to change the base?
fix: remove tax fields from cart queries unless its prepare for completion #280
Conversation
Samples/MobileBuyIntegration/MobileBuyIntegration/CartManager.swift
Outdated
Show resolved
Hide resolved
ab14282
to
332608a
Compare
|
||
do { |
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.
this ensures prepare is called even if updating the shipping options fails, which happens regularly at the moment due to a 500 server error atm
let shippingContact = payment.shippingContact, | ||
payment.shippingContact?.postalAddress?.isoCountryCode == "US" | ||
let shippingContact = payment.shippingContact | ||
// payment.shippingContact?.postalAddress?.isoCountryCode == "US" |
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.
disabled this us country code restriction that only applies to tiagos store, will remove this going forwards i think
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.
Want to remove it now?
* update the buyerIdentity with the shippingContact.email | ||
*/ | ||
guard | ||
let emailAddress = shippingContact.emailAddress, |
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.
email guard moved in to vaulted state check as we require it via apple payment so its guaranteed to be set outside of this flow
@@ -345,7 +351,7 @@ class CartManager: ObservableObject { | |||
|
|||
let mutation = Storefront.buildMutation(inContext: CartManager.ContextDirective) { | |||
$0.cartPaymentUpdate(cartId: cartId, payment: paymentInput) { | |||
$0.cart { $0.cartManagerFragment() } | |||
$0.cart { $0.cartPrepareForCompletionFragment() } |
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.
this change adds tax pulling for the payment update which is still not deprecated
I've just pushed some changes whilst debugging issues with american addresses, so converted back to draft. |
@@ -146,7 +145,7 @@ extension ApplePayHandler: PKPaymentAuthorizationControllerDelegate { | |||
didSelectShippingContact contact: PKContact | |||
) async -> PKPaymentRequestShippingContactUpdate { | |||
do { | |||
_ = try await CartManager.shared.performBuyerIdentityUpdate( | |||
_ = try await CartManager.shared.performCartBuyerIdentityUpdate( |
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.
Let's add @discardableResult
to these methods to avoid the _ =
everywhere
let shippingContact = payment.shippingContact, | ||
payment.shippingContact?.postalAddress?.isoCountryCode == "US" | ||
let shippingContact = payment.shippingContact | ||
// payment.shippingContact?.postalAddress?.isoCountryCode == "US" |
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.
Want to remove it now?
Samples/MobileBuyIntegration/MobileBuyIntegration/CartManager.swift
Outdated
Show resolved
Hide resolved
* Note - `totalTaxAmount` will not be available on self.cart, only access local value | ||
*/ |
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'm not 100% following the "only access local value" part of the comment here
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.
Yeah I can see it may only really makes sense in context with the comment on self.totalTaxAmount
I've modified the comment, and the variable name to make it more obvious
<key>ITSAppUsesNonExemptEncryption</key> | ||
<false/> |
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.
Why is this needed?
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.
…swift Co-authored-by: Mark Murray <2034704+markmur@users.noreply.github.com>
2df72da
to
91ad2c3
Compare
What changes are you making?
There is a graphql schema issue (currently being tracked elsewhere, issue # TBT) where the total tax amount has been marked as deprecated on cart, but this should only be true for non cartCompletion requests
This PR adds an additional fragment specifically for cart completion that accesses this, and separates it from the original cart object for the sake of clarity (and safety, as the Buy sdk will throw if it you access a property that wasn't queried)
How to test
Open apple pay and ensure the requests that happen on open (
cartBuyerIdentityUpdate
,cartSelectedDeliveryOptionsUpdate
) do not request the totalTax amount, but thecartPrepareForCompletion
after each doesBefore you merge
Important
Checklist for releasing a new version
podspec
file.Tip
See the Contributing documentation for instructions on how to publish a new version of the library.