> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bilalsadasub.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Buy eSIM

> Purchase an eSIM plan. Your wallet is debited at `price_ngn`. When `plan_status` is `0` the eSIM is still provisioning — poll My eSIMs (or wait for the webhook) until it becomes `1`. plan_status: 0 processing, 1 success, 2 failed (auto-refunded).

Purchases an eSIM plan and debits your wallet at `price_ngn`.

## Provisioning & status

eSIMs provision asynchronously, so read **`data.plan_status`**:

| `plan_status` | Meaning | What to do |
| - | - | - |
| `1` | Provisioned | `iccid`, `ac` and `qr_code` are ready — install now |
| `0` | Still provisioning | Poll [My eSIMs](https://docs.bilalsadasub.com/reference/esim-my.md) (or wait for the webhook) until it turns `1` |
| `2` | Failed | Wallet is **auto-refunded** |

## Installing the eSIM

Give the customer the **`qr_code`** image to scan, or the **`ac`** (an `LPA:1$...` activation string) to install manually.

> [!NOTE]
>
> Send a unique **`request-id`** to make retries safe — the same id returns the original purchase instead of charging again.


## OpenAPI

````yaml POST /api/esim/buy
openapi: 3.1.0
info:
  title: Bilalsadasub API
  version: 1.0.0
  description: >-
    Bilalsadasub developer API — buy data, airtime, cable, electricity, bulk
    SMS, exam pins, airtime-to-cash and flights, funded from your wallet.
servers:
  - url: https://bilalsadasub.com
    description: Production (live — charges your wallet)
security:
  - TokenAuth: []
tags:
  - name: Purchases
  - name: Verification
  - name: Betting
  - name: eSIM
  - name: Flights
  - name: Wallet
  - name: Catalogs
  - name: Account
paths:
  /api/esim/buy:
    post:
      tags:
        - eSIM
      summary: Buy eSIM
      description: >-
        Purchase an eSIM plan. Your wallet is debited at `price_ngn`. When
        `plan_status` is `0` the eSIM is still provisioning — poll My eSIMs (or
        wait for the webhook) until it becomes `1`. plan_status: 0 processing, 1
        success, 2 failed (auto-refunded).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                plan_id:
                  type: integer
                  description: eSIM plan ID from List eSIM Plans
                pin:
                  type: string
                  description: 4-digit transaction PIN (WEBSITE only, when enabled)
                request-id:
                  type: string
                  description: Optional unique idempotency key
              required:
                - plan_id
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  message:
                    type: string
                  data:
                    type: object
                    properties:
                      transid:
                        type: string
                        description: Transaction reference (use with Requery)
                      order_no:
                        type: string
                        description: Provider order number (may be null until provisioned)
                      iccid:
                        type: string
                        description: eSIM ICCID (null until provisioned)
                      ac:
                        type: string
                        description: Activation code / LPA string
                      qr_code:
                        type: string
                        description: QR code image URL for installation
                      newbal:
                        type: number
                        description: Wallet balance after the debit
                      plan_status:
                        type: integer
                        description: 0 processing, 1 success, 2 failed
              example:
                status: success
                message: USA 5GB / 30 Days purchased.
                data:
                  transid: ES_1a2b3c
                  order_no: B24101700001
                  iccid: '8910300000000123456'
                  ac: LPA:1$rsp.truphone.com$QR-G4-XXXX
                  qr_code: https://bilalsadasub.com/storage/esim/qr/ES_1a2b3c.png
                  newbal: 110225.5
                  plan_status: 1
components:
  securitySchemes:
    TokenAuth:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Send your API key as `Token <your_api_key>`.


        Use your **live key** for real transactions, or your **sandbox key**
        (`sk_test_…`) to test — sandbox calls return a realistic simulated
        result and never touch your wallet. Add `"sandbox_status": "fail"` to
        any sandbox request to simulate a failure.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.