Skip to content

fix(payments): categorize binance_enabled under Payment settings, not general (#479) - #490

Merged
guillermoscript merged 1 commit into
masterfrom
fix/binance-settings-category-479
Jul 23, 2026
Merged

fix(payments): categorize binance_enabled under Payment settings, not general (#479)#490
guillermoscript merged 1 commit into
masterfrom
fix/binance-settings-category-479

Conversation

@guillermoscript

Copy link
Copy Markdown
Owner

What & why

Closes part of #479 (credentialed-QA follow-up to #466 / PR #478). While setting up the live PayPal sandbox portion of that QA, a survey of app/actions/admin/settings.ts and components/admin/payment-settings-form.tsx — needed to enable PayPal for a test tenant — turned up a second, credential-independent bug in the same admin Settings > Payment surface #479's "UI polish check" covers. The live PayPal/Binance sandbox runs are tracked separately; see the QA record comment on #479.

The bug

getAllSettingsByCategory() hardcodes a categoryMap that assigns each tenant_settings row to a tab (general/email/payment/enrollment) for the admin Settings page. It listed stripe_enabled, paypal_enabled, lemonsqueezy_enabled, and solana_enabled under 'payment' — but not binance_enabled. Any key missing from the map falls through to 'general'.

PaymentSettingsForm reads settings.binance_enabled?.value?.enabled ?? false from the payment bucket to set the Binance Pay switch's initial state. Since the row never landed there, the Binance Pay toggle always rendered unchecked on page load, regardless of the saved DB value. An admin who enabled it, navigated away, and came back would see it off — and because the form resubmits every field from its current checkbox state, hitting Save from that stale view would silently flip binance_enabled back to false in the database.

This is a display/round-trip bug only: getEnabledPaymentProviders() (used by checkout, product creation, and plan creation to decide which providers to show) queries binance_enabled directly and was unaffected — actual provider gating elsewhere in the app kept working correctly throughout.

Verified live in a local Code Academy Pro tenant: enabling the toggle persisted binance_enabled: {"enabled": true} to tenant_settings, but reloading the Payment tab with the bug present showed the switch unchecked; with the fix, it correctly shows checked after reload.

The fix

Add binance_enabled: 'payment' to the categoryMap in getAllSettingsByCategory(), and binance_ to the equivalent prefix list in the sibling getSettings(category) helper (same root cause, same file — currently unused elsewhere in the app, but left consistent rather than leaving an identical latent bug behind).

Test plan

  • New regression test tests/unit/admin-settings-category-map.test.ts — asserts a binance_enabled row lands under payment, not general, and stays grouped alongside the other payment toggles.
  • npx vitest run tests/unit/admin-settings-category-map.test.ts tests/unit/admin-enabled-providers.test.ts tests/unit/admin-provider-actions.test.ts tests/unit/paypal-binance-providers.test.ts → 33/33 pass.
  • npx tsc --noEmit → clean.
  • npx eslint on changed files → only the 8 pre-existing no-explicit-any errors already present on app/actions/admin/settings.ts before this change (same lines, unrelated to this diff) — no new errors introduced.
  • Live-verified in the browser against a local Code Academy Pro tenant: reproduced the bug (toggle shows unchecked after reload despite binance_enabled: true in the DB), applied the fix, confirmed the toggle now shows checked after reload. Screenshots attached below.

Screenshots

Before (bug): Binance Pay switch unchecked after reload, despite tenant_settings.binance_enabled = {"enabled": true} in the DB.
After (fixed): Binance Pay switch correctly shows checked after reload.

(attached as a PR comment)

… general (#479)

getAllSettingsByCategory()'s categoryMap had no entry for binance_enabled,
so it fell through to 'general' instead of 'payment'. The admin Settings >
Payment page reads settings.payment.binance_enabled to set the Binance Pay
switch's initial state, so the toggle always rendered unchecked on reload
regardless of the saved value — an admin who enabled it would see it off on
next visit, and re-saving from that state would silently disable it in the
DB. getEnabledPaymentProviders() (used by checkout/product forms) queries
the key directly and was unaffected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UYWqTKnHDLQC1hbithnsb3
@guillermoscript

Copy link
Copy Markdown
Owner Author

Visual verification

Before — Binance Pay toggle shows unchecked despite tenant_settings.binance_enabled = {"enabled": true} in the DB (Stripe/PayPal correctly show their saved state, Binance doesn't):

before

After — same DB row, same page, Binance Pay now correctly shows checked:

after

@guillermoscript
guillermoscript marked this pull request as ready for review July 23, 2026 19:54
@guillermoscript
guillermoscript merged commit d6e6467 into master Jul 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

payments Payment provider / billing related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant