将来の Amazon Pay による支払いを設定する
Amazon Pay の詳細を保存し、後で顧客に請求する方法をご紹介します。
This guide describes how to save Amazon Pay payment details using Checkout, our fully hosted checkout page.
Learn how to set up a subscription with Amazon Pay to create recurring payments after saving a payment method in Checkout.
支払い方法を保存する許可を得るサーバー側
将来の使用に備えて顧客の支払い方法を保存する場合は、顧客の許可を得る必要があります。あらかじめ契約 (同意書とも呼ばれます) を作成しておくことで、顧客の支払い情報を保存し、顧客がウェブサイトやアプリを能動的に使用していないときでも請求できるようになります。
顧客の支払い方法の保存をどのように計画しているかを示す規約をウェブサイトやアプリに追加し、顧客が許可できるようにします。顧客がオフラインのときに請求する予定である場合は、規約に以下の内容も含める必要があります。
- 指定された取引で顧客の代理として単独の支払いまたは一連の支払いを開始するための顧客の許可
- 予測される支払い頻度 (1 回限り、継続支払い) とタイミング
- 支払い金額の決定方法
- サブスクリプションサービスに使用される支払い方法を設定する場合は、キャンセルに関するポリシー。
これらの規約に関する顧客の書面による同意の記録を必ず保管してください。
Customer の作成または取得サーバー側
今後の支払いで Amazon Pay 支払い方法を再利用できるようにするには、これを Customer に関連付けます。
Create a Customer object when your customer creates an account with your business, and associate the ID of the Customer object with your own internal representation of that customer. Alternatively, you can create a new Customer before saving a payment method for future payments.
新しい Customer を作成するか、または既存の Customer を取得して、この決済に関連付けます。サーバーに以下のコードを含め、新しい Customer を作成します。
Checkout セッションを作成するサーバー側
Your customer must authorize you to use their Amazon account for future payments through Stripe Checkout. This allows you to accept Amazon payments. Add a checkout button to your website that calls a server-side endpoint to create a Checkout Session.
<html> <head> <title>Checkout</title> </head> <body> <form action="/create-checkout-session" method="POST"> <button type="submit">Checkout</button> </form> </body> </html>
Create a Checkout Session in setup
mode to collect the required information. After creating the Checkout Session, redirect your customer to the URL that the response returns.
実装内容をテストする
支払い方法として Amazon Pay を選択してから、Continue to Amazon Pay (Amazon Pay に進む) をクリックします。リダイレクトページで SetupIntent を認証することで、設定の成功ケースをテストできます。SetupIntent のステータスが requires_action から succeeded に移行します。