ToAPIsToAPIs
帳單

查詢付款方式

查詢本地記錄的預設支付方式

GET
/api/v1/billing/payment-method

中國大陸用戶請注意: 中國大陸用戶請使用 https://api.toapis.cn 作為接口地址 (Base URL). 文檔示例中的 https://api.toapis.com 請替換為 https://api.toapis.cn.

驗證, 分頁及錯誤處理請參閱接入方式.

使用說明

回傳當前綁定的支付方式摘要, 用於確認是否已設定銀行卡. 僅主帳號可查詢自身帳單; 子帳號存取回傳 HTTP 403, 主帳號也不能藉此查詢成員帳單.

source=local_configuration 表示回傳的是本地儲存的預設卡摘要, 不是 Stripe 即時查詢結果, 也不是全部卡片清單. 未綁定支付方式時 configured=false, 其餘卡片欄位為 null. 已綁定時個別欄位仍可能為 null. 不回傳完整卡號或支付方式 ID.

本介面是唯讀查詢, 不能用來綁定卡片, 也不會在 Stripe 側建立 Customer.

驗證

Authorizationstring請求頭必填

使用系統存取權杖, 格式為 Bearer YOUR_SYSTEM_ACCESS_TOKEN. 此介面不接受模型 API Key, 不需要 X-User-Id.

請求參數

此介面不接受路徑或查詢參數, 不需要請求主體.

請求範例

請求示例

curl --request GET \
  --url 'https://api.toapis.com/api/v1/billing/payment-method' \
  --header 'Authorization: Bearer YOUR_SYSTEM_ACCESS_TOKEN'
import requests

response = requests.get(
    "https://api.toapis.com/api/v1/billing/payment-method",
    headers={"Authorization": "Bearer YOUR_SYSTEM_ACCESS_TOKEN"},
    timeout=30,
)
response.raise_for_status()
print(response.json())
const url = new URL("https://api.toapis.com/api/v1/billing/payment-method");

const response = await fetch(url, {
  headers: { Authorization: "Bearer YOUR_SYSTEM_ACCESS_TOKEN" },
  signal: AbortSignal.timeout(30_000),
});

if (!response.ok) {
  throw new Error(`HTTP ${response.status}: ${await response.text()}`);
}
console.log(await response.json());

回應欄位

範例使用虛構資料, 並假設 credits_per_usd="100". 實際換算請以回應為準.

codeinteger

業務狀態碼, 成功時為 0.

messagestring

回應訊息, 成功時為空字串. 錯誤訊息依請求語言回傳.

dataobject

本次查詢的結果物件.

data.configuredboolean

是否已設定預設付款卡. 為 false 時卡片摘要欄位均為 null.

data.providerstring | null

付款服務提供方. 無法確認或不適用時為 null.

data.typestring | null

預設付款方式的類型, 如 card. 無法確認或不適用時為 null.

data.brandstring | null

預設卡片品牌, 如 visa. 無法確認或不適用時為 null.

data.last4string | null

預設卡號末 4 位, 不回傳完整卡號. 無法確認或不適用時為 null.

data.exp_monthinteger | null

預設卡片到期月份. 無法確認或不適用時為 null.

data.exp_yearinteger | null

預設卡片到期年份. 無法確認或不適用時為 null.

data.sourcestring

資料來源. 本地設定或帳本快照不代表 Stripe 即時狀態. 固定值: "local_configuration".

回應範例

響應示例

{
  "code": 0,
  "message": "",
  "data": {
    "configured": true,
    "provider": "stripe",
    "type": "card",
    "brand": "visa",
    "last4": "4242",
    "exp_month": 12,
    "exp_year": 2028,
    "source": "local_configuration"
  }
}