feat(cli,sdk): redeem promo codes via billing top-up --code (RND-557)#135
Draft
mmurrs wants to merge 1 commit into
Draft
feat(cli,sdk): redeem promo codes via billing top-up --code (RND-557)#135mmurrs wants to merge 1 commit into
billing top-up --code (RND-557)#135mmurrs wants to merge 1 commit into
Conversation
Adds a --code flag to `ecloud billing top-up` so existing subscribers can apply a Stripe promotion code without going through the initial Checkout flow. Pairs with the new POST /products/:id/redeem endpoint on ecloud-billing-api (#41). SDK: - BillingApiClient.redeemCode() — thin POST wrapper - BillingModule.redeemCode() — telemetry-wrapped, product-aware - RedeemCodeRequest/RedeemCodeResponse types exported through common/types CLI: - New --code flag on the existing `billing top-up` command - Short-circuits before USDC flow when --code is set; USDC path unchanged - Friendly errors for 404 (bad/inactive code) and 422 (percent-off rejected) - Prints granted amount, new balance, and expiry in a single pass — agent-friendly, non-interactive, no prompts Tests: two vitest cases covering happy path and 404; all 55 existing billing tests still green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Adds
--codetoecloud billing top-upso existing subscribers can apply a Stripe promo code. Today there's no way to do this — the Stripe Checkout "Add code" box only shows on initial subscribe.Usage (agent-friendly, non-interactive, no prompts):
Pairs with API PR: https://github.com/Layr-Labs/ecloud-billing-api/pull/41
Scope
No changes to
subscribe,status,cancel, or the existing USDC top-up flow.--codeshort-circuits before any on-chain interaction, so nothing in the USDC path is touched.How to validate
Unit tests:
All 55 tests pass (including 2 new
--codecases).Manual dry-run (no Stripe needed):
End-to-end (against Stripe test mode + local billing-api from #41):
feat/redeem-codeonecloud-billing-apiandmake runwith a Stripe test key.TEST5,max_redemptions=1) in the Stripe Dashboard (test mode).pnpm --filter @layr-labs/ecloud-cli build✓ Redeemed TEST5: $5.00 in credits+ new balance + expiry.Code "TEST5" is not valid, inactive, or already redeemed.(because Promotion Code got deactivated after the first burn).Code "..." is not a fixed-amount credit code (percent-off codes are not supported).ecloud billing status—Remaining Creditsshould reflect the new amount.Not in this PR
Linear
RND-557 — https://linear.app/eigenlabs/issue/RND-557/add-couponcredit-code-redemption-to-ecloud-billing-top-up
🤖 Generated with Claude Code