コンテンツにスキップ
アカウントを作成
または
サインイン
Stripe ドキュメントのロゴ
/
AI に質問する
アカウントを作成
サインイン
始める
支払い
売上
プラットフォームおよびマーケットプレイス
資金管理
開発者向けリソース
概要
Stripe Payments について
構築済みのシステムをアップグレード
支払いの分析
オンライン決済
概要ユースケースを見つけるManaged Payments
Payment Links を使用する
決済ページを構築
高度なシステムを構築
アプリ内実装を構築
    概要
    Payment Sheet
    Payment Element
    アプリ内購入のリンク
    住所を収集
    Manage payment methods in settings
    アメリカとカナダのカード
決済手段
決済手段を追加
決済手段を管理
Link による購入の迅速化
支払いインターフェイス
Payment Links
Checkout
Web Elements
In-app Payments
決済シナリオ
複数の通貨を扱う
カスタムの決済フロー
柔軟なアクワイアリング
オーケストレーション
店頭支払い
端末
決済にとどまらない機能
会社を設立する
仮想通貨
Financial Connections
Climate
不正利用について
Radar の不正防止
不審請求の申請の管理
本人確認
ホーム支払いBuild an in-app integration

注

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

Customer Sheet を導入する

顧客がアプリの設定で保存済みの決済手段を管理できるようにします。

注

The Payment Method Settings Sheet is intended for use on an app settings page. For checkout and payments, use the In-app Payments, which also has built-in support for saving and displaying payment methods and supports more payment methods than the Payment Method Settings Sheet.

注

In code, this component is referenced as CustomerSheet for historical reasons. Throughout the documentation, when you see CustomerSheet in code examples, this refers to the Payment Method Settings Sheet.

The Payment Method Settings Sheet is a prebuilt UI component that lets your customers manage their saved payment methods. You can use the Payment Method Settings Sheet UI outside of a checkout flow, and the appearance and styling is customizable to match the appearance and aesthetic of your app. Customers can add and remove payment methods, which get saved to the customer object, and set their default payment method stored locally on the device. Use both the In-app Payments and the Payment Method Settings Sheet to provide customers a consistent end-to-end solution for saved payment methods.

Screenshot of Payment Method Settings Sheet presenting multiple saved payment methods in an iOS app.

Stripe を設定する

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

React Native SDK はオープンソースであり、詳細なドキュメントが提供されています。内部では、ネイティブの iOS および Android の SDK を使用します。Stripe の React Native SDK をインストールするには、プロジェクトのディレクトリーで (使用するパッケージマネージャーによって異なる) 次のいずれかのコマンドを実行します。

Command Line
yarn add @stripe/stripe-react-native

次に、その他の必要な依存関係をインストールします。

  • iOS の場合は、ios ディレクトリに移動して pod install を実行し、必要なネイティブ依存関係もインストールします。
  • Android の場合は、依存関係をインストールする必要はありません。

注

公式の TypeScript ガイドに従って TypeScript のサポートを追加することをお勧めします。

Stripe の初期化

React Native アプリで Stripe を初期化するには、決済画面を StripeProvider コンポーネントでラップするか、initStripe 初期化メソッドを使用します。publishableKey の API 公開可能キーのみが必要です。次の例は、StripeProvider コンポーネントを使用して Stripe を初期化する方法を示しています。

import { useState, useEffect } from 'react'; import { StripeProvider } from '@stripe/stripe-react-native'; function App() { const [publishableKey, setPublishableKey] = useState(''); const fetchPublishableKey = async () => { const key = await fetchKey(); // fetch key from your server here setPublishableKey(key); }; useEffect(() => { fetchPublishableKey(); }, []); return ( <StripeProvider publishableKey={publishableKey} merchantIdentifier="merchant.identifier" // required for Apple Pay urlScheme="your-url-scheme" // required for 3D Secure and bank redirects > {/* Your app code here */} </StripeProvider> ); }

注

テストおよび開発時には API のテストキーを使用し、アプリの公開時には本番環境キーを使用します。

支払い方法を有効にする

支払い方法の設定を表示して、サポートする支払い方法を有効にします。SetupIntent を作成するには、少なくとも 1 つは支払い方法を有効にする必要があります。

多くの顧客から決済を受け付けられるよう、Stripe では、カードやその他一般的な決済手段がデフォルトで有効になっていますが、ビジネスや顧客に適した追加の決済手段を有効にすることをお勧めします。プロダクトと決済手段のサポートについては決済手段のサポートを、手数料については料金体系ページをご覧ください。

注

現時点では、CustomerSheet はカードとアメリカの銀行口座のみに対応しています。

Customer エンドポイントを追加する
サーバー側

サーバー側で、Customer の一時キーを取得するエンドポイントと、新しい決済手段を Customer に保存する SetupIntent を作成するエンドポイントの 2 つのエンドポイントを作成します。

  1. Customer ID と関連する一時キーを返すエンドポイントを作成します。SDK で使用される API バージョンは、こちらで確認できます。
Command Line
curl
Ruby
Python
PHP
Node.js
Java
No results
# Create a Customer (skip this and get the existing Customer ID if this is a returning customer) curl https://api.stripe.com/v1/customers \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -X "POST" curl https://api.stripe.com/v1/ephemeral_keys \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -X "POST" \ -d "customer"="{{CUSTOMER_ID}}" \
  1. Customer ID を指定して設定された SetupIntent を返すエンドポイントを作成します。
Command Line
curl
Ruby
Python
PHP
Node.js
Java
No results
# Create a Customer (skip this and get the existing Customer ID if this is a returning customer) curl https://api.stripe.com/v1/customers \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -X "POST" curl https://api.stripe.com/v1/setup_intents \ -u
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:
\ -d "customer"="{{CUSTOMER_ID}}" \

今後の支払いで、顧客が決済フローでオンセッション時にのみ決済手段を使用する場合、usage パラメーターを on_session に設定して、オーソリ率を改善します。

画面を初期化する

Next, configure the Payment Method Settings Sheet using the CustomerSheetBeta class by providing your desired settings to CustomerSheetBeta.initialize.

import {CustomerSheetBeta} from '@stripe/stripe-react-native'; const {error} = await CustomerSheetBeta.initialize({ setupIntentClientSecret: 'SETUP-INTENT', customerEphemeralKeySecret: 'EPHEMERAL-KEY', customerId: 'CUSTOMER-ID', headerTextForSelectionScreen: 'Manage your payment method', returnURL: 'my-return-url://', });

支払い画面を表示する

Present the Payment Method Settings Sheet using CustomerSheetBeta. When the customer dismisses the sheet, the promise resolves with a CustomerSheetResult.

import {CustomerSheetBeta} from '@stripe/stripe-react-native'; const {error, paymentOption, paymentMethod} = await CustomerSheetBeta.present(); if (error) { if (error.code === CustomerSheetError.Canceled) { // Customer dismissed the sheet without changing their payment option } else { // Show the error in your UI } } else { if (paymentOption) { // Configure your UI based on the payment option MyBackend.setDefaultPaymentMethod(paymentMethod.id); } if (paymentMethod) { console.log(JSON.stringify(paymentMethod, null, 2)); } }
  • 顧客が決済手段を選択する場合、その結果は paymentOption になります。関連付けられる値は、選択した PaymentOption になり、ユーザーが過去に選択した決済手段を削除した場合は nil になります。決済手段の詳細は、paymentMethod フィールドで確認できます。
  • ユーザーが画面をキャンセルした場合、その結果には error.code === CustomerSheetError.Canceled の error が含まれます。選択された支払い方法は変更されていません。
  • エラーが発生した場合、詳細は error に含まれます。

詳しくは、Apple Pay を有効にする方法をご確認ください。

オプションACH 決済を有効にする

ACH デビット支払いを有効にするには: ダッシュボードの設定セクションで、支払い方法としてアメリカの銀行口座を有効化します。

オプション選択した支払い方法を取得する

To fetch the default payment method without presenting the Payment Method Settings Sheet, call CustomerSheetBeta.retrievePaymentOptionSelection() after initializing the sheet.

// Call CustomerSheetBeta.initialize() ... const { error, paymentOption, paymentMethod, } = await CustomerSheetBeta.retrievePaymentOptionSelection();

オプション画面をカスタマイズする

デザイン

Appearance API を使用して、アプリのデザインに合わせて色、フォント、その他のデザインの属性をカスタマイズします。

動作

保存された支払い方法の関連付け、関連付け解除、一覧表示を行うためのカスタム動作を追加するには、CustomerAdapter を CustomerSheetBeta.initialize に、またはプロパティとして <CustomerSheetBeta.CustomerSheet /> に渡します。

const { error } = await CustomerSheetBeta.initialize({ ... customerAdapter: { fetchPaymentMethods: async () => { const paymentMethods = // Get your Stripe payment methods from the server const filteredPaymentMethods = // Perform custom filtering return filteredPaymentMethods; } }, });

注

fetchPaymentMethods は、保存された決済手段を除外して表示しないようにできますが、追加可能な決済手段のタイプには影響しません。

デフォルトの請求詳細

To set default values for billing details collected in the Payment Method Settings Sheet, configure the defaultBillingDetails property. The Payment Method Settings Sheet pre-populates its fields with the values that you provide.

await CustomerSheetBeta.initialize({ // ... defaultBillingDetails: { email: 'foo@bar.com', address: { country: 'US', }, }, });

請求詳細の収集

Use billingDetailsCollectionConfiguration to specify how you want to collect billing details in the Payment Method Settings Sheet.

顧客の名前、メールアドレス、電話番号、住所を収集できます。

支払い方法に必要な値を収集しない場合は、以下を実行する必要があります。

  1. Attach the values that aren’t collected by the Payment Method Settings Sheet to the defaultBillingDetails property.
  2. billingDetailsCollectionConfiguration.attachDefaultsToPaymentMethod を true に設定します。
await CustomerSheetBeta.initialize({ // ... defaultBillingDetails: { email: 'foo@bar.com', } billingDetailsCollectionConfiguration: { name: PaymentSheet.CollectionMode.ALWAYS, email: PaymentSheet.CollectionMode.NEVER, address: PaymentSheet.AddressCollectionMode.FULL, attachDefaultsToPaymentMethod: true }, });

注

情報の収集に適用される法律については、弁護士に相談してください。電話番号は、取引に必要な場合にのみ収集してください。

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