Documentation Index
Fetch the complete documentation index at: https://docs.flexprice.io/llms.txt
Use this file to discover all available pages before exploring further.
Overview
What is wallet conversion rate?
Wallet conversion rate tells you how much money one credit is worth in your wallet’s currency.- The wallet stores balance in credits only. Currency is used only for calculation and display. Formula: amount in currency = credits × conversion rate.
- Example: Conversion rate 0.01, wallet in USD. Then 1 credit = 0.01 USD. So 100 credits = 1 USD, and 1000 credits show as a 10 USD balance.
- You can set two rates on a wallet:
- Conversion rate — used when you spend (debit) and when balance is shown in currency.
- Top-up conversion rate — used only when you add credits (top-up). If you don’t set it, top-ups use conversion rate.
What is conversion rate?
It is the number that links your unit to base currency. It appears in two places:| Field | Purpose |
|---|---|
conversion_rate | Links stored credits to currency (for display and when user spends). Wallet stores balance in credits; currency is worked out from this. Formula: amount in currency = credits × conversion_rate. Default: "1". |
topup_conversion_rate | Same formula; used only for top-ups. If you do not set it, the wallet uses conversion_rate for top-ups. |
How it works internally
- Price unit: Has
base_currencyandconversion_rate. Billing converts price unit amounts into that base currency for invoicing. - Wallet: Balance is stored in credits. To show it in currency: amount = credits × conversion rate.
When conversion is used
Wallet top-up (amount to credits)
Uses
topup_conversion_rate (or conversion_rate if not set). If you send amount and not credits_to_add, credits = amount ÷ rate. If both are sent, credits_to_add wins and amount is ignored.Wallet debit (currency to credits)
Uses
conversion_rate (e.g. invoice payment). Manual debit uses credits directly; no conversion.Conversion during credit
Top-up by amount
Send
amount (in wallet currency). System works out credits_to_add = amount ÷ topup_conversion_rate and adds that many credits to the wallet.Conversion during debit
Invoice payment
Amount in currency is turned into credits:
credits = amount ÷ conversion_rate. That many credits are taken out.Configuration
Set conversion rate on a wallet
Set conversion rate via API
Create wallet
POST /v1/wallets — send currency (required), conversion_rate (optional, default "1"), topup_conversion_rate (optional), or price_unit (then currency and conversion_rate come from the price unit).Create wallet with explicit rates:Validation
- Wallet:
conversion_ratedefaults to"1". If you set it, it must be > 0.topup_conversion_ratemust be > 0 if you set it. When you useprice_unit, that price unit must be Active.
Use cases
Promotional top-up
Set
topup_conversion_rate so users get more credits per 1 USD. conversion_rate is still used for spending and for showing balance.Edge cases
| Case | What happens |
|---|---|
| Missing or zero rate | Price unit: request fails. Wallet: conversion_rate can default to "1". Best: send a valid rate or use price_unit. |
| Invalid or negative rate | Request fails. Rate must be > 0. |
| Top-up: amount and credits both sent | credits_to_add is used. amount is ignored. |
| Wallet with price_unit | conversion_rate in the request is ignored. Currency and rate come from the price unit. |
Examples
Wallet
conversion_rate = "0.01". So 1 credit = 0.01 USD. Top-up 10 USD (same top-up rate) adds 1000 credits. Manual debit 500 credits takes out 5 USD worth.


