24.2. 将 Stripe 配置为信用卡网关

作为 3scale API 提供程序,配置管理门户和开发人员门户,将忽略作为付款网关,以通过使用条带作为信用卡网关从订阅中接收 API 付款。

先决条件

  • 您必须有一个 Stripe 帐户。

    • Stripe 建议您为每个业务或项目使用单独的 Stripe 子帐户。
    • 有关多帐户的信息,请参阅 Stripe 文档。
  • 您必须具有 Stripe 管理员权限。

流程

要将 3scale 配置为使用 Stripe 作为支付网关,请按照以下步骤执行:

24.2.1. 使用 3scale 管理门户中的 Billing API 范围生成访问令牌

  1. 在 3scale 管理门户中,前往 Account Settings > Personal > Tokens
  2. 使用 Billing API 范围创建一个 Read and Write 令牌:

    1. 单击 Add Access Token
    2. 为令牌指定一个名称。
    3. 选择范围:Billing API
    4. 选择权限级别:Read & Write
    5. 单击 Create Access token
    6. 复制访问令牌。

      • 确保您将访问令牌复制到文件文本。访问令牌之后不会显示。
    7. 要完成令牌生成,请单击 I have copied the token

返回至流程.

24.2.2. 从 stripe 获取密钥和 webhook secret

注意
  • 需要在 Stripe 中配置 webhook。
  • 使用 Webhook 通知 3scale 付款已成功。
  • 然后 3scale 更新发票的状态,并防止进一步尝试收费。

在您自己的帐户中,获取 Secret 密钥发布密钥

  1. 打开资源面板。
  2. 按照 stripe 文档中的说明查找您的 API 密钥
  3. 复制 Secret 密钥发布密钥

仍在您的 stripe 帐户中,创建一个 Webhook Signing Secret:

  1. 前往 Developers > Webhooks
  2. Add endpoint
  3. 使用以下端点 URL 填写:

    https://<Your-provider-admin-domain>/api/payment_callbacks/stripe_callbacks?access_token=<value-of-access-token>
  4. Events to send 中,添加 payment_intent.succeeded
  5. 单击 Add endpoint
  6. 单击以显示您刚才创建的 webhook 的签名机密并记下此机密。这是 Webhook 签名 Secret

返回至流程.

24.2.3. 在 3scale 管理门户中配置计费

在 3scale 管理门户中:

  1. 前往 Audience > Billing > Charging & Gateway
  2. 选择 Charging enabled,点 Save
  3. Credit Car gateway > Gateway 中,选择 Stripe 作为网关。
  4. 添加 Secret KeyPublishable KeyWebhook Signing Secret,您从 第 24.2.2 节 “从 stripe 获取密钥和 webhook secret” 中的 stripe 帐户获取。
  5. 点击 Save

返回至流程

24.2.4. 在 3scale 开发人员门户中编辑信用卡详情

  1. 使用开发人员帐户登录 3scale 开发人员门户。
  2. 进入 Settings > Credit Card Details
  3. 添加以下信用卡详细信息:信用卡号码、到期日期和 CVC。
  4. Save details

返回至流程

24.2.5. 更新收费失败的电子邮件回复的文本

对于 SCA 付款的修复,3scale 2.10 中需要手动更新 invoice_messenger_unsuccessfully_charged_for_buyer.text.liquid 电子邮件的文本。

  1. 在 3scale 管理门户中,转至 Audience > Messages > Email Templates
  2. 选择 Invoice charge failure for buyer with retry
  3. Override
  4. 更新模板消息:这是在不成功收费的电子邮件响应中使用的完整文本:

    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
  5. 单击 Create Email Template

通过这些步骤,您已更新了电子邮件模板,以便收费失败的电子邮件回复。

返回至流程

其他资源