隨機生成帳單地址
返回一份隨機生成的帳單地址,形狀就是 billing_address 物件(v1.6.6)。可用來預填 /cardholder/create / /cardholder/update 的 billing_address,或不用持卡人開卡時 /card/apply 的 billing_address。不儲存任何內容,也不要求你的帳號下已有持卡人。
地址取自平台自有的地址來源,並規整為一份乾淨的地址:country / state / city / line1 / postcode 一定有值,地址行只含英文字母、數字和空格,郵編 4–10 位,沒有州 / 省的國家以城市填入 state —— 因此返回值可以原樣通過 /card/apply 與 /cardholder/create 對 billing_address 的校驗。
端點
| 項 | 值 |
|---|---|
| Method | POST |
| Path | /api/v1/openapi/cardholder/billing_address/random |
| 鑑權 | HMAC |
| 冪等鍵 | 不需要 |
請求欄位
| 欄位 | 型別 | 必填 | 說明 |
|---|---|---|---|
header_id | string | 將要開卡 / 登記持卡人的目標卡頭 hdr_<id>(列卡頭),決定取址的國家範圍(見下)。不傳則在任意國家取址 | |
country | string | ISO 3166-1 alpha-2,大小寫不敏感。傳了只在該國家取址 —— 沒有可用地址不會換成別的國家。不傳時:卡頭的發卡地區,否則範圍內任意國家 |
按卡頭決定的國家範圍:
| 卡頭 | 範圍 |
|---|---|
使用持卡人(virtual_v / virtual_r / virtual_g / virtual_a / virtual_s921 卡頭 —— 全部要求持卡人,/cardholder/requirement 的 required=true) | 只在卡頭的帳單國家名單(rules.country_lists.billing_countries,扁平形態即 support_billing_region)內取:沒有名單 = 任意國家,名單出現但為空 = 不允許任何國家。指定名單外的 country 返回 cardholder_billing_country_unsupported |
不使用持卡人(virtual_l / virtual_p 卡頭,supported=false) | 沒有國家名單 —— 任意國家,與 /card/apply 不用持卡人開卡時對 billing_address 的要求一致。預設國家 = 卡頭的發卡地區 |
不傳 header_id | 任意國家 |
只套用卡頭的帳單國家名單。v1.6.8 起平台沒有自己的居住國家名單;其他國家 / 居住國限制(如 /cardholder/requirement 的 rules.country_lists.blocked_residence_countries)由發卡方在預檢 / 提交審核 / 開卡時校驗。地址要給持卡人用時,可以傳一個符合該卡頭 rules.country_lists 的 country。
json
{ "header_id": "hdr_194" }json
{ "header_id": "hdr_5", "country": "SG" }響應欄位
data 就是帳單地址物件 —— 與 /cardholder/create 和 /card/apply 的 billing_address 同一組欄位:
| 欄位 | 型別 | 說明 |
|---|---|---|
country | string | ISO 3166-1 alpha-2,大寫 |
state | string | 州 / 省(該國家沒有州時為城市) |
city | string | 城市 |
district | string | 通常為空字串 |
line1 | string | 地址第一行 —— 只含英文字母、數字和空格 |
line2 | string | 地址第二行 —— 可能為空字串 |
postcode | string | 4–10 位字母或數字 |
響應示例
json
{
"code": 0,
"message": "Success",
"data": {
"country": "SG",
"state": "Singapore",
"city": "Singapore",
"district": "",
"line1": "1 Raffles Place",
"line2": "",
"postcode": "048616"
}
}典型錯誤
| HTTP | code | error_key | 說明 |
|---|---|---|---|
| 200 | 40001 | validation_failed | 請求體無法解析 |
| 200 | 40000 | openapi_invalid_header_id | header_id 格式錯誤 |
| 404 | 40400 | cardholder_header_not_found | 卡頭不存在 |
| 200 | 40000 | openapi_card_type_not_supported | 該卡頭不是虛擬卡卡頭(OpenAPI 只開虛擬卡,因此這裡只接受虛擬卡卡頭) |
| 200 | 40000 | cardholder_country_code_invalid | country 不是兩位字母(data.field=country) |
| 200 | 40000 | cardholder_billing_country_unsupported | 該卡頭要求持卡人,且 country 不在它的 support_billing_region 內(data.field=country) |
| 200 | 40000 | cardholder_random_address_unavailable | 當前範圍 / 國家暫無可用地址(data.field=country)—— 換一個國家,或讓終端使用者手動填寫 |
| 200 | 50000 | cardholder_provider_unavailable | 地址來源暫不可用 —— 請稍後重試 |
| 200 | 50000 | cardholder_service_not_configured | 持卡人服務未開通 —— 請聯絡我們 |
| 401 | 40100 | openapi_invalid_credentials | 鑑權失敗 |
| 429 | 42900 | too_many_requests | 觸發限流 —— 本介面每帳號每 60 秒 60 次的配額,或通用限流;按 Retry-After 重試 |
| 200 | 50000 | openapi_cardholder_failed | 服務端異常 |
注意事項
- 每次呼叫都返回一份新的隨機地址;不落庫,也不改變任何卡片或持卡人。建議先展示給終端使用者確認或修改,再提交。
- 隨機地址是一份合理的地址,不是終端使用者的真實地址。卡頭要求地址證明時(
/cardholder/requirement的required_fields或某條條件要求中出現identity.proof_of_address_*)請使用真實地址 —— 隨機地址拿不出對應的證明檔案。 /card/billing_address/generate需要已有卡片,返回的是本平台記錄的形狀(street/zip_code);本介面在卡片存在之前就能用,返回的是登記 / 開卡用的形狀。- 本介面在通用限流之外另有配額:每帳號每 60 秒最多 60 次。每位終端使用者取一份隨機地址即可,不要迴圈呼叫。