Skip to content

feat(settings): in-window PayPal subscribe via JS SDK (no redirect) + popup resize#26

Merged
max-tet merged 3 commits into
mainfrom
paypal-sdk-flow
Jun 3, 2026
Merged

feat(settings): in-window PayPal subscribe via JS SDK (no redirect) + popup resize#26
max-tet merged 3 commits into
mainfrom
paypal-sdk-flow

Conversation

@ClaydeCode

Copy link
Copy Markdown
Contributor

What

Frontend half of the in-window PayPal flow (spec: knowledge_base/specs/2026-06-03-paypal-in-window-subscribe-design.md). Replaces the full-page redirect with PayPal's JS SDK — the user never leaves the shard, and there is no return_url (removes the hash-route mangling bug class).

  • Capability gate: the whole subscription section renders, and the SDK loads, only when profile.billing_enabled is true. Self-hosted/disabled shards show nothing and load no PayPal JS.
  • SDK loader (src/lib/paypal-sdk.js): loads www.paypal.com/sdk/js once, intent=subscription, with the public client id from the self-view. Unit-tested.
  • Subscribe/reactivate: the SDK button's createSubscription calls POST .../shards/self/subscribe (server-created, returns subscription_id); onApprove triggers a profile refresh + the existing interstitial/poll. Removed the old redirect + ?sub=return handling. The SDK opens a real popup window (matches the desired UX).
  • Resize: subscribed-resize approval opens via window.open(approval_url) (popup; SDK has no revise action — per spike), with a redirect fallback if the popup is blocked, and a popup.closed poll to refresh.

Depends on

freeshard-controller#286 (provides billing_enabled / paypal_client_id on the self-view, and subscription_id from subscribe/resize). Deploy that first.

Verification

Unit: SDK loader spec + existing suite (14/14). Build compiles. The SDK flow itself requires live sandbox browser verification (cannot be unit-tested): subscribe, reactivate-from-grace, resize — all in-window. Spike already confirmed the SDK loads + approves in-window and that resize needs the popup.

Live-test watch items (flagged during implementation): SDK button re-render on trial↔grace transitions in one session (addressed by fa3b70a — confirm); popup-blocker fallback on resize.

Recommended reading order

  1. src/lib/paypal-sdk.js (+ tests/unit/paypal-sdk.spec.js) — the loader
  2. src/views/Settings.vue — gate, SDK button (renderPaypalButton), resizeShard popup

Tracks #265.

🤖 Generated with Claude Code

max-tet and others added 3 commits June 3, 2026 19:13
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
… resize

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Reset paypalButtonRendered flag in the subscriptionState watcher whenever
the state leaves trial/grace, and guard renderPaypalButton() on DOM
emptiness so the button re-renders correctly after a subscribe → cancel
cycle within a single page session.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@max-tet max-tet merged commit 32db676 into main Jun 3, 2026
2 checks passed
@max-tet max-tet deleted the paypal-sdk-flow branch June 3, 2026 19:43
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.

2 participants