コンテンツにスキップ
アカウントを作成
または
サインイン
Stripe ドキュメントのロゴ
/
AI に質問する
アカウントを作成
サインイン
始める
支払い
財務の自動化
プラットフォームおよびマーケットプレイス
資金管理
開発者向けのツール
始める
支払い
財務の自動化
始める
支払い
財務の自動化
プラットフォームおよびマーケットプレイス
資金管理
概要
Stripe Payments について
構築済みのシステムをアップグレード
支払いの分析
オンライン決済
概要ユースケースを見つけるManaged Payments
Payment Links を使用する
決済ページを構築
高度なシステムを構築
アプリ内実装を構築
決済手段
決済手段を追加
    概要
    支払い方法の導入オプション
    ダッシュボードで支払い方法を管理
    決済手段のタイプ
    カード
    銀行口座引き落とし
    銀行へのリダイレクト
    銀行振込
    クレジットトランスファー (Sources)
    後払い
    リアルタイム決済
      Pay by Bank
      PayNow
      PayTo
        決済を受け付ける
        今後の決済のために同意書を保存
        支払いの事前設定
      Pix
      PromptPay
      Swish
    店舗支払い
    ウォレット
    国ごとに現地の支払い方法を有効化
    カスタムの決済手段
決済手段を管理
Link による購入の迅速化
支払いインターフェイス
Payment Links
Checkout
Web Elements
アプリ内 Elements
決済シナリオ
カスタムの決済フロー
柔軟なアクワイアリング
オーケストレーション
店頭支払い
端末
他の Stripe プロダクト
Financial Connections
仮想通貨
Climate
ホーム支払いAdd payment methodsReal-time paymentsPayTo

注

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

PayTo 支払いの事前設定招待のみ

PayTo 支払いを事前設定する方法をご紹介します。

ページをコピー

PayTo を使用すると、オーストラリアの顧客は、銀行アプリで 1 回限りの支払いと継続支払いの PayTo 契約を承認できます。顧客は、保留中の契約リクエストについての通知を受け取り、契約条件を承認してからアプリに戻り、そこで支払います。

将来の支払いに備えて PayTo の契約を設定することで、将来の支払いの回収に向けて現時点で顧客の承認を得ることができます。顧客はバンキングアプリで PayTo の同意書を表示、管理、一時停止、取り消すことができます。

注意

Stripe は顧客による PayTo の同意書の変更や一時停止に対応していません。顧客が契約を一時停止または変更しようとした場合、Stripe は契約を取り消して、mandate.updated Webhook をお客様に送信します。Webhook を受信した後で、顧客に連絡を取って契約を調整した理由を確認するとともに、新しい契約を設定できます。

注意

Stripe は、顧客の通貨、決済手段の制限、その他のパラメーターを評価して、決済手段オプションを自動的に提示します。決済を受け付けるの手順を使用して、Stripe ダッシュボードから決済手段を設定することをお勧めします。

引き続き、Checkout で顧客に提示する決済手段を手動で設定する場合は、このガイドを使用します。それ以外の場合は、ダッシュボードで決済手段を設定できるように、構築済みのシステムを更新してください。

Stripe を設定する
サーバー側

まず、Stripe アカウントが必要です。今すぐご登録ください。

アプリケーションから Stripe API にアクセスするには、Stripe の公式ライブラリを使用してください。

Command Line
Ruby
# Available as a gem sudo gem install stripe
Gemfile
Ruby
# If you use bundler, you can add this line to your Gemfile gem 'stripe'

顧客を作成する
サーバー側

顧客がビジネスでアカウントを作成したら、顧客を作成し、アカウントを表す内部表記と関連付けます。このようにすると、保存されている支払い方法の詳細を後で取得して使用することができます。

Command Line
cURL
curl https://api.stripe.com/v1/customers \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d name="Jenny Rosen" \ --data-urlencode email="jenny@example.com"

SetupIntent を作成する
サーバー側

SetupIntent (支払い方法設定インテント) は顧客から将来の支払いを回収する意図を示すオブジェクトであり、承認プロセスを追跡します。PayTo による決済手段を受け付ける SetupIntent を作成するには、契約条件を指定し、payment_method_types のリストに payto を指定します。SetupIntent の作成時に渡す決済手段タイプのリストを保持している場合は、それに payto を追加します。

決済手段オプションを使用して、顧客に同意を求める契約条件を指定します。

Command Line
cURL
curl https://api.stripe.com/v1/setup_intents \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d "payment_method_types[]"=payto \ -d customer=
{{CUSTOMER_ID}}
\ -d "payment_method_options[payto][mandate_options][amount_type]"=maximum \ -d "payment_method_options[payto][mandate_options][payment_schedule]"=annual \ -d "payment_method_options[payto][mandate_options][amount]"=150000 \ -d "payment_method_options[payto][mandate_options][payments_per_period]"=13 \ -d "payment_method_options[payto][mandate_options][start_date]"=2026-12-25 \ -d "payment_method_options[payto][mandate_options][end_date]"=2036-12-25 \ -d "payment_method_options[payto][mandate_options][purpose]"=mortgage

Stripe はさまざまな種類の同意書に対応し、同意書の金額、期間、頻度、目的を管理できます。できる限り忠実に要件に一致する同意条件を指定します。これらの詳細な条件は承認時に顧客に表示されるため、正確にすることで購入完了率を向上できます。

デフォルトの purpose は retail に設定されています。retail が契約の目的を正確に表していない場合は、有効値のいずれかを使用してこのフィールドを上書きします。

client secret を取得する

SetupIntent には、client secret が含まれています。これは、支払いプロセスを安全に完了するためにクライアント側で使用されます。client secret をクライアント側に渡す際は、いくつかの方法を使用できます。

ブラウザーの fetch 関数を使用して、サーバーのエンドポイントから client secret を取得します。この方法は、クライアント側が 1 ページのアプリケーションで、特に React などの最新のフロントエンドフレームワークで構築されている場合に最適です。client secret を処理するサーバーのエンドポイントを作成します。

main.rb
Ruby
get '/secret' do intent = # ... Create or retrieve the SetupIntent {client_secret: intent.client_secret}.to_json end

その後、クライアント側で JavaScript を使用して client secret を取得します。

(async () => { const response = await fetch('/secret'); const {client_secret: clientSecret} = await response.json(); // Render the form using the clientSecret })();

支払い方法の詳細を収集してオーソリリクエストを送信する
クライアント側

Payment Element を使用してクライアント側で支払い詳細を収集します。Payment Element は事前構築された UI コンポーネントであり、さまざまな決済手段の詳細の収集をシンプルにします。

Payment Element には、HTTPS 接続を介して支払い情報を Stripe に安全に送信する iframe が含まれています。一部の支払い方法では、支払いを確定するために別のページにリダイレクトする必要があるため、Payment Element を別の iframe 内に配置しないでください。

構築済みのシステムを機能させるには、決済ページのアドレスの先頭を http:// ではなく https:// にする必要があります。HTTPS を使用しなくてもシステムをテストできますが、本番環境で決済を受け付ける準備が整ったら、必ず、HTTPS を有効にしてください。

Stripe.js を設定する

Payment Element は Stripe.js の機能として自動的に使用できるようになります。決済ページに Stripe.js スクリプトを含めるには、HTML ファイルの head にスクリプトを追加します。常に js.stripe.com から Stripe.js を直接読み込むことにより、PCI 準拠が維持されます。スクリプトをバンドルに含めたり、そのコピーを自身でホストしたりしないでください。

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

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

checkout.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'
, { betas: 'payto_pm_beta_1', });

Payment Element を支払いページに追加する

Payment Element を決済ページに配置する場所が必要です。決済フォームで、一意の ID を持つ空の DOM ノード (コンテナー) を作成します。

checkout.html
<form id="payment-form"> <div id="payment-element"> <!-- Elements will create form elements here --> </div> <button id="submit">Submit</button> <div id="error-message"> <!-- Display error message to your customers here --> </div> </form>

前のフォームが読み込まれたら、Payment Element のインスタンスを作成して、それをコンテナーの DOM ノードにマウントします。Elements インスタンスを作成する際に、前のステップからの client secret を options に渡します。

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

checkout.js
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 step const elements = stripe.elements(options); // Optional: Autofill user's saved payment methods. If the customer's // email is known when the page is loaded, you can pass the email // to the linkAuthenticationElement on mount: // // linkAuthenticationElement.mount("#link-authentication-element", { // defaultValues: { // email: 'jenny.rosen@example.com', // } // }) // Create and mount the Payment Element const paymentElementOptions = { layout: 'accordion'}; const paymentElement = elements.create('payment', paymentElementOptions); paymentElement.mount('#payment-element');

stripe.confirmSetup を使用し、Payment Element の詳細を使用して設定を完了します。これにより、オーソリリクエストが買い手に送信されます。

注

顧客による支払いの承認を待っている間、stripe.confirmSetup の完了には数秒かかる場合があります。この間、フォームが再送信されないように無効化し、スピナーのような待機中のインジケーターを表示します。エラーが発生した場合は、それを顧客に表示し、フォームを再度有効化し、待機中のインジケーターを非表示にします。

checkout.js
const form = document.getElementById('payment-form'); form.addEventListener('submit', async (event) => { event.preventDefault(); const {error, setupIntent} = await stripe.confirmSetup({ //`Elements` instance that was used to create the Payment Element elements, redirect: 'if_required', confirmParams: { mandate_data: { customer_acceptance: { type: 'online', online: { infer_from_client: true, }, }, } } }); const message = document.querySelector('#message') if (error) { // This point will only be reached if there is an immediate error when // confirming the SetupIntent. Show error to your customer (for example, payment // details incomplete) message.innerText = error.message; } else { // This will execute if the confirm request is successful, or if the // setup fails asynchronously. switch (setupIntent.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 details again break; default: message.innerText = 'Something went wrong.'; break; } } });

PayTo PaymentMethod に後で請求する

顧客に請求する必要がある場合は、新たに PaymentIntent を作成します。以前の SetupIntent を取得して、同意書 ID、顧客 ID、決済手段 ID を確認します。

Command Line
cURL
curl https://api.stripe.com/v1/setup_intents/
{{SETUP_INTENT_ID}}
\ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"

以下のレスポンスで必要な ID を確認してください。

{ // ... "customer": "cus_PW6rQWRGAaBD7z", // <---- Here is the customer "mandate": "mandate_1Ok6ZrA8DuEjWaGw2nrO9xeS", // <---- Here is the mandate "metadata": {}, "next_action": null, "on_behalf_of": null, "payment_method": "pm_1Ok4l9A8DuEjWaGwhB4SGrWh", // <---- Here is the payment method "payment_method_configuration_details": null, "payment_method_options": { "payto": { "mandate_options": { "amount": 150000, "amount_type": "maximum", "start_date": "2026-12-25", "end_date": "2036-12-25", "payment_schedule": "annual", "payments_per_period": 13, "purpose": "mortgage", } } }, "payment_method_types": [ "payto" ], "single_use_mandate": null, "status": "succeeded", "usage": "off_session" // ... }

PaymentMethod ID、同意書 ID、顧客 ID を指定して PaymentIntent を作成します。

Command Line
cURL
curl https://api.stripe.com/v1/payment_intents \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d "payment_method_types[]"=payto \ -d amount=1099 \ -d currency=aud \ -d customer=
{{CUSTOMER_ID}}
\ -d payment_method=
{{PAYMENT_METHOD_ID}}
\ -d mandate=
{{MANDATE_ID}}
\ -d confirm=true

実装内容をテストする

以下のさまざまなテスト用 PayID と銀行口座情報を使用して、テスト API キーで PayTo の実装内容をテストします。各セットによって、本番環境でシステムが直面する各種シナリオが再現されています。

PayID説明
{any_prefix}+succeed@{any_domain}PaymentIntent のステータスは、60 秒後に requires_action から processing に移行し、さらに 2 秒後に succeeded に移行します。同意書のステータスは active になります。
{any_prefix}+decline@{any_domain}PaymentIntent のステータスは、60 秒後に requires_action から requires_payment_method に移行します。Stripe は、payment_method_provider_decline エラーコードと invalid_authorization 拒否コードを返します。同意書のステータスは inactive になります。
{any_prefix}+expire@{any_domain}PaymentIntent のステータスは、5 分後に requires_action から requires_payment_method に移行します。Stripe は、payment_method_provider_decline エラーコードと generic_decline 支払い拒否コードを返します。同意書のステータスは inactive になります。
{any_prefix}+insufficient_funds@{any_domain}PaymentIntent のステータスは、60 秒後に requires_action から processing に移行し、さらに 2 秒後に requires_payment_method に移行します。Stripe は、payment_method_provider_decline エラーコードと insufficient_funds 支払い拒否コードを返します。同意書のステータスは inactive になります。
{any_prefix}+revoke@{any_domain}PaymentIntent のステータスは、60 秒後に requires_action から processing に移行し、さらに 2 秒後に succeeded に移行します。同意書は active ステータスで始まり、5 分後に inactive ステータスに移行します。

オプション支払い後のイベントを処理する

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