Rails stripe_event gem issue: uninitialized constant Stripe::SignatureVerificationError - ruby-on-rails

I am using the stripe gem and stripe_event gem in a Rails 4.0.6 application using Ruby 2.1.5. It has been working well until I tried either the 'Securing your webhook endpoint' or 'Authenticating webhooks' section of the stripe_event gem readme (https://github.com/integrallis/stripe_event#authenticating-webhooks). It seems both issues have similar behavior so I will just describe the second one here.
When I try to authenticate my webhook (which worked fine before trying this) with the following code, I get an uninitialized constant error.
#config/initializers/stripe.rb
Rails.configuration.stripe = {
:publishable_key => ENV['STRIPE_PUBLISHABLE_KEY'],
:secret_key => ENV['STRIPE_SECRET_KEY']
}
Stripe.api_key = Rails.configuration.stripe[:secret_key]
#this is the line that supposedly tells stripe_event to verify the stripe signature
StripeEvent.signing_secret = ENV['STRIPE_SIGNING_SECRET']
StripeEvent.configure do |events|
events.all do |event|
if event.type == 'invoice.payment_failed'
#handled this event...removed code for clarity since works fine
end
end
end
This is the error:
NameError stripe_event/webhook#event
uninitialized constant Stripe::SignatureVerificationError
I got the stripe signing secret from my stripe dashboard as described in the stripe docs: https://stripe.com/docs/webhooks#signatures
I have been testing triggering the event as described in the stripe docs: https://stripe.com/docs/recipes/sending-emails-for-failed-payments#testing
Any help on this will be much appreciated.

Try to update your stripe gem. It will start working.

Related

Error when trying to use ruby gem- NameError (uninitialized constant RightScraper::Scraper)

I am trying to use a ruby gem called right_scraper. I have added the gem to my gem file and it installs fine. I used the example code from the gems github page (https://github.com/rightscale/right_scraper)
require 'rubygems'
require 'right_scraper'
scraper = RightScraper::Scraper.new(:basedir => '/tmp', :kind => :cookbook)
scraper.scrape(:type => :git, :url => 'git://github.com/rightscale/right_scraper.git')
running this code returns the following error:
NameError (uninitialized constant RightScraper::Scraper)
Does anyone know whats going wrong?
Looks like the README is out of date; that class does indeed not exist.
In cases like this, it is often a good idea to look at the specs to see what the correct usage should be. For example, based on this spec, I found the following works:
RightScraper::Main.new(:basedir => '/tmp', :kind => :cookbook)
It would also be a good idea to raise this as an issue with the author. You could even provide a pull request with some up-to-date documentation.

how to retrieve data from Bigcommerce using Rails application?

I am trying to connect a Rails application with the Bigcommerce API but I can't and I don't know why.
I made the next:
Add 'gem bigcommerce' to my gem file
Execute 'bundle install'
Put the code behind in the ApplicationController index
def index
api = Bigcommerce::Api.new({
:store_url => "http://mystore.mybigcommerce.com",
:username => "user",
:api_key => "3a0ce...[my api key]"
})
puts api.time
end
Stop and Start Rails server
I received an error saying 'undefined method `time' for #'
Does any body could tell me what I am doing wrong and how to configure Bigcommerce in a Rails app? I found the official documentation, but it's not very clear for me.
Thanks in advance
Have you added require at the beggining of your ApplicationController file?
require 'bigcommerce'

Integrating payu payment gateway (active_merchant_payu_in) with spree

I am trying to integrate payu.in payment gateway with spree into my rails application. I have included gem 'active_merchant_payu_in' in the application.
My app/models/spree/gateway/payu.rb looks like this:
module Spree
class Gateway::Payu < Gateway
def provider_class
ActiveMerchant::Billing::Integrations::PayuIn
end
end
end
In application.rb
config.after_initialize do |app|
app.config.spree.payment_methods += [
Spree::Gateway::Payu
]
end
Development.rb
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
$payu_merchant_id = ActiveMerchant::Billing::Integrations::PayuIn.merchant_id = '--ID--'
$payu_secret_key = ActiveMerchant::Billing::Integrations::PayuIn.secret_key = '--Key--'
end
I have enabled Spree::Gateway::Payu from admin credentials. Now when i do a checkout i get below error.
NoMethodError in Spree::CheckoutController#update
undefined method `authorize' for ActiveMerchant::Billing::Integrations::PayuIn:Module
can someone guide me towards right path.
Many Thanks :)
Incase anyone is still facing this problem.
Solution: Edit your payment method "Spree::Gateway::Payu" and set auto_capture? field to true.
Payu does not support authorize method which is called when "auto capture" is set to false, when set to true, "purchase" method is called which is supported by payu.
You can read more about auto capture in Spree's documentation. https://guides.spreecommerce.com/developer/payments.html

Ruby on Rails Net HTTP or HTTPParty

I've been at this for awhile. I've tried using net http to connect to a https url with no luck. I've tried http party and getting uninitialized constant httpparty. I am running rails 3.2.7. I have httpparty add to gem file.
Can someone please provide an example with either problem sending params to a https url and receiving a response.
code:
options = {:id => params[:id], :code => params[:code]}
response = HTTPParty.post('https://test.com', options)
gem file:
gem "httparty", "~> 0.9.0"
HTTParty.get('https://google.com', :query => {:q => 'stack overflow'})
If this doesn't work for you, please show the code you're using. It you're getting an uninitialized constant error, you've done something wrong. Did you run bundle after adding to your Gemfile?
Also, it's HTTParty, not HTTPParty.

Using actionwebservice and Rails 3

We want to use actionwebservice for some SOAP integration. We were able to install it however using it causes an error. Here's my code:
class HelloMessageApi < ActionWebService::Base
api_method :hello_message,
:expects => [{:firstname=>:string},
{:lastname=>:string}],
:returns => [:string]
end
The error returned is
uninitialized constant
ActionWebService
When I do a gem list I can see the gem installed, what am I missing? Please help.

Resources