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 +4 -4
- data/app/models/pay/stripe/subscription.rb +13 -0
- data/lib/pay/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 82ea490d9dcf523e5d673e8a0672e18c984e1eca14da96e72ff58e997952bf33
|
|
4
|
+
data.tar.gz: 2c14c13fcfb5d1deb1aa1265116fd74cd8b255989991d49574a5236dd1fa5863
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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