获取余额交易
按 ID 获取余额交易。每条记录展示扣款、转账、提现或退款背后的资金流动。
GET https://api.stripe.com/v1/balance_transactions/{id}
示例
运行以下 cURL 命令发送请求。
cURL
curl -X GET https://api.stripe.com/v1/balance_transactions/txn_1234567890 \
-u "<YOUR_SECRET_KEY>:"
参数
查询参数
| 参数 | 类型 | 必需 | 说明 |
|---|---|---|---|
expand[] | 字符串数组 | 可选 | 标识需要补充数据并内联返回的嵌套响应对象。 |
路径变量
| 名称 | 类型 | 必需 | 说明 |
|---|---|---|---|
id | 字符串 | 必需 | 要获取的余额交易 ID。 |
响应
响应使用标准状态码。200 表示成功,401 表示 API 密钥无效。格式错误的请求返回 400,例如 expand[] 数组的键不连续。完整列表见 Stripe 的错误代码。
200: OK
Response
{
"id": "txn_1234567890",
"object": "balance_transaction",
"amount": 1000,
"available_on": 1693028800,
"created": 1692942400,
"currency": "usd",
"description": "Payment for invoice",
"exchange_rate": null,
"fee": 59,
"fee_details": [
{
"amount": 59,
"application": null,
"currency": "usd",
"description": "Stripe processing fees",
"type": "stripe_fee"
}
],
"net": 941,
"reporting_category": "charge",
"source": "ch_1NirD82eZvKYlo2CIvbtLWuY",
"status": "available",
"type": "charge"
}
响应属性
| 属性 | 类型 | 说明 |
|---|---|---|
id | 字符串 | 余额交易的唯一标识符,以 txn_ 为前缀。 |
object | 字符串 | 始终为 balance_transaction。 |
amount | 整数 | 资金流动的金额,以最小货币单位表示,未扣除费用。负值表示资金流出账户。 |
available_on | 时间戳 | 资金可用于提现的 Unix 时间。 |
created | 时间戳 | Stripe 创建该余额交易的 Unix 时间。 |
currency | 字符串 | 小写的三字母货币代码,例如 usd。 |
description | 字符串 | 交易的自由文本说明,或 null。 |
exchange_rate | 小数 | Stripe 转换原始货币时使用的汇率。未发生转换时为 null。 |
fee | 整数 | Stripe 从该资金流动中扣除的费用总额,以最小货币单位表示。 |
fee_details | 对象数组 | fee 的明细,每种费用类型一项。每项包含 amount、application、currency、description 和 type。 |
net | 整数 | amount 减去 fee,以最小货币单位表示。 |
reporting_category | 字符串 | Stripe 为该资金流动指定的报告分类,例如 charge、refund 或 payout。 |
source | 字符串 | 产生该资金流动的对象的 ID,例如扣款、退款或转账。可展开。 |
status | 字符串 | 资金结算后为 available,Stripe 暂扣期间为 pending。 |
type | 字符串 | 产生该资金流动的对象,例如 charge、refund 或 transfer。 |
错误响应
400: Bad Request
Response
{
"error": {
"message": "If passing an array with explicit keys (e.g. foo[0]=a&foo[1]=b) instead of as an array (e.g. foo[]=a&foo[]=b), the keys must be numeric and sequential starting from 0. You passed the keys `1`, we expected to have a key with the value `0`.",
"param": "expand",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_kCeAL5FAly5bkh?t=1734734555",
"type": "invalid_request_error"
}
}
401: Unauthorized
Response
{
"error": {
"type": "invalid_request_error",
"message": "Invalid API Key provided: sk_test_********************1234"
}
}