2016-11-21 6 views
0

私はRailsプロジェクトでStripe APIを統合しようとしています。しかし、インターネット接続が正常であることを確認したときに、なぜAPIConnectionErrorが失敗したのか不思議です。APIConnectionError with Stripe API

users_controller.rb

/views/users/_form.html.erb

def charge 
    token = params["stripeToken"] 
    customer = Stripe::Customer.create(
    source: token, 
    plan: 'mysubscriptionlevel1', 
    email: current_user.email 
) 

    current_user.subscription.stripe_user_id = customer.id 
    current_user.subscription.active = true 
    current_user.subscription.save 

    redirect_to users_info_path 
end 

、私は、フォームのPOST-INGの/users/charge URLパスにしています。

<h4>Begin your £9.99 a month subscription</h4> 
    <form action="https://stackoverflow.com/users/charge" method="POST" id="payment-form"> 
    <span class="payment-errors"></span> 

そして、私のroutes.rbファイルで、私が持っている:config/initializer/stripe.rb

post '/users/charge', to: 'users#charge' 

を、私はストライプを必要と.envファイルの私のAPIキーを入れています。私は、私が行方不明ですかわからないですし、これは私がusers_controller.rbchargeアクションを呼び出すとき、私は取得エラーです

gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby' 
gem 'dotenv-rails', :groups => [:development, :test] 

require "stripe" 
Stripe.api_key = ENV["STRIPE_API_KEY"] 

は、私は私のGemfileでstripe宝石をも含まれています:

Stripe::APIConnectionError (Unexpected error communicating when trying to connect to Stripe. You may be seeing this message because your DNS is not working. To check, try running 'host stripe.com' from the command line. 

(Network error: Failed to open TCP connection to : (getaddrinfo: nodename nor servname provided, or not known))): 

それが機能していないDNSによって何を意味し、私はちょうど「ホストstripe.com」

を実行して、どのようにデバッグすることができます
+0

あなたはファイアウォールの背後にいますか? – shivam

+0

ありがとう、それは問題でした。私はプロキシを切り替え、今すぐ動作します。 –

答えて

0

プロキシを切り替えて、今すぐ動作します。