[eas-cli] Add eas billing:subscribe and billing:manage commands#4007
Draft
jonsamp wants to merge 2 commits into
Draft
[eas-cli] Add eas billing:subscribe and billing:manage commands#4007jonsamp wants to merge 2 commits into
jonsamp wants to merge 2 commits into
Conversation
Adds a billing topic with:
- billing:subscribe <plan> - creates a Stripe checkout session for an EAS
plan and returns/opens the checkout URL. Guards against double-subscribing
by routing already-subscribed accounts to billing:manage.
- billing:manage - opens the Stripe customer portal (change plan, update
payment method, cancel).
Calls the stripe-auth apiv2 endpoints, unwrapping the { data } envelope, and
uses open (not better-opn) so the pre-encoded Stripe checkout fragment is not
double-encoded. Depends on the www-side change (ENG-24461) that makes the
checkout endpoint return session.url and accept planTypes.
|
✅ Thank you for adding the changelog entry! |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4007 +/- ##
==========================================
+ Coverage 59.67% 59.74% +0.07%
==========================================
Files 941 947 +6
Lines 41319 41459 +140
Branches 8675 8698 +23
==========================================
+ Hits 24654 24766 +112
- Misses 16571 16599 +28
Partials 94 94 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Why
Implements the CLI half of ENG-24459: let users subscribe to an EAS plan and get a Stripe checkout link from the terminal (e.g.
eas billing:subscribe starter), plus manage/cancel an existing subscription.The www-side half is ENG-24461 (
jon/eng-24461-add-stripe-link-support-to-www), which makes thestripe-auth/checkoutendpoint accept plan slugs and returnsession.url. This PR depends on that shipping first.How
New
billingtopic:eas billing:subscribe <plan>(starter,agent,production-plus,enterprise) — resolves the account (-a/--account, single account, or interactive picker), POSTsstripe-auth/checkoutwith the plan slug, and opens/prints the returned Stripe checkout URL. If the account already has a paid subscription it does not create a second one; it points the user atbilling:manage(Stripe's portal handles plan changes with proration).eas billing:manage— POSTsstripe-auth/customer-portaland opens/prints the portal URL (change plan, update payment method, cancel).Implementation notes:
PlanTypemapping lives in the CLI; the env-specific Stripe price ids stay server-side.ApiV2Client; unwraps the apiv2{ data }response envelope (eas-cli'sApiV2Clientreturns the raw body, unlike the website client).openinstead ofbetter-opn:better-opnruns the URL throughencodeURI, which double-encodes Stripe's already-percent-encoded checkout fragment (%2F→%252F) and breaks the link. The URL is always printed as a clickable fallback.AccountQuery.getSubscriptionAsyncfor the already-subscribed check.Test Plan
billingClient(envelope unwrapping),subscribe(plan mapping, already-subscribed guard, free-plan handling, non-interactive/JSON output, missing-URL error),manage(portal open, verbatim URL).yarn test src/billing src/commands/billing→ 10/10 pass.yarn typecheck,yarn lint,yarn fmt:checkclean.https://checkout.stripe.com/...URL with the fragment intact.