# ReceivedDebit オブジェクトを使用した資金移動 外部アカウント所有者が金融口座から資金を引き出す方法をご覧ください。 プラットフォーム向け Treasury の外部で開始される特定のプロセスでは、金融口座から資金が引き出されます。これには以下が含まれます。 - [Stripe Issuing によるカードでの支出](https://docs.stripe.com/issuing/purchases/transactions.md#transactions) - ACH デビットを使用して、金融口座から資金を引き出し、外部口座に追加する - [トップアップ](https://docs.stripe.com/treasury/connect/moving-money/payouts.md#top-ups)を使用して、プラットフォームの金融口座からそのプラットフォームの Stripe 決済残高に資金を引き出し このような資金を移動すると、`ReceivedDebit` オブジェクトが作成されます。ご自身で直接 `ReceivedDebits` を作成することはなく、Webhook を使用して `ReceivedDebit` オブジェクトが作成されるのを監視します。アカウントに十分な資金がなければ、ほとんどの場合 `ReceivedDebit` は失敗します。 ## ReceivedDebit を取得する `GET /v1/treasury/received_debits/{{RECEIVED_DEBIT_ID}}` を使用して、関連付けられた ID の `ReceivedDebit` を取得します。 ```curl curl https://api.stripe.com/v1/treasury/received_debits/{{RECEIVED_DEBIT_ID}} \ -u "<>:" \ -H "Stripe-Account: {{CONNECTEDACCOUNT_ID}}" ``` 成功すると、関連付けられた ID の `ReceivedDebit` オブジェクトがレスポンスで返されます。 レスポンスの一部のパラメーターには、`expand[]` パラメーターに値として追加した場合にのみ返される追加情報があります。次のレスポンス例で、拡張できるフィールドには、「Expandable」コメントが付いています。オブジェクトレスポンスの拡張の詳細については、[レスポンスを拡張する](https://docs.stripe.com/api/expanding_objects.md)をご覧ください。 #### JSON (コメント付き) ```json { "id": "{{RECEIVED_DEBIT_ID}}", "object": "received_debit", "livemode": Boolean, "created": Timestamp, // The FinancialAccount funds have been pulled from "financial_account": "{{FINANCIAL_ACCOUNT_ID}}", // Expandable "amount": 1000, "currency": "usd", "description": "Testing", // ReceivedCredits are created with a status of either succeeded (approved) or failed // (declined). When failed, no Transaction is created. The failure reason can be found // under "failure_code". "status": "succeeded" | "failed", // The network that was used for this movement // Can only be ach today "network": "ach", // Information about how the debit was created. "received_payment_method_details": { "type": "us_bank_account" | "balance" | "financial_account", // Only set if type is `us_bank_account`. // This contains information of the source external bank account. "us_bank_account": nil | { "bank_name": String, "routing_number": "12341234", "last4": "6789" }, // Only set if type is `financial_account`. // This contains information of the source FinancialAccount. "financial_account": nil | { "id": "{{DESTINATION_FINANCIAL_ACCOUNT_ID}}" }, // Only set if type is `balance`. // This is only set when the source is a Payout. "balance": nil | "payments", "billing_details": nil | { "name": nil | String, "phone": nil | String, "email": nil | String, "address": nil | { "line1": nil | String, "line2": nil | String, "city": nil | String, "state": nil | String, "postal_code": nil | String, "country": nil | String } } }, // A unique, Stripe-hosted direct link to the regulatory receipt for the ReceivedDebit "hosted_regulatory_receipt_url": Url, "reversal_details": { "restricted_reason": nil | "source_flow_restricted" | "network_restricted" | "deadline_passed" | "already_reversed", "deadline": nil | Timestamp, }, "linked_flows": { // DebitReversals allow you to reverse a ReceivedDebit as long as it's before the reversal_details['deadline'] // If reversed, the ReceivedDebit will link to the DebitReversal. "debit_reversal": nil | "{{DEBIT_REVERSAL_ID}}", "returns_flow": nil | "{{INBOUND_TRANSFER_ID}}", }, // nil when status succeeded "failure_code": "insufficient_funds" | "account_closed" | "account_frozen", "failure_message": "The ReceivedDebit could not be completed because the Financial Account doesn't have a sufficient balance available. Please try again using an amount less than or equal to the Financial Account’s available balance." | "Funds can't be sent or withdrawn from this Financial Account because it has been closed. Please re-open the account, or try again with another Financial Account." | "Funds can't be sent or withdrawn from this Financial Account because it has been frozen.", // Transaction created by the ReceivedDebit. Only set for succeeded ReceivedDebits. "transaction": nil | "{{TRANSACTION_ID}}", // Expandable } ``` ## ReceivedDebit を一覧表示する `GET /v1/treasury/received_debits` を使用して特定の金融口座のすべての `ReceivedDebits` を取得します。`financial_account` パラメーターには金融口座 ID を指定する必要があります。標準のリストパラメーターまたは `status` で結果をフィルタリングできます。 ```json { // Standard list parameters "limit", "starting_after", "ending_before", // Filter by FinancialAccount (Required) "financial_account": "{{FINANCIAL_ACCOUNT_ID}}", // Filter by status "status": "succeeded" | "failed" } ``` 以下のリクエストは、特定された金融口座に対する指定された `ReceivedDebit` 以前に発生した、最後の成功した [ReceivedDebit オブジェクト](https://docs.stripe.com/api/treasury/received_debits/object.md) を取得します。 ```curl curl -G https://api.stripe.com/v1/treasury/received_debits \ -u "<>:" \ -H "Stripe-Account: {{CONNECTEDACCOUNT_ID}}" \ -d "financial_account={{TREASURYFINANCIALACCOUNT_ID}}" \ -d limit=1 \ -d ending_before={{RECEIVED_DEBIT_ID}} ``` ## ReceivedDebit をテストする プラットフォーム向け Treasury では、`ReceivedDebit` オブジェクト用のテストエンドポイントを提供しています。テスト環境では、`POST /v1/test_helpers/treasury/received_debits` を使用して、`ReceivedDebit` の作成をシミュレーションします。本番環境では `ReceivedDebit` オブジェクトを作成できないため、このエンドポイントを使用すると、第三者が `ReceivedDebit` の作成を開始した場合の資金フローをテストできます。`financial_account` を、送金元の金融口座の ID に設定します。`network` を `ach` に設定し、必要に応じて `source_details.aba` パラメーターに ABA の金融アドレス詳細を指定します。本番環境と同様に、利用可能な資金が不足している場合、テスト用の `ReceivedDebits` は失敗します。 ## ReceivedDebit Webhook Stripe は、以下の `ReceivedDebit` イベントを [Webhook](https://docs.stripe.com/webhooks.md) エンドポイントに送信します。 - `ReceivedDebit` 作成時の `treasury.received_debit.created`。