pay 12.5.0 → 12.5.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: 618d06be256f138854df0025d396ec8a3eb19ba19d2bc1892ba5c7ac147f832c
4
- data.tar.gz: 4d8fec94d382dd451e3e5c0a2e82292c45559b320645a649edecf6cc358f24e3
3
+ metadata.gz: 4fcf236ca20e7f572dc4e3cbf9670bf98a3f4013cfa62885f0aa8d02db549f66
4
+ data.tar.gz: ddb22f464e1e9ed66a47f02e7211782e7d5806dced0308ede3408cd104a8fe0c
5
5
  SHA512:
6
- metadata.gz: 1010542511e8d58d0e077d7a1b0e006cc7c2935ded4d5e1b499724d9e1214b55e4cf730b07eb6c02a28fbb0772f024d6ce47d26d8806bca644f58cb19f15fe6e
7
- data.tar.gz: 48f66dca21dcf2120a5136d3b723418835097a4b45a2da50a03847227f4bb763178272d757fb698d68d374ec22dc7fee65fa9399b5ab2e07b1f5e744d651442c
6
+ metadata.gz: a541d444013a7a2b9e1867e484d53462bf930c8161dca6ace3b240adbb09acd25c3635be68d149bc73257be3bd83b199fe6fce29953e51b06b0b833cd315b036
7
+ data.tar.gz: f448557d4091cb6c1627809b1dd4bc0e2ede05bff80fedb2487a631173bcd2d1aedd6a05a107fffba3beea27a89867d2be94e6562c4875e275917d57496ee9e4
@@ -310,6 +310,12 @@ module Pay
310
310
  options[:billing_cycle_anchor] = {type: options[:billing_cycle_anchor].to_s}
311
311
  end
312
312
 
313
+ # Flexible billing mode keeps the anchor when the interval changes (monthly to yearly bills a partial year),
314
+ # so start the new interval today like classic mode does
315
+ if !options.key?(:billing_cycle_anchor) && !on_trial? && interval_changes?(plan)
316
+ options[:billing_cycle_anchor] = {type: "now"}
317
+ end
318
+
313
319
  @api_record = ::Stripe::Subscription.update(
314
320
  processor_id,
315
321
  {
@@ -411,6 +417,13 @@ module Pay
411
417
  def expand_options
412
418
  self.class.expand_options
413
419
  end
420
+
421
+ def interval_changes?(plan)
422
+ if (current = subscription_items.first.price.try(:recurring))
423
+ requested = ::Stripe::Price.retrieve(plan, stripe_options).recurring
424
+ requested.present? && [current.interval, current.interval_count] != [requested.interval, requested.interval_count]
425
+ end
426
+ end
414
427
  end
415
428
  end
416
429
  end
data/lib/pay/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Pay
4
- VERSION = "12.5.0"
4
+ VERSION = "12.5.1"
5
5
  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: 12.5.0
4
+ version: 12.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes