Payment — TypeScript SDK
Recharge records, statistics, and per-model usage billing.
Overview
The Payment resource exposes recharge transaction records (with optional time/status/type filters), an account-wide recharge statistics summary, single-record lookup by platform transaction number, and a paginated model usage billing list with totals over a window.
Accessed via client.payment.
Available Operations
| Method | Description |
|---|---|
records() | Paginated recharge records |
statistics() | Recharge statistics summary (account totals) |
getRecord() | Look up a single recharge record by transaction number |
billingList() | Paginated model usage billing list |
billingQueryAllAmount() | Model usage billing total across a window |
records
Paginated recharge records with optional time, status, and transaction-type filters.
Example Usage
import { WltClient } from 'wlt-platform';
const client = new WltClient({ apiKey: 'your-api-key', baseUrl: 'https://console.example.com' });
// Successful recharges only
const result = await client.payment.records({
pageNum: 1,
pageSize: 10,
statusList: ['1'], // 0=processing, 1=success, 2=failed, 3=closed
});
console.log(`Total: ${result.total}`);
for (const record of result.list) {
console.log(record.transactionNo, record.amount, record.status);
}
// With time range and transaction type
const filtered = await client.payment.records({
startTime: '2026-04-01T00:00:00',
endTime: '2026-04-30T23:59:59',
transactionType: 'Recharge',
});
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
pageNum | number | No | 1 | Page number, starting from 1 |
pageSize | number | No | 10 | Items per page (max 1000) |
statusList | string[] | No | — | Status filter: "0"=processing, "1"=success, "2"=failed, "3"=closed |
startTime | string | No | — | Query start time (ISO 8601 local datetime) |
endTime | string | No | — | Query end time (ISO 8601 local datetime) |
transactionType | string | No | — | Transaction type: "Recharge" or "Refund" |
Response
Returns PageResponse<RechargeTransactionResponse> — a payment-specific pagination shape:
| Field | Type | Description |
|---|---|---|
pageNum | number | Current page number |
pageSize | number | Items per page |
total | number | Total record count |
pages | number | Total number of pages |
hasNext | boolean | Whether there is a next page |
hasPrevious | boolean | Whether there is a previous page |
list | RechargeTransactionResponse[] | Data list |
RechargeTransactionResponse:
| Field | Type | Description |
|---|---|---|
id | number | Record primary key ID |
createdAtUtc | string | Creation time (UTC) |
updatedAtUtc | string | Update time (UTC) |
userId | number | User ID |
payChannel | string | Payment channel (e.g. "Stripe") |
payType | string | Payment type (APP / WEB) |
transactionType | string | Transaction type (Recharge / Refund) |
status | string | Status: 0=processing, 1=success, 2=failed, 3=closed |
callbackAtUtc | string | Callback time (UTC) |
transactionNo | string | Platform transaction number |
externalNo | string | External transaction number (Stripe ID) |
amount | string | Transaction amount |
refundAmount | string | Refunded amount |
currency | string | Currency (ISO 4217) |
refundStatus | string | Refund status: 0=none, 1=partial, 2=full |
originalTransactionNo | string | Original transaction number (for refund records) |
extend | string | Extension field (JSON) |
Errors
| Code | Error | When |
|---|---|---|
2000 / 2002 | Authentication failure | API Key invalid |
2007 | Permission denied | Token lacks permission |
3001 | Token expired | Refresh failed |
statistics
Recharge statistics summary across the account.
Example Usage
const stats = await client.payment.statistics();
console.log(`Total recharged: ${stats.totalRechargedAmount}`);
Parameters
None.
Response
Returns RechargeStatisticsResponse:
| Field | Type | Description |
|---|---|---|
totalRechargedAmount | string | Total recharged amount |
totalUsedRechargedAmount | string | Total used recharged amount |
totalBalanceRechargedAmount | string | Unused recharge balance |
totalRefundAmount | string | Total refund amount |
totalFreeAmount | string | Free quota amount |
currency | string | Currency code |
Errors
| Code | Error | When |
|---|---|---|
2000 / 2002 | Authentication failure | API Key invalid |
2007 | Permission denied | Token lacks permission |
3001 | Token expired | Refresh failed |
getRecord
Look up a single recharge record by platform transaction number.
Example Usage
const record = await client.payment.getRecord('TXN20260421001');
console.log(`Amount: ${record.amount}`);
console.log(`Status: ${record.status}`);
console.log(`Created: ${record.createdAtUtc}`);
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
transactionNo | string | Yes | — | Platform transaction number |
Response
Returns RechargeTransactionResponse. See records() for field definitions.
Errors
| Code | Error | When |
|---|---|---|
1002 | Data not found | Transaction number does not exist |
2000 / 2002 | Authentication failure | API Key invalid |
2007 | Permission denied | Token lacks permission |
3001 | Token expired | Refresh failed |
billingList
Example Usage
client.payment.billingList(params?: {
pageNum?: number;
pageSize?: number;
startTime?: string;
endTime?: string;
modelId?: string;
})
Paginated model usage billing list.
const result = await client.payment.billingList({
pageNum: 1,
pageSize: 10,
startTime: '2026-04-01 00:00:00',
endTime: '2026-04-30 23:59:59',
});
console.log(`Total: ${result.total}`);
for (const item of result.list) {
console.log(item.modelName, item.amount);
}
// Filter by model
const filtered = await client.payment.billingList({
startTime: '2026-04-01 00:00:00',
endTime: '2026-04-30 23:59:59',
modelId: 'qwen-turbo',
});
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
pageNum | number | No | 1 | Page number, starting from 1 |
pageSize | number | No | 10 | Items per page (max 1000) |
startTime | string | No | — | Start time, format "YYYY-MM-DD HH:MM:SS" |
endTime | string | No | — | End time, format "YYYY-MM-DD HH:MM:SS" |
modelId | string | No | — | Model ID for exact filtering |
Response
Returns PageInfo<LmModelUsageBillingResponse>. LmModelUsageBillingResponse:
| Field | Type | Description |
|---|---|---|
id | number | Record primary key ID |
createdAtUtc | string | Record creation time (UTC) |
userId | number | User ID |
username | string | Username |
modelName | string | Model name |
modelType | string | Model type |
feeType | string | Fee type (e.g. "input tokens" / "output tokens") |
unitPrice | string | Unit price (per 1K tokens) |
currency | string | Currency (ISO 4217) |
usedAmout | string | Usage amount (token count). Note: backend field is misspelled |
amount | string | Billed amount |
billingTimeStart | string | Billing start time |
billingTimeEnd | string | Billing end time |
extend | string | Extension field (JSON) |
inputs | string[] | Input type list |
outputs | string[] | Output type list |
Errors
| Code | Error | When |
|---|---|---|
1001 | Validation error | Time format must be YYYY-MM-DD HH:MM:SS |
2000 / 2002 | Authentication failure | API Key invalid |
2007 | Permission denied | Token lacks permission |
3001 | Token expired | Refresh failed |
billingQueryAllAmount
Model usage billing total across a time window.
Example Usage
const total = await client.payment.billingQueryAllAmount({
startTime: '2026-04-01 00:00:00',
endTime: '2026-04-30 23:59:59',
});
console.log(`Total billing amount: ${total.totalBillingAmount}`);
// Filter by specific model
const modelTotal = await client.payment.billingQueryAllAmount({
startTime: '2026-04-01 00:00:00',
endTime: '2026-04-30 23:59:59',
modelId: 'qwen-turbo',
});
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
startTime | string | No | — | Start time, format "YYYY-MM-DD HH:MM:SS" |
endTime | string | No | — | End time, format "YYYY-MM-DD HH:MM:SS" |
modelId | string | No | — | Model ID for exact filtering |
Response
Returns ModelUsageBillingAmountResponse:
| Field | Type | Description |
|---|---|---|
totalBillingAmount | string | Total billing amount |
currency | string | Currency code |
Errors
| Code | Error | When |
|---|---|---|
1001 | Validation error | Time format must be YYYY-MM-DD HH:MM:SS |
2000 / 2002 | Authentication failure | API Key invalid |
2007 | Permission denied | Token lacks permission |
3001 | Token expired | Refresh failed |