# 銀行振込を受け付ける Payment Intents API を使用して、銀行振込による支払いを受け付けます。 顧客からの銀行振込による決済を初めて受け付ける際に、Stripe はその顧客用に仮想銀行口座を生成します。この口座は、顧客と直接共有できます。この顧客からの以降のすべての銀行振込による支払いは、この銀行口座に送金する必要があります。一部の国では、Stripe は、一意の送金照会番号も提供します。未払いの支払いと振込の照合を簡単にするため、顧客は各振込にこの番号を含める必要があります。国によっては、無料で作成できる仮想銀行口座番号の数に制限があります。 以下のシーケンス図は、銀行振込による決済を受け付ける際の一般的なステップの概要を示しています。 #### 請求書を使用する場合 銀行振込による決済を受け付ける際の一般的なステップ (See full diagram at https://docs.stripe.com/payments/bank-transfers/accept-a-payment) #### 請求書を使用しない場合 ![](https://b.stripecdn.com/docs-statics-srv/assets/without-invoices-diagram-1.49f7cde37ea5ffaf0fea278acbc2b9c8.svg) ## 支払い不足と過払いを処理する 銀行振込による決済では、顧客の振込額が予想される決済金額よりも多い場合や少ない場合があります。顧客の振込額が少ない場合、Stripe は、未払いの Payment Intent に部分的に資金を充当します。請求書に部分的に資金が充当されることはありません。入金された資金によって請求額の全額が支払われるまで、請求書は未払いのままになります。 顧客から予想される金額よりも多く振り込まれた場合、Stripe は、未払いの決済に対して入金された資金の照合を試行し、残りの超過額を顧客の残高に保持します。[照合処理](https://docs.stripe.com/payments/customer-balance/reconciliation.md) の詳細をご覧ください。 #### 請求書を使用する場合 顧客の支払いが不足している場合は以下のようになります。 顧客が予定よりも少ない金額を銀行振込で送金 (See full diagram at https://docs.stripe.com/payments/bank-transfers/accept-a-payment) 顧客の支払いが過払いの場合は以下のようになります。 顧客が予定よりも多い金額を銀行振込で送金 (See full diagram at https://docs.stripe.com/payments/bank-transfers/accept-a-payment) #### 請求書を使用しない場合 ![](https://b.stripecdn.com/docs-statics-srv/assets/without-invoices-diagram-2.5a500b70917ee9f5a5630e442bd2c4e6.svg) ![](https://b.stripecdn.com/docs-statics-srv/assets/without-invoices-diagram-3.2b20d27f7fc2208ed31cc95eab9de868.svg) ## 複数の未払いの支払いまたは請求書を処理する 銀行振込で支払うことができる未払いの支払いや請求書が複数ある場合があります。デフォルトの設定の場合、Stripe が振込の参照コードや送金額などの情報を使用して、銀行振込の[自動消し込み](https://docs.stripe.com/payments/customer-balance/reconciliation.md)を試行します。 自動消し込みを無効にして、支払いと請求書を[手動で消し込む](https://docs.stripe.com/payments/customer-balance/reconciliation.md#cash-manual-reconciliation)ことができます。[reconciliation mode (消し込みモード)](https://docs.stripe.com/api/customers/create.md#create_customer-cash_balance-settings-reconciliation_mode) を manual に設定すると、顧客ごとに自動消し込み動作を上書きできます。 # Checkout > This is a Checkout for when payment-ui is checkout. View the full page at https://docs.stripe.com/payments/bank-transfers/accept-a-payment?payment-ui=checkout. > Stripe は、通貨、支払い方法の制限、その他のパラメーターを評価することで、適切な支払い方法を顧客に自動的に提示できます。 > > - [決済の受け付け](https://docs.stripe.com/payments/accept-a-payment.md?payment-ui=checkout&ui=stripe-hosted)ガイドに従って、[動的な決済手段](https://docs.stripe.com/payments/payment-methods/dynamic-payment-methods.md)を使用するチェックアウトの統合機能を構築します。 - 動的な決済手段を使用しない場合は、チェックアウトの導入で、決済方法を手動で設定するために以下のステップに従ってください。 銀行振込は、Checkout の [1 回限りの使用](https://docs.stripe.com/payments/payment-methods.md#usage)の支払い方法であり、顧客は提示された決済手順を使用して銀行振込で支払います。支払いを選択すると、ユーザーはオンラインページにリダイレクトされ、そこに銀行振込の手順と送金のステータスが表示されます。 銀行振込は、*通知遅延型の決済手段* (A payment method that can't immediately return payment status when a customer attempts a transaction (for example, ACH debits). Businesses commonly hold an order in a pending state until payment is successful with these payment methods)でもあるため、決済後すぐには売上が利用可能になりません。 > 銀行振込は、セッション作成リクエストの一部として既存の [Customer オブジェクト](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-customer) を含んでいなかった Checkout セッションでは、使用できません。 ## 互換性を判断する **サポート対象のビジネスの所在地**: Europe (SEPA area), UK, JP, MX, US **対応可能な通貨**: `eur, gbp, jpy, mxn, usd` **取引通貨**: `eur, gbp, jpy, mxn, usd` **支払いモード**: Yes **セットアップモード**: No **サブスクリプションモード**: No Bank Transfer 決済に対応するには、Checkout セッションが次の条件をすべて満たしている必要があります。 - すべてのラインアイテムの*価格* (Prices define how much and how often to charge for products. This includes how much the product costs, what currency to use, and the interval if the price is for subscriptions)が、同じ通貨である必要があります。異なる通貨のラインアイテムが存在する場合は、通貨ごとに別の Checkout セッションを作成します。 - 使用できるのは単一の項目だけです (銀行振込の Checkout セッションは、継続的な*サブスクリプション* (A Subscription represents the product details associated with the plan that your customer subscribes to. Allows you to charge the customer on a recurring basis)プランに対応していません)。 ## 決済を受け付ける > このガイドを使用する前に、まず Checkout で[決済を受け付ける](https://docs.stripe.com/payments/accept-a-payment.md?integration=checkout)ための実装を構築します。 このガイドを使用して Bank Transfer を有効化します。 ### Customer を作成または取得する 銀行振込による各支払いを消し込むには、[Customer (顧客)](https://docs.stripe.com/api/customers.md) オブジェクトを関連付ける必要があります。すでに Customer オブジェクトが存在する場合は、このステップをスキップできます。ない場合は、新しい Customer オブジェクトを作成します。 ```curl curl -X POST https://api.stripe.com/v1/customers \ -u "<>:" ``` ### 支払い方法として Bank Transfer を有効にする 新しい [Checkout Session (セッション)](https://docs.stripe.com/api/checkout/sessions.md) を作成する際は、以下を行う必要があります。 1. `customer` を設定します 1. `customer_balance` を `payment_method_types` のリストに追加します 1. すべての `line_items` が同じ通貨を使用していることを確認します #### US ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -d customer="{{CUSTOMER_ID}}" \ -d "line_items[0][price_data][currency]"=usd \ -d "line_items[0][price_data][product_data][name]"=T-shirt \ -d "line_items[0][price_data][unit_amount]"=2000 \ -d "line_items[0][quantity]"=1 \ -d mode=payment \ -d "payment_method_types[0]"=card \ -d "payment_method_types[1]"=customer_balance \ -d "payment_method_options[customer_balance][funding_type]"=bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][type]"=us_bank_transfer \ --data-urlencode success_url="https://example.com/success" ``` #### UK ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -d customer="{{CUSTOMER_ID}}" \ -d "line_items[0][price_data][currency]"=gbp \ -d "line_items[0][price_data][product_data][name]"=T-shirt \ -d "line_items[0][price_data][unit_amount]"=2000 \ -d "line_items[0][quantity]"=1 \ -d mode=payment \ -d "payment_method_types[0]"=card \ -d "payment_method_types[1]"=customer_balance \ -d "payment_method_options[customer_balance][funding_type]"=bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][type]"=gb_bank_transfer \ --data-urlencode success_url="https://example.com/success" ``` #### EU ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -d customer="{{CUSTOMER_ID}}" \ -d "line_items[0][price_data][currency]"=eur \ -d "line_items[0][price_data][product_data][name]"=T-shirt \ -d "line_items[0][price_data][unit_amount]"=2000 \ -d "line_items[0][quantity]"=1 \ -d mode=payment \ -d "payment_method_types[0]"=card \ -d "payment_method_types[1]"=customer_balance \ -d "payment_method_options[customer_balance][funding_type]"=bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][type]"=eu_bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][eu_bank_transfer][country]"=FR \ --data-urlencode success_url="https://example.com/success" ``` [payment_method_options[customer_balance][bank_transfer][eu_bank_transfer][country]](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-bank_transfer-eu_bank_account-country) を `BE`、`DE`、`FR`、`IE`、`NL` のいずれかに設定し、顧客にローカライズされた IBAN を表示します。 #### JP ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -d customer="{{CUSTOMER_ID}}" \ -d "line_items[0][price_data][currency]"=jpy \ -d "line_items[0][price_data][product_data][name]"="Tシャツ" \ -d "line_items[0][price_data][unit_amount]"=19000 \ -d "line_items[0][quantity]"=1 \ -d mode=payment \ -d "payment_method_types[0]"=card \ -d "payment_method_types[1]"=customer_balance \ -d "payment_method_options[customer_balance][funding_type]"=bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][type]"=jp_bank_transfer \ --data-urlencode success_url="https://example.com/success" ``` #### MX ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -d customer="{{CUSTOMER_ID}}" \ -d "line_items[0][price_data][currency]"=mxn \ -d "line_items[0][price_data][product_data][name]"=T-shirt \ -d "line_items[0][price_data][unit_amount]"=18000 \ -d "line_items[0][quantity]"=1 \ -d mode=payment \ -d "payment_method_types[0]"=card \ -d "payment_method_types[1]"=customer_balance \ -d "payment_method_options[customer_balance][funding_type]"=bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][type]"=mx_bank_transfer \ --data-urlencode success_url="https://example.com/success" ``` ### Stripe がオンラインで提供する銀行振込の手順ページにリダイレクトする > カード決済と異なり、銀行振込による決済では顧客が常に [success_url](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-success_url) にリダイレクトされるわけではありません。 Checkout フォームの*送信* (Submitting an order indicates that the customer intends to pay. Upon submission, the order can no longer be updated and is ready for payment)に成功すると、 - 顧客の残高にリクエストに対応するための十分な金額がある場合、支払いはすぐに成功し、顧客は [success_url](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-success_url) にリダイレクトされます。 - 顧客の残高にリクエストに対応するための十分な金額がない場合、顧客は [hosted_instructions_url](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-hosted_instructions_url) にリダイレクトされます。このページには、送金を完了できるよう顧客に説明する手順が含まれています。 Stripe では、[ブランディング設定](https://dashboard.stripe.com/account/branding)ページで顧客に表示される UI をカスタマイズすることができます。オンラインの手順ページには、以下のブランド設定を適用できます。 - **アイコン**: ブランド画像と公開ビジネス名 - **ブランドカラー**: 背景色として使用されます ### 注文のフルフィルメントを実行する 銀行振込は*通知遅延型の決済手段* (A payment method that can't immediately return payment status when a customer attempts a transaction (for example, ACH debits). Businesses commonly hold an order in a pending state until payment is successful with these payment methods)であるため、*Webhook* (A webhook is a real-time push notification sent to your application as a JSON payload through HTTPS requests) などの方法を使用して支払いステータスを監視し、注文の*フルフィルメント* (Fulfillment is the process of providing the goods or services purchased by a customer, typically after payment is collected)を行う必要があります。詳しくは、[Webhook の設定と注文のフルフィルメントの実行](https://docs.stripe.com/checkout/fulfillment.md)をご覧ください。 支払いステータスに変化があると、以下のイベントが送信されます。 | イベント名 | 説明 | 次のステップ | | -------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | ------------------------------- | | [checkout.session.completed](https://docs.stripe.com/api/events/types.md#event_types-checkout.session.completed) | 顧客は Checkout フォームの送信を完了し、`hosted_instructions_url` にリダイレクトされます。 | 顧客が銀行振込を行うのを待っています。 | | [checkout.session.async_payment_succeeded](https://docs.stripe.com/api/events/types.md#event_types-checkout.session.async_payment_succeeded) | 顧客は銀行振込の支払いを完了しました。`PaymentIntent` は `succeeded` に移行します。 | 顧客が購入した商品またはサービスのフルフィルメントを行います。 | ## Optional: 決済手順メールを送信する [ダッシュボード](https://dashboard.stripe.com/settings/emails)から銀行振込決済の手順メールを有効にできます。決済手順メールが有効になると、Stripe は以下の場合に顧客にメールを送信します。 - PaymentIntent が確定されましたが、顧客の残高が不足しています。 - 顧客が銀行振込を行いましたが、残高が不足しているため保留中の支払いを完了できませんでした。 銀行振込決済の手順メールには、請求金額、振込先の銀行情報、Stripe がオンラインで提供する手順ページへのリンクが記載されています。 > サンドボックスでは、決済手順メールは Stripe アカウントに関連付けられているメールアドレスにのみ送信されます。 ## 組み込みをテストする API、ダッシュボード、または Stripe CLI のベータバージョンを使用して、銀行振込の受け取りをシミュレーションすることにより、実装をテストできます。 #### ダッシュボード ダッシュボードを使用して*サンドボックス* (A sandbox is an isolated test environment that allows you to test Stripe functionality in your account without affecting your live integration. Use sandboxes to safely experiment with new features and changes)で銀行振込をシミュレーションするには、ダッシュボードで顧客のページに移動します。**決済手段**で、**追加**をクリックして、**現金残高に資金を追加 (テスト環境のみ)** を選択します。 #### API API を使用して銀行振込をシミュレーションするには、以下のようにします。 #### US ```bash curl https://api.stripe.com/v1/test_helpers/customers/{{CUSTOMER_ID}}/fund_cash_balance \ -X POST \ -u <>: \ -d "reference"="REF-4242" \ -d "amount"="1000" \ -d "currency"="usd" ``` #### UK ```bash curl https://api.stripe.com/v1/test_helpers/customers/{{CUSTOMER_ID}}/fund_cash_balance \ -X POST \ -u <>: \ -d "reference"="REF-4242" \ -d "amount"="1000" \ -d "currency"="gbp" ``` #### EU ```bash curl https://api.stripe.com/v1/test_helpers/customers/{{CUSTOMER_ID}}/fund_cash_balance \ -X POST \ -u <>: \ -d "reference"="REF-4242" \ -d "amount"="1000" \ -d "currency"="eur" ``` #### JP ```bash curl https://api.stripe.com/v1/test_helpers/customers/{{CUSTOMER_ID}}/fund_cash_balance \ -X POST \ -u <>: \ -d "amount"="1000" \ -d "currency"="jpy" ``` #### MX ```bash curl https://api.stripe.com/v1/test_helpers/customers/{{CUSTOMER_ID}}/fund_cash_balance \ -X POST \ -u <>: \ -d "reference"="123456" \ -d "amount"="1000" \ -d "currency"="mxn" ``` #### Stripe CLI Stripe CLI で銀行振込をシミュレーションするには、以下のようにします。 1. [Stripe CLI をインストール](https://docs.stripe.com/stripe-cli.md)します。 1. Stripe ダッシュボードへのサインインに使用したアカウントで、CLI にログインします。 ```bash stripe login ``` 1. 既存の顧客への銀行振込をシミュレーションします。 #### US ```bash stripe test_helpers customers fund_cash_balance "{{CUSTOMER_ID}}" \ --amount=1099 \ --reference=DVGBG97TZ6ZV \ --currency=usd ``` `reference` パラメーターはオプションであり、顧客が銀行振込の参照フィールドに入力した値をシミュレーションします。 #### UK ```bash stripe test_helpers customers fund_cash_balance "{{CUSTOMER_ID}}" \ --amount=1099 \ --reference=DVGBG97TZ6ZV \ --currency=gbp ``` `reference` パラメーターはオプションであり、顧客が銀行振込の参照フィールドに入力した値をシミュレーションします。 #### EU ```bash stripe test_helpers customers fund_cash_balance "{{CUSTOMER_ID}}" \ --amount=1099 \ --reference=DVGBG97TZ6ZV \ --currency=eur ``` `reference` パラメーターはオプションであり、顧客が銀行振込の参照フィールドに入力した値をシミュレーションします。 #### JP ```bash stripe test_helpers customers fund_cash_balance "{{CUSTOMER_ID}}" \ --amount=1000 \ --currency=jpy ``` #### MX ```bash stripe test_helpers customers fund_cash_balance "{{CUSTOMER_ID}}" \ --amount=1099 \ --reference=123456 \ --currency=mxn ``` `reference` パラメーターはオプションであり、顧客が銀行振込の参照フィールドに入力した値をシミュレーションします。 ## See also - [Checkout のフルフィルメント](https://docs.stripe.com/checkout/fulfillment.md) - [Checkout のカスタマイズ](https://docs.stripe.com/payments/checkout/customization.md) # Elements > This is a Elements for when payment-ui is elements. View the full page at https://docs.stripe.com/payments/bank-transfers/accept-a-payment?payment-ui=elements. ## Stripe を設定する [サーバー側] まず、Stripe アカウントが必要です。[今すぐ登録](https://dashboard.stripe.com/register)してください。 アプリケーションから Stripe API にアクセスするには、Stripe の公式ライブラリを使用します。 #### Ruby ```bash # Available as a gem sudo gem install stripe ``` ```ruby # If you use bundler, you can add this line to your Gemfile gem 'stripe' ``` ## Customer を作成または取得する [サーバー側] 銀行振込による各支払いを消し込むには、[Customer (顧客)](https://docs.stripe.com/api/customers.md) オブジェクトを関連付ける必要があります。すでに Customer オブジェクトが存在する場合は、このステップをスキップできます。ない場合は、新しい Customer オブジェクトを作成します。 ```curl curl -X POST https://api.stripe.com/v1/customers \ -u "<>:" ``` ## PaymentIntent を作成する [サーバー側] [PaymentIntent](https://docs.stripe.com/api/payment_intents/object.md) は、顧客から支払いを回収する意図を表すオブジェクトであり、支払いプロセスのライフサイクルをステージごとに追跡します。回収する金額と通貨を指定して、サーバーで PaymentIntent を作成します。PaymentIntent 作成リクエストの [customer パラメーター](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-customer)にも入力する必要があります。銀行振込は、顧客が指定されていない PaymentIntents には利用できません。 #### ダッシュボードで支払い方法を管理する Payment Intent を作成する前に、ダッシュボードの[支払い方法の設定](https://dashboard.stripe.com/settings/payment_methods)ページで、**銀行振込**を有効にしていることを確認します。 > [動的な支払い方法](https://docs.stripe.com/payments/payment-methods/dynamic-payment-methods.md)の場合、Stripe は取引額、通貨、決済フローなどの要素に基づいて、適切な支払い方法が返されるように処理します。 #### US ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d customer="{{CUSTOMER_ID}}" \ -d currency=usd \ -d "automatic_payment_methods[enabled]"=true ``` #### UK ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d customer="{{CUSTOMER_ID}}" \ -d currency=gbp \ -d "automatic_payment_methods[enabled]"=true ``` #### EU ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d customer="{{CUSTOMER_ID}}" \ -d currency=eur \ -d "automatic_payment_methods[enabled]"=true ``` 顧客に表示される IBAN を各地域に合わせるには、[`address.country`](https://docs.stripe.com/api/customers/object.md#customer_object-address-country) プロパティを設定するか、[ダッシュボードで顧客を編集](https://docs.stripe.com/invoicing/customer.md#edit-a-customer)して、顧客の国を設定できます。 Stripe では の IBAN ローカライゼーションに対応しています。 - 顧客に国を設定していない場合、または顧客の国が IBAN コードに対応していない場合は、Stripe アカウントの国に戻されます。 - IBAN のローカライゼーションが Stripe アカウントの国でサポートされていない場合、`IE` に戻されます。 > 現在、スペイン (ES) では、ローカライズされた仮想銀行口座番号を新規作成できません。代わりに、他の EU VBAN 加盟国を使用してください。 #### JP ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=19000 \ -d customer="{{CUSTOMER_ID}}" \ -d currency=jpy \ -d "automatic_payment_methods[enabled]"=true \ --data-urlencode return_url="https://example.com/return_url" ``` #### MX ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d customer="{{CUSTOMER_ID}}" \ -d currency=mxn \ -d "automatic_payment_methods[enabled]"=true \ --data-urlencode return_url="https://example.com/return_url" ``` 最新バージョンの API では、`automatic_payment_methods` パラメーターがデフォルトで有効になっているため、機能の指定は任意です。 支払い額に充当できる金額が顧客の残高に十分にある場合、PaymentIntent は `succeeded` ステータスで即座に成功します。顧客が誤って取引に対して過払いをした場合 (銀行振込の場合によく発生します)、差額が生じることがあります。[お客様の所在地に基づいて一定期間内に顧客の残高を消し込む](https://docs.stripe.com/payments/customer-balance/reconciliation.md)必要があります。 #### 支払い方法を手動でリスト化する API を使用して支払い方法を手動で指定するには、PaymentIntent の[支払い方法のタイプ](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_types)の一覧に `customer_balance` を追加します。Customer の [ID](https://docs.stripe.com/api/customers/object.md#customer_object-id) を指定します。 #### US ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d currency=usd \ -d customer="{{CUSTOMER_ID}}" \ -d "payment_method_types[]"=customer_balance \ -d "payment_method_options[customer_balance][funding_type]"=bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][type]"=us_bank_transfer ``` 支払い額に充当できる金額が顧客の残高に十分にある場合、PaymentIntent は `succeeded` ステータスで即座に成功します。顧客が誤って取引に対して過払いをした場合 (銀行振込の場合によく発生します)、差額が生じることがあります。[お客様の所在地に基づいて一定期間内に顧客の残高を消し込む](https://docs.stripe.com/payments/customer-balance/reconciliation.md)必要があります。 - [funding_type](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-funding_type) として `bank_transfer` を使用することで、顧客に支払い金額に対応できるだけの十分な残高がない場合の対処方法を指定します。 - [bank_transfer[type]](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-bank_transfer-type) として `us_bank_transfer` を使用することで、支払いの実行に使用できる銀行振込タイプを指定します。 #### UK ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d currency=gbp \ -d customer="{{CUSTOMER_ID}}" \ -d "payment_method_types[]"=customer_balance \ -d "payment_method_options[customer_balance][funding_type]"=bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][type]"=gb_bank_transfer ``` 支払い額に充当できる金額が顧客の残高に十分にある場合、PaymentIntent は `succeeded` ステータスで即座に成功します。顧客が誤って取引に対して過払いをした場合 (銀行振込の場合によく発生します)、差額が生じることがあります。[お客様の所在地に基づいて一定期間内に顧客の残高を消し込む](https://docs.stripe.com/payments/customer-balance/reconciliation.md)必要があります。 - [funding_type](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-funding_type) として `bank_transfer` を使用することで、顧客に支払い金額に対応できるだけの十分な残高がない場合の対処方法を指定します。 - [bank_transfer[type]](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-bank_transfer-type) として `gb_bank_transfer` を使用することで、支払いの実行に使用できる銀行振込タイプを指定します。 #### EU ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d currency=eur \ -d customer="{{CUSTOMER_ID}}" \ -d "payment_method_types[]"=customer_balance \ -d "payment_method_options[customer_balance][funding_type]"=bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][type]"=eu_bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][eu_bank_transfer][country]"=FR ``` 支払い額に充当できる金額が顧客の残高に十分にある場合、PaymentIntent は `succeeded` ステータスで即座に成功します。顧客が誤って取引に対して過払いをした場合 (銀行振込の場合によく発生します)、差額が生じることがあります。[お客様の所在地に基づいて一定期間内に顧客の残高を消し込む](https://docs.stripe.com/payments/customer-balance/reconciliation.md)必要があります。 - [funding_type](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-funding_type) として `bank_transfer` を使用することで、顧客に支払い金額に対応できるだけの十分な残高がない場合の対処方法を指定します。 - [bank_transfer[type]](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-bank_transfer-type) として `eu_bank_transfer` を使用することで、支払いの実行に使用できる銀行振込タイプを指定します。 - [payment_method_options[customer_balance][bank_transfer][eu_bank_transfer][country]](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-bank_transfer-eu_bank_account-country) を のいずれかに設定します。顧客に表示される IBAN は、選択した国に合わせて適応されます。 > 現在、スペイン (ES) では、ローカライズされた仮想銀行口座番号を新規作成できません。代わりに、他の EU VBAN 加盟国を使用してください。 #### JP ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=19000 \ -d currency=jpy \ -d customer="{{CUSTOMER_ID}}" \ -d "payment_method_types[]"=customer_balance \ -d "payment_method_options[customer_balance][funding_type]"=bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][type]"=jp_bank_transfer ``` 支払い額に充当できる金額が顧客の残高に十分にある場合、PaymentIntent は `succeeded` ステータスで即座に成功します。顧客が誤って取引に対して過払いをした場合 (銀行振込の場合によく発生します)、差額が生じることがあります。[お客様の所在地に基づいて一定期間内に顧客の残高を消し込む](https://docs.stripe.com/payments/customer-balance/reconciliation.md)必要があります。 - [funding_type](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-funding_type) として `bank_transfer` を使用することで、顧客に支払い金額に対応できるだけの十分な残高がない場合の対処方法を指定します。 - [bank_transfer[type]](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-bank_transfer-type) として `jp_bank_transfer` を使用することで、支払いの実行に使用できる銀行振込タイプを指定します。 #### MX ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d currency=mxn \ -d customer="{{CUSTOMER_ID}}" \ -d "payment_method_types[]"=customer_balance \ -d "payment_method_options[customer_balance][funding_type]"=bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][type]"=mx_bank_transfer ``` 支払い額に充当できる金額が顧客の残高に十分にある場合、PaymentIntent は `succeeded` ステータスで即座に成功します。顧客が誤って取引に対して過払いをした場合 (銀行振込の場合によく発生します)、差額が生じることがあります。[お客様の所在地に基づいて一定期間内に顧客の残高を消し込む](https://docs.stripe.com/payments/customer-balance/reconciliation.md)必要があります。 - [funding_type](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-funding_type) として `bank_transfer` を使用することで、顧客に支払い金額に対応できるだけの十分な残高がない場合の対処方法を指定します。 - [bank_transfer[type]](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-bank_transfer-type) として `mx_bank_transfer` を使用することで、支払いの実行に使用できる銀行振込タイプを指定します。 > 支払いを作成するときは必ず、`payment_method_types` を指定します。[将来の支払い](https://docs.stripe.com/payments/save-and-reuse.md)には `customer_balance` を使用することはできません。 ## 支払いの詳細を収集する [クライアント側] [Payment Element](https://docs.stripe.com/payments/payment-element.md) を使用してクライアント側で支払い詳細を収集します。Payment Element は事前構築された UI コンポーネントであり、さまざまな決済手段の詳細の収集をシンプルにします。 Payment Element には、HTTPS 接続を介して支払い情報を Stripe に安全に送信する iframe が含まれています。一部の支払い方法では、支払いを確定するために別のページにリダイレクトする必要があるため、Payment Element を別の iframe 内に配置しないでください。 iframe を使用して Apple Pay または Google Pay を受け付けたい場合は、iframe の [allow](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-allowpaymentrequest) 属性を `"payment *"` と等しく設定する必要があります。 構築済みのシステムを機能させるには、決済ページのアドレスの先頭を `http://` ではなく `https://` にする必要があります。HTTPS を使用しなくてもシステムをテストできますが、本番環境で決済を受け付ける準備が整ったら、必ず、HTTPS を[有効](https://docs.stripe.com/security/guide.md#tls)にしてください。 #### HTML + JS ### Stripe.js を設定する Payment Element は Stripe.js の機能として自動的に使用できるようになります。決済ページに Stripe.js スクリプトを含めるには、HTML ファイルの `head` にスクリプトを追加します。常に js.stripe.com から Stripe.js を直接読み込むことにより、PCI 準拠が維持されます。スクリプトをバンドルに含めたり、そのコピーを自身でホストしたりしないでください。 ```html Checkout ``` 決済ページで以下の JavaScript を使用して、Stripe のインスタンスを作成します。 ```javascript // Set your publishable key: remember to change this to your live publishable key in production // See your keys here: https://dashboard.stripe.com/apikeys const stripe = Stripe('<>'); ``` ### Payment Element を支払いページに追加する Payment Element を決済ページに配置する場所が必要です。決済フォームで、一意の ID を持つ空の DOM ノード (コンテナー) を作成します。 ```html
``` 前のフォームが読み込まれたら、Payment Element のインスタンスを作成して、それをコンテナーの DOM ノードにマウントします。[Elements](https://docs.stripe.com/js/elements_object/create) インスタンスを作成する際に、前のステップからの [client secret](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-client_secret) を `options` に渡します。 client secret は支払いを完了できるため、慎重に取り扱う必要があります。記録したり、URL に埋め込んだり、当該の顧客以外に漏洩することがないようにしてください。 ```javascript const options = { clientSecret: '{{CLIENT_SECRET}}', // Fully customizable with appearance API. appearance: {/*...*/}, }; // Set up Stripe.js and Elements to use in checkout form, passing the client secret obtained in a previous stepconst elements = stripe.elements(options); // Create and mount the Payment Element const paymentElementOptions = { layout: 'accordion'}; const paymentElement = elements.create('payment', paymentElementOptions); paymentElement.mount('#payment-element'); ``` #### React ### Stripe.js を設定する 次の npm パブリックレジストリーから [React Stripe.js](https://www.npmjs.com/package/@stripe/react-stripe-js) と [Stripe.js ローダー](https://www.npmjs.com/package/@stripe/stripe-js)をインストールします。 ```bash npm install --save @stripe/react-stripe-js @stripe/stripe-js ``` ### Elements プロバイダーを支払いページに追加して設定する Payment Element コンポーネントを使用するには、決済ページコンポーネントを [Elements プロバイダー](https://docs.stripe.com/sdks/stripejs-react.md#elements-provider)でラップします。公開キーを使用して `loadStripe` を呼び出し、返された `Promise` を `Elements` プロバイダーに渡します。加えて、前のステップの [client secret](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-client_secret) を `options` にして `Elements` プロバイダーに渡します。 ```jsx import React from 'react'; import ReactDOM from 'react-dom'; import {Elements} from '@stripe/react-stripe-js'; import {loadStripe} from '@stripe/stripe-js'; import CheckoutForm from './CheckoutForm'; // Make sure to call `loadStripe` outside of a component’s render to avoid // recreating the `Stripe` object on every render. const stripePromise = loadStripe('<>'); function App() { const options = { // passing the client secret obtained in step 3 clientSecret: '{{CLIENT_SECRET}}', // Fully customizable with appearance API. appearance: {/*...*/}, }; return ( ); }; ReactDOM.render(, document.getElementById('root')); ``` ### Payment Element コンポーネントを追加する `PaymentElement` コンポーネントを使用して、フォームを構築します。 ```jsx import React from 'react'; import {PaymentElement} from '@stripe/react-stripe-js'; const CheckoutForm = () => { return (
); }; export default CheckoutForm; ``` Stripe Elements は、ドロップイン UI コンポーネントのコレクションです。フォームをさらにカスタマイズしたり、その他の顧客情報を収集したりする場合は、[Elements のドキュメント](https://docs.stripe.com/payments/elements.md)をご覧ください。 Payment Element によって動的なフォームが表示され、顧客はここで支払い方法を選択できます。支払い方法ごとに、フォームでは、必要な支払いの詳細のすべてを入力するように顧客に自動的に求めます。 ### デザインをカスタマイズする `Elements` プロバイダーを作成する際に、[Appearance (デザイン) オブジェクト](https://docs.stripe.com/js/elements_object/create#stripe_elements-options-appearance)を `options` に渡すことで、サイトのデザインに合わせて Payment Element をカスタマイズできます。 ### 住所を収集 デフォルトでは、Payment Element は必要な請求住所の詳細のみを収集します。[税金の計算](https://docs.stripe.com/api/tax/calculations/create.md)、配送先情報を入力するなどの一部の動作では、顧客の完全な住所が必要です。次のように対応できます。 - [Address Element](https://docs.stripe.com/elements/address-element.md) を使用して、オートコンプリートとローカリゼーションの機能を利用して、顧客の完全な住所を収集します。これにより、最も正確な税金計算が可能になります。 - 独自のカスタムフォームを使用して住所の詳細を収集する。 確定されると、Stripe は顧客に銀行振込の詳細を表示するモーダルを自動的に開きます。 ## Stripe に支払いを送信する [クライアント側] Payment Element からの詳細を指定して [stripe.confirmPayment](https://docs.stripe.com/js/payment_intents/confirm_payment) を使用し、支払いを完了します。ユーザーが支払いを完了した後に Stripe がユーザーをリダイレクトする場所を指定するには、この関数に [return_url](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-return_url) を指定します。ユーザーはまず、銀行のオーソリページなどの中間サイトにリダイレクトされ、その後 `return_url` にリダイレクトされます。カード支払いでは、支払いが正常に完了するとすぐに `return_url` にリダイレクトします。 カード決済で支払いの完了後にリダイレクトを行わない場合は、[redirect](https://docs.stripe.com/js/payment_intents/confirm_payment#confirm_payment_intent-options-redirect) に `if_required` を設定できます。これで、リダイレクトベースの決済手段で購入する顧客のみがリダイレクトされます。 #### HTML + JS ```javascript const form = document.getElementById('payment-form'); form.addEventListener('submit', async (event) => { event.preventDefault(); const {error} = await stripe.confirmPayment({ //`Elements` instance that was used to create the Payment Element elements, confirmParams: { return_url: 'https://example.com/order/123/complete', }, }); if (error) { // This point will only be reached if there is an immediate error when // confirming the payment. Show error to your customer (for example, payment // details incomplete) const messageContainer = document.querySelector('#error-message'); messageContainer.textContent = error.message; } else { // Your customer will be redirected to your `return_url`. For some payment // methods like iDEAL, your customer will be redirected to an intermediate // site first to authorize the payment, then redirected to the `return_url`. } }); ``` #### React 支払いフォームコンポーネントから [stripe.confirmPayment](https://docs.stripe.com/js/payment_intents/confirm_payment) を呼び出すには、[useStripe](https://docs.stripe.com/sdks/stripejs-react.md#usestripe-hook) フックと [useElements](https://docs.stripe.com/sdks/stripejs-react.md#useelements-hook) フックを使用します。 フックではなく従来のクラスコンポーネントを使用する場合は、代わりに [ElementsConsumer](https://docs.stripe.com/sdks/stripejs-react.md#elements-consumer) を使用します。 ```jsx import React, {useState} from 'react'; import {useStripe, useElements, PaymentElement} from '@stripe/react-stripe-js'; const CheckoutForm = () => { const stripe = useStripe(); const elements = useElements(); const [errorMessage, setErrorMessage] = useState(null); const handleSubmit = async (event) => { // We don't want to let default form submission happen here, // which would refresh the page. event.preventDefault(); if (!stripe || !elements) { // Stripe.js hasn't yet loaded. // Make sure to disable form submission until Stripe.js has loaded. return; } const {error} = await stripe.confirmPayment({ //`Elements` instance that was used to create the Payment Element elements, confirmParams: { return_url: 'https://example.com/order/123/complete', }, }); if (error) { // This point will only be reached if there is an immediate error when // confirming the payment. Show error to your customer (for example, payment // details incomplete) setErrorMessage(error.message); } else { // Your customer will be redirected to your `return_url`. For some payment // methods like iDEAL, your customer will be redirected to an intermediate // site first to authorize the payment, then redirected to the `return_url`. } }; return (
{/* Show error message to your customers */} {errorMessage &&
{errorMessage}
} ); }; export default CheckoutForm; ``` `return_url` が、Web サイト上の支払いステータスを表示するページと対応していることを確認します。Stripe が顧客を `return_url` にリダイレクトするときは、以下の URL クエリーパラメーターが指定されます。 | パラメーター | 説明 | | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- | | `payment_intent` | `PaymentIntent` の一意の識別子。 | | `payment_intent_client_secret` | `PaymentIntent` オブジェクトの [client secret](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-client_secret)。 | > 顧客のブラウザーセッションを追跡するツールを利用している場合、リファラー除外リストに `stripe.com` ドメインの追加が必要になる場合があります。リダイレクトを行うと、一部のツールでは新しいセッションが作成され、セッション全体の追跡ができなくなります。 クエリパラメーターのいずれか 1 つを使用して PaymentIntent を取得します。[PaymentIntent のステータス](https://docs.stripe.com/payments/paymentintents/lifecycle.md)を調べて、顧客に表示する内容を決定します。また、`return_url` を指定するときにカスタムのクエリパラメーターを追加することもできます。このパラメーターはリダイレクトプロセスの間維持されます。 #### HTML + JS ```javascript // Initialize Stripe.js using your publishable key const stripe = Stripe('<>'); // Retrieve the "payment_intent_client_secret" query parameter appended to // your return_url by Stripe.js const clientSecret = new URLSearchParams(window.location.search).get( 'payment_intent_client_secret' ); // Retrieve the PaymentIntent stripe.retrievePaymentIntent(clientSecret).then(({paymentIntent}) => { const message = document.querySelector('#message') // Inspect the PaymentIntent `status` to indicate the status of the payment // to your customer. // // Some payment methods will [immediately succeed or fail][0] upon // confirmation, while others will first enter a `processing` state. // // [0]: https://stripe.com/docs/payments/payment-methods#payment-notification switch (paymentIntent.status) { case 'succeeded': message.innerText = 'Success! Payment received.'; break; case 'processing': message.innerText = "Payment processing. We'll update you when payment is received."; break; case 'requires_payment_method': message.innerText = 'Payment failed. Please try another payment method.'; // Redirect your user back to your payment page to attempt collecting // payment again break; default: message.innerText = 'Something went wrong.'; break; } }); ``` #### React ```jsx import React, {useState, useEffect} from 'react'; import {useStripe} from '@stripe/react-stripe-js'; const PaymentStatus = () => { const stripe = useStripe(); const [message, setMessage] = useState(null); useEffect(() => { if (!stripe) { return; } // Retrieve the "payment_intent_client_secret" query parameter appended to // your return_url by Stripe.js const clientSecret = new URLSearchParams(window.location.search).get( 'payment_intent_client_secret' ); // Retrieve the PaymentIntent stripe .retrievePaymentIntent(clientSecret) .then(({paymentIntent}) => { // Inspect the PaymentIntent `status` to indicate the status of the payment // to your customer. // // Some payment methods will [immediately succeed or fail][0] upon // confirmation, while others will first enter a `processing` state. // // [0]: https://stripe.com/docs/payments/payment-methods#payment-notification switch (paymentIntent.status) { case 'succeeded': setMessage('Success! Payment received.'); break; case 'processing': setMessage("Payment processing. We'll update you when payment is received."); break; case 'requires_payment_method': // Redirect your user back to your payment page to attempt collecting // payment again setMessage('Payment failed. Please try another payment method.'); break; default: setMessage('Something went wrong.'); break; } }); }, [stripe]); return message; }; export default PaymentStatus; ``` ## Optional: 決済手順メールを送信する [ダッシュボード](https://dashboard.stripe.com/settings/emails)から銀行振込決済の手順メールを有効にできます。決済手順メールが有効になると、Stripe は以下の場合に顧客にメールを送信します。 - PaymentIntent が確定されましたが、顧客の残高が不足しています。 - 顧客が銀行振込を行いましたが、残高が不足しているため保留中の支払いを完了できませんでした。 銀行振込決済の手順メールには、請求金額、振込先の銀行情報、Stripe がオンラインで提供する手順ページへのリンクが記載されています。 > サンドボックスでは、決済手順メールは Stripe アカウントに関連付けられているメールアドレスにのみ送信されます。 ## PaymentIntent の成功を確認する PaymentIntent は、売上が銀行口座に入金されるまで `requires_action` ステータスのままとなります。売上の準備ができると、PaymentIntent のステータスが `requires_action` から `succeeded` に更新されます。 *Webhook* (A webhook is a real-time push notification sent to your application as a JSON payload through HTTPS requests) エンドポイントは、`payment_intent.partially_funded` イベントの受信を開始するように設定する必要があります。PaymentIntent の一部だけ入金された場合、ステータスは `requires_action` ステータスのままとなります。 [ダッシュボードから Webhook を追加](https://dashboard.stripe.com/webhooks/create)できます。 また、[Webhook Endpoints API](https://docs.stripe.com/api/webhook_endpoints.md) を使用して [payment_intent.partially_funded](https://docs.stripe.com/api/events/types.md#event_types-payment_intent.partially_funded) イベントの受信を開始することもできます。 > [Stripe CLI](https://docs.stripe.com/stripe-cli.md) は、`payment_intent.partially_funded` など、ベータ API バージョンのイベントのトリガーはサポートしていません。 PaymentIntent が更新されると、以下のイベントが支払い資金追加フロー中に送信されます。 | イベント | 説明 | 次のステップ | | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `payment_intent.requires_action` | 顧客の残高に PaymentIntent を消し込むのに十分な資金がない場合、確定時に送信され、PaymentIntent は `requires_action` に移行します。 | `amount_remaining` を使用して銀行振込を行うよう顧客に指示します。 | | `payment_intent.partially_funded` | 顧客は PaymentIntent に充てられた銀行振込を行いましたが、支払いを完了するのに十分ではありませんでした。このような状況は、振込額が不足していたり (誤りによる支払い不足または銀行から請求される手数料のため)、差引残高がこの PaymentIntent に適用されていたりすると発生する可能性があります。一部のみ資金追加された PaymentIntent は支払いが完了するまでアカウント残高に反映されません。 | 新しい `amount_remaining` を使用して別の銀行振込を行い、支払いを完了するよう顧客に指示します。部分的に資金を充当して支払いを完了する場合は、`amount` を更新して PaymentIntent をもう一度[確定](https://docs.stripe.com/api/payment_intents/confirm.md)できます。 | | `payment_intent.succeeded` | 顧客の支払いが成功しました。 | 顧客が購入した商品またはサービスのフルフィルメントを行います。 | > 部分的に資金が充当された PaymentIntent の金額を変更すると、売上は顧客の残高に戻されます。他に open 状態の PaymentIntent がある場合、Stripe はそれらに自動で資金追加します。顧客に手動消し込みが設定されている場合は、もう一度[売上を充当する](https://docs.stripe.com/api/payment_intents/apply_customer_balance.md)必要があります。 支払いが成功したことを確認し、顧客に支払い完了を通知するには、[Webhook を使用](https://docs.stripe.com/payments/payment-intents/verifying-status.md#webhooks)することをお勧めします。 ### サンプルコード #### Ruby ```ruby require 'json' # Using Sinatra post '/webhook' do payload = request.body.read event = nil begin event = Stripe::Event.construct_from( JSON.parse(payload, symbolize_names: true) ) rescue JSON::ParserError => e # Invalid payload status 400 return end # Handle the event case event.type when 'payment_intent.requires_action' payment_intent = event.data.object # contains a Stripe::PaymentIntent # The payment intent was not fully funded due to insufficient funds # on the customer balance. Define and call a method to handle the payment intent. # handle_payment_intent_requires_action(payment_intent) when 'payment_intent.partially_funded' payment_intent = event.data.object # contains a Stripe::PaymentIntent # Then define and call a method to handle the payment intent being partially funded. # handle_payment_intent_partially_funded(payment_intent) when 'payment_intent.succeeded' payment_intent = event.data.object # contains a Stripe::PaymentIntent # Then define and call a method to handle the successful payment intent. # handle_payment_intent_succeeded(payment_intent) else puts "Unhandled event type: #{event.type}" end status 200 end ``` ### ダッシュボードで保留中の支払いを確認する [ダッシュボード](https://dashboard.stripe.com/payments)で**ステータス**に**資金供給待ち**のフィルターを適用すると、保留中のすべての銀行振込 PaymentIntent を確認できます。 ## 組み込みをテストする API、ダッシュボード、または Stripe CLI のベータバージョンを使用して、銀行振込の受け取りをシミュレーションすることにより、実装をテストできます。 #### ダッシュボード ダッシュボードを使用して*サンドボックス* (A sandbox is an isolated test environment that allows you to test Stripe functionality in your account without affecting your live integration. Use sandboxes to safely experiment with new features and changes)で銀行振込をシミュレーションするには、ダッシュボードで顧客のページに移動します。**決済手段**で、**追加**をクリックして、**現金残高に資金を追加 (テスト環境のみ)** を選択します。 #### API API を使用して銀行振込をシミュレーションするには、以下のようにします。 #### US ```bash curl https://api.stripe.com/v1/test_helpers/customers/{{CUSTOMER_ID}}/fund_cash_balance \ -X POST \ -u <>: \ -d "reference"="REF-4242" \ -d "amount"="1000" \ -d "currency"="usd" ``` #### UK ```bash curl https://api.stripe.com/v1/test_helpers/customers/{{CUSTOMER_ID}}/fund_cash_balance \ -X POST \ -u <>: \ -d "reference"="REF-4242" \ -d "amount"="1000" \ -d "currency"="gbp" ``` #### EU ```bash curl https://api.stripe.com/v1/test_helpers/customers/{{CUSTOMER_ID}}/fund_cash_balance \ -X POST \ -u <>: \ -d "reference"="REF-4242" \ -d "amount"="1000" \ -d "currency"="eur" ``` #### JP ```bash curl https://api.stripe.com/v1/test_helpers/customers/{{CUSTOMER_ID}}/fund_cash_balance \ -X POST \ -u <>: \ -d "amount"="1000" \ -d "currency"="jpy" ``` #### MX ```bash curl https://api.stripe.com/v1/test_helpers/customers/{{CUSTOMER_ID}}/fund_cash_balance \ -X POST \ -u <>: \ -d "reference"="123456" \ -d "amount"="1000" \ -d "currency"="mxn" ``` #### Stripe CLI Stripe CLI で銀行振込をシミュレーションするには、以下のようにします。 1. [Stripe CLI をインストール](https://docs.stripe.com/stripe-cli.md)します。 1. Stripe ダッシュボードへのサインインに使用したアカウントで、CLI にログインします。 ```bash stripe login ``` 1. 既存の顧客への銀行振込をシミュレーションします。 #### US ```bash stripe test_helpers customers fund_cash_balance "{{CUSTOMER_ID}}" \ --amount=1099 \ --reference=DVGBG97TZ6ZV \ --currency=usd ``` `reference` パラメーターはオプションであり、顧客が銀行振込の参照フィールドに入力した値をシミュレーションします。 #### UK ```bash stripe test_helpers customers fund_cash_balance "{{CUSTOMER_ID}}" \ --amount=1099 \ --reference=DVGBG97TZ6ZV \ --currency=gbp ``` `reference` パラメーターはオプションであり、顧客が銀行振込の参照フィールドに入力した値をシミュレーションします。 #### EU ```bash stripe test_helpers customers fund_cash_balance "{{CUSTOMER_ID}}" \ --amount=1099 \ --reference=DVGBG97TZ6ZV \ --currency=eur ``` `reference` パラメーターはオプションであり、顧客が銀行振込の参照フィールドに入力した値をシミュレーションします。 #### JP ```bash stripe test_helpers customers fund_cash_balance "{{CUSTOMER_ID}}" \ --amount=1000 \ --currency=jpy ``` #### MX ```bash stripe test_helpers customers fund_cash_balance "{{CUSTOMER_ID}}" \ --amount=1099 \ --reference=123456 \ --currency=mxn ``` `reference` パラメーターはオプションであり、顧客が銀行振込の参照フィールドに入力した値をシミュレーションします。 ## 一時的に利用できない問題に対応する 次のエラーコードは、その支払い方法が一時的に使用できない状態にあることを示しています。 | コード | 説明 | 処理 | | ------------------------------------ | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | `payment_method_rate_limit_exceeded` | この決済手段には、[API 全体のレート制限](https://docs.stripe.com/rate-limits.md)よりも厳しい制限が課されていますが、大量のリクエストが立て続けに実行されました。 | このエラーは、Web サイトでのセール期間中などに、多くの顧客が同じ決済方法を使用しようとすると、複数の API リクエストで生じることがあります。その場合は、顧客に別の決済方法を使用するように依頼します。 | > 全般的に、または今後のイベントで使用量が高くなることが想定される場合は、すぐに Stripe にお問い合わせください。 # ダイレクト API > This is a ダイレクト API for when payment-ui is direct-api. View the full page at https://docs.stripe.com/payments/bank-transfers/accept-a-payment?payment-ui=direct-api. ## Stripe を設定する [サーバ側] まず、Stripe アカウントが必要です。[今すぐ登録](https://dashboard.stripe.com/register)してください。 アプリケーションから Stripe API にアクセスするには、Stripe の公式ライブラリを使用します。 #### Ruby ```bash # Available as a gem sudo gem install stripe ``` ```ruby # If you use bundler, you can add this line to your Gemfile gem 'stripe' ``` ## Customer を作成または取得する [サーバ側] 銀行振込による各支払いを消し込むには、[Customer (顧客)](https://docs.stripe.com/api/customers.md) オブジェクトを関連付ける必要があります。すでに Customer オブジェクトが存在する場合は、このステップをスキップできます。ない場合は、新しい Customer オブジェクトを作成します。 ```curl curl -X POST https://api.stripe.com/v1/customers \ -u "<>:" ``` ## PaymentIntent を作成および確定する [サーバ側] [PaymentIntent](https://docs.stripe.com/api/payment_intents/object.md) は、顧客から支払いを回収するお客様の意図を表すオブジェクトであり、支払いプロセスのライフサイクルの各段階を追跡します。回収する金額と通貨を指定して、お客様のサーバーで PaymentIntent を作成して確定してください。PaymentIntent 作成リクエストの [customer パラメーター](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-customer)にも入力する必要があります。銀行振込は、顧客が指定されていない PaymentIntent では利用できません。 #### ダッシュボードで支払い方法を管理する Payment Intent を作成する前に、ダッシュボードの[支払い方法の設定](https://dashboard.stripe.com/settings/payment_methods)ページで、**銀行振込**を有効にしていることを確認します。 > [動的な支払い方法](https://docs.stripe.com/payments/payment-methods/dynamic-payment-methods.md)の場合、Stripe は取引額、通貨、決済フローなどの要素に基づいて、適切な支払い方法が返されるように処理します。 #### US ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d customer="{{CUSTOMER_ID}}" \ -d currency=usd \ -d "automatic_payment_methods[enabled]"=true \ --data-urlencode return_url="https://example.com/return_url" \ -d "payment_method_data[type]"=customer_balance \ -d confirm=true ``` #### UK ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d customer="{{CUSTOMER_ID}}" \ -d currency=gbp \ -d "automatic_payment_methods[enabled]"=true \ --data-urlencode return_url="https://example.com/return_url" \ -d "payment_method_data[type]"=customer_balance \ -d confirm=true ``` #### EU ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d customer="{{CUSTOMER_ID}}" \ -d currency=eur \ -d "automatic_payment_methods[enabled]"=true \ --data-urlencode return_url="https://example.com/return_url" \ -d "payment_method_data[type]"=customer_balance \ -d confirm=true ``` 顧客に表示される IBAN を各地域に合わせるには、[`address.country`](https://docs.stripe.com/api/customers/object.md#customer_object-address-country) プロパティを設定するか、[ダッシュボードで顧客を編集](https://docs.stripe.com/invoicing/customer.md#edit-a-customer)して、顧客の国を設定できます。 Stripe では の IBAN ローカライゼーションに対応しています。 - 顧客に国を設定していない場合、または顧客の国が IBAN コードに対応していない場合は、Stripe アカウントの国に戻されます。 - IBAN のローカライゼーションが Stripe アカウントの国でサポートされていない場合、`IE` に戻されます。 > 現在、スペイン (ES) では、ローカライズされた仮想銀行口座番号を新規作成できません。代わりに、他の EU VBAN 加盟国を使用してください。 #### JP ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=19000 \ -d customer="{{CUSTOMER_ID}}" \ -d currency=jpy \ -d "automatic_payment_methods[enabled]"=true \ --data-urlencode return_url="https://example.com/return_url" \ -d "payment_method_data[type]"=customer_balance \ -d confirm=true ``` #### MX ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d customer="{{CUSTOMER_ID}}" \ -d currency=mxn \ -d "automatic_payment_methods[enabled]"=true \ --data-urlencode return_url="https://example.com/return_url" \ -d "payment_method_data[type]"=customer_balance \ -d confirm=true ``` 最新バージョンの API では、`automatic_payment_methods` パラメーターがデフォルトで有効になっているため、機能の指定は任意です。 支払い額に充当できる金額が顧客の残高に十分にある場合、PaymentIntent は `succeeded` ステータスで即座に成功します。顧客が誤って取引に対して過払いをした場合 (銀行振込の場合によく発生します)、差額が生じることがあります。[お客様の所在地に基づいて一定期間内に顧客の残高を消し込む](https://docs.stripe.com/payments/customer-balance/reconciliation.md)必要があります。 #### 支払い方法を手動でリスト化する API を使用して支払い方法を手動で指定するには、PaymentIntent の[支払い方法のタイプ](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_types)の一覧に `customer_balance` を追加します。Customer の [ID](https://docs.stripe.com/api/customers/object.md#customer_object-id) を指定します。 #### US ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d currency=usd \ -d customer="{{CUSTOMER_ID}}" \ -d "payment_method_types[]"=customer_balance \ -d "payment_method_data[type]"=customer_balance \ -d "payment_method_options[customer_balance][funding_type]"=bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][type]"=us_bank_transfer \ -d confirm=true ``` 支払い額に充当できる金額が顧客の残高に十分にある場合、PaymentIntent は `succeeded` ステータスで即座に成功します。顧客が誤って取引に対して過払いをした場合 (銀行振込の場合によく発生します)、差額が生じることがあります。[お客様の所在地に基づいて一定期間内に顧客の残高を消し込む](https://docs.stripe.com/payments/customer-balance/reconciliation.md)必要があります。 - [funding_type](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-funding_type) として `bank_transfer` を使用することで、顧客に支払い金額に対応できるだけの十分な残高がない場合の対処方法を指定します。 - [bank_transfer[type]](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-bank_transfer-type) として `us_bank_transfer` を使用することで、支払いの実行に使用できる銀行振込タイプを指定します。 #### UK ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d currency=gbp \ -d customer="{{CUSTOMER_ID}}" \ -d "payment_method_types[]"=customer_balance \ -d "payment_method_data[type]"=customer_balance \ -d "payment_method_options[customer_balance][funding_type]"=bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][type]"=gb_bank_transfer \ -d confirm=true ``` 支払い額に充当できる金額が顧客の残高に十分にある場合、PaymentIntent は `succeeded` ステータスで即座に成功します。顧客が誤って取引に対して過払いをした場合 (銀行振込の場合によく発生します)、差額が生じることがあります。[お客様の所在地に基づいて一定期間内に顧客の残高を消し込む](https://docs.stripe.com/payments/customer-balance/reconciliation.md)必要があります。 - [funding_type](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-funding_type) として `bank_transfer` を使用することで、顧客に支払い金額に対応できるだけの十分な残高がない場合の対処方法を指定します。 - [bank_transfer[type]](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-bank_transfer-type) として `gb_bank_transfer` を使用することで、支払いの実行に使用できる銀行振込タイプを指定します。 #### EU ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d currency=eur \ -d customer="{{CUSTOMER_ID}}" \ -d "payment_method_types[]"=customer_balance \ -d "payment_method_data[type]"=customer_balance \ -d "payment_method_options[customer_balance][funding_type]"=bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][type]"=eu_bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][eu_bank_transfer][country]"=FR \ -d confirm=true ``` 支払い額に充当できる金額が顧客の残高に十分にある場合、PaymentIntent は `succeeded` ステータスで即座に成功します。顧客が誤って取引に対して過払いをした場合 (銀行振込の場合によく発生します)、差額が生じることがあります。[お客様の所在地に基づいて一定期間内に顧客の残高を消し込む](https://docs.stripe.com/payments/customer-balance/reconciliation.md)必要があります。 - [funding_type](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-funding_type) として `bank_transfer` を使用することで、顧客に支払い金額に対応できるだけの十分な残高がない場合の対処方法を指定します。 - [bank_transfer[type]](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-bank_transfer-type) として `eu_bank_transfer` を使用することで、支払いの実行に使用できる銀行振込タイプを指定します。 - [payment_method_options[customer_balance][bank_transfer][eu_bank_transfer][country]](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-bank_transfer-eu_bank_account-country) を のいずれかに設定します。顧客に表示される IBAN は、選択した国に合わせて適応されます。 > 現在、スペイン (ES) では、ローカライズされた仮想銀行口座番号を新規作成できません。代わりに、他の EU VBAN 加盟国を使用してください。 #### JP ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=19000 \ -d currency=jpy \ -d customer="{{CUSTOMER_ID}}" \ -d "payment_method_types[]"=customer_balance \ -d "payment_method_data[type]"=customer_balance \ -d "payment_method_options[customer_balance][funding_type]"=bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][type]"=jp_bank_transfer \ -d confirm=true ``` 支払い額に充当できる金額が顧客の残高に十分にある場合、PaymentIntent は `succeeded` ステータスで即座に成功します。顧客が誤って取引に対して過払いをした場合 (銀行振込の場合によく発生します)、差額が生じることがあります。[お客様の所在地に基づいて一定期間内に顧客の残高を消し込む](https://docs.stripe.com/payments/customer-balance/reconciliation.md)必要があります。 - [funding_type](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-funding_type) として `bank_transfer` を使用することで、顧客に支払い金額に対応できるだけの十分な残高がない場合の対処方法を指定します。 - [bank_transfer[type]](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-bank_transfer-type) として `jp_bank_transfer` を使用することで、支払いの実行に使用できる銀行振込タイプを指定します。 #### MX ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1099 \ -d currency=mxn \ -d customer="{{CUSTOMER_ID}}" \ -d "payment_method_types[]"=customer_balance \ -d "payment_method_data[type]"=customer_balance \ -d "payment_method_options[customer_balance][funding_type]"=bank_transfer \ -d "payment_method_options[customer_balance][bank_transfer][type]"=mx_bank_transfer \ -d confirm=true ``` 支払い額に充当できる金額が顧客の残高に十分にある場合、PaymentIntent は `succeeded` ステータスで即座に成功します。顧客が誤って取引に対して過払いをした場合 (銀行振込の場合によく発生します)、差額が生じることがあります。[お客様の所在地に基づいて一定期間内に顧客の残高を消し込む](https://docs.stripe.com/payments/customer-balance/reconciliation.md)必要があります。 - [funding_type](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-funding_type) として `bank_transfer` を使用することで、顧客に支払い金額に対応できるだけの十分な残高がない場合の対処方法を指定します。 - [bank_transfer[type]](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-bank_transfer-type) として `mx_bank_transfer` を使用することで、支払いの実行に使用できる銀行振込タイプを指定します。 > 支払いを作成するときは必ず、`payment_method_types` を指定します。[将来の支払い](https://docs.stripe.com/payments/save-and-reuse.md)には `customer_balance` を使用することはできません。 ## 銀行振込を完了するよう顧客に指示する [クライアント側] 顧客の残高がリクエスト金額を賄うのに十分でない場合、PaymentIntent には `requires_action` ステータスが表示されます。応答には、`display_bank_transfer_instructions` の `type` 値を含む `next_action` フィールドがあります。`next_action[display_bank_transfer_instructions]` ハッシュには、顧客が銀行振込を完了できるように顧客に表示する情報が含まれています。売上を確実に決済するために、特に該当する場合は口座名義と口座番号について、提供された正確な詳細を使用するよう顧客に指示します。 > *本番環境* (Use this mode when you’re ready to launch your app. Card networks or payment providers process payments)では、Stripe は各顧客に一意の銀行振込の詳細を提供します。これに対し、テスト環境では、Stripe はすべての顧客に無効な銀行振込の詳細を提供します。本番環境とは異なり、これらの無効な詳細は一意であるとは限りません。 #### US | フィールド | 説明 | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | | [type](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-type) | 使用する銀行振込のタイプ。アメリカでは、タイプは `us_bank_transfer` である必要があります。 | | [reference](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-reference) | 銀行送金を識別するための一意の参照コード。銀行送金の参照フィールドにこのコードを含めるよう顧客に指示します。 | | [amount_remaining](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-amount_remaining) | 支払いを完了するために送金する必要がある残りの金額。この金額を送金するよう顧客に指示してください。顧客の残高にある既存の資金が PaymentIntent に適用された場合や、顧客の支払いが不足している場合には、これは PaymentIntent の金額と異なることがあります。 | | [currency](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-currency) | 残りの金額の通貨。 | | [financial_addresses](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions) | アメリカの銀行口座の財務アドレスのリスト。タイプには `aba` と `swift` が含まれます。詳細については、以下を参照してください。 | | [hosted_instructions_url](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-hosted_instructions_url) | 送金を完了する方法を顧客に説明するオンラインページへのリンク。 | #### aba ハッシュ `aba` ハッシュの例: ```json { "aba": { "account_number": "111222333444", "bank_name": "Wells Fargo Bank, NA", "routing_number": "444555666" }, "supported_networks": [ "ach", "domestic_wire_us" ], "type": "aba" } ``` | フィールド | 値 | 説明 | | -------------------- | ------------------------------ | --------------------------- | | `type` | `aba` | 財務アドレスのタイプ。 | | `supported_networks` | - `ach` - `domestic_wire_us` | このアドレスでサポートされているネットワークのリスト。 | | `aba.account_number` | 111222333444 | ABA の口座番号。 | | `aba.routing_number` | 444555666 | ABA の金融番号。 | | `aba.bank_name` | Wells Fargo 銀行、NA | 銀行名。 | #### swift ハッシュ `swift` ハッシュの例: ```json { "swift": { "account_number": "111222333444", "bank_name": "Wells Fargo Bank, NA", "swift_code": "AAAA-BB-CC-123" }, "supported_networks": [ "swift" ], "type": "swift" } ``` | フィールド | 値 | 説明 | | ---------------------- | ----------------- | --------------------------- | | `type` | `swift` | 財務アドレスのタイプ。 | | `supported_networks` | - `swift` | このアドレスでサポートされているネットワークのリスト。 | | `swift.account_number` | 111222333444 | SWIFT 口座番号。 | | `swift.swift_code` | AAAA-BB-CC-123 | SWIFT コード。 | | `swift.bank_name` | Wells Fargo 銀行、NA | 銀行名。 | #### 売上処理のタイミング 指定した情報を使用して銀行で振込手続きを行うよう顧客に指示した後、振込が完了するまでに最大 5 日かかります。売上処理のタイミングは、Stripe への送金に使用されたバンキングレールによって異なります。 - ACH 送金は 1 ~ 3 営業日以内に届きます。 - 国内の電信送金 (Fedwire) は当日中に届きます (送金が銀行のカットオフタイム前であったかどうかによって異なります)。 - 国際電信送金 (SWIFT) は 1 ~ 5 営業日以内に届きます。 #### UK | フィールド | 説明 | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | | [type](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-type) | 使用する銀行振込の種類。イギリスでは、タイプは `gb_bank_transfer` である必要があります。 | | [reference](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-reference) | 銀行送金を識別するための一意の参照コード。銀行送金の参照フィールドにこのコードを含めるよう顧客に指示します。 | | [amount_remaining](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-amount_remaining) | 支払いを完了するために送金する必要がある残りの金額。この金額を送金するよう顧客に指示してください。顧客の残高にある既存の資金が PaymentIntent に適用された場合や、顧客の支払いが不足している場合には、これは PaymentIntent の金額と異なることがあります。 | | [currency](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-currency) | 残りの金額の通貨。 | | [financial_addresses](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions) | イギリスの銀行口座の財務アドレスのリスト。タイプには `sort_code` が含まれます。詳細については、以下を参照してください。 | | [hosted_instructions_url](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-hosted_instructions_url) | 送金を完了する方法を顧客に説明するオンラインページへのリンク。 | ### sort_code ハッシュ `sort_code` ハッシュの例: ```json { "sort_code": { "account_holder_name": "Demo Test Inc.", "account_number": "98765432", "sort_code": "200000" }, "supported_networks": [ "bacs", "fps" ], "type": "sort_code" } ``` | フィールド | 値 | 説明 | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | --------------------------- | | [type](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-type) | `sort_code` | 財務アドレスのタイプ。 | | [supported_networks](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-supported_networks) | - `bacs` - `fps` | このアドレスでサポートされているネットワークのリスト。 | | [sort_code.account_number](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-sort_code-account_number) | 98765432 | 8 桁の口座番号。 | | [sort_code.sort_code](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-sort_code-sort_code) | 200000 | 6 桁の銀行コード。 | | [sort_code.account_holder_name](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-sort_code-account_holder_name) | Demo Test Inc. | 銀行口座を所有する個人または法人の名前。 | #### 売上処理のタイミング 指定した情報を使用して銀行で振込手続きを行うよう顧客に指示した後、振込が完了するまでに最大 5 日かかります。売上処理のタイミングは、Stripe への送金に使用されたバンキングレールによって異なります。 - FPS の送金は 15 分以内に着金します。 - BACS の送金は 5 日以内に着金します。 > 現在、[CHAPS](https://www.bankofengland.co.uk/payment-and-settlement/chaps) 支払いネットワーク経由で送金される銀行振込には対応していません。 #### EU | フィールド | 説明 | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | | [type](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-type) | 使用する銀行送金の種類。EU では、タイプは `eu_bank_transfer` である必要があります。 | | [reference](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-reference) | 銀行送金を識別するための一意の参照コード。銀行送金の参照フィールドにこのコードを含めるよう顧客に指示します。 | | [amount_remaining](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-amount_remaining) | 支払いを完了するために送金する必要がある残りの金額。この金額を送金するよう顧客に指示してください。顧客の残高にある既存の資金が PaymentIntent に適用された場合や、顧客の支払いが不足している場合には、これは PaymentIntent の金額と異なることがあります。 | | [currency](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-currency) | 残りの金額の通貨。 | | [financial_addresses](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions) | EU の銀行口座の財務アドレスのリスト。タイプには `iban` が含まれます。詳細については、以下を参照してください。 | | [hosted_instructions_url](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-hosted_instructions_url) | 送金を完了する方法を顧客に説明するオンラインページへのリンク。 | ### iban ハッシュ `iban` ハッシュの例: ```json { "iban": { "account_holder_name": "Demo Test Inc.", "bic": "CITINL2XXXX", "country": "NL", "iban": "NL40CITI7000799556 " }, "supported_networks": [ "sepa" ], "type": "iban" } ``` | フィールド | 値 | 説明 | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | [type](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-type) | `iban` | 財務アドレスのタイプ。 | | [supported_networks](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-supported_networks) | - `sepa` | このアドレスでサポートされているネットワークのリスト。 | | [iban.iban](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-iban-iban) | NL40CITI7000799556 | 顧客が支払いを行う必要のある対象の IBAN。 [ダッシュボード](https://dashboard.stripe.com/settings/payment_methods)から支払い方法を管理している場合、IBAN の国は Customer の [country](https://docs.stripe.com/api/customers/object.md#customer_object-country) または Stripe アカウントの国に基づいて選択されます。 [payment_method_types](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_types) パラメーターを使用して手動で支払い方法をリスト化している場合、IBAN の国はリクエストで渡された [country](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-payment_method_options-customer_balance-bank_transfer-eu_bank_transfer-country) パラメーターに基づいて選択されます。 | | [iban.bic](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-iban-bic) | CITINL2XXXX | この IBAN の BIC。 | | [iban.country](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-iban-country) | `NL` | 振込先の銀行口座の 2 文字の国コード。 | | [iban.account_holder_name](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-iban-account_holder_name) | Demo Test Inc. | 銀行口座を所有する個人または法人の名前。 | #### 売上処理のタイミング 国内送金では、提供された情報を使用して (可能な場合) SEPA Instant 送金をするよう顧客に求めます。資金は通常、数秒以内に入金され、30 分以内に入金されます。売上処理が長くなるのは、週末、祝日、または送金者の銀行が即時スキームによる決済の経路を選定できない場合です。このような場合、送金は標準 SEPA 決済として処理されます。 > 国際 EUR 送金の受け付けはプレビューです。早期アクセスのご利用をご希望の場合は、[sepa-bank-transfers-beta@stripe.com ](mailto:sepa-bank-transfers-beta@stripe.com)までお問い合わせください。 #### JP | フィールド | 説明 | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | | [type](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-type) | 使用する銀行振込の種類。日本では、タイプは `jp_bank_transfer` である必要があります。 | | [reference](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-reference) | このフィールドは使用されません。 | | [amount_remaining](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-amount_remaining) | 支払いを完了するために送金する必要がある残りの金額。この金額を送金するよう顧客に指示してください。顧客の残高にある既存の資金が PaymentIntent に適用された場合や、顧客の支払いが不足している場合には、これは PaymentIntent の金額と異なることがあります。 | | [currency](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-currency) | 残りの金額の通貨。 | | [financial_addresses](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses) | 日本の銀行口座の財務アドレスのリスト。タイプには `zengin` が含まれます。詳細については、以下を参照してください。 | | [hosted_instructions_url](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-hosted_instructions_url) | 送金を完了する方法を顧客に説明するオンラインページへのリンク。 | ### zengin ハッシュ `zengin` ハッシュの例: ```json { "zengin": { "account_holder_name": "ストライプジャパン(カ シュウノウダイコウ", "account_number": "1234567", "account_type": "futsu", "bank_code": "0009", "bank_name": "三井住友銀行", "branch_code": "950", "branch_name": "東京第二" }, "supported_networks": [ "zengin" ], "type": "zengin" } ``` | フィールド | 値 | 説明 | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- | --------------------------- | | [type](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-type) | `zengin` | 財務アドレスのタイプ。 | | [supported_networks](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-supported_networks) | - `zengin` | このアドレスでサポートされているネットワークのリスト。 | | [zengin.bank_code](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-zengin-bank_code) | 0009 | 4 桁の金融機関コード。 | | [zengin.bank_name](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-zengin-bank_name) | 三井住友銀行 | 銀行名。 | | [zengin.branch_code](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-zengin-branch_code) | 950 | 3 桁の支店コード。 | | [zengin.branch_name](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-zengin-branch_name) | 東京第二 | 支店名。 | | [zengin.account_type](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-zengin-account_type) | `futsu`、`toza` | 口座種別。 | | [zengin.account_holder_name](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-zengin-account_holder_name) | ストライプジャパン(カ シュウノウダイコウ | 口座名義。 | | [zengin.account_number](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-zengin-account_number) | 1234567 | 7 桁の口座番号。 | #### 売上処理のタイミング 貴社が提供した情報を使用して銀行で振込手続きを行うよう顧客に指示します。 営業時間内に行われた送金は、同日に着金します。営業時間外に送金された場合は、翌営業日に着金します。 #### MX | フィールド | 説明 | | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | | [type](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-type) | 使用する銀行振込の種類。メキシコでは、タイプは `mx_bank_transfer` である必要があります。 | | [reference](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-reference) | 銀行送金を識別するための一意の参照コード。銀行送金の参照フィールドにこのコードを含めるよう顧客に指示します。 | | [amount_remaining](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-amount_remaining) | 支払いを完了するために送金する必要がある残りの金額。この金額を送金するよう顧客に指示してください。顧客の残高にある既存の資金が PaymentIntent に適用された場合や、顧客の支払いが不足している場合には、これは PaymentIntent の金額と異なることがあります。 | | [currency](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-currency) | 残りの金額の通貨。 | | [financial_addresses](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions) | メキシコの銀行口座の財務アドレスのリスト。タイプには `spei` が含まれます。詳細については、以下を参照してください。 | | [hosted_instructions_url](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-hosted_instructions_url) | 送金を完了する方法を顧客に説明するオンラインページへのリンク。 | ### spei ハッシュ `spei` ハッシュの例: ```json { "spei": { "bank_code": "002", "bank_name": "BANAMEX", "clabe": "002180650612345670" }, "supported_networks": [ "spei" ], "type": "spei" } ``` | フィールド | 値 | 説明 | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------ | --------------------------- | | [type](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-type) | `spei` | 財務アドレスのタイプ。 | | [supported_networks](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-supported_networks) | - `spei` | このアドレスでサポートされているネットワークのリスト。 | | [spei.clabe](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-spei-clabe) | 002180650612345670 | 18 桁の CLABE 番号。 | | [spei.bank_code](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-spei-bank_code) | 002 | 3 桁の銀行コード。 | | [spei.bank_name](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-display_bank_transfer_instructions-financial_addresses-spei-bank_name) | BANAMEX | 金融機関の略称 | 貴社が提供した情報を使用して銀行で振込手続きを行うよう顧客に指示します。 ほとんどの支払いは、銀行営業日・非営業日に関わらず、10 分以内に到着することを想定しています。 ## PaymentIntent の成功を確認する PaymentIntent は、売上が銀行口座に入金されるまで `requires_action` ステータスのままとなります。売上の準備ができると、PaymentIntent のステータスが `requires_action` から `succeeded` に更新されます。 `payment_intent.partially_funded` イベントの受信を開始するには、*Webhook* (A webhook is a real-time push notification sent to your application as a JSON payload through HTTPS requests) エンドポイントを設定する必要があります。 [ダッシュボードから Webhook を追加](https://dashboard.stripe.com/webhooks/create)できます。 また、[Webhook Endpoint API](https://docs.stripe.com/api/webhook_endpoints.md) を使用して [payment_intent.partially_funded](https://docs.stripe.com/api/events/types.md#event_types-payment_intent.partially_funded) イベントの受信を開始することもできます。 PaymentIntent が更新されると、Stripe は、以下のイベントを支払い資金追加フロー中に送信します。 | イベント | 説明 | 次のステップ | | --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `payment_intent.requires_action` | 顧客の残高に PaymentIntent を照合するのに十分な売上がない場合、確定時に送信されると、PaymentIntent は `requires_action` に移行します。顧客の現金残高が自動的に PaymentIntent に適用され、その金額が PaymentIntent の`金額`を完全にカバーしていない場合、Stripe は正確な `amount_remaining` を指定してこのイベントを送信します。 | `amount_remaining` を使用して銀行振込を行うよう顧客に指示します。 | | `payment_intent.partially_funded` | 顧客は PaymentIntent に充てられた銀行振込を行いましたが、決済を完了するには十分な金額ではありませんでした。これは、顧客が `PaymentIntent` を確定した後に顧客が不足分を送金した場合に発生することがあります。不足支払いや顧客の銀行による手数料が原因となる場合があります。部分的に資金が適用された PaymentIntent は、決済が完了するまでアカウント残高に反映されません。 | 新しい `amount_remaining` を使用して別の銀行振込を行い、支払いを完了するよう顧客に指示します。部分的に資金を充当して支払いを完了する場合は、`amount` を更新して PaymentIntent をもう一度[確定](https://docs.stripe.com/api/payment_intents/confirm.md)できます。 | | `payment_intent.succeeded` | 顧客の決済が成功しました。 | 顧客が購入した商品またはサービスの発送を行います。 | 部分資金に関連するすべてのイベントを監視するには、`requires_action` と `partially_funded` の両方を監視してください。`requires_action` は、確認後も資金が不足している場合に Stripe が発行します。`partially_funded` は、後から顧客から追加の資金が入金されたものの、残額を完全にカバーしない場合に発行されます。 > 部分的に資金が充当された PaymentIntent の金額を変更すると、売上は顧客の残高に戻されます。他に open 状態の PaymentIntent がある場合、Stripe はそれらに自動で資金追加します。顧客に手動消し込みが設定されている場合は、もう一度[売上を充当する](https://docs.stripe.com/api/payment_intents/apply_customer_balance.md)必要があります。 支払いが成功したことを確認し、顧客に支払い完了を通知するには、[Webhook を使用](https://docs.stripe.com/payments/payment-intents/verifying-status.md#webhooks)することをお勧めします。 ### サンプルコード #### Ruby ```ruby require 'json' # Using Sinatra post '/webhook' do payload = request.body.read event = nil begin event = Stripe::Event.construct_from( JSON.parse(payload, symbolize_names: true) ) rescue JSON::ParserError => e # Invalid payload status 400 return end # Handle the event case event.type when 'payment_intent.requires_action' payment_intent = event.data.object # contains a Stripe::PaymentIntent # The payment intent was not fully funded due to insufficient funds # on the customer balance. Define and call a method to handle the payment intent. # handle_payment_intent_requires_action(payment_intent) when 'payment_intent.partially_funded' payment_intent = event.data.object # contains a Stripe::PaymentIntent # Then define and call a method to handle the payment intent being partially funded. # handle_payment_intent_partially_funded(payment_intent) when 'payment_intent.succeeded' payment_intent = event.data.object # contains a Stripe::PaymentIntent # Then define and call a method to handle the successful payment intent. # handle_payment_intent_succeeded(payment_intent) else puts "Unhandled event type: #{event.type}" end status 200 end ``` ### ダッシュボードで保留中の支払いを表示する [ダッシュボード](https://dashboard.stripe.com/payments)で**ステータス**に**資金供給待ち**のフィルターを適用すると、保留中のすべての銀行振込 PaymentIntent を表示できます。 ## 組み込みをテストする ダッシュボードまたは HTTP リクエストを使用して、銀行振込の受け取りをシミュレーションすることにより、お使いの組み込みをテストできます。 ### ダッシュボードを使用する ダッシュボードを使用して*サンドボックス* (A sandbox is an isolated test environment that allows you to test Stripe functionality in your account without affecting your live integration. Use sandboxes to safely experiment with new features and changes)で銀行振込をシミュレーションするには、ダッシュボードで顧客のページに移動します。**決済手段**で、**追加**をクリックして、**現金残高に資金を追加 (テスト環境のみ)** を選択します。 ### Stripe API を使用 API コールを作成して、銀行振込をシミュレーションできます。 #### US ```curl curl https://api.stripe.com/v1/test_helpers/customers/cus_xxxxxxxxx/fund_cash_balance \ -u "<>:" \ -d amount=1000 \ -d currency=usd \ -d reference=REF-4242 ``` You can simulate a reversal by prefixing the `reference` parameter with `reversal_` (for example, `reversal_123`). #### UK ```curl curl https://api.stripe.com/v1/test_helpers/customers/cus_xxxxxxxxx/fund_cash_balance \ -u "<>:" \ -d amount=1000 \ -d currency=gbp \ -d reference=REF-4242 ``` #### EU ```curl curl https://api.stripe.com/v1/test_helpers/customers/cus_xxxx/fund_cash_balance \ -u "<>:" \ -d amount=1000 \ -d currency=eur \ -d reference=REF-4242 ``` #### JP ```curl curl https://api.stripe.com/v1/test_helpers/customers/cus_xxxx/fund_cash_balance \ -u "<>:" \ -d amount=10000 \ -d currency=jpy ``` #### MX ```curl curl https://api.stripe.com/v1/test_helpers/customers/cus_xxxx/fund_cash_balance \ -u "<>:" \ -d amount=1000 \ -d currency=mxn \ -d reference=123456 ``` ## 一時的な使用上の問題を処理する 次のエラーコードは、その支払い方法が一時的に使用できない状態にあることを示しています。 | コード | 説明 | 処理 | | ------------------------------------ | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | | `payment_method_rate_limit_exceeded` | この決済手段には、[API 全体のレート制限](https://docs.stripe.com/rate-limits.md)よりも厳しい制限が課されていますが、大量のリクエストが立て続けに実行されました。 | このエラーは、Web サイトでのセール期間中などに、多くの顧客が同じ決済方法を使用しようとすると、複数の API リクエストで生じることがあります。その場合は、顧客に別の決済方法を使用するように依頼します。 | > 全般的に、または今後のイベントで使用量が高くなることが想定される場合は、すぐに Stripe にお問い合わせください。 ## Optional: 顧客から支払い方法オプションを収集する 必要に応じ、お客様のサイトで顧客が希望する資金追加タイプを収集し、[Stripe.js](https://docs.stripe.com/js.md) の[confirmCustomerBalancePayment](https://docs.stripe.com/js/payment_intents/confirm_customer_balance_payment) メソッドを使用して PaymentIntent を確定します。 HTML フォームを表示して、顧客が希望する銀行振込による資金追加の詳細を収集します。この入力内容を使用して、`payment_method_options` に入力します。 `confirmCustomerBalancePayment` に使用できる `payment_method_options` パラメーターの全リストについては、[JS リファレンスドキュメント](https://docs.stripe.com/js/payment_intents/confirm_customer_balance_payment)をご覧ください。 以下にユースケースの例を示します。お客様がアイルランドの加盟店であり、顧客の所在国が不明な場合は、最初に `payment_method_options[customer_balance][bank_transfer][eu_bank_transfer][country]` を ‘IE’ に設定して `PaymentIntent` を作成します。その後、[confirmCustomerBalancePayment](https://docs.stripe.com/js/payment_intents/confirm_customer_balance_payment) メソッドを使用して、ユーザーの入力に基づき、国を更新します。 ### サンプルコード ```javascript const {paymentIntent, error} = await stripe.confirmCustomerBalancePayment( '{PAYMENT_INTENT_CLIENT_SECRET}', { payment_method: { customer_balance: { }, }, payment_method_options: { customer_balance: { funding_type: 'bank_transfer', bank_transfer: { type: 'eu_bank_transfer', eu_bank_transfer: { country: 'FR', } }, }, }, }, { handleActions: false, } ); if (error) { // Inform the customer that there was an error. } else if (paymentIntent.status === 'requires_payment_method') { // If `payment_method_options.funding_type` wasn't set this // is where you would need to handle the insufficient customer // balance state. } else if (paymentIntent.status === 'requires_action') { // If the current customer balance is insufficient to cover // the amount, and you've passed // `payment_method_options.funding_type` for funding the // customer balance, you can display the bank transfer // instructions to your user. if (paymentIntent.next_action.type === 'display_bank_transfer_instructions') { // Bank transfer details can be found under: // paymentIntent.next_action.display_bank_transfer_instructions } } ``` ## Optional: 決済手順メールを送信する [ダッシュボード](https://dashboard.stripe.com/settings/emails)から銀行振込決済の手順メールを有効にできます。決済手順メールが有効になると、Stripe は以下の場合に顧客にメールを送信します。 - PaymentIntent が確定されましたが、顧客の残高が不足しています。 - 顧客が銀行振込を行いましたが、残高が不足しているため保留中の支払いを完了できませんでした。 銀行振込決済の手順メールには、請求金額、振込先の銀行情報、Stripe がオンラインで提供する手順ページへのリンクが記載されています。 > サンドボックスでは、決済手順メールは Stripe アカウントに関連付けられているメールアドレスにのみ送信されます。