コンテンツにスキップ
アカウントを作成
または
サインイン
Stripe ドキュメントのロゴ
/
Ask AI
アカウントを作成
サインイン
始める
支払い
財務の自動化
プラットフォームおよびマーケットプレイス
資金管理
開発者向けのツール
始める
支払い
財務の自動化
始める
支払い
財務の自動化
プラットフォームおよびマーケットプレイス
資金管理
概要
Stripe Payments について
構築済みのシステムをアップグレード
支払いの分析
オンライン決済
概要ユースケースを見つけるManaged Payments
Payment Links を使用する
決済ページを構築
高度なシステムを構築
アプリ内実装を構築
支払い方法
決済手段を追加
    概要
    支払い方法の導入オプション
    ダッシュボードで支払い方法を管理
    決済手段のタイプ
    カード
    銀行口座引き落とし
    銀行へのリダイレクト
    銀行振込
    クレジットトランスファー (Sources)
    後払い
      Affirm
      Afterpay/Clearpay
      Alma
      Billie
      Capchase Pay
      Klarna
      Kriya
        決済を受け付ける
      Mondu
      請求書支払い
      Scalapay
      SeQura
      Sunbit
      Zip
    リアルタイム決済
    店舗支払い
    ウォレット
    国ごとに現地の支払い方法を有効化
    カスタムの決済手段
決済手段を管理
Link による購入の迅速化
支払いインターフェイス
Payment Links
Checkout
Web Elements
アプリ内 Elements
決済シナリオ
カスタムの決済フロー
柔軟なアクワイアリング
オーケストレーション
店頭支払い
端末
他の Stripe プロダクト
Financial Connections
仮想通貨
Climate
ホーム支払いAdd payment methodsBuy now, pay laterKriya

注

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

Kriya による支払いを受け付ける非公開プレビュー

Kriya の導入の設定方法をご紹介します。

ページをコピー

Use the Payment Element to embed a custom Stripe payment form in your website or application and offer payment methods to customers. For advanced configurations and customizations, refer to the Accept a Payment integration guide.

Stripe を設定する
サーバー側

開始するには、Stripe アカウントを作成を作成します。

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

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'

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

Payment Element を使用してクライアントで支払い詳細を収集する準備ができました。Payment Element は事前構築された UI コンポーネントであり、多様な支払い方法の支払い詳細の収集を容易にします。

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

実装を機能させるには、決済ページのアドレスの先頭を http:// ではなく 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'
);

Payment Element を決済ページに追加する

The Payment Element needs a place on your checkout page. Create an empty DOM node (container) with a unique ID in your payment form:

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>

上記のフォームが読み込まれたら、mode、amount、currency を指定して Elements インスタンスを作成します。これらの値によって、顧客に表示される決済手段が決まります。フォームで新しい決済手段を指定するには、必ずダッシュボードで有効にしてください。

checkout.js
const options = { mode: 'payment', amount: 1000, currency: 'gbp', // Fully customizable with appearance API. appearance: {/*...*/}, }; // Set up Stripe.js and Elements to use in checkout form const elements = stripe.elements(options); // Create and mount the Payment Element const paymentElementOptions = { layout: 'accordion'}; const paymentElement = elements.create('payment', paymentElementOptions); paymentElement.mount('#payment-element');

Elements プロバイダーを作成する際に Appearance (デザイン) オブジェクト を options に渡すことで、サイトのデザインに合わせて Payment Element をカスタマイズできます。

住所を収集

デフォルトでは、Payment Element は必要な請求先住所情報のみを収集します。(たとえば、デジタル商品およびサービスの税金を計算するなどの目的で) 顧客の詳細な請求先住所または配送先住所を収集するには、Address Element を使用します。

PaymentIntent を作成する
サーバー側

Run custom business logic immediately before payment confirmation

支払いの確定ガイドのステップ 5 に移動して、支払い確定の直前にカスタムのビジネスロジックを実行します。または、以下のステップに従って既存のシステムをシンプルにします。ここでは、クライアント側で stripe.confirmPayment を使用して、支払いの確定と次のアクションの処理の両方を行います。

顧客が支払いフォームを送信したら、PaymentIntent を使用して確認と支払いのプロセスを適切に管理します。amount と currency を指定してサーバー側で PaymentIntent を作成します。悪意のある顧客が独自の価格を選択できないように、請求金額はクライアント側ではなく、常にサーバー側 (信頼できる環境) で決定してください。

PaymentIntent には、client secret が含まれています。 この値をクライアントに返し、Stripe.js がこれを使用して支払いプロセスを安全に完了できるようにします。

main.rb
Ruby
require 'stripe' Stripe.api_key =
'sk_test_BQokikJOvBiI2HlWgH4olfQ2'
post '/create-intent' do intent = Stripe::PaymentIntent.create({ # To allow saving and retrieving payment methods, provide the Customer ID. customer: customer.id, amount: 1000, currency: 'gbp', }) {client_secret: intent.client_secret}.to_json end

Stripe に支払いを送信する
クライアント側

stripe.confirmPayment を使用して、Payment Element の詳細を使って支払いを完了します。

この関数に return_url を指定して、支払い完了後に Stripe がユーザーをリダイレクトする場所を示します。ユーザーは、最初に銀行の認証ページなどの中間サイトにリダイレクトされてから、return_url にリダイレクトされる場合があります。カード支払いでは、支払いが成功するとすぐに return_url にリダイレクトされます。

支払い完了後にカード支払いのリダイレクトを行わない場合は、redirect を if_required に設定できます。これにより、リダイレクトベースの決済手段で購入した顧客のみがリダイレクトされます。

checkout.js
const form = document.getElementById('payment-form'); const submitBtn = document.getElementById('submit'); const handleError = (error) => { const messageContainer = document.querySelector('#error-message'); messageContainer.textContent = error.message; submitBtn.disabled = false; } form.addEventListener('submit', async (event) => { // We don't want to let default form submission happen here, // which would refresh the page. event.preventDefault(); // Prevent multiple form submissions if (submitBtn.disabled) { return; } // Disable form submission while loading submitBtn.disabled = true; // Trigger form validation and wallet collection const {error: submitError} = await elements.submit(); if (submitError) { handleError(submitError); return; } // Create the PaymentIntent and obtain clientSecret const res = await fetch("/create-intent", { method: "POST", }); const {client_secret: clientSecret} = await res.json(); // Confirm the PaymentIntent using the details collected by the Payment Element const {error} = await stripe.confirmPayment({ elements, clientSecret, confirmParams: { return_url: 'https://example.com/order/123/complete', }, }); if (error) { // This point is only reached if there's an immediate error when // confirming the payment. Show the error to your customer (for example, payment details incomplete) handleError(error); } else { // Your customer is redirected to your `return_url`. For some payment // methods like iDEAL, your customer is redirected to an intermediate // site first to authorize the payment, then redirected to the `return_url`. } });

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

オプションオーソリとキャプチャの分離

実装内容をテストする

To test your integration, choose the payment method and tap Pay. In a sandbox, this redirects you to a test payment page where you can approve or decline the payment.

In live mode, tapping Pay redirects you to the Kriya website—you don’t have the option to approve or decline the payment with Kriya.

エラーコード

次の表に、一般的なエラーコードと推奨される対応の詳細を示します。

エラーコード推奨される対応
payment_intent_invalid_currencyEnter a supported currency.
missing_required_parameter必須パラメーターの詳細については、エラーメッセージをご確認ください。
payment_intent_payment_attempt_failedこのコードは、PaymentIntent の last_payment_error.code フィールドに表示されることがあります。エラーメッセージで、エラーの詳細な理由とエラー処理に関する提案を確認してください。
payment_intent_redirect_confirmation_without_return_urlPaymentIntent を確定する際は、return_url を指定します。
このページはお役に立ちましたか。
はいいいえ
お困りのことがございましたら 、サポートにお問い合わせください。
早期アクセスプログラムにご参加ください。
変更ログをご覧ください。
ご不明な点がございましたら、お問い合わせください。
LLM ですか?llms.txt を読んでください。
Powered by Markdoc