4 min readUpdated Mar 2, 2026

BuyCreditsModal Documentation

Overview

The BuyCreditsModal component is an essential part of the Vantage analytics and data platform. Its primary purpose is to facilitate the purchase of credits (tokens) by users, enabling them to access various features within the platform. The modal provides a two-step purchasing flow:

  1. Tier Selection: Users can select a specific pricing tier for tokens.
  2. Stripe Embedded Checkout: Once a tier is selected, the user is taken through an embedded Stripe checkout process to complete the transaction.

Upon successful payment, the tokens are immediately credited to the user's account.

Settings

The BuyCreditsModal accepts several props that control its behavior and appearance. Below is a comprehensive list of each setting:

1. open

2. onClose

3. tiers

4. clientId

5. onPurchase

6. message

Functionality

Data Expectations

The BuyCreditsModal expects certain data constructs:

json
[
  {
    "price": 10.0,
    "priceId": "tier_123456",
    "tokens": 100
  },
  {
    "price": 25.0,
    "priceId": "tier_789012",
    "tokens": 300
  }
]

Use Cases & Examples

Use Case 1: Token Purchase for Usage Tracking

A company utilizes Vantage to track user interactions within their application. They require users to purchase tokens to access premium analytical features.

Use Case 2: Dynamic Pricing Adjustments

A marketing team wants to run a promotion where they offer discounted token tiers for a limited time.

Example Configuration

To implement Use Case 1, the BuyCreditsModal could be configured as follows to set pricing tiers and proper callbacks:

jsx
const tiers = [
    { price: 10.00, priceId: "tier_001", tokens: 100 },
    { price: 20.00, priceId: "tier_002", tokens: 250 },
    { price: 50.00, priceId: "tier_003", tokens: 600 }
];

<BuyCreditsModal
    open={true}
    onClose={() => console.log('Modal closed')}
    tiers={tiers}
    clientId={"client_abc_123"}
    onPurchase={() => console.log('Purchase successful!')}
    message="Purchase tokens to unlock premium features."
/>

This configuration would create a modal where users can choose between different tiers of token purchases, each associated with the necessary payment processing details.