24.2. 将 Stripe 配置为信用卡网关
作为 3scale API 提供程序,配置管理门户和开发人员门户,将忽略作为付款网关,以通过使用条带作为信用卡网关从订阅中接收 API 付款。
先决条件
- 您必须有一个 Stripe 帐户。
- 您必须具有 Stripe 管理员权限。
流程
要将 3scale 配置为使用 Stripe 作为支付网关,请按照以下步骤执行:
使用 3scale 管理门户中的 Billing API 范围生成访问令牌
- 在 3scale 管理门户中,前往 Account Settings > Personal > Tokens。
使用 Billing API 范围创建一个 Read and Write 令牌:
- 单击 Add Access Token。
- 为令牌指定一个名称。
- 选择 scope: Billing API。
- 选择权限级别: Read & Write。
- 单击 Create Access token。
复制访问令牌。
- 确保您将访问令牌复制到文件文本。访问令牌之后不会显示。
- 要完成令牌生成,请单击 I have copied the token。
从 stripe 获取密钥和 webhook secret
在您自己的帐户中,获取 Secret 密钥和发布密钥 :
- 打开资源面板。
- 按照 stripe 文档中的说明查找您的 API 密钥。
- 复制 Secret 密钥和发布密钥
仍在您的 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 签名 Secret。
在 3scale 管理门户中配置计费
在 3scale 管理门户中:
- 前往 Audience > Billing > Charging & Gateway。
- 选择 Charging enabled,点 Save。
- 在 Credit Car gateway > Gateway 中,选择 Stripe 作为网关。
- 添加 Secret Key、Publishable Key 和 Webhook Signing Secret,您从 从 stripe 获取密钥和 webhook secret 中的 stripe 帐户获取。
- 点 Save。
在 3scale 开发人员门户中编辑信用卡详情
- 使用开发人员帐户登录 3scale 开发人员门户。
- 进入 Settings > Credit Card Details。
- 添加以下信用卡详细信息:信用卡号码、到期日期和 CVC。
- 点 Save details。
更新收费失败的电子邮件回复的文本
对于 SCA 付款的修复,3scale 2.10 中需要手动更新 invoice_messenger_unsuccessfully_charged_for_buyer.text.liquid 电子邮件的文本。
- 在 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。
通过这些步骤,您已更新了电子邮件模板,以便收费失败的电子邮件回复。
可选:通过开发人员门户支付被拒绝的发票
如果要允许通过 Developer Portal 支付被拒绝的发票,您可以在管理门户中更新发票模板。请注意,这个步骤适用于 Developer Portal 的现有实例:
- 在 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>
其他资源