24.2. クレジットカードゲートウェイとしての Stripe の設定
3scale API プロバイダーとして、Stripe を支払いゲートウェイとして管理ポータルおよびデベロッパーポータルを設定し、クレジットカードゲートウェイとして Stripe を使用して API に対するサブスクリプションからの支払いを受け取ります。
前提条件
- Stripe のアカウントが必要です。
- Stripe 管理者パーミッションが必要です。
手順
Stripe を支払いゲートウェイとして 3scale を設定するには、以下の手順に従います。
3scale 管理ポータルでの Billing API スコープを設定したアクセストークンの生成
- 3scale 管理ポータルで、Account Settings > Personal > Tokens の順に移動します。
Billing API スコープを設定して 読み取り/書き込み のトークンを作成します。
- Add Access Token をクリックします。
- トークンの名前を指定します。
- スコープに Billing API を選択します。
- パーミッションレベルに 読み取り/書き込み を選択します。
- Create Access token をクリックします。
アクセストークンをコピーします。
- アクセストークンをファイルテキストにコピーしてください。これ以降アクセストークンは表示されません。
- トークンの生成を完了するには、I have copied the token をクリックします。
Stripe からのキーおよび Webhook シークレットの取得
Stripe アカウントで、Secret Key および Publishable Key を取得します。
- Stripe ダッシュボードを開きます。
- Stripe ドキュメントの手順に従って、API キーを確認してください。
- Secret Key および Publishable Key をコピーします。
引き続き、Stripe アカウントで Webhook Signing Secret を作成します。
- Developers > Webhooks の順に移動します。
- Add endpoint をクリックします。
以下のエンドポイント URL を入力します。
https://<Your-provider-admin-domain>/api/payment_callbacks/stripe_callbacks?access_token=<value-of-access-token>
-
Events to send に
payment_intent.succeeded
を追加します。 - Add endpoint をクリックします。
- クリックして作成した Webhook の署名シークレットを表示し、このシークレットを書き留めます。これは Webhook Signing Secret です。
3scale 管理ポータルでの課金の設定
3scale 管理ポータルで以下を行います。
- Audience > Billing > Charging & Gateway の順に移動します。
- Charging enabled を選択し、Save をクリックします。
- Credit card gateway > Gateway で、Stripe をゲートウェイとして選択します。
- Stripe からのキーおよび Webhook シークレットの取得で Stripe アカウントから取得した Secret Key、Publishable Key、および Webhook Signing Secret を追加します。
- Save をクリックします。
3scale デベロッパーポータルでのクレジットカード情報の編集
- 開発者アカウントを使用して 3scale デベロッパーポータルにログインします。
- Settings > Credit Card Details の順に移動します。
- クレジットカード情報 (クレジットカード番号、有効期限、および CVC) を追加します。
- Save details をクリックします。
unsuccessfully charged
電子メール応答のテキストを更新する
SCA 支払いの修正に関連して、invoice_messenger_unsuccessfully_charged_for_buyer.text.liquid
メールのテキストには、3scale 2.10 での手動更新が必要です。
- 3scale 管理ポータルで Audience > Messages > Email Templates の順に移動します。
- Invoice charge failure for buyer with retry を選択します。
- Override をクリックします。
テンプレートのメッセージを更新します。以下は、課金に失敗した場合のメールレスポンスで使用される完全なテキストです。
Dear {{ account.name }}, Thank you for using our service. We're sorry to inform you that your last payment was declined. This may have been caused by a few common reasons: - A new authentication policy enforced by your bank - An expired credit card - Insufficient funds on the account To continue using your service, verify the status of your credit card and update or re-enter the credit card details at {{payment_url}}. If you need help, don't hesitate to contact us at {{ provider.finance_support_email }}. Best regards, The {{ provider.name }} API Team
- Create Email Template をクリックします。
以下の手順により、unsuccessfully charged
メールのレスポンスのメールテンプレートを更新しました。
(オプション) デベロッパーポータルで拒否された請求書の支払いの許可
デベロッパーポータルで拒否された請求書の支払いを許可する必要がある場合には、管理ポータルで請求書テンプレートを更新することができます。以下の手順は、デベロッパーポータルの既存のインスタンス用であることに留意してください。
- 3scale 管理ポータルで Audience > Developer Portal > Content の順に移動します。
- Root > Invoices > Show template の順に移動して編集を行います。
コードの以下の行を編集します。
<a href="{{ urls.invoices }}"> <i class="fa fa-chevron-left"></i> Cancel </a> {{ invoice.period_begin | date: '%B, %Y' }} Invoice
置き換えるスニペットを以下に示します。
<div class="clearfix"> <a href="{{ urls.invoices }}"> <i class="fa fa-chevron-left"></i> Cancel </a> {{ invoice.period_begin | date: '%B, %Y' }} Invoice {% if invoice.pay_now? %} <a href="{{invoice.url}}/payment" class="pull-right btn btn-success pay-invoice-btn">Pay invoice</a> {% endif %} </div>
関連情報