You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(ad-hoc): improve native alternative payment state handling - #552
Native alternative payment improvements that don't depend on payment finalization, ported from #539.
Solution
Poll only while payment is PENDING; new steps are now accepted while awaiting completion.
Ignore redirect-result-unexpected and redirect-result-unexpected-for-step when resolving return deep links; polling picks up the actual state.
setState(with:) reports its own failures with the response's payment state; callers only handle request errors.
Store payment state in interactor states and report it in didFail.
cancel() always fails the payment, unless it is already completed. Check cancellation before state changes and before starting a redirect.
In submit(), separate request errors (recoverable) from response handling errors.
Add Task.poCheckCancellation() and metadata to POInvoiceCreationRequest.
Clarify enableHeadlessMode: it only skips the first redirect's confirmation, has no effect when redirectButton is nil, and with deep links start() usually returns while payment is pending.
Notes
Unknown or failed states returned while polling now fail right away instead of after the timeout.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Automatic redirects retain the awaiting-completion state, causing valid pending → redirect → pending flows to fail with a generic error instead of resuming polling.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A critical polling flaw can repeatedly reset the configured timeout, and cancellation during the redirect delegate callback can still allow an external redirect to launch.
If the synchronous willStartRedirect delegate callback calls the component's cancel(), the payment enters failure after this cancellation check, but a deep-link redirect still reaches UIApplication.open. Recheck cancellation and terminal state after notifying the delegate so cancelling at this boundary does not launch the external redirect.
let response = try await serviceAdapter.expectPaymentCompletion(with: request)
try await setState(with: response)
await setState(with: response)
This branch has not been deployed
No deployments
This file contains hidden or 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
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.
Description
Native alternative payment improvements that don't depend on payment finalization, ported from #539.
Solution
PENDING; new steps are now accepted while awaiting completion.redirect-result-unexpectedandredirect-result-unexpected-for-stepwhen resolving return deep links; polling picks up the actual state.setState(with:)reports its own failures with the response's payment state; callers only handle request errors.didFail.cancel()always fails the payment, unless it is already completed. Check cancellation before state changes and before starting a redirect.submit(), separate request errors (recoverable) from response handling errors.Task.poCheckCancellation()andmetadatatoPOInvoiceCreationRequest.enableHeadlessMode: it only skips the first redirect's confirmation, has no effect whenredirectButtonisnil, and with deep linksstart()usually returns while payment is pending.Notes