Credit packs
Offer one-time credit purchases to subscribed customers
A credit pack lets a customer buy more credits for an existing subscription. Each pack belongs to a plan and defines how much one block of credits costs. A completed purchase adds a credit grant to the subscription.
How credit packs work
A pack has four main parts:
For example, money_minor: "100" and unit_amount: "2500" means the customer pays $1.00 for 2,500 credits when the plan uses USD.
Grant calculates the purchase total from the selected credit quantity and rounds the result to the plan currency’s smallest unit.
Before you begin
In the Grant dashboard:
- Create the pricing unit that the pack will grant.
- Add the pricing unit to a billing plan.
- Create a credit pack on that plan and set its price and optional expiry.
- Make sure the customer has an
active,trialing, orpast_duesubscription to the same plan.
Use the pack’s id in API calls. Pack codes are labels for people and are not accepted in place of credit_pack_id.
1. List a plan’s credit packs
Use the plan ID to find every pack available for that plan.
See List credit packs for the full response.
2. Retrieve one pack
Fetch a pack by ID when you need to show its price or confirm its expiry rules.
3. Create a checkout link
Credit packs are bought through a hosted checkout page. Create a link for the customer’s subscription, then send its URL to that customer. Each link expires 24 hours after creation and completes after one purchase.
Set the quantity
Pass quantity when you know how many credits the customer will buy. The value is a number of pricing units, not a number of pack bundles.
The hosted page shows the fixed credit amount and its total price. The pack must belong to the subscription’s plan.
Let the customer choose
Omit quantity, or pass null, to let the customer choose a purchase amount on the hosted page. Grant shows how many credits that amount buys at the pack’s rate.
Use the returned URL
The response includes the hosted checkout URL and its expiry time.
Send credit_pack_checkout_link.url to the customer tied to the subscription. Do not put the URL in public pages, logs, or analytics events because it contains the checkout token.
See Create a credit pack checkout link for the full request and response.
Redirect the customer
Both redirect fields are optional and must use HTTP or HTTPS:
success_urlsends the customer back to your app after Grant confirms the purchase.back_urlsets the destination of the back action on the hosted page.
Do not treat the browser redirect as proof of payment. Read the customer’s credit balances from your server when your app needs the current balance.
What happens after payment
- Grant attaches the payment method to the customer.
- Grant creates, finalizes, and charges a one-time invoice.
- Grant adds a credit grant to the subscription for the purchased quantity.
- The link changes to
completed. A later visit shows that it has already been used. - If
success_urlis set, the hosted page sends the customer there.
If a payment fails, the customer can try again while the link remains valid. Create a new link after it expires.
Good practices
- Store
credit_pack_idwith your own product or purchase option so you do not need to match on display text. - Read
money_minorandunit_amountas strings to avoid losing precision in languages with limited integer sizes. - Show the pricing unit and expiry before sending a customer to checkout.
- Create links only from your server, after it has chosen the subscription and
credit_pack_id. - Use HTTPS redirect URLs in production.
- Treat the checkout URL as a secret until it expires or completes.
