pay 11.0.0 → 11.0.1

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: bbc13750a45c160a2cf53afc173735a5e846d3401955b3c05b080b61936b3173
4
- data.tar.gz: 315acc27967b4dc0063981950dbb25aade62c8e29447714d410db48066acbf83
3
+ metadata.gz: a7200a013cb88ad073e1de38f397fa6b46e28892dbfd3e70426dd99308422a1f
4
+ data.tar.gz: 6397051e6cfaf375f5e66bb5eab4a13c4fd22a7204939876e08452bf4f1f9c55
5
5
  SHA512:
6
- metadata.gz: 6730e4367a8c0de82aa4f7daddb87c8c4184fe3f87830b5dff9fb13480f2583c002d7ef0c65c466a528596d3c60a373c69112a396c01a8903103c640417ba304
7
- data.tar.gz: 8bb32b72e87510fa62be51140271a163424d7bfc12c046b1faa128ff155fa46e03f43018f79e205283c07d56674083cb0de1b278c10c0fd61d65569f468fcdd7
6
+ metadata.gz: 3cbc10ffdf3b6d277c833fe3bc51536f57f09d26fa524db6d2ea8fc876751926b04334e6ca530a2a8ff9911dbcbca672c67f83e7799519a174f2ac2164d86807
7
+ data.tar.gz: 81f0182087f30e15f90557cf78442425b2a44316d3db29f3ccc08f759183ad75bdb1bb64a03aa7d7515b953d5dc32b3e244d878308eaab09d5140333feb926d8
@@ -47,6 +47,8 @@ module Pay
47
47
  if object.trial_end
48
48
  trial_ended_at = [object.ended_at, object.trial_end].compact.min
49
49
  attributes[:trial_ends_at] = Time.at(trial_ended_at)
50
+ else
51
+ attributes[:trial_ends_at] = nil
50
52
  end
51
53
 
52
54
  object.items.auto_paging_each do |subscription_item|
@@ -164,7 +166,7 @@ module Pay
164
166
  cancel_now!
165
167
  else
166
168
  @api_record = ::Stripe::Subscription.update(processor_id, {cancel_at_period_end: true}.merge(expand_options), stripe_options)
167
- update(ends_at: (on_trial? ? trial_ends_at : Time.at(@api_record.items.first.current_period_end)))
169
+ update(ends_at: Time.at(@api_record.cancel_at))
168
170
  end
169
171
  rescue ::Stripe::StripeError => e
170
172
  raise Pay::Stripe::Error, e
@@ -178,7 +180,11 @@ module Pay
178
180
  return if canceled? && ends_at.past?
179
181
 
180
182
  @api_record = ::Stripe::Subscription.cancel(processor_id, options.merge(expand_options), stripe_options)
181
- update(trial_ends_at: Time.current, ends_at: Time.current, status: :canceled)
183
+ update(
184
+ trial_ends_at: (@api_record.trial_end ? Time.at(@api_record.trial_end) : nil),
185
+ ends_at: Time.at(@api_record.ended_at),
186
+ status: @api_record.status
187
+ )
182
188
  rescue ::Stripe::StripeError => e
183
189
  raise Pay::Stripe::Error, e
184
190
  end
@@ -66,10 +66,12 @@ module Pay
66
66
 
67
67
  # Does not include the last second of the trial
68
68
  def on_trial?
69
+ return false if ended?
69
70
  trial_ends_at? && trial_ends_at > Time.current
70
71
  end
71
72
 
72
73
  def trial_ended?
74
+ return true if ended?
73
75
  trial_ends_at? && trial_ends_at <= Time.current
74
76
  end
75
77
 
data/lib/pay/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "11.0.0"
2
+ VERSION = "11.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pay
3
3
  version: !ruby/object:Gem::Version
4
- version: 11.0.0
4
+ version: 11.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes