Ruby on Rails:Braintree :: AuthenticationError

时间:2016-06-28 10:13:36

标签: ruby-on-rails ruby braintree

你好,我的Braintree实现有问题!我在braintree网站上创建了一个Sandbox帐户,然后将gem添加到我的Gemfile中:

gem 'braintree', "~> 2.62.0"

创建文件/initializers/braintree.rb:

  Braintree::Configuration.environment = :sandbox
  Braintree::Configuration.merchant_id = ENV['MERCHANT_ID']
  Braintree::Configuration.public_key = ENV['PUBLIC_KEY_B']
  Braintree::Configuration.private_key = ENV['PRIVATE_KEY_B']

(我使用Figaro Gem来处理常量:application.yml

MERCHANT_ID             : "xxxxxxxxxxxxxxxx"
PUBLIC_KEY_B            : "xxxxxxxxxxxxxxxxx"
PRIVATE_KEY_B           : "xxxxxxxxxxxxxxxxxxxxxxxxxx"

按照路线文件中的文档添加此路线:

  scope '/api' do
    scope  '/v1' do
      scope '/client_token' do
        get '/' => Braintree::ClientToken.generate
      end
      ...
    end
  end

现在,如果我通过命令rails s启动服务器,则会出现以下错误:

=> Booting Puma
=> Rails 4.2.5.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
I, [2016-06-28T11:59:59.271177 #16383]  INFO -- : [Braintree] [28/Jun/2016 09:59:59 UTC] POST /merchants/xxxxxxxxxxx/client_token 401
Exiting
/Users/xxxxxxx/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/braintree-2.62.0/lib/braintree/util.rb:51:in `raise_exception_for_status_code': Braintree::AuthenticationError (Braintree::AuthenticationError)

我该怎么办?

0 个答案:

没有答案