Skip to content

feat: add surcharge message display support (showShortSurchargeMessage)#460

Open
AbhishekChorotiya wants to merge 1 commit into
mainfrom
feat/surcharge-message-display
Open

feat: add surcharge message display support (showShortSurchargeMessage)#460
AbhishekChorotiya wants to merge 1 commit into
mainfrom
feat/surcharge-message-display

Conversation

@AbhishekChorotiya

Copy link
Copy Markdown

Summary

  • Ports the showShortSurchargeMessage feature from hyperswitch-web to the mobile SDK
  • Parses surcharge_details from the payment methods list API and displays surcharge fee information on payment method forms and saved payment methods
  • Adds showShortSurchargeMessage merchant configuration option to toggle between short ("Fee : USD 5.00") and long ("A surcharge amount of USD 5.00 will be applied") message formats

Changes

New files

  • src/components/common/SurchargeUtils.res — Pure utility function getSurchargeMessage that generates locale-aware surcharge messages based on payment method type, currency, and display preference
  • src/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 message

Modified files

  • AccountPaymentMethodType.res — Added surchargeDetails type, surcharge_details field to card_networks and payment_method_type records, parseSurchargeDetails helper, updated merge logic
  • CustomerPaymentMethodType.res — Changed surcharge_details from option<string> to option<AccountPaymentMethodType.surchargeDetails> with proper structured parsing
  • SdkTypes.res — Added showShortSurchargeMessage: bool to configurationType with parsing
  • S3ApiHook.res — Added parsing for shortSurchargeMessage locale key
  • DynamicFieldsContext.res — Added surcharge_details: None to default payment_method_type records
  • TabElement.res — Integrated <Surcharge> component after <DynamicFields> for tab-based payment methods
  • SavedPaymentMethod.res — Added SavedMethodSurcharge module and integrated surcharge display for saved payment methods

Submodule (hyperswitch-sdk-utils)

How it works

  1. Merchant sets showShortSurchargeMessage: true/false in SDK configuration
  2. API returns surcharge_details.display_total_surcharge_amount per payment method type and/or card network
  3. Surcharge.res component resolves the applicable surcharge (for cards, picks the highest across credit/debit networks)
  4. Message is rendered below payment method forms (tab-based PMs) and saved payment method list items

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)
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.

1 participant