Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8424385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:58:29+00:00 2026-06-10T03:58:29+00:00

I’m working on integrating Stripe’s webhooks into a Rails app using https://github.com/integrallis/stripe_event . I’m

  • 0

I’m working on integrating Stripe’s webhooks into a Rails app using https://github.com/integrallis/stripe_event. I’m struggling to get my code to working according to the example in the gem’s docs whereby an initializer is used to dictate which code responds to a particular event. It seems that Rails isn’t (auto)loading my module in the initializer.

I’m configuring the autoload path properly:

# config/application.rb

config.autoload_paths += %W(#{config.root}/lib)

The stripe initializer:

#config/initializers/stripe.rb

stripe_config = YAML.load_file(Rails.root.join('config', 'stripe.yml'))[Rails.env]
Stripe.api_key = stripe_config["secret_key"]
STRIPE_PUBLIC_KEY = stripe_config["publishable_key"]

StripeEvent.setup do
  # Not sure if I need this to load my module
  require 'stripe_event_handlers' # => true

  subscribe 'customer.subscription.created' do |event|
    StripeEventHanders.handle_customer_subscription_created(event) # Define subscriber behavior
  end
end

Here’s my custom module (though I’ve tried it as a class too):

#lib/stripe_event_handlers.rb

module StripeEventHandlers

  def handle_customer_subscription_created(event) # Define subscriber behavior
    puts event
  end
end

This is my test:

require 'test_helper'

# --- Run this in the console to get event response for mocking ---
#serialized_object = YAML::dump(Stripe::Event.retrieve('evt_0Cizt88YP0nCle'))
#filename = Rails.root.join('test/fixtures/stripe_objects', 'customer_subscription_created.yml')
#File.open(filename, 'w') {|f| f.write(serialized_object) }

class StripeEvent::WebhookControllerTest < ActionController::TestCase

  def test_mock_event
    event_id = 'evt_0Cizt88YP0nCle'
    event = YAML.load_file(Rails.root.join('test/fixtures/stripe_objects', 'customer_subscription_created.yml'))
    Stripe::Event.expects(:retrieve).with(event_id).returns(event)
    assert_equal Stripe::Event.retrieve(event_id), event
  end

  def test_customer_subscription_created_webhook
    event_id = 'evt_0Cizt88YP0nCle'
    event = YAML.load_file(Rails.root.join('test/fixtures/stripe_objects', 'customer_subscription_created.yml'))
    Stripe::Event.expects(:retrieve).at_most(2).with(event_id).returns(event)
    # This should be a raw post request but that doesn't seem to come through
    # on the stripe_event / rails side in the params hash. For testing
    # purposes, we can just use a get request as the route doesn't specify an
    # HTTP method.
    get :event, :use_route => :stripe_event, :id => event_id
    assert_response :success
  end
end

And here’s my test result failure:

StripeEvent::WebhookControllerTest
    ERROR (0:00:00.043) test_customer_subscription_created_webhook
          uninitialized constant StripeEventHanders
        @ config/initializers/stripe.rb:10:in `block (2 levels) in <top (required)>'


     PASS (0:00:00.053) test_mock_event

Finished in 0.055477 seconds.

2 tests, 1 passed, 0 failures, 1 errors, 0 skips, 2 assertions
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:58:30+00:00Added an answer on June 10, 2026 at 3:58 am

    You are just missing the letter l in StripeEventHandlers.

    subscribe 'customer.subscription.created' do |event|
      StripeEventHanders.handle_customer_subscription_created(event)
    end
    

    Also, handle_customer_subscription_created should be defined as a class method:

    module StripeEventHandlers
    
      def self.handle_customer_subscription_created(event) # Define subscriber behavior
        puts event
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am using Paperclip to handle profile photo uploads in my app. They upload
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.