# Wallet, ledger, invoices and deposits

Read your prepaid balance and transaction history, download invoices and start a wallet top-up through a payment gateway — all amounts in integer cents.

- Canonical: https://fineproxy.org/developers/docs/guides/wallet/

Every purchase, renewal and paid change is charged to your prepaid **wallet**, and every refund goes back to it. This guide shows how to read the balance and the ledger, find invoices, and start a deposit that you or your customer then pays in the browser.

All money values are **integer cents** in the wallet currency (USD): `1200` means $12.00, negative amounts are debits. Scopes: `wallet:read` for balance, ledger and invoices; `wallet:deposit` to start a top-up.

## Check the balance

```bash
curl https://fineproxy.org/account_new/api/v1/customer/wallet/balance \
  -H "Authorization: Bearer $FINEPROXY_API_KEY"
```

```javascript
const response = await fetch('https://fineproxy.org/account_new/api/v1/customer/wallet/balance', {
  headers: { Authorization: `Bearer ${process.env.FINEPROXY_API_KEY}` },
});
const { balance_cents, currency } = await response.json();
console.log(`${(balance_cents / 100).toFixed(2)} ${currency}`);
```

```python
import os
import requests

response = requests.get(
    "https://fineproxy.org/account_new/api/v1/customer/wallet/balance",
    headers={"Authorization": f"Bearer {os.environ['FINEPROXY_API_KEY']}"},
    timeout=30,
)
response.raise_for_status()
wallet = response.json()
print(f"{wallet['balance_cents'] / 100:.2f} {wallet['currency']}")
```

```json
{
  "wallet_id": "00000000-0000-0000-0000-000000000000",
  "owner_type": "customer",
  "balance_cents": 5000,
  "currency": "USD",
  "has_wallet": true
}
```

`has_wallet: false` means no wallet exists yet and `balance_cents` is `0`. Check the balance before any paid call; a purchase the wallet cannot cover fails with `402` and changes nothing.

Reference: [Get balance](/developers/docs/api/wallet/#get-get-balance). MCP: [`wallet_balance`](/developers/docs/mcp/tools/#wallet_balance).

## Read the ledger

`GET /api/v1/customer/wallet/ledger` lists completed money movements, newest first. Paginate with `offset` and `limit` (1–200, default 50); `total` is the number of entries.

```bash
curl "https://fineproxy.org/account_new/api/v1/customer/wallet/ledger?limit=5&offset=0" \
  -H "Authorization: Bearer $FINEPROXY_API_KEY"
```

```javascript
async function* ledgerEntries(pageSize = 50) {
  for (let offset = 0; ; offset += pageSize) {
    const url = `https://fineproxy.org/account_new/api/v1/customer/wallet/ledger?limit=${pageSize}&offset=${offset}`;
    const response = await fetch(url, { headers: { Authorization: `Bearer ${process.env.FINEPROXY_API_KEY}` } });
    const page = await response.json();
    yield* page.entries;
    if (offset + page.entries.length >= page.total) return;
    await new Promise((resolve) => setTimeout(resolve, 1000));
  }
}

for await (const entry of ledgerEntries()) console.log(entry.created_at, entry.amount_cents, entry.description);
```

```python
import os
import time
import requests


def ledger_entries(page_size=50):
    offset = 0
    while True:
        response = requests.get(
            "https://fineproxy.org/account_new/api/v1/customer/wallet/ledger",
            params={"limit": page_size, "offset": offset},
            headers={"Authorization": f"Bearer {os.environ['FINEPROXY_API_KEY']}"},
            timeout=30,
        )
        response.raise_for_status()
        page = response.json()
        yield from page["entries"]
        offset += len(page["entries"])
        if not page["entries"] or offset >= page["total"]:
            return
        time.sleep(1)


for entry in ledger_entries():
    print(entry["created_at"], entry["amount_cents"], entry["description"])
```

Two real entries — a purchase and a refund:

```json
{
  "entries": [
    {
      "id": "00000000-0000-0000-0000-000000000001",
      "wallet_id": "00000000-0000-0000-0000-000000000000",
      "idempotency_key": "rotating_cancel_refund:00000000-0000-0000-0000-000000000002:2026-11-27#s1",
      "provider": null,
      "provider_tx_id": null,
      "amount_cents": 3500,
      "balance_after_cents": 10000,
      "entry_type": "refund",
      "status": "completed",
      "description": "Rotating cancel refund: DC Rotating 2500k requests (package=3500, topup=0)",
      "service_id": "00000000-0000-0000-0000-000000000002",
      "usage_requests": null,
      "usage_bytes": null,
      "created_at": "2026-11-27T10:04:47.926477Z",
      "auto_topup": false
    },
    {
      "id": "00000000-0000-0000-0000-000000000003",
      "wallet_id": "00000000-0000-0000-0000-000000000000",
      "idempotency_key": "svc_create:...",
      "provider": null,
      "provider_tx_id": null,
      "amount_cents": -3500,
      "balance_after_cents": 6500,
      "entry_type": "debit",
      "status": "completed",
      "description": "Purchase: Rotating Proxies 2.5M Credits",
      "service_id": "00000000-0000-0000-0000-000000000002",
      "usage_requests": null,
      "usage_bytes": null,
      "created_at": "2026-11-27T10:04:24.239082Z",
      "auto_topup": false
    }
  ],
  "total": 9,
  "offset": 0,
  "limit": 5
}
```

| Field | Meaning |
| --- | --- |
| `amount_cents` | Signed amount: negative for debits, positive for credits and refunds. |
| `balance_after_cents` | Running balance right after this entry. |
| `entry_type` | Seen values: `debit`, `refund`, `correction` (manual adjustment). |
| `status` | `completed` for settled entries. |
| `description` | Human-readable reason, such as `Composite purchase (balance): …`, `Renew: …`, `Period renewal: …`. |
| `service_id` | The service the entry belongs to, or `null`. |
| `provider`, `provider_tx_id` | Payment provider details for deposits. |
| `idempotency_key` | Server-side key of the operation; one operation never produces two entries. |
| `auto_topup` | `true` when the credit came from an automatic top-up of a saved card. |

The ledger is the source of truth for money: reconcile against it rather than against webhook events or API responses alone.

Reference: [List ledger](/developers/docs/api/wallet/#get-list-ledger). MCP: [`list_ledger`](/developers/docs/mcp/tools/#list_ledger).

## Invoices

Two sources exist:

- **Invoices of the current billing system** — list them with the MCP tool [`list_invoices`](/developers/docs/mcp/tools/#list_invoices) (or fetch one with [`get_invoice`](/developers/docs/mcp/tools/#get_invoice)). Each invoice has `lago_id`, `number`, `issuing_date`, `status` (for example `finalized`), `payment_status` (`pending`, `succeeded`, `failed`), `total_amount_cents`, `currency` and `pdf_download_url`.
- **Archived invoices from the previous billing system** — `GET /api/v1/customer/me/whmcs-invoices`, paginated with `offset` and `limit` (1–200). Each item has `invoice_num`, `status`, `invoice_date`, `due_date`, `date_paid`, `total_cents`, `currency` and `payment_method`. An account without history gets `"items": []`.

```bash
curl "https://fineproxy.org/account_new/api/v1/customer/me/whmcs-invoices?limit=50" \
  -H "Authorization: Bearer $FINEPROXY_API_KEY"
```

Download an invoice PDF with the same API key. Pass the invoice's `lago_id` as `invoice_id`, and build the URL from the REST base URL:

```bash
curl -o invoice.pdf \
  "https://fineproxy.org/account_new/api/v1/customer/invoices/$INVOICE_ID/pdf" \
  -H "Authorization: Bearer $FINEPROXY_API_KEY"
```

An unknown ID returns `404 {"detail":"Invoice not found"}`.

References: [List archived invoices](/developers/docs/api/wallet/#get-list-whmcs-invoices), [Download invoice PDF](/developers/docs/api/wallet/#get-download-the-pdf-for-a-specific-invoice).

## Top up the wallet

A deposit is started through the API but **paid by a person** on the payment provider's page. The API returns a checkout link; the wallet is credited only after the provider confirms the payment.

### 1. Pick a gateway

`POST .../deposit/init` accepts the gateways `stripe`, `heleket`, `freekassa` and `onepayment`. The MCP tool [`list_payment_gateways`](/developers/docs/mcp/tools/#list_payment_gateways) shows which ones your account can use right now:

```json
{
  "gateways": [
    { "provider": "heleket", "kyc_required_level": "off", "kyc_ok": true, "payer_fee_bps": 0 },
    { "provider": "stripe", "kyc_required_level": "liveness", "kyc_ok": false, "payer_fee_bps": 0 }
  ]
}
```

A gateway with `kyc_ok: false` needs identity verification first.

### 2. Start the deposit

```bash
curl -X POST https://fineproxy.org/account_new/api/v1/customer/wallet/deposit/init \
  -H "Authorization: Bearer $FINEPROXY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"gateway": "heleket", "amount_cents": 1000, "idempotency_key": "deposit-2026-11-27-001"}'
```

```javascript
const response = await fetch('https://fineproxy.org/account_new/api/v1/customer/wallet/deposit/init', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.FINEPROXY_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ gateway: 'heleket', amount_cents: 1000, idempotency_key: 'deposit-2026-11-27-001' }),
});
if (!response.ok) throw new Error(`Deposit init failed ${response.status}: ${await response.text()}`);
const deposit = await response.json();
console.log('Open this page to pay:', deposit.payment_url, deposit.our_order_id);
```

```python
response = requests.post(
    "https://fineproxy.org/account_new/api/v1/customer/wallet/deposit/init",
    headers={"Authorization": f"Bearer {os.environ['FINEPROXY_API_KEY']}"},
    json={"gateway": "heleket", "amount_cents": 1000, "idempotency_key": "deposit-2026-11-27-001"},
    timeout=30,
)
response.raise_for_status()
deposit = response.json()
print("Open this page to pay:", deposit["payment_url"], deposit["our_order_id"])
```

```json
{
  "payment_url": "https://checkout.example.com/invoice/00000000-0000-0000-0000-000000000000",
  "our_order_id": "HLK-0000000000000000",
  "amount_cents": 1000,
  "currency": "USD",
  "provider_tx_id": "00000000-0000-0000-0000-000000000000",
  "checkout_kind": "redirect",
  "pay_address": null,
  "pay_amount": null,
  "pay_currency": null
}
```

| Body field | Notes |
| --- | --- |
| `gateway` | Required. One of the gateways above. |
| `amount_cents` | Required, greater than 0. `1000` = $10.00. |
| `idempotency_key` | Recommended. A repeat with the same key returns the original payment instead of creating a new one. |
| `currency` | Three letters, default `USD`. |
| `success_url`, `return_url` | Optional relative paths (starting with `/`) to send the payer back to after payment or cancellation. |

With `checkout_kind: "redirect"`, send the payer to `payment_url`. Keep `our_order_id` to track the payment.

### 3. Wait for the credit

Poll the ledger or the balance until the deposit appears, or subscribe to the `deposit.completed` [webhook](/developers/docs/guides/webhooks/). Over MCP, [`get_deposit_status`](/developers/docs/mcp/tools/#get_deposit_status) takes `our_order_id` as `order_id`, and [`list_payments`](/developers/docs/mcp/tools/#list_payments) shows all attempts, including pending and abandoned ones that never reach the ledger.

> **Important:** A `200` from `deposit/init` only means a checkout was created. No money has moved until the payer completes the payment and the ledger shows the credit.

### Verification (KYC)

Some gateways require identity verification first. Without it, `deposit/init` returns `403` and creates no payment:

```json
{
  "detail": {
    "error": "kyc_required",
    "required_level": "liveness",
    "kyc_status": "not_started",
    "verification_url": "/kyc",
    "message": "Identity verification is required before using this payment method. Complete a quick liveness check, then try again. Cryptocurrency deposits usually do not require verification."
  }
}
```

Complete verification in the dashboard or choose another gateway.

### Crypto helper endpoints

Two read-only endpoints support crypto top-ups: `GET .../deposit/nowpayments/coins` lists the allowed coin tickers (the network is part of the ticker, such as `usdttrc20`), and `GET .../deposit/nowpayments/quote?pay_currency=<ticker>&amount_cents=<n>` returns `pay_amount`, `price_amount`, `minimum_usd` and `minimum_met`. The quote creates no payment. The query parameter is `pay_currency`; `currency` is rejected with `422`.

These endpoints depend on an external provider and can return `503` while it is unavailable — retry later or use another gateway:

```json
{
  "detail": {
    "error": "nowpayments_unavailable",
    "message": "The payment method is temporarily unavailable. Please try again."
  }
}
```

References: [Init deposit](/developers/docs/api/wallet/#post-init-deposit), [Coins](/developers/docs/api/wallet/#get-list-nowpayments-coins), [Crypto quote](/developers/docs/api/wallet/#get-get-nowpayments-quote). MCP: [`init_deposit`](/developers/docs/mcp/tools/#init_deposit).

## MCP wallet tools

| Tool | Purpose |
| --- | --- |
| [`wallet_balance`](/developers/docs/mcp/tools/#wallet_balance) | Balance in cents. |
| [`list_ledger`](/developers/docs/mcp/tools/#list_ledger) | Ledger with `offset` / `limit`. |
| [`list_invoices`](/developers/docs/mcp/tools/#list_invoices), [`get_invoice`](/developers/docs/mcp/tools/#get_invoice) | Invoices with `pdf_download_url`. |
| [`list_payment_gateways`](/developers/docs/mcp/tools/#list_payment_gateways) | Gateways and their verification requirements. |
| [`init_deposit`](/developers/docs/mcp/tools/#init_deposit) | Start a top-up; requires `idempotency_key`. Returns a `payment_url` for a person to open. |
| [`get_deposit_status`](/developers/docs/mcp/tools/#get_deposit_status), [`list_payments`](/developers/docs/mcp/tools/#list_payments) | Track pending top-ups. |

## Common pitfalls

- **Treating cents as dollars.** `balance_cents: 5000` is $50.00.
- **Assuming a deposit succeeded** because `deposit/init` returned `200`. Wait for the ledger entry.
- **Retrying `deposit/init` without an idempotency key**, which creates a second checkout.
- **Confusing `pricing-info` millicents with cents.** Only `price_millicents_per_ip` in the pricing terms uses millicents.
