Skip to content

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.

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",
});
const grant = yield* Stripe.CreditGrant("welcome-credits", {
customer: customer.id,
amount: { type: "monetary", monetary: { currency: "usd", value: 1000 } },
expiresAt: 4102444800,
metadata: { campaign: "spring" },
});
// stack.destroy() / resource removal calls void
const grant = yield* Stripe.CreditGrant("welcome-credits", {
customer: customer.id,
amount: { type: "monetary", monetary: { currency: "usd", value: 1000 } },
});