)}
/>
+
+ (
+
+ {t('Default top-up amount')}
+
+
+
+
+ {t(
+ 'Initial amount shown in the top-up input before the user edits it.'
+ )}
+
+
+
+ )}
+ />
{
if (topupInfo && topupAmount === 0) {
- const minTopup = getMinTopupAmount(topupInfo)
- setTopupAmount(minTopup)
+ const defaultTopupAmount = getDefaultCustomTopupAmount(topupInfo)
+ setTopupAmount(defaultTopupAmount)
// Calculate initial payment amount with default payment type
const defaultPaymentType = getDefaultPaymentType(topupInfo)
- calculatePaymentAmount(minTopup, defaultPaymentType)
+ calculatePaymentAmount(defaultTopupAmount, defaultPaymentType)
}
}, [topupInfo, topupAmount, calculatePaymentAmount])
diff --git a/web/default/src/features/wallet/lib/payment.ts b/web/default/src/features/wallet/lib/payment.ts
index 84d1a20e7ce7..c834ee3837cd 100644
--- a/web/default/src/features/wallet/lib/payment.ts
+++ b/web/default/src/features/wallet/lib/payment.ts
@@ -21,6 +21,7 @@ import {
DEFAULT_PRESET_MULTIPLIERS,
DEFAULT_PAYMENT_TYPE,
DEFAULT_MIN_TOPUP,
+ DEFAULT_CUSTOM_TOPUP_AMOUNT,
} from '../constants'
import type { PresetAmount, TopupInfo } from '../types'
@@ -141,6 +142,24 @@ export function getMinTopupAmount(topupInfo: TopupInfo | null): number {
return DEFAULT_MIN_TOPUP
}
+/**
+ * Get the default custom topup amount shown in the input field.
+ * Prefer 100 by default, but never go below the active minimum topup.
+ */
+export function getDefaultCustomTopupAmount(
+ topupInfo: TopupInfo | null
+): number {
+ const minTopup = getMinTopupAmount(topupInfo)
+ const normalizedMinTopup =
+ Number.isFinite(minTopup) && minTopup > 0 ? minTopup : DEFAULT_MIN_TOPUP
+ const configuredDefault = Number(topupInfo?.default_topup_amount)
+ const normalizedConfiguredDefault =
+ Number.isFinite(configuredDefault) && configuredDefault > 0
+ ? configuredDefault
+ : DEFAULT_CUSTOM_TOPUP_AMOUNT
+ return Math.max(normalizedConfiguredDefault, normalizedMinTopup)
+}
+
/**
* Generate preset amounts based on minimum topup
*/
diff --git a/web/default/src/features/wallet/types.ts b/web/default/src/features/wallet/types.ts
index f4ab21937323..53b50d165c0e 100644
--- a/web/default/src/features/wallet/types.ts
+++ b/web/default/src/features/wallet/types.ts
@@ -134,6 +134,8 @@ export interface TopupInfo {
amount_options: number[]
/** Discount rates by amount */
discount: Record
+ /** Default amount shown before the user edits the top-up input */
+ default_topup_amount?: number
/** Optional topup link for purchasing codes */
topup_link?: string
/** Whether Creem topup is enabled */
diff --git a/web/default/src/i18n/locales/en.json b/web/default/src/i18n/locales/en.json
index 6b4c5970302c..711c7735c231 100644
--- a/web/default/src/i18n/locales/en.json
+++ b/web/default/src/i18n/locales/en.json
@@ -1106,6 +1106,7 @@
"Default system prompt for this channel": "Default system prompt for this channel",
"Default time granularity": "Default time granularity",
"Default to auto groups": "Default to auto groups",
+ "Default top-up amount": "Default top-up amount",
"Default TTL (seconds)": "Default TTL (seconds)",
"Defaults to the wallet page when empty": "Defaults to the wallet page when empty",
"Define API endpoints for this model (JSON format)": "Define API endpoints for this model (JSON format)",
@@ -2022,6 +2023,7 @@
"Includes request rules": "Includes request rules",
"Including failed requests, 0 = unlimited": "Including failed requests, 0 = unlimited",
"Index": "Index",
+ "Initial amount shown in the top-up input before the user edits it.": "Initial amount shown in the top-up input before the user edits it.",
"Initial quota given to new users": "Initial quota given to new users",
"Initialization failed, please try again.": "Initialization failed, please try again.",
"Initialize": "Initialize",
diff --git a/web/default/src/i18n/locales/fr.json b/web/default/src/i18n/locales/fr.json
index c9046cd5e06d..c9512f330959 100644
--- a/web/default/src/i18n/locales/fr.json
+++ b/web/default/src/i18n/locales/fr.json
@@ -1106,6 +1106,7 @@
"Default system prompt for this channel": "Invite système par défaut pour ce canal",
"Default time granularity": "Granularité temporelle par défaut",
"Default to auto groups": "Par défaut aux groupes automatiques",
+ "Default top-up amount": "Montant de recharge par défaut",
"Default TTL (seconds)": "TTL par défaut (secondes)",
"Defaults to the wallet page when empty": "Si vide, la page portefeuille est utilisée par défaut",
"Define API endpoints for this model (JSON format)": "Définir les points de terminaison API pour ce modèle (format JSON)",
@@ -2022,6 +2023,7 @@
"Includes request rules": "Inclut des règles de requête",
"Including failed requests, 0 = unlimited": "Y compris les requêtes échouées, 0 = illimité",
"Index": "Index",
+ "Initial amount shown in the top-up input before the user edits it.": "Montant initial affiché dans le champ de recharge avant modification par l'utilisateur.",
"Initial quota given to new users": "Quota initial donné aux nouveaux utilisateurs",
"Initialization failed, please try again.": "L'initialisation a échoué, veuillez réessayer.",
"Initialize": "Initialiser",
diff --git a/web/default/src/i18n/locales/ja.json b/web/default/src/i18n/locales/ja.json
index 51b77317d3ee..208f185cb4c7 100644
--- a/web/default/src/i18n/locales/ja.json
+++ b/web/default/src/i18n/locales/ja.json
@@ -1106,6 +1106,7 @@
"Default system prompt for this channel": "このチャンネルのデフォルトのシステムプロンプト",
"Default time granularity": "デフォルトの時間粒度",
"Default to auto groups": "デフォルトで自動グループ化",
+ "Default top-up amount": "デフォルトのチャージ金額",
"Default TTL (seconds)": "デフォルト TTL(秒)",
"Defaults to the wallet page when empty": "空欄の場合はウォレットページを既定にします",
"Define API endpoints for this model (JSON format)": "このモデルのAPIエンドポイントを定義します (JSON形式)",
@@ -2022,6 +2023,7 @@
"Includes request rules": "リクエストルールを含む",
"Including failed requests, 0 = unlimited": "失敗したリクエストを含む、0 = 無制限",
"Index": "インデックス",
+ "Initial amount shown in the top-up input before the user edits it.": "ユーザーが編集する前に、チャージ入力欄に最初に表示される金額です。",
"Initial quota given to new users": "新規ユーザーに付与される初期クォータ",
"Initialization failed, please try again.": "初期化に失敗しました。もう一度お試しください。",
"Initialize": "初期化",
diff --git a/web/default/src/i18n/locales/ru.json b/web/default/src/i18n/locales/ru.json
index 8362dc5e916a..aa65c53d7733 100644
--- a/web/default/src/i18n/locales/ru.json
+++ b/web/default/src/i18n/locales/ru.json
@@ -1106,6 +1106,7 @@
"Default system prompt for this channel": "Системный промпт по умолчанию для этого канала",
"Default time granularity": "Гранулярность времени по умолчанию",
"Default to auto groups": "По умолчанию использовать автогруппы",
+ "Default top-up amount": "Сумма пополнения по умолчанию",
"Default TTL (seconds)": "TTL по умолчанию (секунды)",
"Defaults to the wallet page when empty": "Если пусто, по умолчанию открывается страница кошелька",
"Define API endpoints for this model (JSON format)": "Определить конечные точки API для этой модели (формат JSON)",
@@ -2022,6 +2023,7 @@
"Includes request rules": "Включает правила запросов",
"Including failed requests, 0 = unlimited": "Включая неудачные запросы, 0 = без ограничений",
"Index": "Индекс",
+ "Initial amount shown in the top-up input before the user edits it.": "Начальная сумма, которая отображается в поле пополнения до редактирования пользователем.",
"Initial quota given to new users": "Начальная квота, предоставляемая новым пользователям",
"Initialization failed, please try again.": "Инициализация не удалась, попробуйте ещё раз.",
"Initialize": "Инициализировать",
diff --git a/web/default/src/i18n/locales/vi.json b/web/default/src/i18n/locales/vi.json
index 4fa8b74f33a1..b90397a1e0ff 100644
--- a/web/default/src/i18n/locales/vi.json
+++ b/web/default/src/i18n/locales/vi.json
@@ -1106,6 +1106,7 @@
"Default system prompt for this channel": "Lời nhắc hệ thống mặc định cho kênh này",
"Default time granularity": "Độ chi tiết thời gian mặc định",
"Default to auto groups": "Mặc định là nhóm tự động",
+ "Default top-up amount": "Số tiền nạp mặc định",
"Default TTL (seconds)": "TTL mặc định (giây)",
"Defaults to the wallet page when empty": "Để trống sẽ dùng trang ví mặc định",
"Define API endpoints for this model (JSON format)": "Định nghĩa các điểm cuối API cho mô hình này (định dạng JSON)",
@@ -2022,6 +2023,7 @@
"Includes request rules": "Bao gồm quy tắc yêu cầu",
"Including failed requests, 0 = unlimited": "Bao gồm các yêu cầu thất bại, 0 = không giới hạn",
"Index": "Chỉ mục",
+ "Initial amount shown in the top-up input before the user edits it.": "Số tiền ban đầu hiển thị trong ô nạp tiền trước khi người dùng chỉnh sửa.",
"Initial quota given to new users": "Hạn mức ban đầu cấp cho người dùng mới",
"Initialization failed, please try again.": "Khởi tạo thất bại, vui lòng thử lại.",
"Initialize": "Khởi tạo",
diff --git a/web/default/src/i18n/locales/zh.json b/web/default/src/i18n/locales/zh.json
index e198228d45c7..c8a27549d2c1 100644
--- a/web/default/src/i18n/locales/zh.json
+++ b/web/default/src/i18n/locales/zh.json
@@ -1106,6 +1106,7 @@
"Default system prompt for this channel": "此渠道的默认系统提示",
"Default time granularity": "默认时间粒度",
"Default to auto groups": "默认使用自动分组",
+ "Default top-up amount": "默认充值金额",
"Default TTL (seconds)": "默认 TTL(秒)",
"Defaults to the wallet page when empty": "为空时默认使用钱包页面",
"Define API endpoints for this model (JSON format)": "为此模型定义 API 端点(JSON 格式)",
@@ -2022,6 +2023,7 @@
"Includes request rules": "包含请求规则",
"Including failed requests, 0 = unlimited": "包括失败的请求,0 = 无限制",
"Index": "索引",
+ "Initial amount shown in the top-up input before the user edits it.": "用户进入充值页时输入框默认显示的金额",
"Initial quota given to new users": "授予新用户的初始配额",
"Initialization failed, please try again.": "初始化失败,请重试。",
"Initialize": "初始化",