Add Polar Builder billing and credit lifecycle - #15
Open
devhims wants to merge 2 commits into
Open
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
devhims
marked this pull request as ready for review
August 20, 2026 18:07
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
Payment and credit policy
A successful order.paid event activates Builder and tops the current balance up to the 20,000-credit monthly allowance. Unused credits carry forward, but a renewal does not increase a balance already at or above the allowance.
A fully refunded order downgrades the account to Starter and adjusts the ledger so the resulting balance equals the 1,000-credit Starter default.
Polar order IDs and webhook event IDs provide idempotency. Billing projection, credit adjustment, and event recording run in one D1 batch. Credit changes also verify that the webhook owns the latest billing state, preventing an older paid event from restoring credits after a newer refund.
Calendar time, checkout redirects, and customer-state synchronization never grant credits.
Architecture
Manual setup before deployment
Verification