CreditGrant
Source:
src/Stripe/CreditGrant.ts
A Stripe Credit Grant — prepaid or promotional billing credits allocated
to a customer and applied against metered prices. Amount, customer,
applicability, category, effective time, and priority are immutable;
changing them replaces the grant. expiresAt and metadata update in
place. Credit grants cannot be hard-deleted: destroying this resource
voids the grant (voided_at is set). Already-voided grants are treated
as success.
Creating a Credit Grant
Section titled “Creating a Credit Grant”Promotional credits for metered prices
const customer = yield* Stripe.Customer("alice", { email: "alice@example.com",});const grant = yield* Stripe.CreditGrant("welcome-credits", { customer: customer.id, amount: { type: "monetary", monetary: { currency: "usd", value: 1000 } }, applicabilityConfig: { scope: { priceType: "metered" } }, category: "promotional", name: "Welcome credits",});Paid credits scoped to specific prices
const grant = yield* Stripe.CreditGrant("prepaid", { customer: customer.id, amount: { type: "monetary", monetary: { currency: "usd", value: 5000 } }, applicabilityConfig: { scope: { prices: [{ id: price.id }] }, }, category: "paid",});Updating a Credit Grant
Section titled “Updating a Credit Grant”const grant = yield* Stripe.CreditGrant("welcome-credits", { customer: customer.id, amount: { type: "monetary", monetary: { currency: "usd", value: 1000 } }, expiresAt: 4102444800, metadata: { campaign: "spring" },});Voiding a Credit Grant
Section titled “Voiding a Credit Grant”// stack.destroy() / resource removal calls voidconst grant = yield* Stripe.CreditGrant("welcome-credits", { customer: customer.id, amount: { type: "monetary", monetary: { currency: "usd", value: 1000 } },});