OutboundPayment オブジェクトを使用して Treasury で送金
Treasury の金融口座からサードパーティーに送金するためのアウトバウンド支払いを作成する方法をご紹介します。
OutboundPayment
objects represent push-based transfers from your financial account to a third-party external account using ACH or wire transfer, or another financial account associated with the same platform instantly using the stripe
network. For example, if you want to send money from your financial account to your vendor’s external US bank account, you create an OutboundPayment
to move the funds. The receiving accounts for an OutboundPayment
are either an external bank account or another financial account.
The typical transfer time for outbound payments can range from minutes (when using the Stripe network), same day, to 1-2 business days (when using the ACH network). For more information, see the Money movement timelines guide.
OutboundPayment を作成する
POST /v1/treasury/outbound_
を使用して OutboundPayment
を作成します。リクエストに使用可能なパラメーターのうち、以下は必須です。
amount
: セント単位での支払い金額。currency
: 3 文字の ISO 通貨コード (サポートされるのはusd
のみ)。financial_
: 資金が送金される支払い元の金融口座。account destination_
またはpayment_ method destination_
: 支払いの送金先に関する情報。payment_ method_ data destination_
では、まず SetupIntent (支払いインテント) を使用して、アウトバウンドフローのpayment_ method PaymentMethod
を設定する必要があります。また、PaymentMethod
が関連付けられるCustomer
オブジェクトと一致する顧客 ID を指定する必要もあります。別の方法として、Customer
に関連付けられた既存のレガシーの BankAccount をPaymentMethod
の代わりに使用することもできます。destination_
を使用すると、インラインで支払い方法の詳細を指定できます。このパラメーターは、銀行口座の詳細の指定や、Stripe ネットワーク経由の別の金融口座への送金に使用できます。payment_ method_ data
外部銀行口座への OutboundPayment を作成する
POST /v1/treasury/outbound_
を使用して、本文の financial_
パラメーター値の ID で特定された金融口座から OutboundPayment
を作成します。以下のリクエストは、statement_
と destination_
の情報を追加します。
成功すると、新しく作成された OutboundPayment
がレスポンスで返されます。
同日の ACH
プライベートプレビュー
同日の ACH は現在、制限付きのプレビュー版として提供されているため、Stripe の審査と承認が必要です。アクセスをリクエストするには、treasury-support@stripe.comにメールを送信してください。
アクセスできない場合、同日の ACH の機能またはパラメーターを含む API コールがエラーを返します。
Using same-day ACH enables sending funds that arrive the same business day if the OutboundPayment
call successfully completes before the cutoff time. To use same-day ACH, set the destination_
parameter to ach
and the destination_
parameter to same_
.
電信送金: 金融番号
一部の銀行では、ACH とは異なる別の電信送金の金融番号を使用することがあります。このため、支払い方法の金融番号が電信送金をサポートしていない場合、電信送金の作成時にエラーが発生することがあります。このエラーを受信した場合には、銀行の電信送金用の金融番号を指定して新しい支払い方法を追加する必要があります。
電信送金: 受取人の住所
電信送金には ACH メタデータのほかに、受取人名と請求先住所が必要です。住所は銀行の住所ではなく、電信送金を受け取るアカウント所有者の住所です。
支払い方法の billing_
を入力する際は、すべての住所フィールドに入力する必要があります。 billing_
に不完全なフィールドがある状態で電信送金しようとすると、エラーが発生します。
注
OutboundTransfer
を使用して電信送金を行う際、住所フィールドに入力しない場合は、デフォルトで Stripe アカウント所有者を代表する法人に設定されます。
金融口座への OutboundPayment を作成する
To move money between financial accounts, call POST /v1/treasury/outbound_
on the origin account and specify the destination account in the destination_
parameter. Both financial accounts must be associated with the same platform, but can’t be associated with the same connected account. To transfer money between financial accounts associated with the same connected account, use an OutboundTransfer.
リクエストの本文は、x-www-form-urlencoded
でなければなりませんが、以下の JSON は、送信できるデータを定義します。
OutboundPayment を取得する
GET /v1/treasury/outbound_
を使用し、関連付けられた ID の OutboundPayment
の詳細を取得します。
成功すると、関連付けられた ID の OutboundPayment
オブジェクトがレスポンスで返されます。 レスポンスの一部のパラメーターには、expand[]
パラメーターに値として追加した場合にのみ返される追加情報があります。次のレスポンス例で、拡張できるフィールドには、「Expandable」コメントが付いています。オブジェクトレスポンスの拡張の詳細については、レスポンスを拡張するをご覧ください。
OutboundPayment をキャンセルする
POST /v1/treasury/outbound_
を使用し、関連付けられた ID の OutboundPayment
をキャンセルします。OutboundPayment
オブジェクトには、送金をキャンセルできるかどうかを示すブール値を含む cancelable
パラメーターが含まれます。OutboundPayment
がネットワークに送信されると、cancelable
値が false
になり、このエンドポイントからの送金に対するエラーが受信されます。
成功すると、レスポンスで、status
値が canceled
に設定された OutboundPayment
オブジェクトが返されます。
{ "id": "{{OUTBOUND_PAYMENT_ID}}", "object": "outbound_payment", "livemode": false, "created": 123456, "financial_account": "{{FINANCIAL_ACCOUNT_ID}}", "amount": 1000, "currency": "usd", ... "status": "canceled",
OutboundPayment を一覧表示する
GET /v1/treasury/outbound_
を使用し、関連付けられた ID の金融口座からの OutboundPayments
をリストします。標準のリストパラメーターや、status
または customer
でリストをフィルタリングできます。
{ // Standard list parameters "limit", "starting_after", "ending_before", // Filter by status "status": "processing" | "canceled" | "failed" | "posted" | "returned", // Filter by FinancialAccount (Required) "financial_account": "{{FINANCIAL_ACCOUNT_ID}}", // Filter by Customer "customer": "{{CUSTOMER_ID}}", }
以下のリクエストは、プラットフォームに関連付けられた金融口座において、特定された Customer
に支払われた最新 5 件の OutboundPayment オブジェクト を取得します。
OutboundPayment の状態
以下の表は、各ステータスと可能な移行状態について説明したものです。
ステータス | 説明 | 可能な状態の移行 |
---|---|---|
processing | OutboundPayment の開始状態。資金は、保留中の取引に割り当てられます (ただし、引き続き現在の残高に含まれています)。cancelable パラメーターの値が true の間は 、ユーザーは OutboundPayment をキャンセルできます。 | posted 、canceled 、failed |
failed (最終状態) | OutboundPayment の確認に失敗しました。Stripe は保留中の取引を無効にし、資金をユーザーに返金します。 | 該当なし |
canceled (最終状態) | ユーザーが、転記前に OutboundPayment をキャンセルしました。Stripe は、保留中の取引を無効にし、資金をユーザーに返金します。 | 該当なし |
posted | OutboundPayment が転記され、資金がアカウントから送金されました。基となる取引が転記されます。 | returned |
returned (最終状態) | OutboundPayment は、送金先に正常に入金されませんでした。資金は取引 (returned_ ) とともにユーザーに返されます。 | 該当なし |
OutboundPayment をテストする
To test your integration end-to-end, we recommend using test SetupIntent requests to create a PaymentMethod
, then passing that PaymentMethod
into an OutboundPayment
creation request using the destination_
parameter.
Stripe では、以下のようなテスト用の PaymentMethod
トークンおよび番号を使用して、特定の機能をトリガーすることもできます。
- テスト用の
PaymentMethod
トークンをdestination_
に渡す (payment_ method ach
およびus_
のネットワークの場合)domestic_ wire - テスト用の
PaymentMethod
トークンをdestination_
に直接渡す場合でも、payment_ method customer
パラメーターに顧客 ID を渡す必要があります。便宜上、Stripe では既存のテスト用顧客を渡すことができます。これは、既存のPaymentMethod
をCustomer
に関連付け、同じ顧客 ID をcustomer
パラメーターに渡す必要がある本番環境とは異なります。
- テスト用の
- テスト用の金融番号と口座番号を
destination_
に渡す (payment_ method_ data[us_ bank_ account] ach
およびus_
のネットワークの場合)。domestic_ wire - プラットフォーム内アカウントが所有する既存のテスト用金融口座の ID を
destination_
(Stripe ネットワーク用) に渡す。payment_ method_ data[financial_ account]
いずれの場合も、OutboundPayment
のレスポンスは処理中のステータスを返します。Stripe は、該当する状態の移行に対して Webhook をトリガーします。OutboundPayment
を作成後に取得すると、想定された状態が返されます。
作成 | DESTINATION_PAYMENT_METHOD (既存のテスト用顧客) | DESTINATION_PAYMENT_METHOD_DATA[US_BANK_ACCOUNT] |
---|---|---|
初期の処理状態の OutboundPayment | pm_ |
|
(processing から) posted に移行する OutboundPayment | pm_ |
|
(processing から) posted に移行する OutboundPayment 。さらに、元の expected_ に 1 日追加します | pm_ |
|
(processing から) canceled に移行する OutboundPayment | pm_ |
|
(processing から) failed に移行する OutboundPayment | pm_ |
|
アカウント閉鎖のために (転記後に processing から) returned に移行する OutboundPayment | pm_ |
|
口座がないために (転記後に processing から) returned に移行する OutboundPayment | pm_ |
|
口座番号が無効であるために (転記後に processing から) returned に移行する OutboundPayment | pm_ |
|
OutboundPayment のテスト用ヘルパーエンドポイント
Stripe は、さまざまな状態の OutboundPayments
をテストできるエンドポイントを提供しています。テストエンドポイントを使用して、作成した OutboundPayment
を posted
、failed
、または returned
などの新しい状態に直接移行します。
テスト用の post エンドポイントを使用して、特定された
OutboundPayment
をprocessing
からposted
に移行します。POST /v1/test_
helpers/treasury/outbound_ payments/{{OUTBOUND_ PAYMENT_ ID}}/post テスト用の fail エンドポイントを使用して、特定された
OutboundPayment
をprocessing
からfailed
に移行します。POST /v1/test_
helpers/treasury/outbound_ payments/{{OUTBOUND_ PAYMENT_ ID}}/fail テスト用の return エンドポイントを使用して、特定された
OutboundPayment
をprocessing
からreturned
に移行します。POST /v1/test_
helpers/treasury/outbound_ payments/{{OUTBOUND_ PAYMENT_ ID}}/return
これらのエンドポイントは、返品などのエラーシナリオをテストするために特に便利です。こういったエンドポイントがなければ、外部でのアクションが必要になります。
return
エンドポイントでは、オプションの returned_
パラメーターを本文に含め、返金理由を示します。この情報が提供されない場合、送金にはデフォルトの declined
返金コードが適用されます。
{ "returned_details": { "code": "account_closed" | "account_frozen" | "bank_account_restricted" | "bank_ownership_changed" | "could_not_process" | "invalid_account_number" | "incorrect_account_holder_name" | "invalid_currency" | "no_account" | "declined" } }
また、テスト用の Outbound Payment
で追跡詳細の転記をシミュレートするための、テスト用更新エンドポイントも提供しています。tracking_
フィールドは、テスト用オブジェクトにのみ設定できます。
いずれのケースでも、Stripe は、該当するそれぞれの状態の移行に対して Webhooks をトリガーします。移行後に OutboundPayment
を取得すると、想定される状態が返されます。
OutboundPayment Webhook
Stripe は、Webhook エンドポイントに以下の OutboundPayment
イベントを送信します。
OutboundPayment
作成時のtreasury.
。outbound_ payment. created OutboundPayment
のステータスが変化した際のtreasury.
。ステータス値のオプションには以下が含まれます。outbound_ payment. {{new_ status}} treasury.
outbound_ payment. posted treasury.
outbound_ payment. failed treasury.
outbound_ payment. canceled treasury.
outbound_ payment. returned
OutboundPayment
のexpected_
が変化した際のarrival_ date treasury.
。outbound_ payment. expected_ arrival_ date_ updated OutboundPayment
の追跡の詳細情報が更新された際のtreasury.
。outbound_ payment. tracking_ details_ updated