残高と取引の使用
Treasury アカウント残高とそれに対する取引の影響をご紹介します。
Financial accounts have their own balance separate from the balance of the account they’re attached to (platform account or connected account). Balance
objects record the amount of funds in a financial account and their state of availability. Transaction
and TransactionEntry
objects debit or credit the funds in that balance.
残高
金融口座には、資金の残高があります。ただし、金融口座からの資金の出入りに影響する保留中の取引が含まれる可能性があるため、残高の合計のすべてを常に使用できるわけではありません。金融口座の残高には、資金の可用性を定義する 3 つのプロパティが含まれます。
cash
: ユーザーがすぐに支出できる資金。inbound_
: まだ支出可能になっていないものの、後で利用できるようになる資金。pending inbound_
プロパティは、将来の機能のためにリザーブされており、値は常に 0 です。pending outbound_
: アカウントにある資金のうち、保留中のアウトバウンドフロー用に留保されているため支出に使用できない金額。pending
GET /v1/treasury/financial_
を使用し、関連付けられた ID の金融口座の残高詳細を取得します。その金融口座が連結アカウントの 1 つに関連付けられている場合には、Stripe-Account
ヘッダーを指定します。その金融口座がプラットフォームアカウントに関連付けられている場合には、Stripe-Account
ヘッダーを含めないでください。
成功すると、レスポンスとして、資金とその利用可能状況の詳細を示す balance
ハッシュが含まれた FinancialAccount オブジェクトが返されます。
{ "object": "treasury.financial_account", "id": "{{FINANCIAL_ACCOUNT_ID}}", ... "balance": { // $90 is currently available for use, // with an additional $10 held in the outbound_pending sub-balance "cash": {"usd": 9000}, "inbound_pending": {"usd": 0}, "outbound_pending": {"usd": 1000} } }
マイナス残高とオーバードラフト
連結アカウントの残高がマイナスの場合 (たとえば、金融口座が差戻しされる ACH クレジットを受け取った場合)、それを 0 USD に戻す責任があります。マイナスの状態が 180 日間続くと、Stripe はプラットフォームから引き落としを行います。個々の残高または合計残高が Stripe のリスク上限を超えた場合にも、ご連絡いたします。
We recommend that you monitor your connected accounts to retrieve funds for their negative balances. You can top up funds into your financial account using Inbound Transfers or Stripe Payouts. Make sure that you regularly monitor your connected account balances and reach out promptly.
金融口座がマイナスの状態が 180 日間続くと、Stripe はプラットフォームの金融口座から資金を引き落とし、メールを事前に送信します。残高不足により送金が失敗した場合、Stripe はお客様に連絡し次の手順をご案内します。
取引
All changes to a balance have a corresponding Transaction object that details money movements. Transactions affect only one balance and are in only one currency (currently, Financial Accounts for platforms supports only USD).
各取引は、OutboundTransfer、ReceivedCredit、または ReceivedDebit など、残高に影響する資金移動オブジェクトを指します。
取引のステートマシン
ステータス | 適用される状態 | 説明 | 移行 |
---|---|---|---|
open | 初期状態 | これはすべての取引の初期状態です。取引によってサブ残高の金額は更新されますが、現在の残高は取引が記帳されるまで影響を受けません。 | posted または void |
posted | 最終状態 | 資金はアカウントから正常に入金/出金されました。現在の残高に反映されています。 | 該当なし |
void | 最終状態 | 取引が残高に影響しませんでした。たとえば、アウトバウンド支払いが開始された後で、アカウントから出金される前にキャンセルされた場合に、取引がこの状態になることがあります。 | 該当なし |
使用可能な Transaction
エンドポイントを使用すると、特定の取引を取得でき、金融口座に影響している取引をリストまたはフィルタリングできます。取引に使用できる Webhook はありませんが、関連する資金移動オブジェクト (OutboundPayments
など) には Webhook を使用できます。
取引を取得する
GET/v1/treasury/transactions/{{TRANSACTION_
を使用して、関連付けられた ID の取引を取得します。
成功すると、レスポンスは Transaction
オブジェクトを返します。
取引をリストする
GET /v1/treasury/transactions
を使用して、金融口座の取引をリストします。本文で必須の financial_
パラメーターを、取引を取得する金融口座 ID の値に設定します。返された結果をフィルタリングするには、追加のパラメーターを含めます。
リストパラメーターの標準セットに加え、以下の方法で取引を絞り込むことができます。
status
flow
created
かposted_
のいずれか (両方ではなく)at
{ // Standard list parameters limit, starting_after, ending_before, // Filter by FinancialAccount, required financial_account: "{{FINANCIAL_ACCOUNT_ID}}" // Filter by status status: "open" | "posted" | "void", // Filter by flow flow: "{{FLOW_OBJECT_ID}}", // Order the results by the created or posted_at timestamps, default is `created`. // For order_by=posted_at, setting status='posted' is required order_by: "created" | "posted_at", // created can only be specified with order_by = 'created' created: {gt, gte, lt, lte}, status_transitions: { // status_transitions.posted_at can only be specified with order_by = 'posted_at' and status = 'posted' posted_at: {gt, gte, lt, lte} } }
次のリクエストは、金融口座で作成された、status
が posted
の直近 3 つの取引を取得します。
Webhook
取引を開始するさまざまな資金移動には、それぞれの Webhook があるため、取引のための Webhook はありません。
取引項目
TransactionEntry (取引項目) オブジェクトは、金融口座の残高に影響を与える資金移動において最も細かなビューです。1 つの資金の流れは、複数の個別の資金移動から構成され、それぞれが取引で表されます。取引は、複数の取引項目を集約したものです。たとえば、T の時点で 10 USD の アウトバウンド支払いを開始すると、資金が cash
サブ残高から outbound_
サブ残高に移動します。以下の Transaction
オブジェクトレスポンスは、この初期のイベントを示したものです。
{ "id": "{{TRANSACTION_ID}}", "object": "treasury.transaction", "created": "{{T}}", ... "flow": "{{OUTBOUND_PAYMENT_ID}}", "flow_type": "outbound_payment", "status": "open", "amount": -1000, "currency": "usd",
T+1 の時点でアウトバウンド支払いが転記されると、その資金は outbound_
から差し引かれ、取引に新しい取引項目が追加されます。次の Transaction
レスポンスは、この経過を示したものです。
{ "id": "{{TRANSACTION_ID}}", "object": "treasury.transaction", "created": "{{T}}", ... "flow": "{{OUTBOUND_PAYMENT_ID}}", "flow_type": "outbound_payment", "status": "posted", "amount": -1000, "currency": "usd",
前述のレスポンスに示されるように、1 つの取引には複数の取引項目が含まれることがあります。利用可能な TransactionEntry
エンドポイントを使用すると、特定の取引項目を取得でき、それらを特定の取引についてリストまたはフィルタリングできます。
void
ステータスの Transaction
には、新しい取引項目が追加されません。posted
ステータスの Transaction
で、すべての balance_
が cash
サブ残高に対するものである場合にも、新しい取引項目は追加されません。
取引項目を取得する
GET /v1/treasury/transaction_
を使用して、関連付けられた ID の取引項目の詳細を取得します。
成功すると、以下のフォームを持つ TransactionEntry
オブジェクトがレスポインスで返されます。
{ "id": "{{TRANSACTION_ENTRY_ID}}", "object": "treasury.transaction_entry", "created": "{{Timestamp}}", "livemode": false, // The FinancialAccount this transaction entry impacts. "financial_account": "{{FINANCIAL_ACCOUNT_ID}}", // The transaction that this transaction entry belongs to. "transaction": "{{TRANSACTION_ID}}", // The flow responsible for this transaction entry.
TransactionEntries をリストする
GET /v1/treasury/transaction_
を使用して、金融口座の取引項目をリストします。本文で必須の financial_
パラメーターを、取引項目を取得する金融口座 ID の値に設定します。リストをフィルタリングするには、追加のパラメーターを含めます。
リストパラメーターの標準セットに加え、以下の方法で取引項目を絞り込むことができます。
transaction
created
かeffective_
のいずれか (両方ではなく)at
{ // Standard list parameters limit, starting_after, ending_before, // Filter by FinancialAccount, required financial_account: "fa_123" // Filter by transaction transaction: 'trxn_123', // Order the results by the created or effective_at timestamps, default is `created`. order_by: "created" | "effective_at", // created can only be specified with order_by = 'created' created: {gt, gte, lt, lte}, // effective_at can only be specified with order_by = 'effective_at' effective_at: {gt, gte, lt, lte}, }
以下のリクエストは、{{Timestamp}}
以前に作成された取引項目を取得し、 created
日の順に並べます。
Webhook
取引項目を開始するさまざまな資金移動には、それぞれの Webhook があるため、取引項目のための Webhook はありません。