---
updatedAt: 2026-01-26T16:05:52.000Z
agentTools:
  projectIndex: https://docs.bitrefill.com/llms.txt
---

# Core Concepts

Understand products, invoices, orders, and eSIMs before you start building.

Before diving into the API, understand these core concepts that form the foundation of every Bitrefill integration.

## Products

A **product** represents something you can purchase — a gift card brand, mobile operator, or eSIM plan.

```json
{
  "id": "amazon-us",
  "name": "Amazon US",
  "type": "gift_card",
  "country": "US",
  "currency": "USD"
}
```

Products define *what* you can buy, but not *how much*. That's where denominations come in.

### Denominations: Packages vs Ranges

Products offer denominations in two ways:

#### Packages (Fixed Values)

Some products have fixed denominations. You must purchase one of the available values.

```json
{
  "packages": [
    { "package_id": "amazon-us<&>25", "value": 25 },
    { "package_id": "amazon-us<&>50", "value": 50 },
    { "package_id": "amazon-us<&>100", "value": 100 }
  ]
}
```

To purchase, use the `package_id` in your invoice request.

#### Ranges (Flexible Values)

Other products accept any value within a range.

```json
{
  "range": {
    "min": 10,
    "max": 200,
    "step": 1
  }
}
```

* `min` — Minimum purchase amount
* `max` — Maximum purchase amount
* `step` — Allowed increment (e.g., step of 5 means you can buy 10, 15, 20... not 12)

To purchase, specify the `value` directly in your invoice request.

<Callout theme="info">
  Some products have both packages AND a range. You can use either approach.
</Callout>

### Product Types

| Type           | Description                            | Example                 |
| -------------- | -------------------------------------- | ----------------------- |
| `gift_card`    | Digital gift card with redemption code | Amazon, Steam, Netflix  |
| `phone_refill` | Mobile airtime/data top-up             | AT\&T, Vodafone, Orange |
| `esim`         | Digital SIM with data plan             | Bitrefill eSIM Europe   |
| `bill_payment` | Utility or service payment             | Regional utilities      |

## Invoices

An **invoice** is a payment request for one or more products. Creating an invoice is the first step in making a purchase.

```json
{
  "id": "inv_abc123",
  "status": "unpaid",
  "payment": {
    "method": "bitcoin",
    "address": "bc1q...",
    "price": 0.00123456
  },
  "orders": [
    { "id": "ord_xyz789", "status": "created" }
  ]
}
```

### Invoice Statuses

| Status              | Meaning                                        |
| ------------------- | ---------------------------------------------- |
| `unpaid`            | Waiting for payment                            |
| `payment_detected`  | Payment seen on network, awaiting confirmation |
| `payment_confirmed` | Payment confirmed                              |
| `pending`           | Processing orders                              |
| `complete`          | All orders delivered                           |
| `blocked`           | Fraud check failed                             |
| `denied`            | Payment rejected                               |
| `payment_error`     | Payment processing error                       |

### Invoice Flow

```mermaid
stateDiagram-v2
    [*] --> unpaid: Invoice created
    unpaid --> payment_detected: Payment seen
    payment_detected --> payment_confirmed: Confirmations received
    payment_confirmed --> pending: Processing
    pending --> complete: All delivered
    unpaid --> denied: Rejected
    payment_detected --> payment_error: Error
```

### Multiple Products per Invoice

An invoice can contain multiple products. Each product becomes a separate **order** within the invoice.

```json
{
  "products": [
    { "product_id": "amazon-us", "value": 50 },
    { "product_id": "spotify-us", "package_id": "spotify-us<&>10" },
    { "product_id": "steam-us", "value": 25, "quantity": 2 }
  ]
}
```

This creates one invoice with 4 orders (2 Steam cards due to `quantity: 2`).

## Orders

An **order** represents a single product purchase within an invoice. When an invoice is paid, each order is processed and delivered individually.

```json
{
  "id": "ord_xyz789",
  "status": "delivered",
  "product": {
    "id": "amazon-us",
    "name": "Amazon US",
    "value": 50
  },
  "redemption_info": {
    "code": "ABCD-EFGH-IJKL",
    "link": "https://redeem.amazon.com/..."
  }
}
```

### Order Statuses

| Status             | Meaning                                          |
| ------------------ | ------------------------------------------------ |
| `created`          | Order created, awaiting payment                  |
| `payment_detected` | Payment in progress                              |
| `processing`       | Being fulfilled                                  |
| `delivered`        | Successfully delivered — check `redemption_info` |
| `failed`           | Delivery failed — check error message            |
| `refunded`         | Payment returned                                 |

### Redemption Info

Once an order is `delivered`, the `redemption_info` object contains what the end user needs:

| Field             | Description                       |
| ----------------- | --------------------------------- |
| `code`            | Gift card code to redeem          |
| `link`            | URL to redeem online              |
| `pin`             | PIN if required for redemption    |
| `instructions`    | Human-readable redemption steps   |
| `barcode_format`  | Barcode type (if applicable)      |
| `barcode_value`   | Value to encode as barcode        |
| `expiration_date` | When the code expires             |
| `extra_fields`    | Additional provider-specific info |

<Callout theme="warning">
  Not all products return the same fields. Gift cards typically have `code` or `link`. Phone top-ups may have no redemption info — the balance is added directly to the phone.
</Callout>

## eSIMs

eSIMs are digital SIM cards that provide mobile data without a physical SIM. They work differently from regular products.

### eSIM Products

eSIM products represent data plans for specific regions:

```json
{
  "id": "bitrefill-esim-europe",
  "name": "Bitrefill eSIM Europe",
  "packages": [
    { "package_id": "bitrefill-esim-europe<&>1GB, 7 Days", "value": "1GB, 7 Days" },
    { "package_id": "bitrefill-esim-europe<&>5GB, 30 Days", "value": "5GB, 30 Days" }
  ]
}
```

Note that eSIM package values are strings describing data and duration, not numbers.

### Initial Purchase vs Top-Up

* **Initial purchase** — Creates a new eSIM with a data bundle
* **Top-up** — Adds a data bundle to an existing eSIM

For top-ups, include the `esim_id` (ICCID) in your invoice request:

```json
{
  "product_id": "bitrefill-esim-europe",
  "value": "5GB, 30 Days",
  "esim_id": "4058965632381351147"
}
```

### eSIM Object

After purchase, you get an eSIM object:

```json
{
  "id": "4058965632381351147",
  "rsp_url": "...",
  "pin": "1234",
  "barcode_value": "LPA:1$...",
  "installed": false,
  "package_history": [
    {
      "package_name": "1GB, 7 Days",
      "data_mb": 1000,
      "status": "active",
      "remaining_quantity": 500000000
    }
  ]
}
```

Key fields:

| Field             | Description                               |
| ----------------- | ----------------------------------------- |
| `id`              | The ICCID (eSIM identifier)               |
| `rsp_url`         | SM-DP+ server address                     |
| `pin`             | Activation PIN                            |
| `barcode_value`   | QR code content for installation          |
| `installed`       | Whether the eSIM is installed on a device |
| `package_history` | All data bundles on this eSIM             |

<br />