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

注

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

Swish 決済招待のみ

スウェーデンで広く普及している支払い方法である Swish を受け付ける方法をご紹介します。

ページをコピー

Swish は、スウェーデンで使用されている 1 回限りの使用の支払い方法です。顧客は Swish モバイルアプリとスウェーデンの BankID モバイルアプリを使用して、支払いの認証と承認を行うことができます。

支払いが成功したか失敗したかに関する即時通知を受け取ります。

必要な通知

Swish の規則に準拠するには、顧客が Swish 支払いを承認する前に、決済フローの画面に以下のテキストを表示する必要があります。

  • 英語の場合: “Stripe Technology Europe Limited (“Stripe”) has acquired the claim for payment. Therefore your payment will be made to Stripe.”
  • スウェーデン語の場合: “Stripe Technology Europe Limited (“Stripe”) har övertagit fordran på betalning. Din betalning görs därför till Stripe.”
  • 他の言語の場合、上記の翻訳文。

Checkout や Payment Element、Stripe がホストする決済フォームや UI コンポーネントから Swish を導入する場合、Stripe はこの通知を表示します。

Stripe を設定する
サーバー側
クライアント側

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

サーバー側

この接続方法では、Stripe API と通信するエンドポイントがサーバー上に必要です。サーバーから 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'

クライアント側

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

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

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

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

注

We recommend following the official TypeScript guide to add TypeScript support.

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> ); }

注

Use your API test keys while you test and develop, and your live mode keys when you publish your app.

PaymentIntent を作成する
サーバー側
クライアント側

サーバー側

PaymentIntent は、顧客から支払いを回収する意図を表すオブジェクトで、決済プロセスのライフサイクルの各段階を追跡します。

サーバーで PaymentIntent を作成して確定するには、以下の手順に従います。

  • 回収する金額と通貨を指定します。
  • PaymentIntent の支払い方法タイプのリストに swish を追加します。ダッシュボードで Swish が有効になっていることを確認してください。
Command Line
cURL
curl https://api.stripe.com/v1/payment_intents \ -u "
sk_test_BQokikJOvBiI2HlWgH4olfQ2
:"
\ -d amount=6000 \ -d currency=sek \ -d "payment_method_types[]"=swish \ --data-urlencode return_url="payments-example://stripe-redirect"

返される PaymentIntent には client secret が含まれ、これは PaymentIntent の確定に使用されます。次のステップで使用できるように、クライアントに client secret を送り返します。

クライアント側

クライアント側で、サーバーの PaymentIntent をリクエストし、その client secret を保存します。

function PaymentScreen() { const fetchPaymentIntentClientSecret = async () => { const response = await fetch(`${API_URL}/create-payment-intent`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ currency: 'sek', }), }); const {clientSecret} = await response.json(); return clientSecret; }; const handlePayPress = async () => { // See below }; return ( <View> <Button onPress={handlePayPress} title="Pay" /> </View> ); }

client secret は、Stripe API リクエストを認証する API キーとは異なります。これは支払いを完了できるため、慎重に扱う必要があります。記録したり、URL に埋め込んだり、当該の顧客以外に漏洩することがないようにしてください。

戻り先 URL を設定する (iOS のみ)
クライアント側

When a customer exits your app (for example to authenticate in Safari or their banking app), provide a way for them to automatically return to your app. Many payment method types require a return URL. If you don’t provide one, we can’t present payment methods that require a return URL to your users, even if you’ve enabled them.

To provide a return URL:

  1. Register a custom URL. Universal links aren’t supported.
  2. Configure your custom URL.
  3. Set up your root component to forward the URL to the Stripe SDK as shown below.

注

Expo を使用している場合は、app.json ファイルでスキームを設定します。

App.tsx
import { useEffect, useCallback } from 'react'; import { Linking } from 'react-native'; import { useStripe } from '@stripe/stripe-react-native'; export default function MyApp() { const { handleURLCallback } = useStripe(); const handleDeepLink = useCallback( async (url: string | null) => { if (url) { const stripeHandled = await handleURLCallback(url); if (stripeHandled) { // This was a Stripe URL - you can return or add extra handling here as you see fit } else { // This was NOT a Stripe URL – handle as you normally would } } }, [handleURLCallback] ); useEffect(() => { const getUrlAsync = async () => { const initialUrl = await Linking.getInitialURL(); handleDeepLink(initialUrl); }; getUrlAsync(); const deepLinkListener = Linking.addEventListener( 'url', (event: { url: string }) => { handleDeepLink(event.url); } ); return () => deepLinkListener.remove(); }, [handleDeepLink]); return ( <View> <AwesomeAppComponent /> </View> ); }

ネイティブ URL スキームの詳細については、Android および iOS のドキュメントをご覧ください。

Swish 決済を確定する
クライアント側

顧客が Swish での支払いを試みてタップすると、confirmPayment を呼び出して支払いを完了します。これにより WebView が表示され、顧客はそこから Swish で支払いを完了できます。完了後、プロミスは、paymentIntent フィールド、または支払いでエラーが発生した場合には error フィールドのどちらかを格納したオブジェクトで解決されます。

import {useConfirmPayment} from '@stripe/stripe-react-native'; function PaymentScreen() { const {confirmPayment, loading} = useConfirmPayment(); const fetchPaymentIntentClientSecret = async () => { // See above }; const handlePayPress = async () => { // Fetch the client secret from the backend. const clientSecret = await fetchPaymentIntentClientSecret(); const {error, paymentIntent} = await confirmPayment(clientSecret, { paymentMethodType: 'Swish', }); if (error) { console.log('Payment confirmation error: ', error); } else if (paymentIntent) { console.log('Successfully confirmed payment: ', paymentIntent); } }; return ( <View> <Button onPress={handlePayPress} title="Pay" disabled={loading} /> </View> ); }

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

オプション実装内容をテストする

オプションキャンセル

失敗した支払い

Swish は複数のデータポイントを使用して、取引を拒否する状況を判断します (たとえば、顧客の銀行口座に十分な残高がない場合や、顧客がアプリでキャンセルをクリックした場合など)。

このケースでは、PaymentMethod は切り離され、PaymentIntent オブジェクトのステータスは自動的に requires_payment_method に移行します。

支払いが拒否された場合を除き、Swish の PaymentIntent (支払いインテント) が requires_action ステータスである場合、顧客は 3 分以内に支払いを完了する必要があります。3 分経過してもアクションが行われない場合、PaymentMethod (支払い方法) の関連付けが解除され、PaymentIntent オブジェクトのステータスは自動的に requires_payment_method に移行します。

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