Skip to content

feat: let integrations narrow the PE transfer-method options - #51

Merged
vorasmit merged 3 commits into
developfrom
develop-compat
Jul 3, 2026
Merged

vorasmit merged 3 commits into
developfrom
develop-compat

Conversation

@vorasmit

@vorasmit vorasmit commented Jul 2, 2026

Copy link
Copy Markdown
Member

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.

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>
@mergify

mergify Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@greptile-apps

greptile-apps Bot commented Jul 2, 2026 •

Copy link
Copy Markdown

Confidence Score: 4/5

Safe to merge after confirming the party_bank_account handler interaction is acceptable or addressed.

The new server-side hook resolver and client-side narrowing logic are well-structured. The primary concern — the party_bank_account event handler unconditionally overwriting payment_transfer_method with values that may be outside the narrowed set — is a real defect in the JS file that was surfaced in a prior review comment and remains unaddressed.

payment_integration_utils/payment_integration_utils/client_overrides/form/payment_entry.js — specifically the party_bank_account handler at line 116.

Important Files Changed

Filename Overview
payment_integration_utils/payment_integration_utils/server_overrides/doctype/payment_entry.py Adds _transfer_method_options helper and wires it into onload. First-resolver-wins logic, error isolation via try/except, and None fallback are all correct. No new issues beyond the already-flagged party_bank_account handler interaction.
payment_integration_utils/payment_integration_utils/client_overrides/form/payment_entry.js Adds apply_transfer_method_options called only in refresh. The party_bank_account handler (line 116-122) still unconditionally sets payment_transfer_method to LINK or NEFT without checking the narrowed options, leaving the field in an invalid state until the next refresh — this pre-existing handler directly undermines the new narrowing feature.

Reviews (3): Last reviewed commit: "fix: keep transfer-method resolver conve..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jul 2, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 726b6685-04be-40f8-b19c-6bfe2fbdd5cf

📥 Commits

Reviewing files that changed from the base of the PR and between 7360602 and 416ace7.

📒 Files selected for processing (2)
  • payment_integration_utils/payment_integration_utils/client_overrides/form/payment_entry.js
  • payment_integration_utils/payment_integration_utils/server_overrides/doctype/payment_entry.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • payment_integration_utils/payment_integration_utils/client_overrides/form/payment_entry.js
  • payment_integration_utils/payment_integration_utils/server_overrides/doctype/payment_entry.py

📝 Walkthrough

Walkthrough

This change adds server-side resolution of payment_transfer_method_options for Payment Entry onload data and client-side application of those options during form refresh. The server helper evaluates configured hooks in order, logs resolver errors, and stores the first non-empty result on the document. The client reads that onload value, narrows the payment_transfer_method field options, and resets invalid draft selections.

Changes

File Summary
server_overrides/doctype/payment_entry.py Added _transfer_method_options(doc) and set payment_transfer_method_options during onload.
client_overrides/form/payment_entry.js Added apply_transfer_method_options(frm) and called it from refresh.

Sequence Diagram(s)

sequenceDiagram
  participant PaymentEntry as PaymentEntry
  participant Hooks as payment_transfer_method_options hooks
  participant Frm as Payment Entry Form

  PaymentEntry->>Hooks: call hook resolvers with doc
  Hooks-->>PaymentEntry: return methods list or error
  PaymentEntry-->>Frm: onload.payment_transfer_method_options
  Frm->>Frm: apply_transfer_method_options(frm)
  Frm->>Frm: set payment_transfer_method options
  Frm->>Frm: reset invalid draft value
Loading

Related issues: None provided.

Related PRs: None provided.

Suggested labels: enhancement, payment-entry

Suggested reviewers: None specified.

Poem:
A rabbit hopped through hooks anew,
Narrowing choices, just a few,
Onload whispered options bright,
The form redrew with fields just right,
Draft values reset if they askew —
Hop, hop, review, all's clean and true! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed It clearly describes the new ability for integrations to narrow Payment Entry transfer-method options.
Description check ✅ Passed It matches the hook, client-side narrowing, draft reset, and fallback behavior described in the changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
payment_integration_utils/payment_integration_utils/server_overrides/doctype/payment_entry.py (1)

46-50: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Include the failing hook path in the error log title.

With multiple registered resolvers, frappe.log_error(title="payment_transfer_method_options resolver failed") gives no way to tell which hook path failed from the Error Log list view.

♻️ Suggested improvement
         except Exception:
-            frappe.log_error(title="payment_transfer_method_options resolver failed")
+            frappe.log_error(title=f"payment_transfer_method_options resolver failed: {path}")
             continue

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 81807c37-8dce-4b84-9348-b2f84e072893

📥 Commits

Reviewing files that changed from the base of the PR and between 7103cff and 7360602.

📒 Files selected for processing (2)
  • payment_integration_utils/payment_integration_utils/client_overrides/form/payment_entry.js
  • payment_integration_utils/payment_integration_utils/server_overrides/doctype/payment_entry.py

…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
@vorasmit
vorasmit merged commit f274b89 into develop Jul 3, 2026
6 checks passed
if methods:
return list(methods)
except Exception:
frappe.log_error(title="payment_transfer_method_options resolver failed")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vorasmit should we add message for which path it failed and trackback

@Abdeali099

Abdeali099 commented Jul 3, 2026 •

Copy link
Copy Markdown
Member

@vorasmit release this right now or wait? Also required to backport to version-15?

mergify Bot added a commit that referenced this pull request Jul 5, 2026
…ix/pr-51

feat: let integrations narrow the PE transfer-method options (backport #51)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants