Skip to content

feat(resize): authorize resize via in-window PayPal SDK revise#29

Merged
max-tet merged 1 commit into
mainfrom
feature/resize-sdk-revise-ui
Jun 5, 2026
Merged

feat(resize): authorize resize via in-window PayPal SDK revise#29
max-tet merged 1 commit into
mainfrom
feature/resize-sdk-revise-ui

Conversation

@ClaydeCode

Copy link
Copy Markdown
Contributor

Problem

The subscribed-resize popup opened PayPal's hosted approval page (window.open(approval_url)) and depended on a return_url redirect. That URL 404s on the shard nginx, so after approving, the popup landed on an error page and never closed.

Fix

Subscribed resizes now use the same in-window JS SDK approach as subscribe — no popup, no redirect, no return_url:

  • When a larger size is selected on an active subscription, render a PayPal button (renderResizeButton).
  • createSubscriptionPOST /self/resize (claims the pending slot, returns subscription_id, plan_id, expected_price_cents) → actions.subscription.revise(subscription_id, { plan_id, quantity }).
  • onApprove → poll until the BILLING.SUBSCRIPTION.UPDATED webhook commits the change; the hasPendingResize watcher then clears the busy state.
  • onCancel/onErrorPOST /self/resize/cancel to release the slot.

Unsubscribed shards keep the immediate resize path.

Depends on

Controller PR: /self/resize returning the revise params + new /self/resize/cancel (FreeshardBase/freeshard-controller — feature/resize-via-sdk-revise), plus the price-promote/pending-clear on the UPDATED webhook (#292).

Verification

ESLint clean; production build succeeds.

⚠️ Needs sandbox verification: the exact actions.subscription.revise(subscriptionID, { plan_id, quantity }) call (PayPal's published docs don't show the JS snippet for quantity revisions). The call site is commented; adjust if the SDK expects a different shape.

🤖 Generated with Claude Code

The resize popup opened PayPal's hosted approval page and relied on a
return_url redirect, which 404s on the shard nginx and never closed the
popup. Switch subscribed resizes to the same in-window JS SDK flow as
subscribe: render a PayPal button whose createSubscription calls
actions.subscription.revise(); onApprove polls until the webhook commits
the change; onCancel/onError release the pending slot via /resize/cancel.

Unsubscribed shards keep the immediate resize path. The hasPendingResize
watcher clears the busy state once the webhook flips pending off.

Depends on controller endpoints returning {subscription_id, plan_id,
expected_price_cents} from /resize and the new /resize/cancel.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@max-tet max-tet merged commit 0f97450 into main Jun 5, 2026
2 checks passed
@max-tet max-tet deleted the feature/resize-sdk-revise-ui branch June 5, 2026 15:52
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