{"action":"opened","issue":{"url":"https://api.github.com/repos/RailsApps/rails-stripe-membership-saas/issues/122","labels_url":"https://api.github.com/repos/RailsApps/rails-stripe-membership-saas/issues/122/labels{/name}","comments_url":"https://api.github.com/repos/RailsApps/rails-stripe-membership-saas/issues/122/comments","events_url":"https://api.github.com/repos/RailsApps/rails-stripe-membership-saas/issues/122/events","html_url":"https://github.com/RailsApps/rails-stripe-membership-saas/issues/122","id":69438743,"number":122,"title":"Unable to cancel subscription from Stripe","user":{"login":"maxgronlund","id":27051,"avatar_url":"https://avatars.githubusercontent.com/u/27051?v=3","gravatar_id":"","url":"https://api.github.com/users/maxgronlund","html_url":"https://github.com/maxgronlund","followers_url":"https://api.github.com/users/maxgronlund/followers","following_url":"https://api.github.com/users/maxgronlund/following{/other_user}","gists_url":"https://api.github.com/users/maxgronlund/gists{/gist_id}","starred_url":"https://api.github.com/users/maxgronlund/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxgronlund/subscriptions","organizations_url":"https://api.github.com/users/maxgronlund/orgs","repos_url":"https://api.github.com/users/maxgronlund/repos","events_url":"https://api.github.com/users/maxgronlund/events{/privacy}","received_events_url":"https://api.github.com/users/maxgronlund/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-19T16:11:27Z","updated_at":"2015-04-19T16:11:27Z","closed_at":null,"body":"When I cancel a subscription for a user from the stripe dashboard\r\nhttps://dashboard.stripe.com/test/customers -> some customer\r\n\r\nthe webhook is called ok. but i get this error\r\nNameError - uninitialized constant Sale:\r\nconfig/initializers/payola line 5\r\nsale = Sale.find_by(stripe_id: event.data.object.id)\r\n\r\nThe implementation example from https://github.com/peterkeen/payola/wiki/Configuration-options\r\nis slightly different\r\n \r\nPayola.configure do |payola|\r\n  payola.subscribe 'charge.succeeded' do |event|\r\n    sale = Sale.find_by(stripe_id: event.data.object.id)\r\n    SaleMailer.admin_receipt(sale.guid)\r\n  end\r\nend\r\n\r\nbut gives the same error\r\nI have been looking in the schema and can see the record created by the payola gem\r\n\r\n\r\nAfter following the tutorial to the letter, I downloaded the example code, same problem\r\n\r\n-----------------------------------------\r\nfrom the log\r\nStarted POST \"/payola/events\" for 127.0.0.1 at 2015-04-19 17:44:05 +0200\r\nProcessing by StripeEvent::WebhookController#event as XML\r\n  Parameters: {\"id\"=>\"evt_15tKaQDCWuUtTcRTD9eamfnc\", \"created\"=>1429458238, \"livemode\"=>false, \"type\"=>\"customer.subscription.deleted\", \"data\"=>{\"object\"=>{\"id\"=>\"sub_65VaQy74gn1TNn\", \"plan\"=>{\"interval\"=>\"month\", \"name\"=>\"Silver\", \"created\"=>1429446273, \"amount\"=>999, \"currency\"=>\"usd\", \"id\"=>\"silver\", \"object\"=>\"plan\", \"livemode\"=>false, \"interval_count\"=>1, \"trial_period_days\"=>nil, \"metadata\"=>{}, \"statement_descriptor\"=>\"digiramp silver\"}, \"object\"=>\"subscription\", \"start\"=>1429458165, \"status\"=>\"canceled\", \"customer\"=>\"cus_65Va0qmIcUkkwc\", \"cancel_at_period_end\"=>false, \"current_period_start\"=>1429458165, \"current_period_end\"=>1432050165, \"ended_at\"=>1429458238, \"trial_start\"=>nil, \"trial_end\"=>nil, \"canceled_at\"=>1429458238, \"quantity\"=>1, \"application_fee_percent\"=>nil, \"discount\"=>nil, \"tax_percent\"=>nil, \"metadata\"=>{}}}, \"object\"=>\"event\", \"pending_webhooks\"=>1, \"request\"=>\"iar_65VbHhLFx8k6AN\", \"api_version\"=>\"2015-04-07\", \"webhook\"=>{\"id\"=>\"evt_15tKaQDCWuUtTcRTD9eamfnc\", \"created\"=>1429458238, \"livemode\"=>false, \"type\"=>\"customer.subscription.deleted\", \"data\"=>{\"object\"=>{\"id\"=>\"sub_65VaQy74gn1TNn\", \"plan\"=>{\"interval\"=>\"month\", \"name\"=>\"Silver\", \"created\"=>1429446273, \"amount\"=>999, \"currency\"=>\"usd\", \"id\"=>\"silver\", \"object\"=>\"plan\", \"livemode\"=>false, \"interval_count\"=>1, \"trial_period_days\"=>nil, \"metadata\"=>{}, \"statement_descriptor\"=>\"digiramp silver\"}, \"object\"=>\"subscription\", \"start\"=>1429458165, \"status\"=>\"canceled\", \"customer\"=>\"cus_65Va0qmIcUkkwc\", \"cancel_at_period_end\"=>false, \"current_period_start\"=>1429458165, \"current_period_end\"=>1432050165, \"ended_at\"=>1429458238, \"trial_start\"=>nil, \"trial_end\"=>nil, \"canceled_at\"=>1429458238, \"quantity\"=>1, \"application_fee_percent\"=>nil, \"discount\"=>nil, \"tax_percent\"=>nil, \"metadata\"=>{}}}, \"object\"=>\"event\", \"pending_webhooks\"=>1, \"request\"=>\"iar_65VbHhLFx8k6AN\", \"api_version\"=>\"2015-04-07\"}}\r\n  Payola::StripeWebhook Exists (0.1ms)  SELECT  1 AS one FROM \"payola_stripe_webhooks\" WHERE \"payola_stripe_webhooks\".\"stripe_id\" = ? LIMIT 1  [[\"stripe_id\", \"evt_15tKaQDCWuUtTcRTD9eamfnc\"]]\r\n   (0.1ms)  begin transaction\r\n  Payola::StripeWebhook Exists (0.1ms)  SELECT  1 AS one FROM \"payola_stripe_webhooks\" WHERE \"payola_stripe_webhooks\".\"stripe_id\" = 'evt_15tKaQDCWuUtTcRTD9eamfnc' LIMIT 1\r\n  SQL (0.2ms)  INSERT INTO \"payola_stripe_webhooks\" (\"stripe_id\", \"created_at\", \"updated_at\") VALUES (?, ?, ?)  [[\"stripe_id\", \"evt_15tKaQDCWuUtTcRTD9eamfnc\"], [\"created_at\", \"2015-04-19 15:44:05.761740\"], [\"updated_at\", \"2015-04-19 15:44:05.761740\"]]\r\n   (2.3ms)  commit transaction\r\nCompleted 500 Internal Server Error in 1327ms (ActiveRecord: 2.8ms)\r\n\r\nNameError - uninitialized constant Sale:\r\n  activesupport (4.2.1) lib/active_support/dependencies.rb:533:in `load_missing_constant'\r\n  activesupport (4.2.1) lib/active_support/dependencies.rb:184:in `const_missing'\r\n  config/initializers/payola.rb:5:in `block (2 levels) in <top (required)>'"}}