14.9. 信用卡网关

3scale 与信用卡交易的以下支付网关集成:

  • Braintree
  • Stripe

14.9.1. 条带集成(推荐)

完成这些步骤后,您要将 Stripe 配置为您帐户的支付网关。这将使开发人员输入他们的信用卡详细信息,并根据计算的发票,自动通过 Stripe 访问您的 API。

如果您为付费 API 启用信用卡付款,则一个关键步骤是设置您的 支付网关。您可以将多个替代支付网关用于 3scale 帐户。在这里,我们将介绍 Stripe 的步骤。

14.9.1.1. 先决条件

在开始这些步骤前,您将需要打开一个 Stripe 的帐户。

14.9.1.2. 从 Stripe 获取您的 API 密钥

登录到您的 Stripe 帐户,并在 https://dashboard.stripe.com/account/apikeys 获取您的 API 密钥。您需要两个键:一个"secret",以及一个"可发布"一个。当您准备好启动慈善时,请使用"test"设置。

条带集成

14.9.1.3. 在 3scale 中配置设置

您需要告诉 3scale 使用这些 API 密钥。要做到这一点,登录到 3scale 管理门户,然后进入 Audience > Billing > Charging & Gateway

账单页

如果 Charging Enabled 标志未激活,请启用它并单击 Save。

启用收费

您应该会在页面底部附近看到一个名为 Gateway 的下拉列表。将其更改为条带.

账单网关

下拉菜单下的表单应更改为显示两个字段。插入您的 Stripe API 密钥并点 Save。

条状账单网关

更改支付网关时,您可能会看到一些警告。这是预期的。读它们并接受它们(如果出现)。

支付网关现已设置,但您的用户可能还没有使用它,因为它没有配置 CMS。前往开发者门户,然后单击名为 pay Gateway / Show on the left navigation 窗格的模板。

开发人员门户 - Billing

如果还没有存在,在 {% "braintree_blue" %} 前添加以下代码:

{% when "stripe" %}
 <p><a href="{{ current_account.edit_stripe_billing_address_url }}">Edit billing address</a></p>

 {% if current_account.has_billing_address? %}
   {% stripe_form "Edit Credit Card Details" %}
 {% else %}
   <p>After entering billing address, the option to enter credit card will be enabled.</p>
 {% endif %}

最后,单击 Save and Publish。您的用户现在应该可以使用 Stripe 网关来支付。

注意

要将 Stripe 数据与 3scale 上的数据映射,您可以使用名为 metadata.3scale_account_reference 的 Stripe 字段,该引用由 3scale-[ural_ID]-[DEVELOPER_ACCOUNT_ID]组成