Repository navigation
feat(checkout): subscribe via Hypery's hosted subscribe page - #24
Merged
Merged
Conversation
Subscriptions now create a hosted subscribe session and open it in a popup (or redirect), where the user picks the team, card and interval. The outcome is verified with a random state and the session /result endpoint. Adds lastResult to useCheckout, SubscribeSessionResult type, docs and tests. Requires the gateway release with hosted subscribe sessions (hyperyai/hypery#193).
…up blockers Open a named about:blank loading window synchronously before any await when the user is already logged in, navigate it to the session URL once created, close it if session creation fails, and fall back to redirect when blocked. openPopup accepts an existing window.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Switches
kind: 'subscription'(anduseAppSubscription().subscribe/SubscribeButton) to the hosted subscribe page from hyperyai/hypery#193.Requires that server release (
/api/marketplace/subscribe-sessions); against an older gateway subscribing will fail.Flow
POST /api/marketplace/subscribe-sessionswith{planId, interval?, state}(state fromcrypto.getRandomValues).returnOrigin= origin ofconfig.redirectUri; openshypery-subscribe480x760; only ahypery:subscribemessage from the gateway origin with matching sessionId + state is accepted (newaccepthook onopenPopup). Closed popup ->cancelled.returnUrl= current URL minus subscribe params; persists{sessionId, state, input}inhypery_pending_subscribe; on return verifies state, strips params viahistory.replaceState, fetches result, setsstatus+ newlastResult.GET .../:id/resultis authoritative: success only oncompleted->data: {subscription, team}; cancelled/pending/expired ->cancelled; state mismatch ->STATE_MISMATCHerror./api/marketplace/subscribeor card-setup popups; purchase/topup untouched.idempotencyKeyon subscription input is deprecated/ignored.useAppSubscriptionrefreshes after a redirect-return success. No team fields added toAppSubscription(server summaries don't expose them).Checks
npx tsc --noEmitOK,npm run buildOK,bun test src50 pass (newsubscribe-session.test.ts: body building, message validation, return parsing/cleanup, outcome mapping; docs-coverage passes).