-
Notifications
You must be signed in to change notification settings - Fork 27
refactor: defer handling of prepareForCompletion violations to submission #545
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -233,7 +233,7 @@ | |
| // Taxes may become pending again fail to resolve despite updating within the didUpdatePaymentMethod | ||
| // So we retry one time to see if the error clears on retry | ||
| _ = try await Task.retrying(priority: nil, maxRetryCount: 1) { | ||
| try await self.controller.storefront.cartPaymentUpdate( | ||
|
Check warning on line 236 in Sources/ShopifyAcceleratedCheckouts/Wallets/ApplePay/ApplePayAuthorizationDelegate/ApplePayAuthorizationDelegate+Controller.swift
|
||
| id: cartID, | ||
| totalAmount: totalAmount, | ||
| applePayPayment: applePayPayment | ||
|
|
@@ -302,14 +302,10 @@ | |
| ) | ||
| } | ||
|
|
||
| // `prepareCartForCompletion` filters 'non-terminal' violations | ||
| // See: `ErrorHandler.filterApplePayResolvableViolations` | ||
| // | ||
| // Before `didAuthorizePayment`, Apple Pay redacts PII, these are expected to be resolved by submit | ||
| // After `didAuthorizePayment`, PII is available, but we continue filtering in `prepareForCompletion` so | ||
| // `cartSubmitForCompletion` can return all violations at once | ||
| // This gives the user the best chance to fix everything in a single pass. | ||
| // | ||
| /// `prepareCartForCompletion` ignores all violations — submit handles error surfacing. | ||
| /// Before `didAuthorizePayment`, Apple Pay redacts PII so most violations are expected. | ||
| /// We rely on `cartSubmitForCompletion` to return all violations at once, | ||
| /// giving the user the best chance to fix everything in a single pass. | ||
| @discardableResult | ||
| func prepareCartForCompletion(id: GraphQLScalars.ID) async throws -> StorefrontAPI.Cart? { | ||
| do { | ||
|
|
@@ -320,11 +316,8 @@ | |
| if case let .response(_, _, .cartPrepareForCompletion(payload)) = error, | ||
| case let .notReady(notReady) = payload.result | ||
| { | ||
| let actionableErrors = ErrorHandler.filterApplePayResolvableViolations(errors: notReady.errors) | ||
| if actionableErrors.isEmpty { | ||
| try setCart(to: notReady.cart) | ||
| return notReady.cart | ||
| } | ||
| try setCart(to: notReady.cart) | ||
| return notReady.cart | ||
| } | ||
| throw error | ||
| } | ||
|
|
||
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 purposefully not fully undoing this path entirely as I know this will be useful again when we improve the UX to surface these errors agin