effective_orders 4.5.2 → 4.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36b254eb8e99a4c04b3b63135b2b1caa15f5a8d7803bcad0fff8323b0aab957a
4
- data.tar.gz: 699ccd522afef972528e9dcee5b5eae8abad124cf11e0002f84e5c7a06bf0e8b
3
+ metadata.gz: d2216991c7430e4902a33b35ee0d8d4ea9e637c927a587b1dbedf1eaf4cf57fe
4
+ data.tar.gz: a51f8b35bfebb1e375664ee006e24717cec9ddac464f17e008296a87e2883c81
5
5
  SHA512:
6
- metadata.gz: 784ec95030d906ab226f26d7f50651062979a3e50fdf286135fc81e3907d6bc23a93c77e1504433012ea59e49bcb4613702723b69a9fe58b858fd36a15ae1590
7
- data.tar.gz: 7f1cf4534c235f84a025a040b2988fcfa8664046d7026de8665f4c14b139afdbd570a4491ffb46ade0d5ba40f80bd6403064f6de6aa5fa4e3ace5e1032331f83
6
+ metadata.gz: 7b5a07d109578b5bc7654ca5eaa6ec3f18b7cd89841b15e7f0a5a1128089e9715cd9b317c884ef0afb6cb4a9fed7f0934b7693f7e0b3ba4648544769a00ef3be
7
+ data.tar.gz: e94f3d309875b26bbf6f185990e80e1d1911ae0d320050550915dd7970f025a07645c402aa1b6422e114f1e1563b1d86420cba3a8d8058123ce437650c900269
@@ -67,6 +67,12 @@ module ActsAsSubscribable
67
67
  subscribed? && subscription_status == EffectiveOrders::PAST_DUE
68
68
  end
69
69
 
70
+ # If we do use stripe
71
+ def subscription_trialing?
72
+ subscribed? && subscription_status == EffectiveOrders::TRIALING
73
+ end
74
+
75
+ # If we don't use stripe
70
76
  def trialing?
71
77
  subscription_status.blank?
72
78
  end
@@ -126,7 +126,13 @@ module Effective
126
126
  return false unless subscription.stripe_subscription.blank?
127
127
 
128
128
  Rails.logger.info "[STRIPE] create subscription: #{items}"
129
- stripe_subscription = Stripe::Subscription.create(customer: customer.stripe_customer_id, items: items, metadata: metadata)
129
+
130
+ stripe_subscription = Stripe::Subscription.create(
131
+ customer: customer.stripe_customer_id,
132
+ items: items,
133
+ metadata: metadata,
134
+ trial_from_plan: true
135
+ )
130
136
 
131
137
  subscription.update!(
132
138
  stripe_subscription: stripe_subscription,
@@ -79,6 +79,10 @@ module Effective
79
79
  name.to_s <=> other&.name.to_s
80
80
  end
81
81
 
82
+ def trialing?
83
+ status == 'trialing'
84
+ end
85
+
82
86
  def active?
83
87
  status == 'active'
84
88
  end
@@ -14,9 +14,10 @@ module EffectiveOrders
14
14
  # Subscription statuses (as per stripe)
15
15
  ACTIVE = 'active'.freeze
16
16
  PAST_DUE = 'past_due'.freeze
17
+ TRIALING = 'trialing'.freeze
17
18
  CANCELED = 'canceled'.freeze
18
19
 
19
- STATUSES = { ACTIVE => ACTIVE, PAST_DUE => PAST_DUE, CANCELED => CANCELED }
20
+ STATUSES = { ACTIVE => ACTIVE, PAST_DUE => PAST_DUE, CANCELED => CANCELED, TRIALING => TRIALING }
20
21
 
21
22
  # The following are all valid config keys
22
23
  mattr_accessor :orders_table_name
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '4.5.2'.freeze
2
+ VERSION = '4.5.3'.freeze
3
3
  end
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.5.2
4
+ version: 4.5.3
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: 2020-07-25 00:00:00.000000000 Z
11
+ date: 2020-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails