ActiveMerchant 获取 Braintree ClientToken

ActiveMerchant Get Braintree ClientToken

我正在尝试将 ActiveMerchant 与 Braintree Dropin UI 一起使用,但我无法找到创建客户端令牌以传递给 JavaScript SDK 的正确方法。我当前的设置是:

# config/environments/development.rb
# ActiveMerchant configuration.
ActiveMerchant::Billing::Base.mode = :test
config.gateway = ActiveMerchant::Billing::BraintreeGateway.new(
  merchant_id: '',
  public_key: '',
  private_key: ''
)

我有一个控制器需要发回客户端令牌作为 API 请求的一部分:

# app/controllers/v1/orders_controller.rb
def token
  @client_token = ...GENERATE CLIENT TOKEN...
  respond_with @client_token
end

我只是不知道如何通过 ActiveMerchant 生成此令牌 API。

我在布伦特里工作。如果你有更多的问题,我建议你email our support team.

ActiveMerchant 目前与 v.zero 不兼容。要使用 Drop-In UI 或任何其他 v.zero 功能,您需要直接使用 Braintree ruby 客户端库。有关说明,请参阅 Braintree "Getting Started" Guide