pay 13.0.0 → 13.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: e070a8068ea85e41632ddea4d3934d471ae2be7c795c6532d965fe93aa809544
4
- data.tar.gz: 9df7a081c6ade23f9b2f146d20ca991556195ffbddb1cc9396098132adb1f6bd
3
+ metadata.gz: 82ea490d9dcf523e5d673e8a0672e18c984e1eca14da96e72ff58e997952bf33
4
+ data.tar.gz: 2c14c13fcfb5d1deb1aa1265116fd74cd8b255989991d49574a5236dd1fa5863
5
5
  SHA512:
6
- metadata.gz: 43cec09eceb32a4f8c3f6bb8df73a220d83452ffc202e297377b615ea418555f8ef91c8da01583e2d29cbd51ed56a20287d1126a2c66e3ab196811a4935af29d
7
- data.tar.gz: 50172d9ddc1ec9e97f0286fe7c9727ae2b33d91f76d32eee5b598f90c381ee237cae8489854e4e22ffabf97842197e3a71996a8c53b75d5dda46fe625b90f909
6
+ metadata.gz: a39478aa6144858f319b33e7970904a2757a60cd4bdf0b3c4e001b99d93cd2449eb5bf3f1a547b1729451fefa1cca1ff651911d18e0ae5db0c2ad1e8a7fc4169
7
+ data.tar.gz: 30000486abfd6bdf51384145fca98ea3c1da4d1410bcf35da2d57d4b6b34019dd3d8b25e690c6cfe973be85556c021f03652cfea745525b5352ebbf029d56d0f
@@ -309,6 +309,12 @@ module Pay
309
309
  options[:billing_cycle_anchor] = {type: options[:billing_cycle_anchor].to_s}
310
310
  end
311
311
 
312
+ # Flexible billing mode keeps the anchor when the interval changes (monthly to yearly bills a partial year),
313
+ # so start the new interval today like classic mode does
314
+ if !options.key?(:billing_cycle_anchor) && !on_trial? && interval_changes?(plan)
315
+ options[:billing_cycle_anchor] = {type: "now"}
316
+ end
317
+
312
318
  @api_record = stripe_client.v1.subscriptions.update(
313
319
  processor_id,
314
320
  {
@@ -412,6 +418,13 @@ module Pay
412
418
  def expand_options
413
419
  self.class.expand_options
414
420
  end
421
+
422
+ def interval_changes?(plan)
423
+ if (current = subscription_items.first.price.try(:recurring))
424
+ requested = stripe_client.v1.prices.retrieve(plan, {}, stripe_options).recurring
425
+ requested.present? && [current.interval, current.interval_count] != [requested.interval, requested.interval_count]
426
+ end
427
+ end
415
428
  end
416
429
  end
417
430
  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 = "13.0.0"
4
+ VERSION = "13.0.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: 13.0.0
4
+ version: 13.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes