curl
curl -X POST 'https://verification.didit.me/v3/billing/top-up-invoices/' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: 0b8e6f4a-3c2d-4e1f-9a7b-5d6c8e2f1a30' \
-d '{
"amount_in_dollars": 5000,
"po_number": "PO-88213"
}'import requests
url = "https://verification.didit.me/v3/billing/top-up-invoices/"
payload = {
"amount_in_dollars": 5000,
"po_number": "PO-88213"
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
'x-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({amount_in_dollars: 5000, po_number: 'PO-88213'})
};
fetch('https://verification.didit.me/v3/billing/top-up-invoices/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://verification.didit.me/v3/billing/top-up-invoices/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount_in_dollars' => 5000,
'po_number' => 'PO-88213'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://verification.didit.me/v3/billing/top-up-invoices/"
payload := strings.NewReader("{\n \"amount_in_dollars\": 5000,\n \"po_number\": \"PO-88213\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://verification.didit.me/v3/billing/top-up-invoices/")
.header("Idempotency-Key", "<idempotency-key>")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount_in_dollars\": 5000,\n \"po_number\": \"PO-88213\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://verification.didit.me/v3/billing/top-up-invoices/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount_in_dollars\": 5000,\n \"po_number\": \"PO-88213\"\n}"
response = http.request(request)
puts response.read_body{
"id": "9a4f2c1e-7b3d-4e8a-a1c5-6f0d2b9e8c47",
"lane": "bank_transfer",
"status": "open",
"credit_amount": "5000.00",
"total": "5000.00",
"tax": "0.00",
"currency": "usd",
"amount_received": "0.00",
"amount_credited": "0.00",
"amount_open": "5000.00",
"presented": null,
"method": {
"type": "customer_balance",
"name": "Bank transfer"
},
"invoice_number": "7F3A2C1B-0012",
"hosted_invoice_url": "https://invoice.example.com/i/7F3A2C1B-0012",
"invoice_pdf": "https://invoice.example.com/i/7F3A2C1B-0012/pdf",
"po_number": "PO-88213",
"due_at": "2027-01-14T10:00:00Z",
"confirmed_at": null,
"closed_at": null,
"failure_reason": null,
"created_at": "2026-11-30T10:00:00Z",
"bank_details": {
"currency": "USD",
"amount_due": "5000.00",
"account_holder_name": "Didit",
"bank_name": "Example Bank, N.A.",
"account_number": "000123456789",
"routing_number": "000000000",
"swift_code": "EXAMUS33XXX",
"reference": "7F3A2C1B-0012"
}
}
计费
创建充值发票 API:银行转账付款
通过 Didit API 创建充值发票,并在 45 天内以银行转账付款:额度 1,000至20,000,附银行信息和 PDF。
POST
/
v3
/
billing
/
top-up-invoices
/
curl
curl -X POST 'https://verification.didit.me/v3/billing/top-up-invoices/' \
-H 'x-api-key: YOUR_API_KEY' \
-H 'Content-Type: application/json' \
-H 'Idempotency-Key: 0b8e6f4a-3c2d-4e1f-9a7b-5d6c8e2f1a30' \
-d '{
"amount_in_dollars": 5000,
"po_number": "PO-88213"
}'import requests
url = "https://verification.didit.me/v3/billing/top-up-invoices/"
payload = {
"amount_in_dollars": 5000,
"po_number": "PO-88213"
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
'x-api-key': '<api-key>',
'Content-Type': 'application/json'
},
body: JSON.stringify({amount_in_dollars: 5000, po_number: 'PO-88213'})
};
fetch('https://verification.didit.me/v3/billing/top-up-invoices/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://verification.didit.me/v3/billing/top-up-invoices/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'amount_in_dollars' => 5000,
'po_number' => 'PO-88213'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"Idempotency-Key: <idempotency-key>",
"x-api-key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://verification.didit.me/v3/billing/top-up-invoices/"
payload := strings.NewReader("{\n \"amount_in_dollars\": 5000,\n \"po_number\": \"PO-88213\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://verification.didit.me/v3/billing/top-up-invoices/")
.header("Idempotency-Key", "<idempotency-key>")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"amount_in_dollars\": 5000,\n \"po_number\": \"PO-88213\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://verification.didit.me/v3/billing/top-up-invoices/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"amount_in_dollars\": 5000,\n \"po_number\": \"PO-88213\"\n}"
response = http.request(request)
puts response.read_body{
"id": "9a4f2c1e-7b3d-4e8a-a1c5-6f0d2b9e8c47",
"lane": "bank_transfer",
"status": "open",
"credit_amount": "5000.00",
"total": "5000.00",
"tax": "0.00",
"currency": "usd",
"amount_received": "0.00",
"amount_credited": "0.00",
"amount_open": "5000.00",
"presented": null,
"method": {
"type": "customer_balance",
"name": "Bank transfer"
},
"invoice_number": "7F3A2C1B-0012",
"hosted_invoice_url": "https://invoice.example.com/i/7F3A2C1B-0012",
"invoice_pdf": "https://invoice.example.com/i/7F3A2C1B-0012/pdf",
"po_number": "PO-88213",
"due_at": "2027-01-14T10:00:00Z",
"confirmed_at": null,
"closed_at": null,
"failure_reason": null,
"created_at": "2026-11-30T10:00:00Z",
"bank_details": {
"currency": "USD",
"amount_due": "5000.00",
"account_holder_name": "Didit",
"bank_name": "Example Bank, N.A.",
"account_number": "000123456789",
"routing_number": "000000000",
"swift_code": "EXAMUS33XXX",
"reference": "7F3A2C1B-0012"
}
}
Didit 的充值发票 API 会签发一张美元发票。您的财务团队可在 45 天内从任何银行通过银行转账支付该发票,付款后发票会为您的余额增加额度。
它与用户在控制台的“充值”对话框中创建的发票相同。
若要改用银行卡充值,请参阅充值额度。
工作原理
- 通过 获取额度余额 查看您的余额。
- 为所需额度创建发票,金额范围为 $1,000 至 $20,000,并附带新的
Idempotency-Key。 - 向
bank_details中的账户转账amount_open金额,并将invoice_number填写为汇款备注。 - 随后通过 获取充值发票 跟踪该发票,直至其
status变为paid,或发票以expired或cancelled状态关闭。
您支付的费用与获得的内容
amount_in_dollars是您增加的额度。适用时,税费会加到发票中,因此您需要转账的total可能高于credit_amount。- 只有实际到账的金额才会在到账时计入您的余额。
- 部分付款会按其支付的
total占比增加相应额度,其余未付金额保持同一参考号,直至due_at。 due_at是发票上载明的到期日,即开具之日起 45 天。请使用返回的值;按早期条款开具的发票保留其自身的日期。- 如果
total在due_at之前未全部到账,发票将变为expired状态。之后带有参考号到账的转账,仍会按其支付金额计入额度。 routing_number适用于 ACH 和美国电汇,swift_code适用于国际电汇。当bank_details为 null 时,hosted_invoice_url会显示相同的银行信息。- 您的计费联系人也会通过电子邮件收到发票。
首次开具发票之前
- 需要有人在控制台的账单详情中保存贵公司的法定名称和地址,且只需保存一次。在此之前,请求返回
400 billing_details_required,并附带missing字段。 - 充值发票适用于 Free、Growth 和 Scale 套餐。年度 Enterprise 合同会返回
409 top_up_not_allowed。
幂等性与重试
- 为您打算创建的每张发票使用一个
Idempotency-Key,将其保存下来,并且仅在重试该请求时重复使用。 - 缺少、为空或超过 255 个字符的密钥会返回
400 idempotency_key_required。 - 同一凭证使用相同的密钥和金额时,会返回该发票的当前状态,即使发票已支付、已取消或已过期。仅当
status为open或part_paid,且amount_open大于零时,才提供付款说明。 - 同一密钥若对应不同金额,或来自其他凭证,会返回
409 idempotency_key_conflict。 502 payment_provider_error表示无法确认发票的状态。请使用相同的密钥重试:若发票已签发,则返回该发票;若未签发任何发票,则返回409 top_up_not_completed。只有在这种情况下,才可以使用新密钥创建新发票。
同一时间只能存在一张发票
当发票处于open 或 part_paid 状态时,再次创建发票会返回 409 top_up_invoice_open,并附带 open_invoice。
请支付该发票仍需支付的金额,或等待其过期。
只有在尚未收到任何款项时,用户才能在控制台中取消发票。
错误
| HTTP | code | 含义 |
|---|---|---|
| 400 | amount_in_dollars 的字段错误 | 金额低于 $1,000、高于 $20,000,或小数位超过两位。 |
| 400 | idempotency_key_required | 缺少 Idempotency-Key 请求头,或其值为空,或长度超过 255 个字符。 |
| 400 | 无(仅 detail) | 请求体不是有效的 JSON。 |
| 400 | billing_details_required | 开具发票需要贵公司的法定名称和地址;missing 列出仍缺少的信息。 |
| 404 | billing_not_available | 您的组织暂不支持计费功能。 |
| 409 | top_up_invoice_open | 另一张发票处于未结清或部分支付状态;open_invoice 会指明该发票。 |
| 409 | idempotency_key_conflict | 该密钥曾用于其他金额,或被其他 API 密钥使用。 |
| 409 | top_up_not_completed | 之前使用此密钥的请求未能开具发票。未开具任何发票:请使用新密钥创建新发票。 |
| 409 | top_up_not_allowed | 年度 Enterprise 合同不能充值。 |
| 409 | billing_customer_missing | 您的组织尚无计费账户;需由相关人员在控制台中设置计费。 |
| 502 | payment_provider_error | 无法确认发票的状态。请使用相同的密钥重试。 |
授权
ApiKeyAuthBearerAuth
您的应用 API 密钥,可在 Business Console 的开发者 -> API 密钥中获取。主密钥拥有完全访问权限。命名密钥可以设置范围:可按资源设置无权限、只读或读写,可限定为部分工作流或已批准的会话,可限定为一组 IP 地址,并可设置过期日期。401 表示密钥错误、已被撤销或已过期;403 表示未发送密钥、密钥无权访问该资源或执行该操作,或请求来自其 IP 列表之外的地址;会话相关路由返回 404,表示该会话不在密钥的工作流或状态范围内。没有媒体访问权限的密钥会将图片、视频和 PDF 的 URL 返回为 null;没有会话写入权限的密钥会将会话链接和令牌返回为 null。请参阅 https://docs.didit.me/console/api-keys。
请求头
请求体
application/json
响应
发票:新建的,或此密钥已创建的那张,以其当前状态返回。
通过银行转账支付的充值发票,与控制台“充值”对话框签发的发票相同。请通过 status 和金额了解其当前状态;时间戳仅记录事件。
open:等待转账。part_paid:已收到部分 total,并已将对应比例的额度计入账户;请在 due_at 之前使用相同的备注发送 amount_open。paid:已收到全部 total,并已计入 credit_amount。expired:在收到全部 total 之前已超过 due_at;已收到的金额仍会计入账户,之后带有该备注的转账仍会按其金额计入。cancelled:在收到任何款项之前,有人通过控制台取消了该发票(款项到账后,发票无法再取消)。failed:发票未能开具;未开具任何发票。
可用选项:
open, part_paid, paid, expired, cancelled, failed 最后修改于 2026年12月1日