コンテンツにスキップ
アカウントを作成
または
サインイン
Stripe ドキュメントのロゴ
/
AI に質問する
アカウントを作成
サインイン
始める
支払い
Revenue
プラットフォームおよびマーケットプレイス
資金管理
開発者向けのツール
概要
Billing
    概要
    Billing API について
    サブスクリプション
      サブスクリプションの仕組み
      クイックスタート
      ユースケース
      実装を構築
      サブスクリプション機能
        サブスクリプションの請求書
        サブスクリプションのスケジュール
        サブスクリプションの料金体系
        継続的な料金体系モデル
        料金表を埋め込む
        サブスクリプションを始める
        数量の設定
        請求サイクルの設定
        サブスクリプションの遡及適用
        複数のアイテムに登録
        トライアル期間を設定
        クーポンを適用
        サブスクリプションを Stripe に移行する
        クレジットの比例分配の計算方法
        サブスクリプションの決済
        サブスクリプションの決済手段
          ACH ダイレクトデビット
          Amazon Pay
          イギリスでの Bacs ダイレクトデビット
          銀行振込
          オーストラリアの BECS ダイレクトデビット
          Cash App Pay
          PayPal
          Revolut Pay
          韓国のカード
          カカオペイ
          Naver Pay
          カナダのプレオーソリデビット
          EU の SEPA ダイレクトデビット
          iDEAL と SEPA ダイレクトデビット
          Bancontact と SEPA ダイレクトデビット
          Sofort と SEPA ダイレクトデビット
        サードパーティーによる決済処理を導入
        回収方法
        支払いの詳細を更新するリンクを共有する
        強力な顧客認証 (SCA)
        サブスクリプションを管理
        サブスクリプションの修正
        保留中の更新の管理
      アナリティクス
    Invoicing
    従量課金
    Connect と Billing
    Tax と Billing
    見積もり
    売上回収
    オートメーション
    スクリプト
    収益認識
    顧客管理
    エンタイトルメント
    実装内容をテストする
税金
レポート機能
データ
スタートアップの企業設立
ホームRevenueBillingSubscriptionsSubscription featuresSubscription payment methods

注

このページはまだ日本語ではご利用いただけません。より多くの言語で文書が閲覧できるように現在取り組んでいます。準備が整い次第、翻訳版を提供いたしますので、もう少しお待ちください。

ACH ダイレクトデビットによるサブスクリプションを設定する

アメリカの銀行口座を使用したサブスクリプションの作成と請求の方法をご紹介します。

ページをコピー

このガイドを使用して、ACH ダイレクトデビットを使用するサブスクリプションを設定します。

注

新しいユーザーの場合には、このガイドで説明されているように、Stripe Elements ではなく、Payment Element を使用してください。Payment Element は、コンバージョン最適化が組み込まれたローコードの導入パスを提供します。手順については、サブスクリプションの構築をご覧ください。

商品と価格を作成する
ダッシュボード

Products (商品) は、販売しているアイテムまたはサービスを表します。Prices (価格) は、商品の価格と請求頻度を定義します。これには、商品の価格、受け付ける通貨、および 1 回限りの支払いか継続支払いかが含まれます。商品と価格が数個のみの場合は、ダッシュボードでそれらを作成および管理します。

このガイドでは、例としてストックフォトサービスを使用し、15 USD の月次サブスクリプションを顧客に請求します。これをモデル化するには、次のようにします。

  1. 商品を追加ページに移動します。
  2. 商品の名前を入力します。
  3. 価格に 15 を入力します。
  4. 通貨として USD を選択します。
  5. 商品を保存をクリックします。

商品と価格を作成したら、価格 ID を記録しておき、後続のステップで使用できるようにします。ID は料金体系ページで price_G0FvDp6vZvdwRZ のように表示されます。

サブスクリプションを作成する
サーバー側

注

無料のトライアル期間付きのサブスクリプションの作成については、サブスクリプションのトライアルをご覧ください。

payment_behavior パラメーターの値として default_incomplete を指定して、ステータスが incomplete の価格と顧客の Subscription (サブスクリプション) を作成します。

Command Line
curl
curl https://api.stripe.com/v1/subscriptions \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -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"

The response includes the subscription’s first Invoice. This contains the invoice’s payments, which includes a default PaymentIntent that Stripe generated for this invoice and the confirmation secret which you can use on the client side to securely complete the payment process instead of passing the entire PaymentIntent object. Return the latest_invoice.confirmation_secret.client_secret to the front end to complete payment.

支払い方法の詳細を収集する
クライアント側

顧客が ACH Direct Debitでの支払いをクリックしたときに、Stripe.js を使用してその支払いを Stripe に送信することをお勧めします。Stripe.js は、決済フローを構築するための Stripe の基本的な JavaScript ライブラリです。これにより、実装に関する複雑な処理が自動的に行われ、将来、他の決済手段にも対応できるように実装を簡単に拡張できます。

Stripe.js スクリプトを決済ページに含めるには、このスクリプトを HTML ファイルの head に追加します。

checkout.html
<head> <title>Checkout</title> <script src="https://js.stripe.com/v3/"></script> </head>

決済ページで以下の JavaScript を使用して、Stripe.js のインスタンスを作成します。

client.js
// 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(
'pk_test_TYooMQauvdEDq54NiTphI7jx'
);

PaymentIntent オブジェクト全体をクライアントに送信する代わりに、前のステップからの client secret を使用します。これは、Stripe API リクエストを認証する API キーとは異なります。

client secret は支払いを完了できるため、慎重に取り扱う必要があります。記録したり、URL に埋め込んだり、当該の顧客以外に漏洩することがないようにしてください。

stripe.collectBankAccountForPayment を使用して、Financial Connections で銀行口座の詳細を収集し、PaymentMethod を作成して PaymentIntent に関連付けます。ACH ダイレクトデビットの PaymentMethod を作成するには、billing_details パラメーターに口座名義人を含める必要があります。

script.js
// 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 認証フローでは、銀行口座の詳細の収集と確認を自動的に処理します。顧客が認証フローを完了すると、PaymentMethod が自動的に PaymentIntent に関連付けられ、Financial Connections アカウントが作成されます。

よくある間違い

手動入力と少額入金によって顧客が関連付けた銀行口座では、残高、所有権、取引などの追加の銀行口座データにアクセスできません。

すべてのデバイスで最適なユーザー体験を提供できるように、ビューポートの meta タグを使用して、ページのビューポートの minimum-scale を 1 に設定します。

<meta name="viewport" content="width=device-width, minimum-scale=1" />

同意書承認を収集し送信する
クライアント側

支払いを開始する前に、顧客に同意書の規約を表示して、顧客から承認を得る必要があります。

To be compliant with Nacha rules, you must obtain authorization from your customer before you can initiate payment by displaying mandate terms for them to accept. For more information on mandates, see Mandates.

顧客が同意書の規約を承認する場合、PaymentIntent を確定する必要があります。顧客がフォームを送信したら、stripe.confirmUsBankAccountPayment を使用して支払いを完了します。

script.js
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 の完了には数秒かかる場合があります。この間、フォームが再送信されないように無効化し、待機中のインジケーター (スピナーなど) を表示します。エラーが発生した場合は、それを顧客に表示し、フォームを再度有効化し、待機中のインジケーターを非表示にします。

顧客が即時確認を完了すると、サブスクリプションは自動的に active になります。そうでない場合には、少額入金で銀行口座を確認するをご覧になり、サブスクリプションが incomplete の状態のままであるときに少額入金による確認を処理する方法を確認してください。

少額入金で銀行口座を確認する
クライアント側

注

顧客はサブスクリプションに対する少額入金を、 サブスクリプションのライフサイクルで通常指定されている 23 時間以内ではなく、10 日以内に確認する必要があります。ただし、この期限は請求サイクルの日付より前にする必要があります。

すべての顧客が銀行口座を即時に確認できるわけではありません。このステップは、顧客が前のステップで即時確認フローからオプトアウトした場合にのみ適用されます。

このような場合、Stripe は descriptor_code による少額入金を送金し、銀行口座の確認でさらに問題が発生した場合には、amount による少額入金に戻る場合があります。これらの入金が顧客のオンライン明細書に表示されるには 1 ~ 2 営業日かかります。

  • 明細書表記コード。SM で始まる一意の 6 桁の descriptor_code を指定して、0.01 USD の 1 件の少額入金を顧客の銀行口座に送金します。顧客は、この文字列を使用して、銀行口座を確認します。
  • 金額。Stripe は、ACCTVERIFY という明細書表記を使用し、一意でない 2 件の少額入金を顧客の銀行口座に送金します。顧客は、この入金額を使用して銀行口座を確認します。

前のステップの stripe.confirmUsBankAccountPayment メソッドの呼び出しの結果として、requires_action 状態の PaymentIntent が返されます。この PaymentIntent には、確認を完了するための有益な情報を含む next_action フィールドが含まれています。

next_action: { type: "verify_with_microdeposits", verify_with_microdeposits: { arrival_date: 1647586800, hosted_verification_url: "https://payments.stripe.com/…", microdeposit_type: "descriptor_code" } }

If you supplied a billing email, Stripe notifies your customer through this email when the deposits are expected to arrive. The email includes a link to a Stripe-hosted verification page where they can confirm the amounts of the deposits and complete verification.

警告

確認の失敗は、明細書表記ベースの少額入金の場合は 10 回、金額ベースの少額入金の場合は 3 回までです。この上限を超えると、Stripe は銀行口座を確認できなくなります。また、少額入金の確認は 10 日経過するとタイムアウトになります。この期間内に少額入金を確認できなかった場合、PaymentIntent は新しい支払い方法の詳細を要求する状態に戻ります。少額入金とは何か、どのように使用されるのかを顧客に明確に伝えることで、確認に関する問題を回避できます。

オプション: カスタムのメール通知を送信する

Optionally, you can send custom email notifications to your customer. After you set up custom emails, you need to specify how the customer responds to the verification email. To do so, choose one of the following:

  • Use the Stripe-hosted verification page. To do this, use the verify_with_microdeposits[hosted_verification_url] URL in the next_action object to direct your customer to complete the verification process.

  • Stripe がオンラインで提供する確認ページを使用しない場合、ご自身のサイトにフォームを作成します。顧客はこのフォームを使用して少額入金の金額を伝え、Stripe.js を使用して、銀行口座を確認します。

    • 確認のために、少なくとも 6 桁のストリングの descriptor code パラメーターを処理するフォームを設定します。
    • また、Stripe は、フォームで amounts パラメーターを処理するように設定することもお勧めします。顧客が利用する一部の銀行で必要になる場合があるためです。

    組み込みは、descriptor_code 「または」 amounts でのみ渡されます。組み込みでどちらが使用されているかを判断するには、next_action オブジェクトの verify_with_microdeposits[microdeposit_type] の値を確認します。

stripe.verifyMicrodepositsForPayment(clientSecret, { // Provide either a descriptor_code OR amounts, not both descriptor_code: 'SMT86W', amounts: [32, 45], });

デフォルトの支払い方法を設定する
サーバー

これで、支払い方法が指定された顧客の有効なサブスクリプションを作成できましたが、この支払い方法は以降の支払いで自動的には使用されません。これ以降もこの支払い方法に自動的に請求するには、Webhook Consumer を使用して、新しいサブスクリプションの invoice.payment_succeeded イベントをリッスンし、デフォルトの支払い方法を設定します。

server.rb
Ruby
# Set your secret key. Remember to switch to your live secret key in production. # See your keys here: https://dashboard.stripe.com/apikeys Stripe.api_key =
'sk_test_BQokikJOvBiI2HlWgH4olfQ2'
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 になり、それ以上のアクションは不要です。支払いが失敗した場合は、ステータスが自動請求設定で設定されたサブスクリプションステータスに変わります。支払いの失敗時には、顧客に通知して、別の支払い方法で請求する必要があります。

導入をテストする

Financial Connections を使用して即時確認を行うシナリオをテストする方法をご紹介します。

Send transaction emails in a sandbox

After you collect the bank account details and accept a mandate, send the mandate confirmation and microdeposit verification emails in a sandbox.

If your domain is “example.com,” use an email format such as info+testing@example.com for testing non-card payments. You can replace “info” with a standard local term such as “support.” This format ensures emails are routed correctly.

よくある間違い

You need to activate your Stripe account before you can trigger these emails while testing.

テスト用口座番号

Stripe では、手動入力の銀行口座の組み込みが本番環境に移行する準備が整ったかどうかを確認するため、テスト用の口座番号と対応するトークンをいくつか用意しています。

口座番号トークン金融番号動作
000123456789pm_usBankAccount_success110000000支払いは成功します。
000111111113pm_usBankAccount_accountClosed110000000口座が解約済みであるため、支払いは失敗します。
000000004954pm_usBankAccount_riskLevelHighest110000000この支払いは、不正利用のリスクが高いため、Radar によってブロックされています。
000111111116pm_usBankAccount_noAccount110000000口座が見つからないため、支払いは失敗します。
000222222227pm_usBankAccount_insufficientFunds110000000残高不足のため、支払いは失敗します。
000333333335pm_usBankAccount_debitNotAuthorized110000000引き落としがオーソリされていないため、支払いは失敗します。
000444444440pm_usBankAccount_invalidCurrency110000000通貨が無効であるため、支払いは失敗します。
000666666661pm_usBankAccount_failMicrodeposits110000000支払いで少額入金の送金が失敗します。
000555555559pm_usBankAccount_dispute110000000支払いによって不審請求の申請が開始されています。
000000000009pm_usBankAccount_processing110000000支払いは無期限に処理中のままになります。これは PaymentIntent のキャンセルをテストするのに便利です。
000777777771pm_usBankAccount_weeklyLimitExceeded110000000The payment fails due to payment amount causing the account to exceed its weekly payment volume limit.

テスト取引を完了する前に、自動的に支払いに成功または失敗するテスト用のすべての口座を確認する必要があります。確認するには、下記の少額入金のテスト用の金額または明細書表記コードを使用します。

少額入金の金額と明細書表記コードをテストする

さまざまなシナリオを再現するために、これらの少額入金の金額「または」明細書表記コードの値 0.01 を使用します。

少額入金の金額明細書表記コードの値 0.01シナリオ
32 および 45SM11AAアカウントの確認をシミュレーションします。
10 および 11SM33CC許容された確認回数の超過をシミュレーションします。
40 および 41SM44DD少額入金のタイムアウトをシミュレーションします。

Test settlement behavior

Test transactions settle instantly and are added to your available test balance. This behavior differs from livemode, where transactions can take multiple days to settle in your available balance.

オプション請求サイクルを設定する

オプションサブスクリプションのトライアル

オプション将来の利用に備えて支払い方法の情報を保存する

このページはお役に立ちましたか。
はいいいえ
お困りのことがございましたら 、サポートにお問い合わせください。
早期アクセスプログラムにご参加ください。
変更ログをご覧ください。
ご不明な点がございましたら、お問い合わせください。
LLM ですか?llms.txt を読んでください。
Powered by Markdoc