From a69a42df784c0696a0632fdf6e9a5cecd9802d63 Mon Sep 17 00:00:00 2001 From: Christoph Engelhardt Date: Mon, 9 Mar 2015 08:43:46 +0100 Subject: [PATCH] -add: stripe event handler for deleted subscriptions (tries to call subscription_owner#cancel) -change: bumped version to 1.0.0 for semantic versioning --- app/concerns/koudoku/subscription.rb | 4 ++-- config/initializers/stripe_event.rb | 5 +++++ lib/koudoku/version.rb | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/concerns/koudoku/subscription.rb b/app/concerns/koudoku/subscription.rb index c8f8114..d7e91ad 100644 --- a/app/concerns/koudoku/subscription.rb +++ b/app/concerns/koudoku/subscription.rb @@ -135,7 +135,8 @@ def processing! end end - + + def describe_difference(plan_to_describe) if plan.nil? if persisted? @@ -182,7 +183,6 @@ def subscription_owner_description def subscription_owner_email "#{subscription_owner.try(:email)}" - end def changing_plans? diff --git a/config/initializers/stripe_event.rb b/config/initializers/stripe_event.rb index bf431da..8938e62 100644 --- a/config/initializers/stripe_event.rb +++ b/config/initializers/stripe_event.rb @@ -19,4 +19,9 @@ subscription.charge_disputed end + events.subscribe 'customer.subscription.deleted' do |event| + stripe_id = event.data.object['customer'] + subscription = ::Subscription.find_by_stripe_id(stripe_id) + subscription.subscription_owner.try(:cancel) + end end \ No newline at end of file diff --git a/lib/koudoku/version.rb b/lib/koudoku/version.rb index f4d3c05..accb379 100644 --- a/lib/koudoku/version.rb +++ b/lib/koudoku/version.rb @@ -1,3 +1,3 @@ module Koudoku - VERSION = "0.0.13" + VERSION = "1.0.0" end