# ReceivedCredit オブジェクトを使用した資金移動 他の金融口座や銀行口座から金融口座に資金を移動する方法をご紹介します。 資金が金融口座に送金されると、Stripe は対応する [ReceivedCredit](https://docs.stripe.com/api/treasury/received_credits.md)オブジェクトをその口座に作成します。`ReceivedCredit` には、可能な場合、資金の送金方法と送金元の口座の情報が含まれます。金融口座に資金を送金するには、`ach` および `us_domestic_wire` の場合、口座の金融番号と口座番号を使用します。金融口座間での送金の場合は金融口座 ID を使用します。 資金元が別の金融口座の場合、`ReceivedCredit` には、送金元への `linked_flows.source_flow` 参照が含まれます。この場合、ソース `OutboundPayment` は `stripe` を `network` 値として持っています。 ## ReceivedCredit を取得する `GET /v1/treasury/received_credits/{{RECEIVED_CREDIT_ID}}` を使用し、指定した ID の [ReceivedCredit](https://docs.stripe.com/api/treasury/received_credits.md) を取得します。 以下のリクエストは、指定された ID の `ReceivedCredit` を取得します。このリクエストのレスポンスには、展開された[Transaction オブジェクト](https://docs.stripe.com/api/treasury/transactions.md)の詳細が含まれます。 ```curl curl -G https://api.stripe.com/v1/treasury/received_credits/{{RECEIVED_CREDIT_ID}} \ -u "<>:" \ -H "Stripe-Account: {{CONNECTEDACCOUNT_ID}}" \ -d "expand[]=transaction" ``` 成功すると、リクエストされた `ReceivedCredit` オブジェクトがレスポンスで返されます。レスポンスの一部のパラメーターには、リクエストの `expand[]` パラメーターに値として追加した場合にのみ返される追加情報があります。次のレスポンス例で、拡張できるフィールドには、`Expandable` コメントが付いています。オブジェクトレスポンスの拡張の詳細については、[レスポンスを拡張する](https://docs.stripe.com/api/expanding_objects.md)をご覧ください。 #### JSON (コメント付き) ```json { "id": "{{RECEIVED_CREDIT_ID}}", "object": "received_credit", "livemode": true | false, "created": "{{Timestamp}}", // The FinancialAccount that received the funds "financial_account": "{{FINANCIAL_ACCOUNT_ID}}", // Expandable "amount": 1000, "currency": "usd", // The description of this movement sent by the originator "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 // in the "failure_code" field. "status": "succeeded" | "failed", // The network that was used for this movement "network": "ach" | "stripe" | "us_domestic_wire", // Information about the originating account of the movement "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": null | { "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": "{{FINANCIAL_ACCOUNT_ID}}" }, // Only set if type is `balance`. // This is only set when the source is a Payout. "balance": null | "payments", "billing_details": null | { "name": null | "{{String}}", "phone": null | "{{String}}", "email": null | "{{String}}", "address": null | { "line1": null | "{{String}}", "line2": null | "{{String}}", "city": null | "{{String}}", "state": null | "{{String}}", "postal_code": null | "{{String}}", "country": null | "{{String}}" } } }, // A unique, Stripe-hosted direct link to the regulatory receipt for the ReceivedCredit "hosted_regulatory_receipt_url": "{{URL}}", "reversal_details": { "restricted_reason": null | "source_flow_restricted" | "network_restricted" | "deadline_passed" | "already_reversed", "deadline": null | "{{Timestamp}}" }, "linked_flows": { // When the platform can see both source and destination // accounts, we link to the originating flow // When the `network` type is `stripe`, this could be an OutboundPayment originated from another merchant, a // Payout originated from the same merchant (a balance transfer from payments), // or the result of reversing a Stripe network ReceivedCredit by the recipient // whom funds were sent to in the past. // When the `network` type is `ach`, this could be either nil or a Payout. "source_flow": null | "{{OUTBOUND_PAYMENT_ID}}" | "{{PAYOUT_ID}}", "source_flow_type": null | "outbound_payment" | "payout", // Includable by expanding linked_flows['source_flow_details']. When included, this field will // either be an OutboundPayment or a Payout. "source_flow_details": null, // CreditReversals allow you to reverse a ReceivedCredit as long as it's before the reversal_details['deadline'] // If reversed, the ReceivedCredit will link to the CreditReversal. "credit_reversal": null | "{{CREDIT_REVERSAL_ID}}" }, // Currently, the only failure reasons for ReceivedCredits are due to restrictions on the account. "failure_code": null | "account_closed" | "account_frozen", // Transaction created by the ReceivedCredit. Created synchronously. "transaction": "{{TRANSACTION_ID}}" // Expandable } ``` ## ReceivedCredit を一覧表示する `GET /v1/treasury/received_credits` を使用して、必須の `financial_account` パラメーターの ID の金融口座について、すべての `ReceivedCredits` を取得します。標準のリストパラメーター、`status`、`linked_flows.source_flow_type` でリストをフィルタリングできます。 ``` { // Standard list parameters "limit", "starting_after", "ending_before", // Filter by FinancialAccount (required) "financial_account": "{{FINANCIAL_ACCOUNT_ID}}", // Filter by status "status": "succeeded" | "failed", // Filter by `source_flow_type` "linked_flows.source_flow_type": nil | "payout" | "outbound_payment" } ``` 以下のリクエストは、指定された金融口座についてステータスが `failed` の `ReceivedCredits` を取得します。 ```curl curl -G https://api.stripe.com/v1/treasury/received_credits \ -u "<>:" \ -H "Stripe-Account: {{CONNECTEDACCOUNT_ID}}" \ -d "financial_account={{TREASURYFINANCIALACCOUNT_ID}}" \ -d status=failed ``` 成功すると、レスポンスには、リクエストで指定された基準と一致する [ReceivedCredit](https://docs.stripe.com/api/treasury/received_credits.md)オブジェクトが含まれます。 ## ReceivedCredit をテストする `POST /v1/test_helpers/treasury/received_credits` を使用して、金融口座での資金の受け取りをシミュレーションします。Stripe 以外の口座から金融口座への銀行振込をシミュレーションするには、`initiating_payment_method_details` を外部の銀行口座の値に設定し、`network` を `ach` または `us_domestic_wire` に設定します。 次のリクエストは、同じプラットフォーム上の 2 つの金融口座間で `OutboundPayment` を使用して、外部の銀行口座からテスト用の `ReceivedCredit` を作成します。 ```curl curl https://api.stripe.com/v1/test_helpers/treasury/received_credits \ -u "<>:" \ -H "Stripe-Account: {{CONNECTEDACCOUNT_ID}}" \ -d financial_account={{DESTINATION_FINANCIAL_ACCOUNT_ID}} \ -d network=ach \ -d amount=1234 \ -d currency=usd ``` 成功すると、レスポンスで `ReceivedCredit` オブジェクトが返されます。以下の例は、銀行振込のレスポンスを示しています。 ```json { "financial_account": "{{FINANCIAL_ACCOUNT_ID}}", "network": "ach", "amount": "1234", "currency": "usd", "description": "Test", "source_details": { "type": "aba", "aba": { "country": "US", "routing_number": "12341234", "account_number": "0123456789", "account_holder_name": "Jenny Rosen" } } } ``` ## ReceivedCredit Webhook Stripe は、以下の `ReceivedCredit` イベントを [Webhook](https://docs.stripe.com/webhooks.md) エンドポイントに送信します。 - `ReceivedCredit` 作成時の `treasury.received_credit.created`。 - `ReceivedCredit` のステータス変更時の `treasury.received_credit.{{new_status}}`。使用可能なステータス値のオプションは以下のとおりです。 - `treasury.received_credit.succeeded` - `treasury.received_credit.failed`