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.rb
でcharge
アクションを呼び出すとき、私は取得エラーです
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」
を実行して、どのようにデバッグすることができます
あなたはファイアウォールの背後にいますか? – shivam
ありがとう、それは問題でした。私はプロキシを切り替え、今すぐ動作します。 –