# ACH ダイレクトデビットによるサブスクリプションを設定する アメリカの銀行口座を使用したサブスクリプションの作成と請求の方法をご紹介します。 このガイドを使用して、[ACH ダイレクトデビット](https://docs.stripe.com/payments/ach-direct-debit.md)を使用する*サブスクリプション* (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)を設定します。 # 高度な連携機能 > This is a 高度な連携機能 for when platform is web and payment-ui is elements. View the full page at https://docs.stripe.com/billing/subscriptions/ach-debit?platform=web&payment-ui=elements. > 新規ユーザーの場合は、このガイドで説明する Stripe Elements ではなく [Payment Element](https://docs.stripe.com/payments/payment-element.md) を使用してください。Payment Element は、コンバージョン最適化が組み込まれたローコードの連携パスを提供します。手順については、[サブスクリプションの構築](https://docs.stripe.com/billing/subscriptions/build-subscriptions.md?payment-ui=elements)をご覧ください。 ## 商品と価格を作成する [ダッシュボード] [Products (商品)](https://docs.stripe.com/api/products.md) は、販売しているアイテムまたはサービスを表します。[Prices (価格)](https://docs.stripe.com/api/prices.md) は、商品の価格と請求頻度を定義します。これには、商品の価格、受け付ける通貨、および 1 回限りの支払いか継続支払いかが含まれます。商品と価格が数個のみの場合は、ダッシュボードでそれらを作成および管理します。 このガイドでは、例としてストックフォトサービスを使用し、15 USD の月次サブスクリプションを顧客に請求します。これをモデル化するには、次のようにします。 1. [商品](https://dashboard.stripe.com/products?active=true)ページに移動し、**商品を作成**をクリックします。 1. 商品の**名前**を入力します。オプションで**説明**を追加して、商品の画像をアップロードできます。 1. **商品税コード**を選択します。[商品税コード](https://docs.stripe.com/tax/tax-codes.md)の詳細をご確認ください。 1. **継続**を選択します。次に、価格に**15**を入力し、通貨として**\**を選択します。 1. **価格に税金を含める**かどうかを選択します。[税金設定](https://dashboard.stripe.com/test/settings/tax)のデフォルト値を使用するか、値を手動で設定できます。この例では、**自動**を選択します。 1. **請求期間**で**月次**を選択します。 1. **その他の料金体系オプション**をクリックします。次に、この例の料金体系モデルとして**定額**を選択します。[定額料金](https://docs.stripe.com/products-prices/pricing-models.md#flat-rate)とその他の[料金体系モデル](https://docs.stripe.com/products-prices/pricing-models.md)の詳細をご確認ください。 1. 将来的に特定の価格を整理、クエリ、更新するために、内部**価格の説明**と[検索キー](https://docs.stripe.com/products-prices/manage-prices.md#lookup-keys) 追加します。 1. **次へ**をクリックします。次に、**商品を追加**をクリックします。 商品と価格を作成したら、価格 ID を記録しておき、後続のステップで使用できるようにします。ID は料金体系ページで `price_G0FvDp6vZvdwRZ` のように表示されます。 ## サブスクリプションを作成する [サーバー側] > 無料のトライアル期間付きの*サブスクリプション* (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)の作成については、[サブスクリプションのトライアル](https://docs.stripe.com/billing/subscriptions/ach-debit.md#trial-periods)をご覧ください。 [payment_behavior](https://docs.stripe.com/api/subscriptions/create.md#create_subscription-payment_behavior) パラメーターの値として `default_incomplete` を指定して、ステータスが `incomplete` の価格と顧客の [Subscription (サブスクリプション)](https://docs.stripe.com/api/subscriptions.md) を作成します。 #### curl ```bash curl https://api.stripe.com/v1/subscriptions \ -u <>: \ -d "customer"="{{CUSTOMER_ID}}" \ -d "items[0][price]"="price_F52b2UdntfQsfR" \ -d "payment_behavior"="default_incomplete" \ -d "payment_settings[payment_method_types][]"="us_bank_account" \ -d "expand[0]"="latest_invoice.payment_intent" ``` レスポンスには、*サブスクリプション* (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)の最初の [Invoice (請求書)](https://docs.stripe.com/api/invoices.md) が含まれます。これには請求書の支払いが格納され、Stripe がこのインボイスに対して生成したデフォルトの PaymentIntent と、PaymentIntent オブジェクト全体を渡す代わりに、クライアント側で決済プロセスを安全に完了するために使用できる、confirmation secret が含まれます。`latest_invoice.confirmation_secret.client_secret` をフロントエンドに返して、支払いを完了します。 ## 支払い方法の詳細を収集する [クライアント側] 顧客が ACH Direct Debitでの支払いをクリックしたときに、Stripe.js を使用してその支払いを Stripe に送信することをお勧めします。[Stripe.js](https://docs.stripe.com/payments/elements.md) は、決済フローを構築するための Stripe の基本的な JavaScript ライブラリです。これにより、実装に関する複雑な処理が自動的に行われ、将来、他の決済手段にも対応できるように実装を簡単に拡張できます。 Stripe.js スクリプトを決済ページに含めるには、このスクリプトを HTML ファイルの `head` に追加します。 ```html Checkout ``` 決済ページで以下の JavaScript を使用して、Stripe.js のインスタンスを作成します。 ```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('<>'); ``` PaymentIntent オブジェクト全体をクライアントに送信する代わりに、前のステップからの *client secret* (The client secret is a unique key returned from Stripe as part of a PaymentIntent. This key lets the client access important fields from the PaymentIntent (status, amount, currency) while hiding sensitive ones (metadata, customer)) を使用します。これは、Stripe API リクエストを認証する API キーとは異なります。 client secret は支払いを完了できるため、慎重に取り扱う必要があります。記録したり、URL に埋め込んだり、当該の顧客以外に漏洩することがないようにしてください。 [stripe.collectBankAccountForPayment](https://docs.stripe.com/js/payment_intents/collect_bank_account_for_payment) を使用して、[Financial Connections](https://docs.stripe.com/financial-connections.md) で銀行口座の詳細を収集し、*PaymentMethod* (PaymentMethods represent your customer's payment instruments, used with the Payment Intents or Setup Intents APIs) を作成して PaymentIntent に関連付けます。ACH ダイレクトデビットの PaymentMethod を作成するには、`billing_details` パラメーターに口座名義人を含める必要があります。 ```javascript // Use the form that already exists on the web page. const paymentMethodForm = document.getElementById('payment-method-form'); const confirmationForm = document.getElementById('confirmation-form'); paymentMethodForm.addEventListener('submit', (ev) => { ev.preventDefault(); const accountHolderNameField = document.getElementById('account-holder-name-field'); const emailField = document.getElementById('email-field'); // Calling this method will open the instant verification dialog. stripe.collectBankAccountForPayment({ clientSecret: clientSecret, params: { payment_method_type: 'us_bank_account', payment_method_data: { billing_details: { name: accountHolderNameField.value, email: emailField.value, }, }, }, expand: ['payment_method'], }) .then(({paymentIntent, error}) => { if (error) { console.error(error.message); // PaymentMethod collection failed for some reason. } else if (paymentIntent.status === 'requires_payment_method') { // Customer canceled the hosted verification modal. Present them with other // payment method type options. } else if (paymentIntent.status === 'requires_confirmation') { // We collected an account - possibly instantly verified, but possibly // manually-entered. Display payment method details and mandate text // to the customer and confirm the intent once they accept // the mandate. confirmationForm.show(); } }); }); ``` [Financial Connections 認証フロー](https://docs.stripe.com/financial-connections/fundamentals.md#authentication-flow)では、銀行口座の詳細の収集と確認を自動的に処理します。顧客が認証フローを完了すると、*PaymentMethod* (PaymentMethods represent your customer's payment instruments, used with the Payment Intents or Setup Intents APIs) が自動的に PaymentIntent に関連付けられ、[Financial Connections アカウント](https://docs.stripe.com/api/financial_connections/accounts.md)が作成されます。 > 手動入力と少額入金によって顧客が関連付けた銀行口座では、残高、所有権、取引などの追加の銀行口座データにアクセスできません。 すべてのデバイスで最適なユーザー体験を提供できるように、ビューポートの `meta` タグを使用して、ページのビューポートの `minimum-scale` を 1 に設定します。 ```html ``` ## 同意書承認を収集し送信する [クライアント側] 支払いを開始する前に、顧客に同意書の規約を表示して、顧客から承認を得る必要があります。 Nacha の運営規則に準拠するため、決済を開始する前に、同意書の規約を表示して顧客から承認を得る必要があります。[同意書](https://docs.stripe.com/payments/ach-direct-debit.md#mandates)の詳細については、こちらの記事をご覧ください。 顧客が同意書の規約を承認する場合、PaymentIntent を確定する必要があります。顧客がフォームを送信したら、[stripe.confirmUsBankAccountPayment](https://docs.stripe.com/js/payment_intents/confirm_us_bank_account_payment) を使用して支払いを完了します。 ```javascript confirmationForm.addEventListener('submit', (ev) => { ev.preventDefault(); stripe.confirmUsBankAccountPayment(clientSecret) .then(({paymentIntent, error}) => { if (error) { console.error(error.message); // The payment failed for some reason. } else if (paymentIntent.status === "requires_payment_method") { // Confirmation failed. Attempt again with a different payment method. } else if (paymentIntent.status === "processing") { // Confirmation succeeded! The account will be debited. // Display a message to customer. } else if (paymentIntent.next_action?.type === "verify_with_microdeposits") { // The account needs to be verified through microdeposits. // Display a message to consumer with next steps (consumer waits for // microdeposits, then enters a statement descriptor code on a page sent to them through email). } }); }); ``` > [stripe.confirmUsBankAccountPayment](https://docs.stripe.com/js/payment_intents/confirm_us_bank_account_payment) の完了には数秒かかる場合があります。この間、フォームが再送信されないように無効化し、待機中のインジケーター (スピナーなど) を表示します。エラーが発生した場合は、それを顧客に表示し、フォームを再度有効化し、待機中のインジケーターを非表示にします。 顧客が即時確認を完了すると、サブスクリプションは自動的に `active` になります。そうでない場合には、[少額入金で銀行口座を確認する](https://docs.stripe.com/billing/subscriptions/ach-debit.md#verify-with-microdeposits)をご覧になり、サブスクリプションが `incomplete` の状態のままであるときに少額入金による確認を処理する方法を確認してください。 ## 少額入金で銀行口座を確認する [クライアント側] > 顧客はサブスクリプションに対する少額入金を、 [サブスクリプションのライフサイクル](https://docs.stripe.com/billing/subscriptions/overview.md#subscription-lifecycle)で通常指定されている 23 時間以内ではなく、10 日以内に確認する必要があります。ただし、この期限は[請求サイクルの日付](https://docs.stripe.com/billing/subscriptions/ach-debit.md#billing-cycle)より前にする必要があります。 すべての顧客が銀行口座を即時に確認できるわけではありません。このステップは、顧客が前のステップで即時確認フローからオプトアウトした場合にのみ適用されます。 このような場合、Stripe は `descriptor_code` による少額入金を送金し、銀行口座の確認でさらに問題が発生した場合には、`amount` による少額入金に戻る場合があります。これらの入金が顧客のオンライン明細書に表示されるには 1 ~ 2 営業日かかります。 - **明細書表記コード**。SM で始まる一意の 6 桁の `descriptor_code` を指定して、0.01 USD の 1 件の少額入金を顧客の銀行口座に送金します。顧客は、この文字列を使用して、銀行口座を確認します。 - **金額**。Stripe は、`ACCTVERIFY` という明細書表記を使用し、一意でない 2 件の少額入金を顧客の銀行口座に送金します。顧客は、この入金額を使用して銀行口座を確認します。 前のステップの [stripe.confirmUsBankAccountPayment](https://docs.stripe.com/js/payment_intents/confirm_us_bank_account_payment) メソッドの呼び出しの結果として、`requires_action` 状態の PaymentIntent が返されます。この PaymentIntent には、確認を完了するための有益な情報を含む `next_action` フィールドが含まれています。 ```javascript next_action: { type: "verify_with_microdeposits", verify_with_microdeposits: { arrival_date: 1647586800, hosted_verification_url: "https://payments.stripe.com/…", microdeposit_type: "descriptor_code" } } ``` [請求書メール](https://docs.stripe.com/api/payment_methods/object.md#payment_method_object-billing_details-email)を指定した場合、Stripe はこのメールで入金の到着予定日を顧客に通知します。このメールには、Stripe がオンラインで提供する確認ページへのリンクが含まれ、顧客はそのページで入金額を確認して銀行口座の確認を完了することができます。 > 確認の失敗は、明細書表記ベースの少額入金の場合は 10 回、金額ベースの少額入金の場合は 3 回までです。この上限を超えると、Stripe は銀行口座を確認できなくなります。また、少額入金の確認は 10 日経過するとタイムアウトになります。この期間内に少額入金を確認できなかった場合、PaymentIntent は新しい支払い方法の詳細を要求する状態に戻ります。少額入金とは何か、どのように使用されるのかを顧客に明確に伝えることで、確認に関する問題を回避できます。 ### オプション: カスタムのメール通知を送信する 必要に応じて、顧客に[カスタムのメール通知](https://docs.stripe.com/payments/ach-direct-debit.md#mandate-and-microdeposit-emails)を送信することができます。カスタムメールを設定した後は、顧客が確認メールに応答する方法を指定する必要があります。以下の方法のうち、いずれか _1 つ_を指定してください。 - Stripe 上のオンライン確認ページを使用します。これを行うには、[next_action](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-next_action-verify_with_microdeposits-hosted_verification_url) オブジェクトの `verify_with_microdeposits[hosted_verification_url]` URL を使用し、顧客に確認プロセスを完了するよう指示します。 - Stripe がオンラインで提供する確認ページを使用しない場合、ご自身のサイトにフォームを作成します。顧客はこのフォームを使用して少額入金の金額を伝え、[Stripe.js](https://docs.stripe.com/js/payment_intents/verify_microdeposits_for_payment) を使用して、銀行口座を確認します。 - 確認のために、少なくとも 6 桁のストリングの `descriptor code` パラメーターを処理するフォームを設定します。 - また Stripe では、`amounts` パラメーターも処理するようにフォームを設定することをお勧めします。これはこのパラメーターが、顧客が利用する一部の銀行で必要とされることがあるためです。 組み込みは、`descriptor_code` 「または」 `amounts` でのみ渡されます。組み込みでどちらが使用されているかを判断するには、`next_action` オブジェクトの `verify_with_microdeposits[microdeposit_type]` の値を確認します。 ```javascript stripe.verifyMicrodepositsForPayment(clientSecret, { // Provide either a descriptor_code OR amounts, not both descriptor_code: 'SMT86W', amounts: [32, 45], }); ``` ## デフォルトの支払い方法を設定する [サーバー] これで、支払い方法が指定された顧客の有効な*サブスクリプション* (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)を作成できましたが、この支払い方法は以降の支払いで自動的には使用されません。これ以降もこの支払い方法に自動的に請求するには、*Webhook* (A webhook is a real-time push notification sent to your application as a JSON payload through HTTPS requests) Consumer を使用して、新しいサブスクリプションの `invoice.payment_succeeded` イベントをリッスンし、デフォルトの支払い方法を設定します。 #### Ruby ```ruby # Don't put any keys in code. See https://docs.stripe.com/keys-best-practices. # Find your keys at https://dashboard.stripe.com/apikeys. Stripe.api_key = '<>' if event.type == 'invoice.payment_succeeded' invoice = event.data.object if invoice['billing_reason'] == 'subscription_create' subscription_id = invoice['parent']['subscription_details']['subscription'] # This example assumes you're using the default PaymentIntent that Stripe generated for the invoice. invoice_payments = Stripe::InvoicePayment.list({invoice: invoice['id']}) payment_intent_id = invoice_payments.data[0].payment.payment_intent # Retrieve the payment intent used to pay the subscription payment_intent = Stripe::PaymentIntent.retrieve(payment_intent_id) # Set the default payment method Stripe::Subscription.update( subscription_id, default_payment_method: payment_intent.payment_method ) end end ``` ## サブスクリプションのステータスを管理する [クライアント側] 初回の支払いが成功すると、サブスクリプションの状態は `active` になり、それ以上のアクションは不要です。支払いが失敗した場合は、ステータスが[自動請求設定](https://docs.stripe.com/invoicing/automatic-collection.md)で設定された**サブスクリプションステータス**に変わります。支払いの失敗時には、顧客に通知して、[別の支払い方法で請求](https://docs.stripe.com/billing/subscriptions/overview.md#requires-payment-method)する必要があります。 ## 導入をテストする [Financial Connections](https://docs.stripe.com/financial-connections/testing.md#web-how-to-use-test-accounts) を使用して即時確認を行うシナリオをテストする方法をご紹介します。 ### サンドボックスで取引メールを送信する 銀行口座の詳細を収集し、同意書を受け付けたら、*サンドボックス* (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)で同意書の確認メールと少額入金の確認メールを送信します。 ドメインが **{domain}** で、ユーザー名が **{username}** の場合、メール形式 **{username}+test\_email@{domain}** を使用してテスト取引メールを送信します。 たとえば、ドメインが **example.com** でユーザー名が **info** の場合、ACH Direct Debit 決済のテストには **info+test\_email@example.com** という形式を使用します。この形式により、メールが正しくルーティングされます。**+test\_email** サフィックスを含めない場合、メールは送信されません。 > テスト中にこれらのメールをトリガーするには、[Stripe の本番環境利用の申請](https://docs.stripe.com/get-started/account/activate.md)を行う必要があります。 ### テスト用口座番号 Stripe では、手動入力の銀行口座の組み込みが本番環境に移行する準備が整ったかどうかを確認するため、テスト用の口座番号と対応するトークンをいくつか用意しています。 | 口座番号 | トークン | 金融番号 | 動作 | | -------------- | -------------------------------------- | ----------- | ----------------------------------------------------------------------------------------------------------------- | | `000123456789` | `pm_usBankAccount_success` | `110000000` | 支払いは成功します。 | | `000111111113` | `pm_usBankAccount_accountClosed` | `110000000` | 口座が解約済みであるため、支払いは失敗します。 | | `000000004954` | `pm_usBankAccount_riskLevelHighest` | `110000000` | この支払いは、[不正利用のリスクが高い](https://docs.stripe.com/radar/risk-evaluation.md#high-risk)ため、Radar によってブロックされています。 | | `000111111116` | `pm_usBankAccount_noAccount` | `110000000` | 口座が見つからないため、支払いは失敗します。 | | `000222222227` | `pm_usBankAccount_insufficientFunds` | `110000000` | 残高不足のため、支払いは失敗します。 | | `000333333335` | `pm_usBankAccount_debitNotAuthorized` | `110000000` | 引き落としがオーソリされていないため、支払いは失敗します。 | | `000444444440` | `pm_usBankAccount_invalidCurrency` | `110000000` | 通貨が無効であるため、支払いは失敗します。 | | `000666666661` | `pm_usBankAccount_failMicrodeposits` | `110000000` | 支払いで少額入金の送金が失敗します。 | | `000555555559` | `pm_usBankAccount_dispute` | `110000000` | 支払いによって不審請求の申請が開始されています。 | | `000000000009` | `pm_usBankAccount_processing` | `110000000` | 支払いは無期限に処理中のままになります。 [PaymentIntent キャンセル](https://docs.stripe.com/api/payment_intents/cancel.md) をテストするのに役立ちます。 | | `000777777771` | `pm_usBankAccount_weeklyLimitExceeded` | `110000000` | 支払い額がアカウントの週次支払い額の上限を超えているため、支払いが失敗しました。 | | `000888888885` | | `110000000` | [トークン化されたアカウント番号](https://docs.stripe.com/financial-connections/tokenized-account-numbers.md)が無効化されると決済が失敗します。 | テスト取引を完了する前に、自動的に支払いに成功または失敗するテスト用のすべての口座を確認する必要があります。確認するには、下記の少額入金のテスト用の金額または明細書表記コードを使用します。 ### 少額入金の金額と明細書表記コードをテストする さまざまなシナリオを再現するために、これらの少額入金の金額「または」明細書表記コードの値 0.01 を使用します。 | 少額入金の金額 | 明細書表記コードの値 0.01 | シナリオ | | ------------- | --------------- | ------------------------- | | `32` および `45` | SM11AA | アカウントの確認をシミュレーションします。 | | `10` および `11` | SM33CC | 許容された確認回数の超過をシミュレーションします。 | | `40` および `41` | SM44DD | 少額入金のタイムアウトをシミュレーションします。 | ### 売上処理の動作をテストする テスト取引は即座に売上として処理され、利用可能なテスト残高に追加されます。この動作は、利用可能な残高で取引が売上として処理されるまでに[数日](https://docs.stripe.com/billing/subscriptions/ach-debit.md#timing)かかることがある、本番環境とは異なります。 ## Optional: 請求サイクルを設定する デフォルトでは、サブスクリプションの作成時にその請求サイクルが自動的に設定されます。たとえば、顧客が 9 月 7 日に月額プランのサブスクリプションに登録した場合、それ以降毎月 7 日に請求されます。一部のビジネスでは、顧客に対してサイクルごとに同時に請求できるように、請求サイクルの手動設定を希望する場合があります。[billing cycle anchor](https://docs.stripe.com/api/subscriptions/create.md#create_subscription-billing_cycle_anchor) 引数を使用すると、これを実現できます。 ```curl curl https://api.stripe.com/v1/subscriptions \ -u "<>:" \ -d "customer={{CUSTOMER_ID}}" \ -d "items[0][price]={{PRICE_ID}}" \ -d billing_cycle_anchor=1611008505 ``` 請求サイクルを手動で設定すると、作成されたサブスクリプションと請求サイクルのアンカーとの間の期間の分として比例配分 (日割り / 秒割り計算) された金額が顧客に自動的に請求されます。この期間分を顧客に請求しない場合は、[proration_behavior](https://docs.stripe.com/api/subscriptions/create.md#create_subscription-proration_behavior) 引数を `none` に設定できます。請求サイクルのアンカーを[トライアル期間](https://docs.stripe.com/billing/subscriptions/ach-debit.md#trial-periods)と組み合わせ、商品への無料アクセスをユーザーに提供してから、比例配分された金額を請求することもできます。 ## Optional: サブスクリプションのトライアル 無料トライアルを使用すると、顧客はお客様の商品に一定期間請求なしでアクセスできます。トライアル期間を設定するには、[trial_end](https://docs.stripe.com/api/subscriptions/create.md#create_subscription-trial_end) にタイムスタンプを渡します。 > 無料トライアルの使用は、[proration_behavior](https://docs.stripe.com/api/subscriptions/create.md#create_subscription-proration_behavior) を `none` に設定した場合とは異なり、無料の継続期間をカスタマイズできます。 [payment_behavior](https://docs.stripe.com/api/subscriptions/create.md#create_subscription-payment_behavior) 値に `default_incomplete` を使用してトライアル期間のあるサブスクリプションを開始すると、Stripe は Subscription オブジェクトで `pending_setup_intent` 値を返します。[SetupIntent](https://docs.stripe.com/api/setup_intents.md) オブジェクトについて、詳細はドキュメントをご覧ください。 #### curl ```bash curl https://api.stripe.com/v1/subscriptions \ -u <>: \ -d "customer"="cus_4fdAW5ftNQow1a" \ -d "items[0][price]"="price_CBb6IXqvTLXp3f" \ -d "payment_behavior"="default_incomplete" \ -d "payment_settings[payment_method_types][]"="us_bank_account" \ -d "trial_end"=1610403705 \ -d "expand[0]"="pending_setup_intent" ``` 設定を完了するには、サブスクリプションの `pending_setup_intent` からフロントエンドに `client_secret` を返します。このステップは初回の請求サイクルで請求を正常に開始するために必要です。 [支払い方法の詳細を取集する](https://docs.stripe.com/billing/subscriptions/ach-debit.md#collect-payment-details)、[同意書承認を収集し送信する](https://docs.stripe.com/billing/subscriptions/ach-debit.md#collect-mandate-and-submit)、および[少額入金で銀行口座を確認する](https://docs.stripe.com/billing/subscriptions/ach-debit.md#verify-with-microdeposits)手順に従いますが、異なる点が 2 つあります。 - `stripe.collectBankAccountForPayment` の代わりに `stripe.collectBankAccountForSetup` を使用します。 - `stripe.confirmUsBankAccountPayment` の代わりに `stripe.confirmUsBankAccountSetup` を使用します。 顧客が少額入金による確認を選択した場合は、`stripe.verifyMicrodepositsForPayment` ではなく `stripe.verifyMicrodepositsForSetup` を使用します。 確認されると、SetupIntent はただちに `succeeded` ステータスに移行し、Stripe はサブスクリプションの `default_payment_method` を、新規作成された *PaymentMethod* (PaymentMethods represent your customer's payment instruments, used with the Payment Intents or Setup Intents APIs) に自動的に設定します。 [請求サイクルのアンカー](https://docs.stripe.com/billing/subscriptions/ach-debit.md#billing-cycle)を無料トライアルに組み合わせることもできます。たとえば現在が 9 月 15 日だとした場合、顧客に 7 日間の無料トライアルを付与してから、通常の請求サイクルを 10 月 1 日に開始するとします。この場合 9 月 22 日に無料トライアルが終了し、請求サイクルのアンカーが 10 月 1 日となるように設定できます。これにより顧客には 7 日間の無料トライアルが付与され、トライアル終了日から 10 月 1 日までの期間については比例配分を適用した金額が請求されます。10 月 1 日に、初めての完全な請求サイクルとして、顧客は通常のサブスクリプション金額を請求されます。 ## Optional: 将来の利用に備えて支払い方法の情報を保存する 後で作成する*請求書* (Invoices are statements of amounts owed by a customer. They track the status of payments from draft through paid or otherwise finalized. Subscriptions automatically generate invoices, or you can manually create a one-off invoice)、サブスクリプション、サブスクリプションスケジュールで自動的に使用できるように、顧客のアメリカの銀行口座詳細を保存できます。これを行うには、[SetupIntent (支払い方法設定インテント)](https://docs.stripe.com/api/setup_intents.md) オブジェクトを使用します。このオブジェクトは、将来の支払いに備えて顧客の支払い方法を保存する意図を示します。 [将来の決済に備えてアメリカの銀行口座の詳細を保存する](https://docs.stripe.com/payments/ach-direct-debit/set-up-payment.md)ための手順に従ってください。 `SetupIntent` が `succeeded` 状態に達したら、顧客の `default_payment_method` を更新します。 #### Ruby ```ruby # Don't put any keys in code. See https://docs.stripe.com/keys-best-practices. # Find your keys at https://dashboard.stripe.com/apikeys. Stripe.api_key = '<>' if event.type == 'setup_intent.succeeded' setup_intent = event.data.object customer_id = setup_intent['customer'] payment_method_id = setup_intent['payment_method'] # Set the default payment method Stripe::Customer.update( customer_id, { invoice_settings: { default_payment_method: payment_method_id } } ) end ``` # ホスト型ページ > This is a ホスト型ページ for when platform is web and payment-ui is stripe-hosted. View the full page at https://docs.stripe.com/billing/subscriptions/ach-debit?platform=web&payment-ui=stripe-hosted. Stripe Checkout システムにより、顧客が [Checkout セッション](https://docs.stripe.com/api/checkout/sessions.md)でサブスクリプションを作成できる場合には、支払い方法としてアメリカの銀行口座を追加できます。 [Checkout セッション](https://docs.stripe.com/api/checkout/sessions.md)は、顧客の購入意向の詳細を表します。顧客がサブスクリプションを開始する場合は、Checkout セッションを作成します。顧客が Checkout セッションにリダイレクトされると、、顧客が購入を完了できる支払いフォームが Stripe に表示されます。ユーザーが購入を完了すると、Stripe はユーザーをお客様のサイトにリダイレクトします。 組み込み完了後に、以下の拡張を行うことができます。 - [複数の価格を追加](https://docs.stripe.com/products-prices/how-products-and-prices-work.md#multiple-prices) - [変動価格を作成する](https://docs.stripe.com/products-prices/how-products-and-prices-work.md#variable-pricing) - [既存の顧客を処理する](https://docs.stripe.com/payments/existing-customers.md?platform=web&ui=stripe-hosted) - [トライアルを使用する](https://docs.stripe.com/billing/subscriptions/trials.md) - [税金を徴収する](https://docs.stripe.com/billing/taxes/collect-taxes.md?tax-calculation=tax-rates) - [請求クーポンを作成する](https://docs.stripe.com/billing/subscriptions/coupons.md) ## 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' ``` ## 料金体系モデルを作成する [ダッシュボード] [Stripe CLI] [継続的な料金体系モデル](https://docs.stripe.com/products-prices/pricing-models.md)は、お客様が販売する商品またはサービス、そのコスト、決済で受け付ける通貨、請求対象となるサービス提供期間 (サブスクリプションの場合) を表します。価格モデルを構築するには、お客様が販売する「[商品](https://docs.stripe.com/api/products.md)」と、それをいくらで、どのくらいの頻度で請求するかを示す「[価格](https://docs.stripe.com/api/prices.md)」を用います。 この例では、「基本」と「プレミアム」という 2 つのサービスレベルオプションがある固定価格のサービスを使用しています。サービスレベルオプションごとに、1 つの商品と 1 つの継続価格を作成する必要があります (セットアップ料金のような 1 回限りの支払いを追加する場合は、1 回限りの価格で 3 つ目の商品を作成します)。 各商品が月ごとに請求されます。基本商品の価格は 5 USD で、プレミアム商品の価格は 15 USD です。3 段階構成の例については、[定額料金](https://docs.stripe.com/subscriptions/pricing-models/flat-rate-pricing.md)ガイドをご覧ください。 #### ダッシュボード [商品を追加](https://dashboard.stripe.com/test/products/create)ページに移動し、2 つの商品を作成します。商品ごとに 1 つの価格を追加し、それぞれに毎月の継続請求期間を設定します。 - プレミアム商品: 追加機能を備えたプレミアムサービス - 価格:定額 | 15 USD - 基本商品: 最低限の機能を備えた基本サービス - 価格:定額 | 5 USD 価格を作成したら、価格 ID を記録しておき、他のステップで使用できるようにします。価格 ID は、`price_G0FvDp6vZvdwRZ` のように表示されます。 準備が完了したら、ページ右上の**本番環境にコピー**ボタンを使用して、[サンドボックスから本番環境に](https://docs.stripe.com/keys.md#test-live-modes)商品を複製します。 #### API API を使用して[商品](https://docs.stripe.com/api/products.md)と[価格](https://docs.stripe.com/api/prices.md)を作成できます。 プレミアム製品を作成します。 ```curl curl https://api.stripe.com/v1/products \ -u "<>:" \ --data-urlencode "name=Billing Guide: Premium Service" \ -d "description=Premium service with extra features" ``` ベーシック製品を作成します。 ```curl curl https://api.stripe.com/v1/products \ -u "<>:" \ --data-urlencode "name=Billing Guide: Basic Service" \ -d "description=Basic service with minimum features" ``` 各商品の商品 ID を記録しておきます。これは次のように表示されます。 ```json { "id": "prod_H94k5odtwJXMtQ", "object": "product", "active": true, "attributes": [ ], "created": 1587577341, "description": "Premium service with extra features", "images": [ ], "livemode": false, "metadata": { }, "name": "Billing Guide: Premium Service", "statement_descriptor": null, "type": "service", "unit_label": null, "updated": 1587577341 } ``` 商品 ID を使用して各商品の価格を作成します。[unit_amount](https://docs.stripe.com/api/prices/object.md#price_object-unit_amount) の単位はセントであるため、たとえば `1500` = 15 USD です。 プレミアム価格を作成します。 ```curl curl https://api.stripe.com/v1/prices \ -u "<>:" \ -d product={{PREMIUM_PRODUCT_ID}} \ -d unit_amount=1500 \ -d currency=usd \ -d "recurring[interval]=month" ``` 基本価格を作成します。 ```curl curl https://api.stripe.com/v1/prices \ -u "<>:" \ -d product={{BASIC_PRODUCT_ID}} \ -d unit_amount=500 \ -d currency=usd \ -d "recurring[interval]=month" ``` 各価格の価格 ID を記録しておき、後続のステップで使用できるようにします。これは次のように表示されます。 ```json { "id": "price_HGd7M3DV3IMXkC", "object": "price", "product": "prod_HGd6W1VUqqXGvr", "type": "recurring", "currency": "usd", "recurring": { "interval": "month", "interval_count": 1, "trial_period_days": null, "usage_type": "licensed" }, "active": true, "billing_scheme": "per_unit", "created": 1589319695, "livemode": false, "lookup_key": null, "metadata": { }, "nickname": null, "unit_amount": 1500, "unit_amount_decimal": "1500", "tiers": null, "tiers_mode": null, "transform_quantity": null } ``` 他の[料金体系モデル](https://docs.stripe.com/products-prices/pricing-models.md)の例をご覧ください。 ## Checkout セッションを作成する [クライアント側] [サーバー側] サーバー側のエンドポイントを呼び出して Checkout セッションを作成する購入ボタンをウェブサイトに追加します。 ```html Checkout
``` ### Checkout セッションのパラメーター 使用できるパラメーターの一覧については、[セッションの作成](https://docs.stripe.com/api/checkout/sessions/create.md)をご覧ください。 既存の [Price](https://docs.stripe.com/api/prices.md) の ID を使用して Checkout セッションを作成します。モードが `subscription` に設定されており、1 つ以上の継続価格を渡すことを確認してください。継続価格に加えて、1 回限りの価格を追加できます。Checkout セッションを作成したら、レスポンスで返された [URL](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-url) に顧客をリダイレクトします。 #### cURL ```bash curl https://api.stripe.com/v1/checkout/sessions \ -u <>: \ -d "payment_method_types[]"="us_bank_account" \ -d "line_items[][price]"="{{PRICE_ID}}" \ -d "line_items[][quantity]"=1 \ -d "mode"="subscription" \ -d "success_url"="https://example.com/success?session_id={CHECKOUT_SESSION_ID}" \ ``` 顧客が支払いを正常に完了すると、`success_url` (支払いが成功したことを顧客に通知するウェブページ) にリダイレクトされます。上記の例のように、`success_url` に `{CHECKOUT_SESSION_ID}` テンプレート変数を含めることで、成功ページでセッション ID が使用できるようになります。 デフォルトでは、Checkout セッションは作成後 24 時間で期限が切れます。 > 決済開始の検出にあたっては、`success_url` へのリダイレクトのみに依存しないでください。その理由は次のとおりです。 > > - 悪意を持つユーザが、支払いをせずに `success_url` に直接アクセスし、商品やサービスにアクセスできるようになる可能性があります。 - 決済が成功した後で、顧客が `success_url` にリダイレクトされる前にブラウザタブを閉じる可能性あります。 ## 支払いが成功したことを確認する 顧客は支払いを完了すると、`success_url` パラメータで指定された URL にリダイレクトされます。通常、これはお客様の Web サイト上のページであり、支払いが成功したことを顧客に知らせます。 ただし、US bank account debit は通知遅延型の支払い方法であるため、資金はすぐに利用可能になりません。このため、資金が利用可能になるまで、注文の *フルフィルメント* (Fulfillment is the process of providing the goods or services purchased by a customer, typically after payment is collected) を保留にします。支払いが成功すると、基盤となる *PaymentIntent* (The Payment Intents API tracks the lifecycle of a customer checkout flow and triggers additional authentication steps when required by regulatory mandates, custom Radar fraud rules, or redirect-based payment methods) のステータスが `processing` から `succeeded` に変わります。 US bank account debit の支払いでは、売上が利用可能になるまでに通常 four days かかります。 次のように、複数の方法で支払いが成功したことを確認できます。 #### ダッシュボード 成功した決済は、ダッシュボードの [決済の一覧](https://dashboard.stripe.com/payments) に表示されます。決済をクリックすると、その決済の詳細ページに移動します。**決済サマリー** セクションには、Billing 情報と購入された項目の一覧が含まれ、これを使用して手動で注文のフルフィルメントを実行できます。 ![](https://b.stripecdn.com/docs-statics-srv/assets/source.16d3029596357c80a8efdbbfe106108a.png) > Stripe は顧客が支払いに成功するたびにお客様にメール通知を送信し、今後受領する支払いの最新情報を把握できるようサポートします。ダッシュボードを使用して[メール通知を設定](https://dashboard.stripe.com/settings/user)します。 #### Webhook 決済のステータスに変化があると、以下の決済イベントが送信されます。 | イベント名 | 説明 | 次のステップ | | -------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------- | ------------------------------------ | | [checkout.session.completed](https://docs.stripe.com/api/events/types.md#event_types-checkout.session.completed) | 顧客が Checkout フォームを送信して、デビット支払いのオーソリを正常に実行しました。 | 支払いが成功するか、失敗するまで待ちます。 | | [checkout.session.async_payment_succeeded](https://docs.stripe.com/api/events/types.md#event_types-checkout.session.async_payment_succeeded) | 遅延された支払い方法は、最終的に成功しました。 | 顧客が購入した商品またはサービスの発送を行います。 | | [checkout.session.async_payment_failed](https://docs.stripe.com/api/events/types.md#event_types-checkout.session.async_payment_failed) | 遅延された支払い方法は、最終的に失敗しました。 | 顧客にメールをして、決済をもう一度試みるようにリクエストします。 | | [invoice.paid](https://docs.stripe.com/api/events/types.md#event_types-invoice.paid) | 顧客の支払いが成功しました。 | 顧客が購入した商品またはサービスの発送を行います。 | | [invoice.payment_failed](https://docs.stripe.com/api/events/types.md#event_types-invoice.payment_failed) | 何らかの理由により顧客の支払いが拒否されたか、失敗しました。 | メールで顧客に連絡して、支払いをもう一度お試しいただくように依頼します。 | Webhook コードでこれらの決済イベントのすべてを処理する必要があります。 各 Checkout Webhook のペイロードには [Checkout Session オブジェクト](https://docs.stripe.com/api/checkout/sessions.md) が含まれ、インボイスの Webhook には [Invoice (インボイス)](https://docs.stripe.com/api/invoices/object.md) オブジェクトが含まれます。この両方に、*Customer* (Customer objects represent customers of your business. They let you reuse payment methods and give you the ability to track multiple payments) および *PaymentIntent* (The Payment Intents API tracks the lifecycle of a customer checkout flow and triggers additional authentication steps when required by regulatory mandates, custom Radar fraud rules, or redirect-based payment methods) に関する情報が含まれます。 顧客がリダイレクトされる前に、Stripe から `checkout.session.completed` Webhook がお客様のサーバーに送信されます。Webhook の確認応答 (任意の `2xx` ステータスコード) によって、`success_url` への顧客のリダイレクトが開始されます。支払いに成功してから 10 秒以内に Stripe が成功確認応答を受け取らなかった場合、顧客は自動的に `success_url` ページにリダイレクトされます。 `success_url` ページで、顧客に成功のメッセージを表示し、さらに決済手段 US bank account debit が即時処理ではないため、注文のフルフィルメントに最大 four days かかることを通知します。 [Webhook を使用](https://docs.stripe.com/webhooks.md)して支払いの成功を確認し、顧客が購入した商品やサービスのフルフィルメントを行うことをお勧めします。以下は、支払いの成功または失敗を処理する Webhook エンドポイントの例です。 #### Ruby ```ruby # Don't put any keys in code. See https://docs.stripe.com/keys-best-practices. # Find your keys at https://dashboard.stripe.com/apikeys. Stripe.api_key = '<>' # You can find your endpoint's secret in your webhook settings endpoint_secret = 'whsec_...' # Using Sinatra post '/webhook' do payload = request.body.read event = nil # Verify webhook signature and extract the event # See https://stripe.com/docs/webhooks#verify-events for more information. sig_header = request.env['HTTP_STRIPE_SIGNATURE'] begin event = Stripe::Webhook.construct_event( payload, sig_header, endpoint_secret ) rescue JSON::ParserError => e # Invalid payload status 400 return rescue Stripe::SignatureVerificationError => e # Invalid signature status 400 return end case event['type'] when 'checkout.session.completed' session = event['data']['object'] subscription_id = session.subscription # Find the subscription or save it to your database. # invoice.paid may have fired before this so there # could already be a subscription. find_or_create_subscription(subscription_id) when 'invoice.paid' invoice = event['data']['object'] subscription_id = invoice.parent.subscription_details.subscription # Find the subscription or save it to your database. # checkout.session.completed may not have fired yet # so we may need to create the subscription. subscription = find_or_create_subscription(subscription_id) # Fulfill the purchase fulfill_order(invoice) # Record that the subscription has been paid for # this payment period. invoice.paid will fire every # time there is a payment made for this subscription. record_as_paid_for_this_period(subscription) when 'invoice.payment_failed' invoice = event['data']['object'] # Send an email to the customer asking them to retry their payment email_customer_about_failed_payment(invoice) end status 200 end ``` 顧客、決済、またはサブスクリプションに関する情報を取得するには、Webhook のペイロードの `customer`、`payment_intent`、および `subscription` のプロパティによって参照される `Customer`、`PaymentIntent`、または `Subscription` のオブジェクトを取得します。 ### Webhook からラインアイテムを取得する デフォルトでは、Checkout Webhook は `line_items` を返しません。Checkout セッションで作成されたアイテムを取得するには、Checkout セッション ID を使用して追加のリクエストを行います。 #### curl ```bash curl https://api.stripe.com/v1/checkout/sessions/{{CHECKOUT_SESSION_ID}}/line_items \ -u <>: ``` #### Stripe CLI ```bash stripe get /v1/checkout/sessions/{{CHECKOUT_SESSION_ID}}/line_items ``` ### Webhook をローカルでテストする Webhook をローカルでテストするには、[Stripe CLI](https://docs.stripe.com/stripe-cli.md) を使用できます。Stripe CLI をインストールすると、サーバーにイベントを転送できるようになります。 ```bash stripe listen --forward-to localhost:4242/webhook Ready! Your webhook signing secret is '{{WEBHOOK_SIGNING_SECRET}}' (^C to quit) ``` [Webhook の設定](https://docs.stripe.com/webhooks.md)についてもっと知る。 #### サードパーティーのプラグイン [Zapier](https://stripe.com/works-with/zapier) などのプラグインを使用すると、Stripe の決済からの情報を利用して購入のフルフィルメントシステムを自動更新できます。 プラグインで対応可能な自動化の例の一部を以下に挙げます。 - 支払いの成功に対応して、注文の追跡に使用されるスプレッドシートを更新する - 支払いの成功に対応して、在庫管理システムを更新する - メールまたはチャットアプリケーションを使用して、社内のカスタマーサービスチームへの通知をトリガーする ## 導入をテストする [Financial Connections](https://docs.stripe.com/financial-connections/testing.md#web-how-to-use-test-accounts) を使用して即時確認を行うシナリオをテストする方法をご紹介します。 ### サンドボックスで取引メールを送信する 銀行口座の詳細を収集し、同意書を受け付けたら、*サンドボックス* (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)で同意書の確認メールと少額入金の確認メールを送信します。 ドメインが **{domain}** で、ユーザー名が **{username}** の場合、メール形式 **{username}+test\_email@{domain}** を使用してテスト取引メールを送信します。 たとえば、ドメインが **example.com** でユーザー名が **info** の場合、ACH Direct Debit 決済のテストには **info+test\_email@example.com** という形式を使用します。この形式により、メールが正しくルーティングされます。**+test\_email** サフィックスを含めない場合、メールは送信されません。 > テスト中にこれらのメールをトリガーするには、[Stripe の本番環境利用の申請](https://docs.stripe.com/get-started/account/activate.md)を行う必要があります。 ### テスト用口座番号 Stripe では、手動入力の銀行口座の組み込みが本番環境に移行する準備が整ったかどうかを確認するため、テスト用の口座番号と対応するトークンをいくつか用意しています。 | 口座番号 | トークン | 金融番号 | 動作 | | -------------- | -------------------------------------- | ----------- | ----------------------------------------------------------------------------------------------------------------- | | `000123456789` | `pm_usBankAccount_success` | `110000000` | 支払いは成功します。 | | `000111111113` | `pm_usBankAccount_accountClosed` | `110000000` | 口座が解約済みであるため、支払いは失敗します。 | | `000000004954` | `pm_usBankAccount_riskLevelHighest` | `110000000` | この支払いは、[不正利用のリスクが高い](https://docs.stripe.com/radar/risk-evaluation.md#high-risk)ため、Radar によってブロックされています。 | | `000111111116` | `pm_usBankAccount_noAccount` | `110000000` | 口座が見つからないため、支払いは失敗します。 | | `000222222227` | `pm_usBankAccount_insufficientFunds` | `110000000` | 残高不足のため、支払いは失敗します。 | | `000333333335` | `pm_usBankAccount_debitNotAuthorized` | `110000000` | 引き落としがオーソリされていないため、支払いは失敗します。 | | `000444444440` | `pm_usBankAccount_invalidCurrency` | `110000000` | 通貨が無効であるため、支払いは失敗します。 | | `000666666661` | `pm_usBankAccount_failMicrodeposits` | `110000000` | 支払いで少額入金の送金が失敗します。 | | `000555555559` | `pm_usBankAccount_dispute` | `110000000` | 支払いによって不審請求の申請が開始されています。 | | `000000000009` | `pm_usBankAccount_processing` | `110000000` | 支払いは無期限に処理中のままになります。 [PaymentIntent キャンセル](https://docs.stripe.com/api/payment_intents/cancel.md) をテストするのに役立ちます。 | | `000777777771` | `pm_usBankAccount_weeklyLimitExceeded` | `110000000` | 支払い額がアカウントの週次支払い額の上限を超えているため、支払いが失敗しました。 | | `000888888885` | | `110000000` | [トークン化されたアカウント番号](https://docs.stripe.com/financial-connections/tokenized-account-numbers.md)が無効化されると決済が失敗します。 | テスト取引を完了する前に、自動的に支払いに成功または失敗するテスト用のすべての口座を確認する必要があります。確認するには、下記の少額入金のテスト用の金額または明細書表記コードを使用します。 ### 少額入金の金額と明細書表記コードをテストする さまざまなシナリオを再現するために、これらの少額入金の金額「または」明細書表記コードの値 0.01 を使用します。 | 少額入金の金額 | 明細書表記コードの値 0.01 | シナリオ | | ------------- | --------------- | ------------------------- | | `32` および `45` | SM11AA | アカウントの確認をシミュレーションします。 | | `10` および `11` | SM33CC | 許容された確認回数の超過をシミュレーションします。 | | `40` および `41` | SM44DD | 少額入金のタイムアウトをシミュレーションします。 | ### 売上処理の動作をテストする テスト取引は即座に売上として処理され、利用可能なテスト残高に追加されます。この動作は、利用可能な残高で取引が売上として処理されるまでに[数日](https://docs.stripe.com/billing/subscriptions/ach-debit.md#timing)かかることがある、本番環境とは異なります。 ## その他の考慮事項 ### 少額入金確認の失敗 銀行口座で少額入金による確認が進行中のときに、顧客は次の 3 つの理由で確認に失敗することがあります。 - 少額入金を顧客の銀行口座に送金できなかった (これは通常、銀行口座が解約済みまたは使用不可であるか、銀行口座番号が不正確である場合に発生します)。 - 顧客が口座の確認に 10 回失敗した。この試行回数の上限を超えると、その銀行口座は確認することも、再利用することもできなくなります。 - 顧客が 10 日以内に銀行口座を確認しなかった。 これらのいずれかの理由で銀行口座の確認に失敗した場合、[`checkout.session.async_payment_failed` イベントを処理](https://docs.stripe.com/api/events/types.md?event_types-invoice.payment_succeeded=#event_types-checkout.session.async_payment_failed)して、新たに注文を行うよう顧客に連絡できます。 ## Optional: 即時の確認のみ ACH ダイレクトデビットによる決済では、デフォルトで顧客は銀行口座の即時確認、または少額入金を使用できます。オプションとして、Checkout セッションを作成するときに `payment_method_options[us_bank_account][verification_method]` パラメーターを使用して、銀行口座の即時確認のみを要求するように設定することもできます。 ```curl curl https://api.stripe.com/v1/checkout/sessions \ -u "<>:" \ -d mode=subscription \ -d customer={{CUSTOMER_ID}} \ -d "payment_method_types[0]=card" \ -d "payment_method_types[1]=us_bank_account" \ -d "payment_method_options[us_bank_account][verification_method]=instant" \ -d "payment_method_options[us_bank_account][financial_connections][permissions][0]=payment_method" \ -d "line_items[0][price]={{PRICE_ID}}" \ -d "line_items[0][quantity]=1" \ --data-urlencode "success_url=https://example.com/success" ``` ## See also - [自社のシステムを構築する](https://docs.stripe.com/payments/checkout/customization.md) - [カスタマーポータルでサブスクリプションを管理する](https://docs.stripe.com/billing/subscriptions/build-subscriptions.md?payment-ui=checkout&ui=stripe-hosted)