Skip to content

fix: send consent billing address with snake_case keys - #64

Merged
weiping-awx merged 1 commit into
airwallex:mainfrom
Mohith26:fix/consent-billing-address-keys
Nov 3, 2026
Merged

weiping-awx merged 1 commit into
airwallex:mainfrom
Mohith26:fix/consent-billing-address-keys

Conversation

@Mohith26

@Mohith26 Mohith26 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

payWithConsent converts the consent, paymentMethod, card and billing keys to snake_case before calling the native module, but billing.address is passed through as camelCase (countryCode).

On iOS the consent goes through AWXPaymentConsent.decode(fromJSON:), and AWXAddress decodeFromJSON only reads json[@"country_code"] (AWXAddress.m), so the billing address country is dropped. On Android, toAddress() already accepts both countryCode and country_code, so converting the nested address works on both platforms.

Change: also run transformKeysToSnakeCase on billing.address when it is present. Nothing else in the payload changes.

Testing:

  • Added src/__tests__/payWithConsent.test.ts, which mocks the native module and checks the payload: billing address keys come through as snake_case (this fails on main, where countryCode is sent), and no address key is added when billing has none.
  • yarn jest, yarn tsc and yarn eslint pass locally. I have not run it on a device, only the JS-level tests.

payWithConsent converted the consent, payment method, card and billing keys
to snake_case but left billing.address as camelCase. The iOS SDK decodes
the address with AWXAddress decodeFromJSON, which only reads country_code,
so the billing country was dropped on iOS. Android accepts both forms, so
converting the nested address is safe on both platforms.
@weiping-awx

Copy link
Copy Markdown
Contributor

Thanks for the fix and the tests.

The native mobile SDKs do not use the consent billing address in this flow. The change is still correct, so we will merge it.

@weiping-awx
weiping-awx merged commit c745693 into airwallex:main Nov 3, 2026
5 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.

2 participants