コンテンツにスキップ
アカウントを作成
または
サインイン
Stripe ドキュメントのロゴ
/
AI に質問する
アカウントを作成
サインイン
始める
支払い
売上
プラットフォームおよびマーケットプレイス
資金管理
開発者向けのツール

注

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

支払いリクエストボタン非推奨

Apple Pay、Google Pay、または Link を使用する顧客から支払い情報および住所情報を収集します。

レガシーの機能

このページの内容は、レガシーの Element を参照しています。代わりに Express Checkout Element を使用してください。すでに支払いリクエストボタンを実装している場合は、移行ガイドを参照して Express Checkout Element に切り替えてください。

支払いリクエストボタンには以下の制限があります。

  • カードの支払い方法のみに対応している
  • Link には対応している一方、カードの資金調達源が使用されている場合のみ対応している
  • 1 つの支払いオプションのみを表示する

デモ

注意

ご使用のブラウザーが Payment Request API に対応していない場合、または保存済みの支払い方法がない場合。支払いリクエストボタンの本番環境デモを試すには、以下のサポート対象ブラウザーのいずれかに切り替え、保存済みの支払い方法が存在することを確認してください。

Payment Request Button Element により、購入時にウォレットオプションが動的に表示され、Apple Pay、Google Pay、および Link を一度に導入することができます。または、Express Checkout Element を使用して、複数のワンクリックの支払いボタンを顧客に提供できます。Express Checkout Element と支払いリクエストボタンの機能を比較してください。

顧客がデバイスで Apple Pay または Google Pay を有効にしている場合は、使用しているブラウザーに応じて Apple Pay または Google Pay が表示されます。Link が表示される場合は、次の理由が考えられます。

  • Apple Pay または Google Pay をデバイスで有効にしていない。
  • 認証済みのアクティブな Link セッションで Chrome を使用している。

前提条件

開始する前に、以下を行う必要があります。

  • 各支払いボタンタイプの要件を確認します。
    • Apple Pay には、macOS 10.12.1 以降または iOS 10.1 以降が必要です。
    • 互換性のあるデバイスは自動的に Google Pay に対応します。
  • サンドボックスと本番環境の両方で、ドメインを登録 します。
  • ブラウザーに支払い方法を追加します。 たとえば、Chrome にカードを保存したり、Google Pay アカウントにカードを追加したり、Safari のウォレットにカードを追加したりできます。
  • HTTPS 経由でアプリケーションを提供します。 この要件は、開発環境と本番環境のいずれにも適用されます。開始するには、ngrok などのサービスを利用する方法もあります。

Stripe Elements を設定する

Install React Stripe.js and the Stripe.js loader from the npm public registry.

Command Line
npm install --save @stripe/react-stripe-js @stripe/stripe-js

注

CodeSandbox でのデモを使用すると、新しいプロジェクトを作成することなく、React Stripe.js を試してみることができます。

お客様のページへの Stripe.js および Elements の追加

To use Element components, wrap your checkout page component in an Elements provider. Call loadStripe with your publishable key and pass the returned Promise to the Elements provider.

index.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(
'pk_test_TYooMQauvdEDq54NiTphI7jx'
); function App() { return ( <Elements stripe={stripePromise}> <CheckoutForm /> </Elements> ); }; ReactDOM.render(<App />, document.getElementById('root'));

paymentRequest インスタンスを作成する
クライアント側

決済フォームコンポーネントで、必要なすべてのオプションを含む stripe.paymentRequest のインスタンスを作成します。

import React, {useState, useEffect} from 'react'; import {PaymentRequestButtonElement, useStripe} from '@stripe/react-stripe-js'; const CheckoutForm = () => { const stripe = useStripe(); const [paymentRequest, setPaymentRequest] = useState(null); useEffect(() => { if (stripe) { const pr = stripe.paymentRequest({ country: 'US', currency: 'usd', total: { label: 'Demo total', amount: 1099, }, requestPayerName: true, requestPayerEmail: true, }); } }, [stripe]); // Use a traditional checkout form. return 'Insert your form or button component here.'; }

注

requestPayerName パラメーターを使用して、Apple Pay の支払人の請求先住所を収集します。請求先住所を使用して住所の確認を行い、不正な支払いをブロックできます。その他の支払い方法では、請求先住所が使用可能な場合に自動的に収集されます。

支払いリクエストボタン Element をレンダリングする
クライアント側

canMakePayment を使用して、顧客が有効な支払い方法を設定しているかを確認します。設定している場合は、<PaymentRequestButtonElement> を表示します。設定していない場合、Element を表示できないため、代わりに従来の決済フォームを表示することをお勧めします。

import React, {useState, useEffect} from 'react'; import {PaymentRequestButtonElement, useStripe} from '@stripe/react-stripe-js'; const CheckoutForm = () => { const stripe = useStripe(); const [paymentRequest, setPaymentRequest] = useState(null); useEffect(() => { if (stripe) { const pr = stripe.paymentRequest({ country: 'US', currency: 'usd', total: { label: 'Demo total', amount: 1099, }, requestPayerName: true, requestPayerEmail: true, }); // Check the availability of the Payment Request API. pr.canMakePayment().then(result => { if (result) { setPaymentRequest(pr); } }); } }, [stripe]); if (paymentRequest) { return <PaymentRequestButtonElement options={{paymentRequest}} /> } // Use a traditional checkout form. return 'Insert your form or button component here.'; }

PaymentIntent を作成する
サーバー側

Stripe は PaymentIntent (支払いインテント) オブジェクトを使用して、顧客から支払いを回収する意図を示し、プロセス全体を通して請求の実施と支払い状態の変化を追跡します。

サーバーで金額および通貨を指定して PaymentIntent を作成します。支払い額は常に、クライアント側ではなく、信頼性の高い環境であるサーバー側で決定してください。これにより、悪意のある顧客が価格を操作できないようにすることができます。

Command Line
cURL
curl https://api.stripe.com/v1/payment_intents \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d amount=1099 \ -d currency=usd \ -d "payment_method_types[]"=card

返される PaymentIntent には client secret が含まれ、これを使用することで PaymentIntent オブジェクト全体を渡すことなく安全に支払いプロセスを完了できます。次のステップで使用するため、クライアントに client secret を送り返します。

支払いを完了する
クライアント側

paymentmethod イベントをリッスンして、PaymentMethod オブジェクトを受け取ります。PaymentMethod ID と PaymentIntent の client secret を stripe.confirmCardPayment に渡して、支払いを完了します。

paymentRequest.on('paymentmethod', async (ev) => { // Confirm the PaymentIntent without handling potential next actions (yet). const {paymentIntent, error: confirmError} = await stripe.confirmCardPayment( clientSecret, {payment_method: ev.paymentMethod.id}, {handleActions: false} ); if (confirmError) { // Report to the browser that the payment failed, prompting it to // re-show the payment interface, or show an error message and close // the payment interface. ev.complete('fail'); } else { // Report to the browser that the confirmation was successful, prompting // it to close the browser payment method collection interface. ev.complete('success'); // Check if the PaymentIntent requires any actions and, if so, let Stripe.js // handle the flow. If using an API version older than "2019-02-11" // instead check for: `paymentIntent.status === "requires_source_action"`. if (paymentIntent.status === "requires_action") { // Let Stripe.js handle the rest of the payment flow. const {error} = await stripe.confirmCardPayment(clientSecret); if (error) { // The payment failed -- ask your customer for a new payment method. } else { // The payment has succeeded -- show a success message to your customer. } } else { // The payment has succeeded -- show a success message to your customer. } } });

注意

ブラウザーによっては、支払いをオーソリした後でも、顧客は支払いインターフェイスを閉じることができます。そのため、token または paymentmethod イベントを受け取った後に、PaymentRequest オブジェクトで cancel イベントを受け取る可能性があります。顧客の注文キャンセルのフックとして cancel イベントを使用している場合は、直前に作成した支払いも必ず返金してください。

導入をテストする

実装をテストするには、HTTPS とサポート対象のブラウザーを使用する必要があります。iframe で paymentRequestButton Element を使用している場合、iframe で allow 属性を =“payment *” に設定する必要があります。

また、それぞれの支払い方法とブラウザーには固有の要件があります。

Safari

  • macOS Sierra 以降を実行する Mac の Safari。
  • Handoff を使用して Mac とペアリングされ、ウォレットにカードが登録されている互換性のあるデバイス、または TouchID 付きの Mac。手順については、Apple のサポートサイトをご覧ください。
  • Apple Pay に登録されているドメイン。
  • iframe を使用する場合は、そのオリジンがトップレベルのオリジンと一致している必要があります (Safari 17 以降で allow="payment" 属性を指定する場合を除く)。プロトコル、ホスト (フルドメイン名)、ポート (指定されている場合) が 2 つのページで同一である場合、そのオリジンは同一です。

Mobile Safari

  • Mobile Safari on iOS 10.1 以降。
  • ウォレット内のカード (設定 > Wallet と Apple Pay に移動)。
  • Apple Pay に登録されているドメイン。
  • iframe を使用する場合は、そのオリジンがトップレベルのオリジンと一致している必要があります (Safari 17 以降で allow="payment" 属性を指定する場合を除く)。プロトコル、ホスト (フルドメイン名)、ポート (指定されている場合) が 2 つのページで同一である場合、そのオリジンは同一です。

iOS 16 の時点で、Apple Pay はウォレットに保存されたカードを使用して、Safari 以外のモバイルブラウザーで機能する場合があります。

配送先情報を収集する

配送先情報を収集するには、支払いリクエストを作成する際に requestShipping: true を含めます。

配送オプションが顧客の住所に依存しない場合は、この時点で shippingOptions の配列を指定することもできます。

const paymentRequest = stripe.paymentRequest({ country: 'US', currency: 'usd', total: { label: 'Demo total', amount: 1099, }, requestShipping: true, // `shippingOptions` is optional at this point: shippingOptions: [ // The first shipping option in this list appears as the default // option in the browser payment interface. { id: 'free-shipping', label: 'Free shipping', detail: 'Arrives in 5 to 7 days', amount: 0, }, ], });

次に、shippingaddresschange イベントをリッスンして、顧客が配送先住所を選択した際にこれを検出します。この住所は、サーバーから有効な配送先オプションを取得したり、合計額を更新したり、その他のビジネスロジックを実行したりするために使用されます。shippingaddresschange イベントの住所データは、送料計算に必要のない機密情報を公開しないようにするために、ブラウザーによって匿名化される場合があります。

顧客がフローを続行するには、この時点で有効な shippingOptions を指定する必要があります。

paymentRequest.on('shippingaddresschange', async (ev) => { if (ev.shippingAddress.country !== 'US') { ev.updateWith({status: 'invalid_shipping_address'}); } else { // Perform server-side request to fetch shipping options const response = await fetch('/calculateShipping', { data: JSON.stringify({ shippingAddress: ev.shippingAddress }) }); const result = await response.json(); ev.updateWith({ status: 'success', shippingOptions: result.supportedShippingOptions, }); } });

ラインアイテムを表示する

displayItems を使用して、PaymentItem オブジェクトを表示し、ブラウザの決済インターフェースに料金の内訳を表示します。

const pr = stripe.paymentRequest({ country: 'US', currency: 'usd', total: { label: 'Demo total', amount: 2000, }, displayItems: [ { label: 'Sample item', amount: 1000, }, { label: 'Shipping cost', amount: 1000, } ], });

ボタンのスタイルを設定する

Element をカスタマイズするには、以下のパラメーターを使用します。

const options = { paymentRequest, style: { paymentRequestButton: { type: 'default', // One of 'default', 'book', 'buy', or 'donate' // Defaults to 'default' theme: 'dark', // One of 'dark', 'light', or 'light-outline' // Defaults to 'dark' height: '64px', // Defaults to '40px'. The width is always '100%'. }, } } <PaymentRequestButtonElement options={options} />

独自のボタンを使用する

paymentRequestButton Element を使用するのではなく、独自のボタンをデザインする場合は、paymentRequest.canMakePayment() の結果に基づいてカスタムボタンを表示できます。この場合は、paymentRequest.show() を使用して、ボタンがクリックされたときにブラウザーインターフェイスを表示します。

自分のボタンを作成する際は、Apple Pay のヒューマンインターフェイスガイドライン、および Google Pay のブランドガイドラインに従ってください。

Stripe Connect で支払いリクエストボタンを使用する

Connect プラットフォームでは、支払いリクエストボタンを使用する際に追加ステップの実行が必要になることがあります。

  1. 連結アカウントの顧客に対してダイレクト支払いを作成したり、トークンを追加したりする場合は、フロントエンドの Stripe インスタンスで stripeAccount オプションを設定する必要があります。

    const stripe = Stripe(
    'pk_test_TYooMQauvdEDq54NiTphI7jx'
    , { apiVersion: "2025-05-28.basil", stripeAccount: 'CONNECTED_STRIPE_ACCOUNT_ID', });
  2. 支払いインテントや設定インテントの作成時に on_behalf_of を指定した場合は、onBehalfOf オプションを使用して同じ値を paymentRequest インスタンスに渡す必要があります。

    const paymentRequest = stripe.paymentRequest({ country: 'US', currency: 'usd', total: { label: 'Demo total', amount: 1099, }, requestPayerName: true, requestPayerEmail: true, onBehalfOf: 'CONNECTED_STRIPE_ACCOUNT_ID', });
  3. 支払いリクエストボタンを表示する予定のすべてのドメインを登録します。

  1. フロントエンドで、PaymentRequest インスタンスを作成する前に、Stripe インスタンスで stripeAccount オプションを設定します。

    const stripe = Stripe(
    'pk_test_TYooMQauvdEDq54NiTphI7jx'
    , { apiVersion: "2025-05-28.basil", stripeAccount: 'CONNECTED_STRIPE_ACCOUNT_ID', });
  2. 支払いリクエストボタンを表示する予定のすべてのドメインを登録します。

支払いリクエストボタンの Link

When new customers come to your site, they can use Link in the Payment Request Button to pay with their saved payment details. With Link, they don’t need to manually enter their payment information. Link requires domain registration.

顧客に Stripe を開示する

Stripe は顧客の Elements とのやり取りに関する情報を収集して、サービスを提供し、不正利用を防止し、サービスを向上します。これには、Cookie と IP アドレスを使用して、1 つの決済フローセッションで顧客に表示する Elements を特定することが含まれます。Stripe がこのような方法でデータを使用するために必要なすべての権利と同意について開示し、これらを取得することはお客様の責任です。詳細については、プライバシーセンターをご覧ください。

参照情報

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