MobilePay での支払い
デンマークとフィンランドで一般的な支払い方法として使われている MobilePay を受け付ける方法をご紹介します。
MobilePay is a single-use card wallet payment method used in Denmark and Finland. It allows your customer to authenticate and approve payments using the MobilePay app.
When your customer pays with MobilePay, Stripe performs a card transaction using the card data we receive from MobilePay. The processing of the card transaction is invisible to your integration, and Stripe immediately notifies you whether the payment succeeded or failed.
Stripe recommends using the Mobile Payment Element, an embeddable payment form, to add MobilePay and other payment methods to your integration with the least amount of effort.
This guide covers how to accept MobilePay from your native mobile application using your own custom payment form. Your native mobile application redirects your customer to the MobilePay mobile application to complete the payment. Completing the purchase requires no additional action in the MobilePay mobile application.
Stripe を設定するサーバ側クライアント側
まず、Stripe アカウントが必要です。今すぐ登録してください。
サーバ側
この組み込みには、サーバ上に Stripe API と通信するエンドポイントが必要です。サーバから Stripe API にアクセスするには、Stripe の公式ライブラリを使用します。
クライアント側
Stripe iOS SDK はオープンソースです。詳細なドキュメントが提供されており、iOS 13 以降をサポートするアプリと互換性があります。
注
For details on the latest SDK release and past versions, see the Releases page on GitHub. To receive notifications when a new release is published, watch releases for the repository.
アプリの起動時に Stripe 公開可能キーを使用して SDK を設定します。これにより、アプリが Stripe API にリクエストを送信できるようになります。
PaymentIntent を作成するサーバー側クライアント側
サーバー側
A PaymentIntent is an object that represents your intent to collect payment from a customer and tracks the lifecycle of the payment process through each stage.
サーバーで PaymentIntent
を作成して確定するには、以下のようにします。
- Specify the amount to collect and a supported currency (
eur
,dkk
,sek
, ornok
). - Add
mobilepay
to the list of payment method types for yourPaymentIntent
. Make sure that you enable MobilePay in the Dashboard. payment_
をmethod_ data[type] mobilepay
に設定すると、PaymentMethod を作成して、PaymentIntent ですぐに使用できます。
The PaymentIntent includes a client secret. Send the client secret to the client to confirm the PaymentIntent in the next step.
クライアント側
On the client, request a PaymentIntent from your server and store its client secret.
Stripe に支払いを送信するクライアント側
When a customer taps to pay with MobilePay, confirm the PaymentIntent
to complete the payment. Configure an STPPaymentIntentParams
object with the PaymentIntent
client secret.
client secret は、 Stripe API リクエストを認証する API キーとは異なります。このデバイスは支払いを完了できるため、慎重に扱う必要があります。記録したり、URL に埋め込んだり、当該の顧客以外に漏洩することがないようにしてください。
戻り先 URL を設定する
The customer might navigate away from your app to authenticate (for example, in Safari or their banking app). To allow them to automatically return to your app after authenticating, configure a custom URL scheme and set up your app delegate to forward the URL to the SDK. Stripe doesn’t support universal links.
支払いを確定する
Use the PaymentIntent client secret from step 2 to confirm the PaymentIntent using STPPaymentHandler.shared.confirmPayment(). This opens the MobilePay application directly (if present) or a webview showing the MobilePay landing page. After the customer authorizes the payment, the completion block contains the status of the payment.
Your customer has 5 minutes to authorize the payment in the MobilePay app. If the underlying card charge fails, your customer can choose a different card and retry in the MobilePay app.
Handle post-payment events
支払いが完了すると、Stripe は payment_intent.succeeded イベントを送信します。ダッシュボード、カスタム Webhook、またはパートナーソリューションを使用してこれらのイベントを受信し、また、顧客への注文確認メールの送信、データベースでの売上の記録、配送ワークフローの開始などのアクションを実行します。
クライアントからのコールバックを待つのではなく、これらのイベントをリッスンします。クライアント側では、コールバックが実行される前に顧客がブラウザーのウィンドウを閉じたり、アプリを終了したりする可能性があります。また、悪意を持つクライアントがレスポンスを不正操作する恐れもあります。非同期型のイベントをリッスンするよう構築済みのシステムを設定することで、これ以降はより多くの決済手段を簡単に受け付けられるようになります。サポートされているすべての決済手段の違いをご確認ください。
手動
Stripe ダッシュボードは、すべての Stripe 支払いの確認、メールでの領収書の送信、入金処理、または失敗した支払いの再試行に使用できます。
カスタムコード
Webhook ハンドラを作成してイベントをリッスンし、カスタムの非同期決済フローを作成します。Stripe CLI を使用し、ローカルで Webhook 組み込みのテストとデバッグを行います。
事前構築のアプリ
オートメーションやマーケティングとセールスなどの一般的なビジネスイベントを、パートナーアプリケーションとの連携によって処理します。
Test the integration
Use your test API keys to create a PaymentIntent. After confirming the PaymentIntent, follow the next_
redirect URL to a test page with options to authorize or fail the payment.
- Click Authorize test payment to test the case when the payment is successful. The PaymentIntent’s status transitions from
requires_
toaction succeeded
. - Click Fail test payment to test the case when the customer fails to authenticate. The PaymentIntent’s status transitions from
requires_
toaction requires_
.payment_ method
失敗した支払い
MobilePay transactions can fail if the underlying card transaction is declined. Learn more about card declines. In this case, the PaymentMethod is detached and the PaymentIntent’s status automatically transitions to requires_
.
When the PaymentIntent’s status is requires_
, your customer must authenticate the payment within 5 minutes. If no action is taken after 5 minutes, the PaymentMethod detaches and the PaymentIntent’s status automatically transitions to requires_
.
返金と不審請求の申請
Stripe performs a card transaction using standard card rails as part of a MobilePay transaction. Refunds and disputes are subject to the Visa and Mastercard network rules.