0

私は、Rails 4アプリケーションでアクティブマーチャントの宝石を使ってストライプゲートウェイ経由で支払いを行うようになっていました。アクティブマーチャント上のストライプゲートウェイが機能しない

私はこのscriptに沿って来て、次のようにもいくつかの他のリソースを見て、同様のスクリプトを作った:

require 'active_merchant' 

# Use the TrustCommerce test servers 
ActiveMerchant::Billing::Base.mode = :test 

gateway = ActiveMerchant::Billing::StripeGateway.new(:login => Rails.application.secrets.stripe_secret_key) 

# ActiveMerchant accepts all amounts as Integer values in cents 
amount = 1000 # $10.00 

# The card verification value is also known as CVV2, CVC2, or CID 
credit_card = ActiveMerchant::Billing::CreditCard.new(
       :first_name   => 'Bob', 
       :last_name   => 'Bobsen', 
       :number    => '4242424242424242', 
       :month    => '8', 
       :year    => Time.now.year+1, 
       :verification_value => '000') 

purchase_options = { 
     :ip => "127.0.0.1", 
     :billing_address => { 
     :name  => "Ryan Bates", 
     :address1 => "123 Main St.", 
     :city  => "New York", 
     :state => "NY", 
     :country => "US", 
     :zip  => "10001" 
     } 
    } 

# Validating the card automatically detects the card type 
if credit_card.validate.empty? 
    # Capture $10 from the credit card 
    response = gateway.purchase(amount, credit_card, purchase_options) 

    if response.success? 
    puts "Successfully charged $#{sprintf("%.2f", amount/100)} to the credit card #{credit_card.display_number}" 
    else 
    raise StandardError, response.message 
    end 
end 

が、このスクリプトは次のエラー・ログでエラーが発生します。

/Library/Ruby/Gems/2.0.0/gems/activemerchant-1.58.0/lib/active_merchant/billing/gateways/stripe.rb:469:in `rescue in api_request': uninitialized constant ActiveMerchant::Billing::StripeGateway::JSON (NameError) 
     from /Library/Ruby/Gems/2.0.0/gems/activemerchant-1.58.0/lib/active_merchant/billing/gateways/stripe.rb:463:in `api_request' 
     from /Library/Ruby/Gems/2.0.0/gems/activemerchant-1.58.0/lib/active_merchant/billing/gateways/stripe.rb:477:in `commit' 
     from /Library/Ruby/Gems/2.0.0/gems/activemerchant-1.58.0/lib/active_merchant/billing/gateways/stripe.rb:100:in `block (2 levels) in purchase' 
     from /Library/Ruby/Gems/2.0.0/gems/activemerchant-1.58.0/lib/active_merchant/billing/response.rb:59:in `process' 
     from /Library/Ruby/Gems/2.0.0/gems/activemerchant-1.58.0/lib/active_merchant/billing/gateways/stripe.rb:98:in `block in purchase' 
     from /Library/Ruby/Gems/2.0.0/gems/activemerchant-1.58.0/lib/active_merchant/billing/response.rb:45:in `tap' 
     from /Library/Ruby/Gems/2.0.0/gems/activemerchant-1.58.0/lib/active_merchant/billing/response.rb:45:in `run' 
     from /Library/Ruby/Gems/2.0.0/gems/activemerchant-1.58.0/lib/active_merchant/billing/gateways/stripe.rb:93:in `purchase' 
     from stripe.rb:35:in `<main>' 

缶このエラーの回避策を提案しますか?

+1

ストライプの宝石がインストールされていますか?チャンスが得られたら、あなたのgemファイルを投稿してください。 – bkunzi01

+0

ねえ、ありがとう...私は宝石を持っていたが、それを必要としなかった。助けてくれてありがとう:) – srishabh

+0

アップしてくれてありがとう!笑いつでも;) – bkunzi01

答えて

0

bkunzi01 @によって提案されたように、それは私がアクティブな商人がすでにそのActiveMerchant::Billing::StripeGatewayファイルにストライプを使用することを考えたが、それはない簡単な回避策のように見えます。

はちょうどスクリプトと取引の上部にrequire 'stripe'が成功した含ま:)

0

私はあなただけの「JSON」を必要と追加する必要があると思います。あなたのgemfileにストリップを追加する必要はありません。

関連する問題