Skip to content

feat(android): ISO 3166-2 region in addresses - #118

Merged
jkasprzyk17 merged 1 commit into
mainfrom
feat/android-iso-region-code
Nov 23, 2026
Merged

jkasprzyk17 merged 1 commit into
mainfrom
feat/android-iso-region-code

Conversation

@jkasprzyk17

@jkasprzyk17 jkasprzyk17 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Android asks Google Pay for full billing and shipping addresses in the FULL-ISO3166 format (Google release notes, 2025-11-01). This is FULL plus iso3166AdministrativeArea.
  • CNPostalAddress gets an optional isoAdministrativeArea, an ISO 3166-2 code such as 'US-CA'. It is read from iso3166AdministrativeArea and uppercased.
  • A MIN billing address, asked for only to get a phone number, does not change.
  • On iOS the field is always omitted. Apple Pay has no ISO 3166-2 code, and state is free text, so a code can't be derived from it safely.
  • Docs updated: api/types.md, guides/contact-details.md, README, CHANGELOG.

Fixes #90

Test plan

  • cd package && bun run typecheck
  • cd package && bun run lint
  • cd package && bun run test (289 passed)
  • cd package && bun run check:docs
  • bun run docs:build
  • ./gradlew :gmisoftware_react-native-pay:testDebugUnitTest (193 passed; includes the new FULL-ISO3166 format and mapper asserts)
  • ./gradlew :app:assembleDebug -PreactNativeArchitectures=arm64-v8a (builds the regenerated JNI struct)
  • xcodebuild test -scheme NitroPay-Unit-Tests (141 passed)
  • bunx expo run:android: not run. The local emulators have no Google account, so Google Pay shows no card.
  • bunx expo run:ios: not run. iOS only passes nil, and the unit tests cover it.

Risk

  • Not checked: how Play services older than November 2025 handles "format": "FULL-ISO3166". If it rejects the value, every payment that asks for a billing or shipping contact fails. Before release, check on a signed-in device or emulator, ideally one with old Play services. If it fails there, make the format an opt-out.
  • The Nitro struct CNPostalAddress has a new field, so this needs a native rebuild. Nothing changes in the JS API except one new optional field.

Notes

  • Google documents no minimum play-services-wallet version for this format. The repo uses 20.0.0.
  • Follow-up idea: PaymentSheetAddress (from onShippingAddressChange) could carry the same code. Google sends it on IntermediateAddress too, and it would help with tax calculation before authorization.

Get evidence
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • Added an optional ISO 3166-2 administrative-area code to postal addresses returned by Google Pay on Android for full billing and shipping requests. Full-address requests now use the format that can provide this code.
    • The code is omitted when unavailable and is not provided on iOS; existing free-text region information remains unchanged. Minimum billing requests are unchanged.
  • Documentation
    • Updated contact and postal-address documentation to describe the field, its platform availability, and an example.

The change adds an optional isoAdministrativeArea field to postal addresses. Android requests FULL-ISO3166 for full billing and shipping addresses and maps the returned code. Minimal billing requests remain unchanged, and the iOS conversions set the field to nil.

Changes: ISO 3166-2 Address Codes

Layer / File(s) Summary
Postal-address contract and documentation
package/src/types/Contact.ts, README.md, docs/docs/api/types.md, docs/docs/guides/contact-details.md, CHANGELOG.md
CNPostalAddress adds optional isoAdministrativeArea. The documentation describes its Android-only availability and ISO 3166-2 format.
Android full-address requests
package/android/src/main/java/com/margelo/nitro/pay/Constants.kt, package/android/src/main/java/com/margelo/nitro/pay/GooglePayRequestBuilder.kt, package/android/src/test/java/com/margelo/nitro/pay/GooglePayRequestBuilderTest.kt
Shipping and full billing requests use FULL-ISO3166. The minimal billing branch is unchanged. Request-builder tests assert the full-address format.
Platform address mapping
package/android/src/main/java/com/margelo/nitro/pay/PaymentMapper.kt, package/android/src/test/java/com/margelo/nitro/pay/PaymentMapperTest.kt, package/ios/PassKitTypeMapper.swift
Android maps a non-empty administrative-area code to uppercase isoAdministrativeArea; tests cover populated and null values. Both iOS postal-address conversions set the field to nil.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GooglePayRequestBuilder
  participant GooglePay
  participant PaymentMapper
  participant CNPostalAddress
  GooglePayRequestBuilder->>GooglePay: Request full address with FULL-ISO3166
  GooglePay-->>PaymentMapper: Return iso3166AdministrativeArea
  PaymentMapper->>CNPostalAddress: Set uppercase isoAdministrativeArea
Loading
Merge Risk: Minimal · up to 26de0 · assessed changes only

Path filters excluded changed files. This rating applies only to the assessed changes.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed Title 'feat(android): ISO 3166-2 region in addresses' is 45 characters, uses the conventional type prefix, and matches the main change: Android requests FULL-ISO3166 and exposes isoAdministrativeArea.…
Description check Passed Description directly covers the changeset: FULL-ISO3166 request format, the new optional CNPostalAddress.isoAdministrativeArea field, unchanged MIN billing requests, iOS omission, docs updates, test r…
Linked Issues check Passed Issue #90 has two coding acceptance criteria. Both are met by the reviewed changes.

[#90] Criterion 1: a full billing or shipping address returns the ISO region code. Constants.kt replaces the billin…
Out of Scope Changes check Passed Every reviewed change maps to issue #90 or to its documented scope.

- Constants.kt, GooglePayRequestBuilder.kt, and PaymentMapper.kt implement the format change and the field mapping.
- PassKitTypeMa…
Security Check Passed No medium, high, or critical security finding is introduced by this PR. Changed-code review (base..head, 17 files): - Constants.kt: ADDRESS_FORMAT_FULL_ISO3166 = "FULL-ISO3166" is a fixed constant…
Full details: Title check

Explanation

Title 'feat(android): ISO 3166-2 region in addresses' is 45 characters, uses the conventional type prefix, and matches the main change: Android requests FULL-ISO3166 and exposes isoAdministrativeArea. It is under the 50-character target. Brutal verdict: the title is competent, which is rare enough to note.

Full details: Description check

Explanation

Description directly covers the changeset: FULL-ISO3166 request format, the new optional CNPostalAddress.isoAdministrativeArea field, unchanged MIN billing requests, iOS omission, docs updates, test results, and risks around older Play services. Linked issue #90 is referenced. Nothing off-topic. Blunt verdict: thorough, and it does what it says.

Full details: Linked Issues check

Explanation

Issue #90 has two coding acceptance criteria. Both are met by the reviewed changes.

[#90] Criterion 1: a full billing or shipping address returns the ISO region code. Constants.kt replaces the billing FULL constant with ADDRESS_FORMAT_FULL_ISO3166 = "FULL-ISO3166". GooglePayRequestBuilder.kt uses this format for the full billing request and for shipping-address parameters, which had no format before. PaymentMapper.mapContact maps iso3166AdministrativeArea to CNPostalAddress.isoAdministrativeArea and uppercases it. PaymentMapperTest asserts US-CA and US-IL for full billing and shipping fixtures. GooglePayRequestBuilderTest asserts the new format. The author reports 193 passing Android unit tests and a successful :app:assembleDebug build.

[#90] Criterion 2: MIN billing addresses are unchanged. The MIN billing format is not modified. A PaymentMapperTest case asserts a null administrative-area code for a MIN billing address.

[#90] Suggested fix and testing items: isoAdministrativeArea?: string is added in package/src/types/Contact.ts. iOS sets it to nil in PassKitTypeMapper.swift, which the issue allows. Builder and mapper tests are updated. Docs are updated in api/types.md and guides/contact-details.md.

Not established: the generated Nitro files (CNPostalAddress.kt, JCNPostalAddress.hpp, CNPostalAddress.swift, CNPostalAddress.hpp) are in ignored_files and were not inspected. The field mapping relies on them. The reported Gradle build and unit tests give independent evidence that the field compiles and maps. The play-services-wallet compatibility check from the issue is a runtime item. It is not a code requirement, and it remains unverified. This does not change the coding verdict.

Full details: Out of Scope Changes check

Explanation

Every reviewed change maps to issue #90 or to its documented scope.

  • Constants.kt, GooglePayRequestBuilder.kt, and PaymentMapper.kt implement the format change and the field mapping.
  • PassKitTypeMapper.swift and Contact.ts implement the iOS nil value and the TypeScript field.
  • GooglePayRequestBuilderTest.kt and PaymentMapperTest.kt cover the changed behavior.
  • CHANGELOG.md, README.md, api/types.md, and contact-details.md document the new field, as the issue requests.

The shipping-contact test change only moves the shipping parameters to a local variable before assertions. It supports the format check. No unrelated feature or refactor appears in the summary. The generated Nitro files are excluded and are not evidence of out-of-scope work.

Full details: Security Check

Explanation

No medium, high, or critical security finding is introduced by this PR. Changed-code review (base..head, 17 files): - Constants.kt: ADDRESS_FORMAT_FULL_ISO3166 = "FULL-ISO3166" is a fixed constant. GooglePayRequestBuilder.kt uses it for the billing format and adds it to shippingAddressParameters. The value is bounded and not attacker-controlled. - PaymentMapper.kt: iso3166AdministrativeArea is read with optNonEmpty(...)?.uppercase() and stored in isoAdministrativeArea. It is a data string only. No query, path, shell, HTML, or deserialization sink consumes it, and it is not logged. - PassKitTypeMapper.swift: isoAdministrativeArea is always nil on iOS. This adds no data path. - Contact.ts and the generated Nitro bindings: one optional string field. No new dependency, endpoint, secret, or permission boundary. - Docs and tests: no security-relevant behavior. Data exposure: the shipping and billing requests now ask for the FULL-ISO3166 format. The merchant already requests shipping and billing contact data on these paths, and the new field only adds the region code to data Google Pay returns for those requests. This is a data-scope change by design, not a vulnerability. The PR's stated risk, that older Play services may reject the format, is an availability/compatibility concern. It falls outside the check's listed categories. No authn/authz, injection, SSRF, XSS, path traversal, deserialization, secret-handling, or supply-chain issue was found in the changed code. No inline comments are warranted.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 588fa35d-13e7-450b-8bc3-1c326c168046
Commits

Reviewing files that changed from the base of the PR and between 0b63e8b and 26de04b.

Files ignored due to path filters: 4

  • package/nitrogen/generated/android/c++/JCNPostalAddress.hpp is excluded by !**/generated/**
  • package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNPostalAddress.kt is excluded by !**/generated/**
  • package/nitrogen/generated/ios/swift/CNPostalAddress.swift is excluded by !**/generated/**
  • package/nitrogen/generated/shared/c++/CNPostalAddress.hpp is excluded by !**/generated/**
Files selected for processing: 2

  • CHANGELOG.md
  • README.md

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour.

Request FULL-ISO3166 for full billing and shipping addresses and
return iso3166AdministrativeArea as CNPostalAddress.isoAdministrativeArea.
MIN billing addresses are unchanged; iOS always omits the field.

Fixes #90
@jkasprzyk17
jkasprzyk17 force-pushed the feat/android-iso-region-code branch from 0b63e8b to 26de04b Compare November 23, 2026 11:42
@jkasprzyk17
jkasprzyk17 merged commit 00def5b into main Nov 23, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android: addresses have no ISO 3166-2 region code (FULL-ISO3166)

1 participant