Repository navigation
feat(ios): merchant category code and Pay Later - #116
Merged
Merged
Conversation
Adds PaymentRequest.applePayMerchantCategoryCode (iOS 18+) and applePayLaterAvailability (iOS 17+). Both are checked on every iOS version and fail with CONFIGURATION when invalid; Android ignores them. Closes #78
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.
Closes #78
Summary
PaymentRequest.applePayMerchantCategoryCode?: number. It setsPKPaymentRequest.merchantCategoryCode, an ISO 18245 code from 0 to 9999, through the Swift refinement on iOS 18+, so Apple Pay leaves out the cards that don't accept the category.PaymentRequest.applePayLaterAvailability?: stringand theApplePayLaterAvailabilitytype ('available' | 'itemIneligible' | 'recurringTransaction'). On iOS 17+ these map to.available/.unavailable(.itemIneligible)/.unavailable(.recurringTransaction). The field is astring, not the alias, for the same reason asshippingType.CONFIGURATIONeverywhere. Only the assignment sits behind#available, so older iOS versions ignore a valid value. Android ignores both fields.Invalid merchant category code <value>. Use a whole number from 0 to 9999(this covers fractions, NaN and values out of range; the code usesInt16(exactly:), so there is no trap) andUnknown Apple Pay Later availability "<value>". Use "available", "itemIneligible" or "recurringTransaction".types.md(field notes and a newApplePayLaterAvailabilitysection), theCONFIGURATIONrow inpayment-flow.md,README.mdandCHANGELOG.md.Test plan
cd package && bun run typecheckcd package && bun run lintcd package && bun run test(289 passed)./gradlew :gmisoftware_react-native-pay:testDebugUnitTestinexample/android: 193 passed. No Kotlin behaviour change; this run confirms the fixture compiles against the regeneratedPaymentRequest.xcodebuild test ... -scheme NitroPay-Unit-Testsinexample/ioson an iOS 26.5 simulator: 141 passed. New tests inPaymentRequestBuilderTests.swiftcover both fields reachingPKPaymentRequest, each Pay Later value, the 0 and 9999 edges, invalid codes (-1, 10000, 5411.5, 40000, NaN) and unknown Pay Later strings.cd package && bun run check:docsbun run docs:buildbunx expo run:ios/run:android(not run): neither field shows anything in the sheet, so the XCTest assertions on the built request are the check.Risk
Notes
applePayLaterAvailabilityand doesn't deprecate it. Apple doesn't document whether it also hides the bank or Affirm installments that replaced the service. The docs describe the API as Apple defines it; open to wording it differently or adding a note.merchantCategoryCodeon a fresh request is0000, notnil(seen on iOS 26.5), so passing0looks the same as leaving the field out. The 0–9999 range follows the issue.usePaymentCheckoutdoesn't expose either field; this matches the issue's scope, andshippingTypeisn't in the hook either. The category code is fixed for a merchant, so it could go into the hook config in a follow-up.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.