feat: let integrations narrow the PE transfer-method options (backport #51) - #56
Conversation
Add a `payment_transfer_method_options` hook: onload resolves the first registered resolver's non-empty list of allowed methods for the PE, and the PE client JS narrows the Select to it (resetting a now-invalid draft value to the first). No resolver / none installed -> the full default set, so razorpayx is unaffected; a resolver error degrades to the full set rather than breaking the form. Lets a bank integration hide UPI/Link its banks don't support without a global, install-order-dependent property setter. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> (cherry picked from commit 7360602)
…Payment Entry (cherry picked from commit ee3651c)
…s as list
- _transfer_method_options: move `list(methods)` inside the try so a
malformed resolver return degrades to the default set instead of
crashing onload, matching the documented behaviour.
- payment_entry.js: pass options directly to set_df_property instead of
join("\n").
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B7vdkobbjBpanpq9mK1gXq
(cherry picked from commit 416ace7)
|
Tick the box to add this pull request to the merge queue (same as
|
Confidence Score: 3/5The UI narrowing works correctly but the allowed-methods constraint is not enforced during server-side validation, meaning the restriction can be bypassed through API calls or bulk submit. validate() never calls _transfer_method_options to verify the submitted payment_transfer_method is in the hook-provided allowed list, so an API caller or bulk-submit flow can submit a PE with an excluded method and route a payment to a gateway that does not support it. payment_entry.py — the validate/validate_transfer_methods path needs a check against the hook-resolved allowed set before the existing gateway-level validations run.
|
| Filename | Overview |
|---|---|
| payment_integration_utils/payment_integration_utils/server_overrides/doctype/payment_entry.py | Adds _transfer_method_options hook resolver called at onload; validate() never checks the resolved allowed-methods list, leaving the restriction bypassable via API. |
| payment_integration_utils/payment_integration_utils/client_overrides/form/payment_entry.js | Adds apply_transfer_method_options which narrows the Select and resets an invalid draft value on refresh; the party_bank_account event can assign a method outside the narrowed set until the next refresh. |
Comments Outside Diff (2)
-
payment_integration_utils/payment_integration_utils/server_overrides/doctype/payment_entry.py, line 52-76 (link)No server-side enforcement of hook-allowed methods
validate()callsvalidate_transfer_methodswhich checks bank details, UPI ID, and contact info — but it never calls_transfer_method_options(doc)to verify thatdoc.payment_transfer_methodis in the resolver's allowed set. The restriction is therefore client-side only: any API caller (e.g.,bulk_pay_and_submit, a custom script, or a direct REST call) can submit a PE with a method the registered hook explicitly excluded, and the payment will proceed to the gateway with an unsupported method. Adding a guard insidevalidate_transfer_methodswould close this gap. -
payment_integration_utils/payment_integration_utils/client_overrides/form/payment_entry.js, line 116-122 (link)party_bank_accountevent ignores narrowed allowed methodsWhen
party_bank_accountis cleared, the event unconditionally setspayment_transfer_methodtoLINK; when it is set, it resets toNEFT. If an integration's hook excludesLINKorNEFTfrom the allowed set, this creates a UI inconsistency: the narrowed Select no longer shows the just-assigned value, and the displayed value is invalid until the next form refresh triggersapply_transfer_method_optionsagain.
Reviews (1): Last reviewed commit: "fix: keep transfer-method resolver conve..." | Re-trigger Greptile
|
🎉 This PR is included in version 15.2.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Add a
payment_transfer_method_optionshook: onload resolves the first registered resolver's non-empty list of allowed methods for the PE, and the PE client JS narrows the Select to it (resetting a now-invalid draft value to the first). No resolver / none installed -> the full default set, so razorpayx is unaffected; a resolver error degrades to the full set rather than breaking the form. Lets a bank integration hide UPI/Link its banks don't support without a global, install-order-dependent property setter.This is an automatic backport of pull request #51 done by Mergify.