Skip to main content

Currency Switcher v0.7.0 — Manage your subscription from the plugin

· 3 min read
MaxHandMade
Maintainer

The License tab now has a Manage Subscription button that opens the Polar customer portal in a new tab. Cancel auto-renewal, update your card, switch plans, or resubscribe — all without leaving WordPress admin. Snake-case + REST/React parity to MHM Rentiva v4.32.0.

What changed

Inside the License tab's License Management zone (visible when a Pro license is active), a third button joins the existing two:

  1. Manage Subscription — opens Polar customer portal (this release)
  2. Re-validate Now
  3. Deactivate License

The plugin reaches Polar through the same license server already in use. No new external services contacted from your site's perspective. Schema and signature integrity remain RSA-protected (v0.6.0+ pipeline).

State-driven emphasis

The button changes color based on how close your subscription is to renewal:

Days remainingColorIntent
> 30Standard primary blue"Plenty of runway"
≤ 30Yellow"Heads up — renewal is coming"
≤ 7Amber + glow"Decide now"
Expired (0)Amber + glow"Resubscribe to keep Pro"

While the portal session is being minted (a brief async call), the button text becomes "Opening…" and the styling dims to communicate the click registered.

Failure handling

If the portal session can't be minted (server error, network blip, license revoked between page load and click), the button surfaces an in-tab notice instead of breaking:

Subscription management is not available right now. Please try again later or contact support@wpalemi.com.

No raw technical strings ever leak to end users.

Architecture

  • New public method LicenseManager::create_customer_portal_session(string $return_url): array (snake_case parity to Rentiva's camelCase)
  • New REST endpoint POST /mhm-currency/v1/license/manage-subscription (manage_options gated)
  • New React state + callback in License.jsx, button rendered before Deactivate when isActive && license.maskedKey
  • New CSS rules using compound selectors (.button.mhm-cs-license-warning / .mhm-cs-license-urgent) to avoid colliding with the existing .mhm-cs-license-warning alert pill
  • 4 new translatable strings, all translated to Turkish

Compatibility

ComponentRequired version
mhm-license-serverv1.11.0+ (new /customer-portal-session endpoint)
mhm-polar-bridgev1.9.0+ (renewal reminder cron)
WordPress6.0+
PHP7.4+

Older license-server versions without the customer-portal endpoint return a graceful in-tab notice instead of breaking.

Out of scope (not in this release)

  • Past-due / dunning notifications — Polar handles these directly via email.
  • Yearly subscription renewal reminders — Polar sends these 7 days before renewal automatically.

Monthly subscribers receive an additional 7-day-out reminder email from mhm-polar-bridge v1.9.0+, since Polar doesn't generate these for short billing cycles.

Tests

  • 148 → 158 PHPUnit (+10 new across 2 test files)
  • PHPCS new files: 0 errors (after PHPCBF)
  • PHPStan level 6: 0 errors
  • npm run build: success
  • i18n: 0 fuzzy on new strings, all 4 translated