effective_orders 4.0.0beta7 → 4.0.0beta8
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c66a5be43c958c2c0488de0973b4d5c30dff9bd4
|
4
|
+
data.tar.gz: 120bed89ab81bd1e8dc044fc39e8e6d331811032
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e17e53c655a3f620b31442b305ab5fa7c869ab11db9be8b5b135c064fabb1064ce39ad13f91468dabc9dba2bc442c39de92d6dd5a984c23d7e36e4b36daa8fbb
|
7
|
+
data.tar.gz: 59401e22fe8407db0efe2857131d73fcbd1f7a298413c031e6a30e66e6430c1af0e5a372ca50c4d6bcb1dd3c341b0bb983f9bac3ec5506f445e59edc78eaa6e1
|
@@ -36,7 +36,6 @@ module Effective
|
|
36
36
|
send_email(:subscription_payment_failed, customer)
|
37
37
|
when 'customer.subscription.deleted'
|
38
38
|
customer = Effective::Customer.where(stripe_customer_id: @event.data.object.customer).first!
|
39
|
-
Effective::Subscription.where(customer: customer).destroy_all
|
40
39
|
customer.update_attributes!(stripe_subscription_id: nil, status: nil, active_card: nil)
|
41
40
|
customer.subscriptions.delete_all
|
42
41
|
|
@@ -24,6 +24,10 @@ module ActsAsSubscribable
|
|
24
24
|
self.trialing_until = (Time.zone.now + EffectiveOrders.trial.fetch(:length)).end_of_day
|
25
25
|
end
|
26
26
|
|
27
|
+
before_destroy(if: -> { subscribed? }) do
|
28
|
+
raise :abort unless (subscripter.destroy! rescue false)
|
29
|
+
end
|
30
|
+
|
27
31
|
validates :trialing_until, presence: true, if: -> { EffectiveOrders.trial? }
|
28
32
|
validates :subscription_status, inclusion: { allow_nil: true, in: EffectiveOrders::STATUSES.keys }
|
29
33
|
|
@@ -20,7 +20,7 @@ module Effective
|
|
20
20
|
|
21
21
|
scope :deep, -> { includes(subscriptions: :subscribable) }
|
22
22
|
|
23
|
-
after_commit
|
23
|
+
after_commit do
|
24
24
|
subscriptions.each { |subscription| subscription.subscribable.update_column(:subscription_status, status) }
|
25
25
|
end
|
26
26
|
|
@@ -61,6 +61,15 @@ module Effective
|
|
61
61
|
true
|
62
62
|
end
|
63
63
|
|
64
|
+
def destroy!
|
65
|
+
return true unless plan
|
66
|
+
|
67
|
+
subscribable.subscription.destroy!
|
68
|
+
subscribable.update_column(:subscription_status, nil)
|
69
|
+
sync_subscription!
|
70
|
+
true
|
71
|
+
end
|
72
|
+
|
64
73
|
protected
|
65
74
|
|
66
75
|
# This should work even if the rest of the form doesn't. Careful with our transactions...
|
@@ -175,17 +184,6 @@ module Effective
|
|
175
184
|
save!
|
176
185
|
end
|
177
186
|
|
178
|
-
# def destroy!
|
179
|
-
# return true unless subscription && subscription.persisted? && customer.stripe_subscription.present?
|
180
|
-
|
181
|
-
# raise 'is invalid' unless valid?
|
182
|
-
|
183
|
-
# subscription.destroy!
|
184
|
-
# customer.subscriptions.reload
|
185
|
-
|
186
|
-
# sync! && customer.save!
|
187
|
-
# end
|
188
|
-
|
189
187
|
private
|
190
188
|
|
191
189
|
def subscription
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_orders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.0beta8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|