Repository navigation
fix(ios): let the payer retry after onAuthorize reports a failure - #55
Merged
jkasprzyk17 merged 1 commit intoOct 27, 2026
Merged
Conversation
PassKit treats a failure that carries no PassKit error as final: the sheet showed "Payment Failed" and closed, although the docs promise a retry from the same sheet. Complete a failure, a rejected promise and the 25-second timeout with PKPaymentError.unknownError and the error text, which PassKit lets the payer retry. Each retry calls onAuthorize with a new token. On the iOS 26.5 simulator, nil, an empty array and an NSError from another domain all end in PKPaymentAuthorizationStateFatalError, while unknownError ends in the non-fatal PKPaymentAuthorizationStateError.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Stacked on #54. Review and merge that one first; only the last commit belongs to this PR.
Summary
onAuthorizeresolves with'failure', rejects, or times out, the payer can retry from the same Apple Pay sheet, astesting.md,server-processing.md, the README and theonAuthorizeJSDoc already said. Each retry callsonAuthorizeagain with a new token.PKPaymentAuthorizationResult(status: .failure, errors: nil), which PassKit treats as final: the sheet showed "Payment Failed" and closed by itself. It now completes withPKPaymentError.unknownErrorcarrying theerrortext. Apple documents that code as non-fatal: "The user can attempt to authorize the transaction again."startPaymentstill resolves with the last attempt's result (code: 'PROVIDER_ERROR'for a failure).testing.mdsaying that the simulator can rehearse a retry.Test plan
cd package && bun run typecheckcd package && bun run lintcd package && bun run test:ci(135 tests)cd package && bun run check:docscd package && bun run check:packxcodebuild test ... -scheme NitroPay-Unit-Tests(63 tests, 3 new forAuthorizationResultBuilder)decline: after the decline the sheet stays up, a second "Pay" callsonAuthorizeagain, and closing the sheet resolves with "Declined by the test server". Run before rebasing onto feat: report a typed status and error code on every payment result #52 and feat!: add JS wrappers for the pay buttons #53.bun run docs:build./gradlew :gmisoftware_react-native-pay:testDebugUnitTest(not run; no Kotlin changes)Risk
startPaymentresolves later than before. Android is unchanged.Notes
Failure results tried on the iOS 26.5 simulator, read from PassKit's log:
errorspassed with.failurenil(before)PKPaymentAuthorizationStateFatalError[]nilNSErrorfrom another domainPKPaymentAuthorizationStateFatalErrorPKPaymentError(.unknownError)with a messagePKPaymentAuthorizationStateError, then back toAuthenticatedidAuthorizePaymentstripe-ios passes its own error domain here and notes, from iOS 12, that the user "is prompted to try again". On iOS 26.5 that domain is fatal: only
PKPaymentErrorDomainerrors leave the sheet open.PKPaymentAuthorizationViewControlleruses the samePKPaymentAuthorizationCoordinator, so the old code closed the sheet in the same way. The retry claim came from feat: let the app settle Apple Pay authorization with onAuthorize #30, whose test plan lists "retry after a failure" as not run.Not verified: a retry that then succeeds (the result logic is unchanged and keeps the last attempt), and whether the sheet shows the
errortext or only "Payment Failed".Need help on this PR? Tag
@codesmith-botwith what you need.