Skip to content

Improve payment methods: expand list, always-visible custom input, and fix submit validation#455

Merged
grunch merged 8 commits intomainfrom
payment-methods
Feb 13, 2026
Merged

Improve payment methods: expand list, always-visible custom input, and fix submit validation#455
grunch merged 8 commits intomainfrom
payment-methods

Conversation

@Catrya
Copy link
Member

@Catrya Catrya commented Feb 13, 2026

fix #433

  • Add specific payment methods for 14 new fiat currencies (BRL, CAD, PEN, AED, TRY, AUD, BOB, NGN, PYG, PHP, PAB,
    INR, CHF, MYR) and expand methods for existing ones
  • Custom payment method input field is always visible without needing to select "Other"
  • Remove "Other" option from payment method selection dialog
  • Fix submit button being enabled when amount field is empty, preventing null check error
  • UI adjustments to custom input field: font size, margins, and border consistency
image image image

Summary by CodeRabbit

  • New Features

    • Expanded payment method mappings with many additional currencies and regional variants.
  • Improvements

    • Simplified payment-method UI: custom-method input is always available and selection dialog streamlined to checkboxes.
    • Submission validation tightened: requires minimum amount and necessary exchange data before submitting; custom inputs are sanitized.
    • Defaults updated: fallback payment lists no longer include the translated "Other" entry.

  - Remove Other checkbox requirement to show custom input
  - Custom text field always visible below payment method selector
  - Remove showCustomField parameter and _showCustomPaymentMethod state
  - Simplify onMethodsChanged callback signature
  - Match custom field UI style with amount input (fontSize, borders, margins)
  - Add _minFiatAmount null check in _getSubmitCallback()
  - Prevents null check error when submitting without entering an amount
  - Button stays disabled until currency, amount, and payment method are
  filled
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 13, 2026

Warning

Rate limit exceeded

@Catrya has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 17 minutes and 47 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Walkthrough

Restructures payment methods data by adding and extending many currency entries; simplifies payment-method UI by removing the custom-field visibility flag and changing the onMethodsChanged callback signature; submission logic now sanitizes and appends custom input and requires a non-null minimum fiat amount to enable submit.

Changes

Cohort / File(s) Summary
Payment Methods Data
assets/data/payment_methods.json
Replaced per-currency blocks with an expanded mapping adding many currencies (e.g., AUD, BRL, CAD, CHF, NGN, PEN, PHP, PYG, extended USD, EUR, GBP, JPY, etc.) and updated payment-method lists; default fallback preserved.
Order screen
lib/features/order/screens/add_order_screen.dart
Removed _showCustomPaymentMethod state and related handling; updated to new onMethodsChanged(List<String>) signature; clears custom input and selected methods on currency change; submission now sanitizes/appends non-empty custom input and requires non-null _minFiatAmount.
PaymentMethodsSection widget
lib/features/order/widgets/payment_methods_section.dart
Removed showCustomField property and boolean parameter in onMethodsChanged → now Function(List<String>); always renders the dedicated custom TextField in main UI; dialog simplified to checkbox-only list; normalized handling of localized "Other".
Payment methods provider
lib/features/order/providers/payment_methods_provider.dart
Adjusted fallback payloads: removed 'Other' from default and error fallback lists (now ['Bank Transfer','Cash in person']).

Sequence Diagram(s)

(omitted — changes are UI/data-focused and do not introduce new multi-component sequential control flow)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • grunch
  • chebizarro

Poem

🐇
I hopped through lines of JSON light,
Pruned a flag and made the field sit right.
New currencies danced in a row,
Checkboxes checked with a tidy glow.
A rabbit's nibble — simpler flow!

🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: expanding payment method lists, making custom input always visible, and fixing submit validation.
Linked Issues check ✅ Passed The PR successfully expands payment methods for 14+ currencies [#433] with currency-specific defaults while preserving custom method input capability.
Out of Scope Changes check ✅ Passed All changes directly support the stated objectives: payment method expansion, custom input UI improvements, and submit validation fixes; no unrelated modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch payment-methods

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 and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
lib/features/order/screens/add_order_screen.dart (2)

430-432: ⚠️ Potential issue | 🟠 Major

Bug: custom-only payment method won't enable submit.

With the "Other" option removed and the custom field always visible, a user may reasonably enter only a custom payment method without selecting any from the dialog. However, this check returns null (disabling submit) when _selectedPaymentMethods is empty, even if _customPaymentMethodController has valid text.

Proposed fix
-    if (_selectedPaymentMethods.isEmpty) {
+    if (_selectedPaymentMethods.isEmpty &&
+        _customPaymentMethodController.text.trim().isEmpty) {
       return null;
     }

Apply the same logic to the guard in _submitOrder at line 452:

-    if (_selectedPaymentMethods.isEmpty) {
+    if (_selectedPaymentMethods.isEmpty &&
+        _customPaymentMethodController.text.trim().isEmpty) {

504-518: ⚠️ Potential issue | 🟠 Major

Sanitization logic looks correct, but submit reactivity may be stale for custom input.

The sanitization of the custom payment method is sound. However, since _getSubmitCallback() is evaluated during build(), and _customPaymentMethodController changes don't trigger setState, the submit button won't reactively enable/disable as the user types in the custom field. If you fix the validation check above, you'll also need to listen to the controller to rebuild when custom text changes.

Proposed approach — add a listener in initState
  `@override`
  void initState() {
    super.initState();
+   _customPaymentMethodController.addListener(() {
+     setState(() {});
+   });
    ...
🤖 Fix all issues with AI agents
In `@assets/data/payment_methods.json`:
- Around line 2-23: The payment_methods.json contains mixed Spanish/English
user-facing strings causing localization gaps; update the data and widget so all
displayed strings are localized: convert all payment method entries to a
canonical (English) key set in payment_methods.json, then extend
_translatePaymentMethod() (or replace it with ARB keys looked up via
S.of(context)) to map those canonical keys to localized display strings;
alternatively, if these are intentional brand/service names, document that
choice and ensure the widget uses S.of(context) or a pass-through for brand
names so no untranslated Spanish literals are shown.

In `@lib/features/order/widgets/payment_methods_section.dart`:
- Around line 147-163: The dialog can appear empty when availableMethods is
empty; update the dialog logic that builds the CheckboxListTiles (using
availableMethods, dialogSelectedMethods, setDialogState and CheckboxListTile) to
guard against an empty list by either providing a sensible fallback list (ensure
availableMethods contains at least one entry beyond "Other") or rendering a
placeholder/notice widget and disabling the Confirm action when
availableMethods.isEmpty; implement the guard where the children are built so
the dialog shows a helpful message or disabled confirm button instead of a blank
content area.
🧹 Nitpick comments (2)
lib/features/order/widgets/payment_methods_section.dart (2)

45-57: Always-visible custom payment field — clean simplification.

This removes the need for the "Other" toggle and provides a better UX. The extraContent placement within FormSection keeps it visually grouped with the payment methods.

Minor nit: line 54 can use const.

Nit
-              hintStyle: TextStyle(color: Colors.grey, fontSize: 13),
+              hintStyle: const TextStyle(color: Colors.grey, fontSize: 13),

69-78: Default fallback after "Other" filtering may leave only two items — verify this is acceptable.

The default list in JSON is ["Bank Transfer", "Cash in person", "Other"]. After filtering "Other" at line 120, the default becomes ["Bank Transfer", "Cash in person"] (translated). This is fine functionally, but if the intent was always to have at least a few options, consider adding more defaults to the JSON.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Fix all issues with AI agents
In `@assets/data/payment_methods.json`:
- Line 2: The "AED" entry in assets/data/payment_methods.json contains
incorrect, non-UAE banks (the "AED" array currently includes "MBank", "Emirates
NBD", "DBS", "Attijariwafa Bank", "Brubank", "Cash"); update the AED array to
only include UAE-relevant payment methods (e.g., banks like "First Abu Dhabi
Bank (FAB)", "Abu Dhabi Commercial Bank (ADCB)", "Mashreq", and common UAE
payment options like "Apple Pay", "Samsung Pay", "Cash", or local wallets) so
the AED key reflects accurate UAE payment methods.
- Line 22: The "TRY" payment methods array is incorrect and appears copied from
another currency; update the "TRY" array to include relevant Turkish payment
options such as "Papara", "İninal", "Garanti BBVA", "İşBank" or "İş Bankası",
"Ziraat Bankası", "Akbank", "VakıfBank" (and keep generic options like "Bank
Transfer" and "Cash" if desired). Locate the "TRY" JSON array in
payment_methods.json and replace the current values with the appropriate Turkish
payment method strings, preserving JSON syntax and ordering.
- Line 25: Remove "Other" from the JSON fallback list under the "default" key in
assets/data/payment_methods.json so it matches the UI behavior that strips
"Other"; update the "default" array to only include ["Bank Transfer", "Cash in
person"] (this ensures consistency with the logic in PaymentMethodsProvider /
payment_methods_provider.dart and the UI handling in PaymentMethodsSection and
OrderFilter where "Other" is explicitly removed).

  - Check custom text field in addition to selected methods for submit validation
  - Add listener to update button state as user types custom payment method
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/features/order/providers/payment_methods_provider.dart (1)

22-24: ⚠️ Potential issue | 🟡 Minor

Remove the dead "Other" injection — it's bypassed by the UI layer anyway.

The provider adds 'Other' to every currency's method list (lines 22-24), but the widget (payment_methods_section.dart) uses paymentMethodsDataProvider directly instead and explicitly filters out "Other" at lines 118-122 because the custom text field is always visible. This code has no effect and contradicts the design; remove these three lines.

♻️ Suggested fix
     data: (data) {
       if (data.containsKey(currencyCode)) {
-        final methods = List<String>.from(data[currencyCode]);
-
-        if (!methods.contains('Other')) {
-          methods.add('Other');
-        }
-        return methods;
+        return List<String>.from(data[currencyCode]);
       } else {

@grunch
Copy link
Member

grunch commented Feb 13, 2026

@Catrya Why removing other payment method?

Copy link
Member

@grunch grunch left a comment

Choose a reason for hiding this comment

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

tACK

@grunch grunch merged commit e943b8f into main Feb 13, 2026
2 checks passed
@grunch grunch deleted the payment-methods branch February 13, 2026 12:44
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.

Add more payment methods by currency

2 participants