Skip to content

fix: preserve camelCase keys and numeric values in merchant session validation#1571

Merged
ArushKapoorJuspay merged 6 commits into
mainfrom
fix/applepay-merchant-session-data
May 19, 2026
Merged

fix: preserve camelCase keys and numeric values in merchant session validation#1571
ArushKapoorJuspay merged 6 commits into
mainfrom
fix/applepay-merchant-session-data

Conversation

@aritro2002

Copy link
Copy Markdown
Contributor

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Fixes two related bugs in Apple Pay merchant session validation that caused onvalidatemerchant to fail.

Problem

The Apple Pay session token data returned from the backend is already in camelCase (e.g. epochTimestamp, merchantSessionIdentifier). When transformKeys(CamelCase) was applied:

  1. toCamelCase called String.toLowerCase unconditionally before applying the camelCase regex. Since the regex only capitalizes letters after _ or -, keys without separators were fully lowercased (epochTimestamp → epochtimestamp), causing Apple Pay's completeMerchantValidation to fail with malformed session data.
  2. transformKeys coerces all Number values to strings (val->Float.toString), corrupting numeric fields like epochTimestamp and expiresAt that Apple Pay expects as integers.
    Changes
  • toCamelCase / toCamelCaseWithNumberSupport (Utils.res): Only apply the lowercase + regex transform when the string contains _ or -. Otherwise pass through as-is (stripping non-alpha characters only), preserving existing camelCase keys.
  • startApplePaySession (ApplePayHelpers.res): Replace transformKeys(CamelCase) with transformKeysWithoutModifyingValue(CamelCase) so numeric values remain as numbers instead of being stringified.
    Testing
  • Verify Apple Pay merchant validation succeeds end-to-end on a supported device/browser
  • Verify snake_case → camelCase conversion still works correctly for other use cases of transformKeys

How did you test it?

I have tested it locally, by comparing the merchant session before and after transformation and also e2e testing.

before:
image

after:

image
Screen.Recording.2026-05-19.at.5.47.57.pm.mov

Checklist

  • I ran npm run re:build
  • I reviewed submitted code
  • I added unit tests for my changes where possible

@aritro2002 aritro2002 self-assigned this May 19, 2026
@aritro2002 aritro2002 added the Ready for Review PR with label Ready for Review should only be reviewed. label May 19, 2026
@semanticdiff-com

Copy link
Copy Markdown

Review changes with  SemanticDiff

@github-actions

Copy link
Copy Markdown
Contributor

🚫 Missing Linked Issue

Hi 👋 This pull request does not appear to be linked to any open issue yet.

Linking your PR to an issue helps keep the project tidy and ensures the issue is closed automatically.

✔️ How to fix this

  • Add a keyword like Fixes #123 or Closes #456 to your PR description or a commit message.
  • Or link it manually using the "Linked issues" panel in the PR sidebar.

Tip: You can link multiple issues.
🚫 Note: If only one issue is linked, it must be open for this check to pass.

Once linked, this check will pass automatically on your next push or when you re-run the workflow.

Thanks for helping maintainers! 🙌

@ArushKapoorJuspay ArushKapoorJuspay merged commit bf3a5e4 into main May 19, 2026
9 of 10 checks passed
@ArushKapoorJuspay ArushKapoorJuspay deleted the fix/applepay-merchant-session-data branch May 19, 2026 18:49
@github-actions github-actions Bot added the Closed Label will be automatically added when the PR will get merged to main label May 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Closed Label will be automatically added when the PR will get merged to main Ready for Review PR with label Ready for Review should only be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: preserve camelCase keys and numeric values in merchant session validation

4 participants