feat: payment method blocking support from dashboard#4699
Conversation
WalkthroughNew payment method blocking feature is introduced to business profile configuration. Type definitions are added to support blocking card and wallet payment methods by card type. Mapping utilities are updated across V1 and V2 interfaces to transform JSON configuration into domain types. A new React component enables UI-based configuration of these settings, and default values are initialized. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/Interface/BusinessProfileInterface/BusinessProfileInterfaceUtils/BusinessProfileInterfaceUtils.res (1)
167-171: Consider filtering out empty strings from card_types.The mapper allows empty strings to be included in the
card_typesarray whengetStringFromJson("")falls back to its default. This could lead to unexpected behavior if the JSON contains null or invalid values in the array.🔧 Proposed fix to filter empty values
let paymentMethodBlockingEntryMapper: Dict.t<JSON.t> => paymentMethodBlockingEntry = entryDict => { card_types: entryDict ->Dict.get("card_types") - ->Option.map(json => json->getArrayFromJson([])->Array.map(item => item->getStringFromJson(""))), + ->Option.map(json => + json + ->getArrayFromJson([]) + ->Array.map(item => item->getStringFromJson("")) + ->Array.filter(s => s->LogicUtils.isNonEmptyString) + ), }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/Interface/BusinessProfileInterface/BusinessProfileInterfaceUtils/BusinessProfileInterfaceUtils.res` around lines 167 - 171, The mapper paymentMethodBlockingEntryMapper currently maps card_types using getArrayFromJson and getStringFromJson which can yield empty strings; update the mapping so after converting each item to a string you filter out empty strings (e.g., remove values equal to "" or only keep non-empty strings) before returning card_types. Locate the card_types expression in paymentMethodBlockingEntryMapper and add an Array filter step (after Array.map / conversion) to exclude empty strings and ensure card_types is an array of only non-empty string values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In
`@src/Interface/BusinessProfileInterface/BusinessProfileInterfaceUtils/BusinessProfileInterfaceUtils.res`:
- Around line 167-171: The mapper paymentMethodBlockingEntryMapper currently
maps card_types using getArrayFromJson and getStringFromJson which can yield
empty strings; update the mapping so after converting each item to a string you
filter out empty strings (e.g., remove values equal to "" or only keep non-empty
strings) before returning card_types. Locate the card_types expression in
paymentMethodBlockingEntryMapper and add an Array filter step (after Array.map /
conversion) to exclude empty strings and ensure card_types is an array of only
non-empty string values.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: d5a56e93-dba5-452e-a439-e4701a57a97e
📒 Files selected for processing (8)
src/Interface/BusinessProfileInterface/BusinessProfileInterfaceTypes/BusinessProfileInterfaceTypes.ressrc/Interface/BusinessProfileInterface/BusinessProfileInterfaceTypes/BusinessProfileInterfaceTypesV1.ressrc/Interface/BusinessProfileInterface/BusinessProfileInterfaceTypes/BusinessProfileInterfaceTypesV2.ressrc/Interface/BusinessProfileInterface/BusinessProfileInterfaceUtils/BusinessProfileInterfaceUtils.ressrc/Interface/BusinessProfileInterface/BusinessProfileInterfaceUtils/BusinessProfileInterfaceUtilsV1.ressrc/Interface/BusinessProfileInterface/BusinessProfileInterfaceUtils/BusinessProfileInterfaceUtilsV2.ressrc/screens/Developer/PaymentSettingsRevamped/PaymentSettingsPaymentBehaviour.ressrc/screens/Settings/MerchantAccountUtils.res
src/screens/Developer/PaymentSettingsRevamped/PaymentSettingsPaymentBehaviour.res
Outdated
Show resolved
Hide resolved
|
@control_center_review_bot review this |
...ace/BusinessProfileInterface/BusinessProfileInterfaceTypes/BusinessProfileInterfaceTypes.res
Show resolved
Hide resolved
...ace/BusinessProfileInterface/BusinessProfileInterfaceUtils/BusinessProfileInterfaceUtils.res
Outdated
Show resolved
Hide resolved
src/screens/Developer/PaymentSettingsRevamped/PaymentSettingsPaymentBehaviour.res
Outdated
Show resolved
Hide resolved
|
@control_center_review_bot can you review this |
muditbhutani
left a comment
There was a problem hiding this comment.
Merge Confidence: 3.5/5 - Confident
"Looks good - minor concerns only"
Assessment
- ✓ Well-scoped, additive change — all new fields are
optiontypes, no breaking changes to existing records or APIs - ✓ JSON mapper logic follows established codebase patterns (getDictfromDict + isEmptyDict guard), consistent with how external_vault_connector_details was added
- ✓ Type definitions properly shared across V1, V2, and common interfaces with correct cross-references
- ⚠ Wallet section label says "Card Types" and reuses credit/debit options — likely copy-paste error that will confuse users in production
- ⚠
getValueFromBusinessProfilein MerchantAccountUtils.res may not serializepayment_method_blockingto form initial values, meaning saved selections won't repopulate on page load - ⚠ The
card_typesfield name within the wallet entry type is semantically confusing — unclear if this is an API contract constraint or a modeling oversight
Review: Add payment method blocking to business profile settings
Adds a new "Payment Method Blocking" section to the payment settings UI, allowing merchants to block credit/debit card types for card and wallet payment methods. The data plumbing (types, JSON mappers, V1/V2 support) is solid and follows existing patterns. Two concerns: (1) the wallet section has copy-pasted labels/options from the card section that need wallet-specific text, and (2) form initial value serialization may be missing, causing saved values to not repopulate on load.
src/screens/Developer/PaymentSettingsRevamped/PaymentSettingsPaymentBehaviour.res
Show resolved
Hide resolved
...ace/BusinessProfileInterface/BusinessProfileInterfaceTypes/BusinessProfileInterfaceTypes.res
Show resolved
Hide resolved
src/screens/Developer/PaymentSettingsRevamped/PaymentSettingsPaymentBehaviour.res
Show resolved
Hide resolved
src/screens/Developer/PaymentSettingsRevamped/PaymentSettingsPaymentBehaviour.res
Show resolved
Hide resolved
src/screens/Developer/PaymentSettingsRevamped/PaymentSettingsPaymentBehaviour.res
Show resolved
Hide resolved
src/screens/Developer/PaymentSettingsRevamped/PaymentSettingsPaymentBehaviour.res
Outdated
Show resolved
Hide resolved
src/screens/Developer/PaymentSettingsRevamped/PaymentSettingsPaymentBehaviour.res
Show resolved
Hide resolved
hs-control-center-bot
left a comment
There was a problem hiding this comment.
Verdict: 🔄 Request Changes
🚨 0 critical ·
The incorrect label on the Wallet section impacts user clarity and should be fixed. The missing feature flag is a release management concern — confirm whether this feature should roll out unconditionally or be gated. The code is otherwise clean, follows existing patterns, and correctly wires the new field through all three API version mappers.
...ace/BusinessProfileInterface/BusinessProfileInterfaceUtils/BusinessProfileInterfaceUtils.res
Outdated
Show resolved
Hide resolved
src/screens/Developer/PaymentSettingsRevamped/PaymentSettingsPaymentBehaviour.res
Show resolved
Hide resolved
src/screens/Developer/PaymentSettingsRevamped/PaymentSettingsPaymentBehaviour.res
Outdated
Show resolved
Hide resolved
src/screens/Developer/PaymentSettingsRevamped/PaymentSettingsPaymentBehaviour.res
Show resolved
Hide resolved
hs-control-center-bot
left a comment
There was a problem hiding this comment.
Verdict: 🔄 Request Changes
The PR introduces payment method blocking functionality with types, mappers, and a new UI component. Main concerns are the confusing duplicate "Card Types" label for wallets and the unconditional rendering of the feature. Consider whether this should be behind a feature flag for gradual rollout.
Type of Change
Description
Adds a new Payment Method Blocking configuration section under Developer → Payment Settings → Payment Behaviour, allowing merchants to block specific card types on card and wallet payment methods from the dashboard.
UI changes (
PaymentSettingsPaymentBehaviour.res)PaymentMethodBlockingmodule rendered in the Payment Behaviour form, wrapped inRenderIfVersion visibleForVersion=V1payment_method_blocking.card.card_typesandpayment_method_blocking.wallet.card_typesrespectivelyType & mapper changes (
BusinessProfileInterface/…)paymentMethodBlockingEntryandpaymentMethodBlockingtypes inBusinessProfileInterfaceTypes.respayment_method_blockingfield tocommonProfileEntity,profileEntity_v1, and the V1 request typemapJsonToBusinessProfileV1) and typed → common mapper (mapV1toCommonType) wired to read/forward the new fieldcommonTypeJsonToV1ForRequest) forwardspayment_method_blockingon the update requestmapV2toCommonType) setspayment_method_blocking: Nonesince the field is not supported on V2The serialized shape sent on update / received on fetch (V1 only):
{ "payment_method_blocking": { "card": { "card_types": ["credit", "debit"] }, "wallet": { "card_types": ["credit", "debit"] } } }Screen.Recording.2026-04-13.at.5.24.37.PM.mov
Motivation and Context
Merchants on Orchestration V1 need a self-serve way to block specific card types (credit / debit) for card and wallet payment methods on a business profile. Today this is only possible via the API. This PR surfaces the configuration in the dashboard alongside other payment behaviour settings.
Closes #4700
How did you test it?
Manual testing (V1):
npm run re:build— compiles cleanlypayment_method_blockingobject with the expected shapepayment_method_blockingresponseWhere to test it?
Checklist
npm run re:build