feat: add surcharge message display support (showShortSurchargeMessage)#460
Open
AbhishekChorotiya wants to merge 1 commit into
Open
feat: add surcharge message display support (showShortSurchargeMessage)#460AbhishekChorotiya wants to merge 1 commit into
AbhishekChorotiya wants to merge 1 commit into
Conversation
Port the showShortSurchargeMessage feature from hyperswitch-web to the mobile SDK. When merchants enable surcharges, the SDK now displays surcharge fee information on payment method forms and saved payment methods. Changes: - Parse surcharge_details from payment methods list API at both payment_method_type and card_network levels - Add showShortSurchargeMessage config option (default: false) - Create SurchargeUtils.res with message generation logic - Create Surcharge.res React Native component for surcharge display - Integrate surcharge display into TabElement (form-based PMs) and SavedPaymentMethod (saved PMs) - Update CustomerPaymentMethodType to parse surcharge_details as structured data instead of opaque string - Add shortSurchargeMessage locale string (via shared-code submodule)
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.
Summary
showShortSurchargeMessagefeature fromhyperswitch-webto the mobile SDKsurcharge_detailsfrom the payment methods list API and displays surcharge fee information on payment method forms and saved payment methodsshowShortSurchargeMessagemerchant configuration option to toggle between short ("Fee : USD 5.00") and long ("A surcharge amount of USD 5.00 will be applied") message formatsChanges
New files
src/components/common/SurchargeUtils.res— Pure utility functiongetSurchargeMessagethat generates locale-aware surcharge messages based on payment method type, currency, and display preferencesrc/components/common/Surcharge.res— React Native component that resolves surcharge details (checking payment_method_type level first, then card_networks for cards) and renders the messageModified files
AccountPaymentMethodType.res— AddedsurchargeDetailstype,surcharge_detailsfield tocard_networksandpayment_method_typerecords,parseSurchargeDetailshelper, updated merge logicCustomerPaymentMethodType.res— Changedsurcharge_detailsfromoption<string>tooption<AccountPaymentMethodType.surchargeDetails>with proper structured parsingSdkTypes.res— AddedshowShortSurchargeMessage: booltoconfigurationTypewith parsingS3ApiHook.res— Added parsing forshortSurchargeMessagelocale keyDynamicFieldsContext.res— Addedsurcharge_details: Noneto default payment_method_type recordsTabElement.res— Integrated<Surcharge>component after<DynamicFields>for tab-based payment methodsSavedPaymentMethod.res— AddedSavedMethodSurchargemodule and integrated surcharge display for saved payment methodsSubmodule (hyperswitch-sdk-utils)
shortSurchargeMessagefield toLocaleDataType.localeStringsand all 32 locale JSON filesHow it works
showShortSurchargeMessage: true/falsein SDK configurationsurcharge_details.display_total_surcharge_amountper payment method type and/or card networkSurcharge.rescomponent resolves the applicable surcharge (for cards, picks the highest across credit/debit networks)