feat: support customMethodNames in payment sheet#437
Open
ArushKapoorJuspay wants to merge 4 commits into
Open
Conversation
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.
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.
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.
Type of Change
Description
Adds
customMethodNamessupport 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:
customMethodNameshelper is effectively gated by aclassic/evouchercheck inPaymentUtils.getDisplayNameAndIcon(), so aliasing is not applied as a general-purpose rename path for all payment methodsThe mobile bridge path also differs by platform before the value reaches the ReScript layer:
customMethodNamesthrough the native bundle as a JSON stringcustomMethodNamesas native structured data viaDictionaryConverterLinked dependency PRs:
Included changes:
src/types/SdkTypes.res: adds the config type and dual-path parsing for Android/iOS payloadssrc/hooks/AllApiDataModifier.res: resolves merchant aliases when building tab labelsandroidandiossubmodule refs to the new SDK commitsHow did you test it?
npm run re:checkinworkspaces/hyperswitch-client-coreTested passing the following prop in configuration object
customMethodNames: [{paymentMethodName: 'sofort', aliasName: 'Custom'}]Impact on Mobile and Web Repositories
Checklist
Bug Fix (commit cbb0db9)
Icon broken when
aliasNameis providedThe
hoctype previously usednamefor both the display label and the icon asset key. When a merchant configured analiasNameviacustomMethodNames, the icon lookup used the alias instead of the original payment method type, breaking the icon.Fix: Added
iconName: stringto thehoctype, always set to the originalpaymentMethodData.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.resCase-insensitive alias matching
resolveDisplayNameused===so merchant input"IDEAL"or"Ideal"never matched"ideal"from the API.Fix: Both sides now use
String.toLowerCasebefore comparison.Additional fixes
resolveDisplayNamenow applied to the "Saved" tab (was previously hardcoded"Saved", ignoring anycustomMethodNamesentry for"saved")useMemo3→useMemo4withnativePropadded as 4th dependency to prevent stale closure on merchant config changes