Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to cancel subscription from Stripe #122

Open
maxgronlund opened this issue Apr 19, 2015 · 3 comments
Open

Unable to cancel subscription from Stripe #122

maxgronlund opened this issue Apr 19, 2015 · 3 comments

Comments

@maxgronlund
Copy link

When I cancel a subscription for a user from the stripe dashboard
https://dashboard.stripe.com/test/customers -> some customer

the webhook is called ok. but i get this error
NameError - uninitialized constant Sale:
config/initializers/payola line 5
sale = Sale.find_by(stripe_id: event.data.object.id)

The implementation example from https://github.com/peterkeen/payola/wiki/Configuration-options
is slightly different

Payola.configure do |payola| payola.subscribe 'charge.succeeded' do |event| sale = Sale.find_by(stripe_id: event.data.object.id) SaleMailer.admin_receipt(sale.guid) end end

but gives the same error
I have been looking in the schema and can see the schemas created by the payola gem

After following the tutorial to the letter, I downloaded the example code, same problem


from the log
Started POST "/payola/events" for 127.0.0.1 at 2015-04-19 17:44:05 +0200
Processing by StripeEvent::WebhookController#event as XML
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"}}
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"] begin transaction
Payola::StripeWebhook Exists (0.1ms) SELECT 1 AS one FROM "payola_stripe_webhooks" WHERE "payola_stripe_webhooks"."stripe_id" = 'evt_15tKaQDCWuUtTcRTD9eamfnc' LIMIT 1
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"] commit transaction
Completed 500 Internal Server Error in 1327ms (ActiveRecord: 2.8ms)

NameError - uninitialized constant Sale:
activesupport (4.2.1) lib/active_support/dependencies.rb:533:in load_missing_constant' activesupport (4.2.1) lib/active_support/dependencies.rb:184:inconst_missing'
config/initializers/payola.rb:5:in `block (2 levels) in <top (required)>'

@kathyonu
Copy link
Contributor

This problem has been fixed, and the new RSpec tests will be rolling out in over the next
however many days, including all the Stripe and Payola type tests.

@kathyonu
Copy link
Contributor

@maxgronlund , @benmanns , @kureikain , @stevecastaneda , @RailsApps/owners : This note replaced with my next comment

@kathyonu
Copy link
Contributor

kathyonu commented Jul 1, 2015

@maxgronlund , @benmanns , @kureikain , @stevecastaneda , @RailsApps/owners : Please see PR Testsformaster #150 . I invite you to pull this branch into your working app, and take it for a spin. If you can help resolve the four pending tests, that would be grand, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants