Skip to content

feat: support customMethodNames in payment sheet#437

Open
ArushKapoorJuspay wants to merge 4 commits into
mainfrom
feat/custom-method-names
Open

feat: support customMethodNames in payment sheet#437
ArushKapoorJuspay wants to merge 4 commits into
mainfrom
feat/custom-method-names

Conversation

@ArushKapoorJuspay

@ArushKapoorJuspay ArushKapoorJuspay commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Type of Change

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

Description

Adds customMethodNames support to hyperswitch-client-core so merchants can override the display label of TAB-type payment methods in the mobile payment sheet.

This ports the existing hyperswitch-web capability into client-core, but the implementation intentionally differs from web in two ways:

  • in hyperswitch-web, the current customMethodNames helper is effectively gated by a classic / evoucher check in PaymentUtils.getDisplayNameAndIcon(), so aliasing is not applied as a general-purpose rename path for all payment methods
  • in hyperswitch-client-core, aliases are supported for any TAB-type payment method because that approach is more scalable for the mobile payment-sheet architecture

The mobile bridge path also differs by platform before the value reaches the ReScript layer:

  • Android sends customMethodNames through the native bundle as a JSON string
  • iOS sends customMethodNames as native structured data via DictionaryConverter
  • client-core applies aliases only to TAB-type payment methods and keeps wallet/button payment methods unchanged to preserve wallet branding and existing element behavior

Linked dependency PRs:

Included changes:

  • src/types/SdkTypes.res: adds the config type and dual-path parsing for Android/iOS payloads
  • src/hooks/AllApiDataModifier.res: resolves merchant aliases when building tab labels
  • updates the android and ios submodule refs to the new SDK commits

How did you test it?

  • Ran npm run re:check in workspaces/hyperswitch-client-core
  • Reviewed Android and iOS configuration wiring and bridge serialization paths
  • Hardened Android string parsing so malformed JSON falls back safely instead of crashing

Tested passing the following prop in configuration object

customMethodNames: [{paymentMethodName: 'sofort', aliasName: 'Custom'}]

Screenshot 2026-03-29 at 4 19 53 AM

Impact on Mobile and Web Repositories

  • I tested the submodule changes in the mobile repository.
  • I tested the submodule changes in the web repository.
  • I updated the corresponding documentation in both repositories, if applicable.
  • I confirmed the changes do not introduce regressions in either repository.

Checklist

  • I reviewed submitted code thoroughly.
  • I ensured the changes are compatible with both mobile and web repositories.
  • I communicated potential breaking changes, if any, to the relevant teams.

Bug Fix (commit cbb0db9)

Icon broken when aliasName is provided

The hoc type previously used name for both the display label and the icon asset key. When a merchant configured an aliasName via customMethodNames, the icon lookup used the alias instead of the original payment method type, breaking the icon.

Fix: Added iconName: string to the hoc type, always set to the original paymentMethodData.payment_method_type. Display label (name) and icon asset key (iconName) are now fully decoupled.

Files changed: src/hooks/AllApiDataModifier.res, src/components/common/CustomTabView.res, src/components/common/CustomAccordionView.res

Case-insensitive alias matching

resolveDisplayName used === so merchant input "IDEAL" or "Ideal" never matched "ideal" from the API.

Fix: Both sides now use String.toLowerCase before comparison.

Additional fixes

  • resolveDisplayName now applied to the "Saved" tab (was previously hardcoded "Saved", ignoring any customMethodNames entry for "saved")
  • useMemo3useMemo4 with nativeProp added as 4th dependency to prevent stale closure on merchant config changes

Add iconName field to hoc type to preserve the stable payment method
type key for icon asset lookup, independent of any merchant-defined
aliasName. Also fix resolveDisplayName to match case-insensitively,
apply alias resolution to the Saved tab, and add nativeProp to the
useMemo dependency array to prevent stale closure on config changes.
- iOS: bump submodule to 627a5ef — replaces [[String: String]]? with
  [PaymentMethodAlias]? (DictionaryConverter-conforming struct) so the
  field survives toDictionary() reflection-based serialization.
  Previously silently dropped because Dictionary<String,String> is not
  Hashable and not DictionaryConverter.

- SdkTypes.res: filter out alias entries where paymentMethodName or
  aliasName is empty string — prevents invisible tab labels or
  no-op match entries from malformed merchant config.

- SdkTypes.res: Belt.Array.keepMap -> Array.filterMap for RescriptCore
  consistency.
@ArushKapoorJuspay ArushKapoorJuspay added the ai-generated PR generated by AI. Requires human review for correctness and security. label Mar 28, 2026
The check used name == "Card" which breaks when a merchant aliases the
credit payment method via customMethodNames. Switch to iconName == "credit"
which is the stable payment_method_type key, unaffected by aliasing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-generated PR generated by AI. Requires human review for correctness and security.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant