monza 1.3.6 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/README.md +0 -5
- data/lib/monza.rb +1 -1
- data/lib/monza/bool_typecasting.rb +31 -28
- data/lib/monza/renewal_info.rb +2 -0
- data/lib/monza/status_response.rb +142 -38
- data/lib/monza/transaction_receipt.rb +14 -2
- data/lib/monza/verification_response.rb +14 -22
- data/lib/monza/version.rb +3 -1
- data/monza.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a3e8797fbfd911982c72952571bf74f4a2bc43d661ab5453e75c7094a5c58b8
|
4
|
+
data.tar.gz: f6cc849f16e7d9043fde46a8e8a89a1b410305d1f71e3520d73d7a24b34ddefa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba834db0521e45098e1234d314c68a33b01e0d21ba46be4f119ca4a65d8d78e7a0170697fec7439995ff5367058eebf1e5585725931fdf9ddb7d362f94bde5fc
|
7
|
+
data.tar.gz: a873a6aa9d162d2557a348d9a9438edeb6172f03283d9f5a278cfb1506ce89796b3fb10df9b8a970b24e57b1804a258258858f2d348bb20a41c4a03fe5783c6b
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -41,11 +41,6 @@ You can also pass in `exclude_old_transactions` with value `true` as an option i
|
|
41
41
|
# this checks if latest transaction receipt expiry_date is in today or the future
|
42
42
|
response.is_subscription_active? # => true or false
|
43
43
|
|
44
|
-
# Check if subscription is active
|
45
|
-
# this checks if ANY transaction receipt expiry_date is in today or the future
|
46
|
-
# this is helpful in case the most recent transaction was cancelled but the user still has a previous transaction or subscription that is active
|
47
|
-
response.is_any_subscription_active? # => true or false
|
48
|
-
|
49
44
|
# Returns the active subscription TransactionReceipt or nil
|
50
45
|
response.latest_active_transaction_receipt # => TransactionReceipt instance
|
51
46
|
|
data/lib/monza.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "monza/bool_typecasting"
|
1
2
|
require "monza/version"
|
2
3
|
require "monza/client"
|
3
4
|
require "monza/renewal_info"
|
@@ -5,5 +6,4 @@ require "monza/verification_response"
|
|
5
6
|
require "monza/status_response"
|
6
7
|
require "monza/receipt"
|
7
8
|
require "monza/transaction_receipt"
|
8
|
-
require "monza/bool_typecasting"
|
9
9
|
require "monza/config"
|
@@ -1,35 +1,38 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module BoolTypecasting
|
2
|
+
refine String do
|
3
|
+
def to_bool
|
4
|
+
return true if self == true || self =~ (/^(true|t|yes|y|1)$/i)
|
5
|
+
return false if self == false || self.empty? || self =~ (/^(false|f|no|n|0)$/i)
|
6
|
+
raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
|
7
|
+
end
|
8
|
+
# if using Rails empty? can be changed for blank?
|
6
9
|
end
|
7
|
-
# if using Rails empty? can be changed for blank?
|
8
|
-
end
|
9
10
|
|
10
|
-
if RUBY_VERSION >= "2.4"
|
11
|
-
|
12
|
-
else
|
13
|
-
|
14
|
-
end
|
15
|
-
integer_class::class_eval do
|
16
|
-
def to_bool
|
17
|
-
return true if self == 1
|
18
|
-
return false if self == 0
|
19
|
-
raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
|
11
|
+
if RUBY_VERSION >= "2.4"
|
12
|
+
integer_class = Object.const_get("Integer")
|
13
|
+
else
|
14
|
+
integer_class = Object.const_get("Fixnum")
|
20
15
|
end
|
21
|
-
end
|
22
16
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
17
|
+
refine integer_class do
|
18
|
+
def to_bool
|
19
|
+
return true if self == 1
|
20
|
+
return false if self == 0
|
21
|
+
raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
|
22
|
+
end
|
23
|
+
end
|
27
24
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
25
|
+
refine TrueClass do
|
26
|
+
def to_i; 1; end
|
27
|
+
def to_bool; self; end
|
28
|
+
end
|
32
29
|
|
33
|
-
|
34
|
-
|
30
|
+
refine FalseClass do
|
31
|
+
def to_i; 0; end
|
32
|
+
def to_bool; self; end
|
33
|
+
end
|
34
|
+
|
35
|
+
refine NilClass do
|
36
|
+
def to_bool; false; end
|
37
|
+
end
|
35
38
|
end
|
data/lib/monza/renewal_info.rb
CHANGED
@@ -1,17 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'time'
|
2
4
|
|
3
5
|
module Monza
|
4
6
|
class StatusResponse
|
7
|
+
using BoolTypecasting
|
8
|
+
|
5
9
|
# https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html
|
10
|
+
# https://developer.apple.com/documentation/appstoreservernotifications/responsebody
|
11
|
+
module Type
|
12
|
+
CANCEL = 'CANCEL'
|
13
|
+
DID_CHANGE_RENEWAL_PREF = 'DID_CHANGE_RENEWAL_PREF'
|
14
|
+
DID_CHANGE_RENEWAL_STATUS = 'DID_CHANGE_RENEWAL_STATUS'
|
15
|
+
DID_FAIL_TO_RENEW = 'DID_FAIL_TO_RENEW'
|
16
|
+
DID_RECOVER = 'DID_RECOVER'
|
17
|
+
INITIAL_BUY = 'INITIAL_BUY'
|
18
|
+
INTERACTIVE_RENEWAL = 'INTERACTIVE_RENEWAL'
|
19
|
+
RENEWAL = 'RENEWAL'
|
20
|
+
REFUND = 'REFUND'
|
21
|
+
end
|
6
22
|
|
7
23
|
attr_reader :auto_renew_product_id
|
8
24
|
attr_reader :auto_renew_status
|
25
|
+
attr_reader :auto_renew_status_change_date
|
26
|
+
attr_reader :auto_renew_status_change_date_ms
|
27
|
+
attr_reader :auto_renew_status_change_date_pst
|
9
28
|
attr_reader :environment
|
29
|
+
attr_reader :expiration_intent
|
30
|
+
|
10
31
|
attr_reader :latest_receipt
|
11
32
|
|
12
33
|
attr_reader :notification_type
|
13
34
|
attr_reader :password
|
14
35
|
|
36
|
+
attr_reader :latest_receipt_info
|
37
|
+
attr_reader :renewal_info
|
15
38
|
attr_reader :bundle_id
|
16
39
|
attr_reader :bvrs
|
17
40
|
attr_reader :item_id
|
@@ -42,22 +65,40 @@ module Monza
|
|
42
65
|
|
43
66
|
@auto_renew_product_id = attributes['auto_renew_product_id']
|
44
67
|
@auto_renew_status = attributes['auto_renew_status'].to_bool
|
68
|
+
if attributes['auto_renew_status_change_date']
|
69
|
+
@auto_renew_status_change_date = DateTime.parse(attributes['auto_renew_status_change_date'])
|
70
|
+
end
|
71
|
+
if attributes['auto_renew_status_change_date_ms']
|
72
|
+
@auto_renew_status_change_date_ms = Time.zone.at(attributes['auto_renew_status_change_date_ms'].to_i / 1000)
|
73
|
+
end
|
74
|
+
if attributes['auto_renew_status_change_date_pst']
|
75
|
+
@auto_renew_status_change_date_pst = DateTime.parse(attributes['auto_renew_status_change_date_pst'].gsub("America/Los_Angeles", "PST"))
|
76
|
+
end
|
77
|
+
|
45
78
|
@environment = attributes['environment']
|
46
|
-
@
|
47
|
-
@notification_type = attributes['notification_type']
|
79
|
+
@expiration_intent = attributes['expiration_intent']
|
48
80
|
|
49
|
-
|
50
|
-
|
51
|
-
end
|
81
|
+
@latest_receipt = attributes.dig('unified_receipt', 'latest_receipt')
|
82
|
+
@notification_type = attributes['notification_type']
|
52
83
|
|
53
|
-
|
54
|
-
latest_receipt_info = attributes['latest_receipt_info']
|
84
|
+
@password = attributes['password'] if attributes['password']
|
55
85
|
|
56
|
-
|
57
|
-
|
58
|
-
|
86
|
+
latest_receipt_info = []
|
87
|
+
case attributes.dig('unified_receipt', 'latest_receipt_info')
|
88
|
+
when Array
|
89
|
+
attributes.dig('unified_receipt', 'latest_receipt_info').each do |transaction_receipt_attributes|
|
90
|
+
latest_receipt_info << transaction_receipt_attributes
|
91
|
+
end
|
92
|
+
when Hash
|
93
|
+
latest_receipt_info << attributes.dig('unified_receipt', 'latest_receipt_info')
|
94
|
+
end
|
95
|
+
@renewal_info = []
|
96
|
+
attributes.dig('unified_receipt', 'pending_renewal_info')&.each do |renewal_info_attributes|
|
97
|
+
renewal_info << RenewalInfo.new(renewal_info_attributes)
|
59
98
|
end
|
60
99
|
|
100
|
+
latest_receipt_info = latest_receipt_info.first
|
101
|
+
|
61
102
|
@bundle_id = latest_receipt_info['bid']
|
62
103
|
@bvrs = latest_receipt_info['bvrs'].to_i
|
63
104
|
@item_id = latest_receipt_info['item_id'].to_i
|
@@ -66,10 +107,16 @@ module Monza
|
|
66
107
|
@original_transaction_id = latest_receipt_info['original_transaction_id']
|
67
108
|
@purchase_date = DateTime.parse(latest_receipt_info['purchase_date']) if latest_receipt_info['purchase_date']
|
68
109
|
@purchase_date_ms = Time.zone.at(latest_receipt_info['purchase_date_ms'].to_i / 1000)
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
110
|
+
if latest_receipt_info['purchase_date_pst']
|
111
|
+
@purchase_date_pst = date_for_pacific_time(latest_receipt_info['purchase_date_pst'])
|
112
|
+
end
|
113
|
+
if latest_receipt_info['original_purchase_date']
|
114
|
+
@original_purchase_date = DateTime.parse(latest_receipt_info['original_purchase_date'])
|
115
|
+
end
|
116
|
+
@original_purchase_date_ms = Time.zone.at(latest_receipt_info['original_purchase_date_ms'].to_i / 1000)
|
117
|
+
if latest_receipt_info['original_purchase_date_pst']
|
118
|
+
@original_purchase_date_pst = date_for_pacific_time(latest_receipt_info['original_purchase_date_pst'])
|
119
|
+
end
|
73
120
|
@web_order_line_item_id = latest_receipt_info['web_order_line_item_id']
|
74
121
|
@quantity = latest_receipt_info['quantity'].to_i
|
75
122
|
|
@@ -81,10 +128,14 @@ module Monza
|
|
81
128
|
@expires_date = DateTime.parse(latest_receipt_info['expires_date_formatted'])
|
82
129
|
end
|
83
130
|
if latest_receipt_info['expires_date']
|
84
|
-
@expires_date_ms =
|
131
|
+
@expires_date_ms = if latest_receipt_info['expires_date'].size == 13
|
132
|
+
Time.zone.at(latest_receipt_info['expires_date'].to_i / 1000)
|
133
|
+
else
|
134
|
+
DateTime.parse(latest_receipt_info['expires_date'])
|
135
|
+
end
|
85
136
|
end
|
86
137
|
if latest_receipt_info['expires_date_formatted_pst']
|
87
|
-
@expires_date_pst = date_for_pacific_time(latest_receipt_info['expires_date_formatted_pst'])
|
138
|
+
@expires_date_pst = date_for_pacific_time(latest_receipt_info['expires_date_formatted_pst'] || latest_receipt_info['expires_date_pst'])
|
88
139
|
end
|
89
140
|
if latest_receipt_info['is_in_intro_offer_period']
|
90
141
|
@is_in_intro_offer_period = latest_receipt_info['is_in_intro_offer_period'].to_bool
|
@@ -95,6 +146,22 @@ module Monza
|
|
95
146
|
if latest_receipt_info['cancellation_date']
|
96
147
|
@cancellation_date = DateTime.parse(latest_receipt_info['cancellation_date'])
|
97
148
|
end
|
149
|
+
|
150
|
+
@latest_receipt_info = []
|
151
|
+
case attributes.dig('unified_receipt', 'latest_receipt_info')
|
152
|
+
when Array
|
153
|
+
attributes.dig('unified_receipt', 'latest_receipt_info').each do |transaction_receipt_attributes|
|
154
|
+
@latest_receipt_info << TransactionReceipt.new(transaction_receipt_attributes)
|
155
|
+
end
|
156
|
+
when Hash
|
157
|
+
@latest_receipt_info << TransactionReceipt.new(attributes.dig('unified_receipt', 'latest_receipt_info'))
|
158
|
+
end
|
159
|
+
@renewal_info = []
|
160
|
+
if attributes.dig('unified_receipt', 'pending_renewal_info')
|
161
|
+
attributes.dig('unified_receipt', 'pending_renewal_info').each do |renewal_info_attributes|
|
162
|
+
@renewal_info << RenewalInfo.new(renewal_info_attributes)
|
163
|
+
end
|
164
|
+
end
|
98
165
|
end
|
99
166
|
|
100
167
|
def date_for_pacific_time pt
|
@@ -103,6 +170,41 @@ module Monza
|
|
103
170
|
ActiveSupport::TimeZone["Pacific Time (US & Canada)"].parse(pt).to_datetime
|
104
171
|
end
|
105
172
|
|
173
|
+
def cancel?
|
174
|
+
notification_type == Type::CANCEL
|
175
|
+
end
|
176
|
+
|
177
|
+
def did_change_renewal_pref?
|
178
|
+
notification_type == Type::DID_CHANGE_RENEWAL_PREF
|
179
|
+
end
|
180
|
+
|
181
|
+
def did_change_renewal_status?
|
182
|
+
notification_type == Type::DID_CHANGE_RENEWAL_STATUS
|
183
|
+
end
|
184
|
+
|
185
|
+
def did_fail_to_renew?
|
186
|
+
notification_type == Type::DID_FAIL_TO_RENEW
|
187
|
+
end
|
188
|
+
|
189
|
+
def did_recover?
|
190
|
+
notification_type == Type::DID_RECOVER
|
191
|
+
end
|
192
|
+
|
193
|
+
def initial_buy?
|
194
|
+
notification_type == Type::INITIAL_BUY
|
195
|
+
end
|
196
|
+
|
197
|
+
def interactive_renewal?
|
198
|
+
notification_type == Type::INTERACTIVE_RENEWAL
|
199
|
+
end
|
200
|
+
|
201
|
+
def renewal?
|
202
|
+
notification_type == Type::RENEWAL
|
203
|
+
end
|
204
|
+
|
205
|
+
def refund?
|
206
|
+
notification_type == Type::REFUND
|
207
|
+
end
|
106
208
|
end # class
|
107
209
|
end # module
|
108
210
|
|
@@ -112,29 +214,31 @@ end # module
|
|
112
214
|
# "auto_renew_product_id": "product_id.quarterly",
|
113
215
|
# "auto_renew_status": "true",
|
114
216
|
# "environment": "Sandbox",
|
217
|
+
# "unified_receipt": {
|
218
|
+
# "latest_receipt_info": {
|
219
|
+
# "bid": "co.bundle.id",
|
220
|
+
# "bvrs": "1004",
|
221
|
+
# "expires_date": "1521161603000",
|
222
|
+
# "expires_date_formatted": "2018-03-16 00:53:23 Etc/GMT",
|
223
|
+
# "expires_date_formatted_pst": "2018-03-15 17:53:23 America/Los_Angeles",
|
224
|
+
# "is_in_intro_offer_period": "false",
|
225
|
+
# "is_trial_period": "false",
|
226
|
+
# "item_id": "1359908036",
|
227
|
+
# "original_purchase_date": "2018-03-15 23:23:05 Etc/GMT",
|
228
|
+
# "original_purchase_date_ms": "1521156185000",
|
229
|
+
# "original_purchase_date_pst": "2018-03-15 16:23:05 America/Los_Angeles",
|
230
|
+
# "original_transaction_id": "1000000383185294",
|
231
|
+
# "product_id": "product_id.quarterly",
|
232
|
+
# "purchase_date": "2018-03-16 00:38:23 Etc/GMT",
|
233
|
+
# "purchase_date_ms": "1521160703000",
|
234
|
+
# "purchase_date_pst": "2018-03-15 17:38:23 America/Los_Angeles",
|
235
|
+
# "quantity": "1",
|
236
|
+
# "transaction_id": "1000000383189543",
|
237
|
+
# "unique_identifier": "3a142176fee52ba64ddc3ba3b685786bd58cb4fe",
|
238
|
+
# "unique_vendor_identifier": "D8E8B1EB-7A35-4E88-A21C-584E4FEB6543",
|
239
|
+
# "web_order_line_item_id": "1000000038128465"
|
240
|
+
# },
|
115
241
|
# "latest_receipt": "<base 64>",
|
116
|
-
# "latest_receipt_info": {
|
117
|
-
# "bid": "co.bundle.id",
|
118
|
-
# "bvrs": "1004",
|
119
|
-
# "expires_date": "1521161603000",
|
120
|
-
# "expires_date_formatted": "2018-03-16 00:53:23 Etc/GMT",
|
121
|
-
# "expires_date_formatted_pst": "2018-03-15 17:53:23 America/Los_Angeles",
|
122
|
-
# "is_in_intro_offer_period": "false",
|
123
|
-
# "is_trial_period": "false",
|
124
|
-
# "item_id": "1359908036",
|
125
|
-
# "original_purchase_date": "2018-03-15 23:23:05 Etc/GMT",
|
126
|
-
# "original_purchase_date_ms": "1521156185000",
|
127
|
-
# "original_purchase_date_pst": "2018-03-15 16:23:05 America/Los_Angeles",
|
128
|
-
# "original_transaction_id": "1000000383185294",
|
129
|
-
# "product_id": "product_id.quarterly",
|
130
|
-
# "purchase_date": "2018-03-16 00:38:23 Etc/GMT",
|
131
|
-
# "purchase_date_ms": "1521160703000",
|
132
|
-
# "purchase_date_pst": "2018-03-15 17:38:23 America/Los_Angeles",
|
133
|
-
# "quantity": "1",
|
134
|
-
# "transaction_id": "1000000383189543",
|
135
|
-
# "unique_identifier": "3a142176fee52ba64ddc3ba3b685786bd58cb4fe",
|
136
|
-
# "unique_vendor_identifier": "D8E8B1EB-7A35-4E88-A21C-584E4FEB6543",
|
137
|
-
# "web_order_line_item_id": "1000000038128465"
|
138
242
|
# },
|
139
243
|
# "notification_type": "RENEWAL",
|
140
244
|
# "password": "password"
|
@@ -3,6 +3,8 @@ require 'active_support/core_ext/time'
|
|
3
3
|
|
4
4
|
module Monza
|
5
5
|
class TransactionReceipt
|
6
|
+
using BoolTypecasting
|
7
|
+
|
6
8
|
# Receipt Fields Documentation
|
7
9
|
# https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ReceiptFields.html#//apple_ref/doc/uid/TP40010573-CH106-SW1
|
8
10
|
|
@@ -22,9 +24,15 @@ module Monza
|
|
22
24
|
attr_reader :expires_date_ms
|
23
25
|
attr_reader :expires_date_pst
|
24
26
|
attr_reader :is_trial_period
|
27
|
+
attr_reader :cancellation_reason
|
25
28
|
attr_reader :cancellation_date
|
29
|
+
attr_reader :cancellation_date_ms
|
30
|
+
attr_reader :cancellation_date_pst
|
31
|
+
attr_reader :is_in_intro_offer_period
|
32
|
+
attr_reader :original_attributes
|
26
33
|
|
27
34
|
def initialize(attributes)
|
35
|
+
@original_attributes = attributes
|
28
36
|
@quantity = attributes['quantity'].to_i
|
29
37
|
@product_id = attributes['product_id']
|
30
38
|
@transaction_id = attributes['transaction_id']
|
@@ -36,6 +44,10 @@ module Monza
|
|
36
44
|
@original_purchase_date_ms = Time.zone.at(attributes['original_purchase_date_ms'].to_i / 1000)
|
37
45
|
@original_purchase_date_pst = DateTime.parse(attributes['original_purchase_date_pst'].gsub("America/Los_Angeles","PST")) if attributes['original_purchase_date_pst']
|
38
46
|
@web_order_line_item_id = attributes['web_order_line_item_id']
|
47
|
+
@cancellation_reason = attributes['cancellation_reason'] if attributes['cancellation_reason']
|
48
|
+
@cancellation_date = DateTime.parse(attributes['cancellation_date']) if attributes['cancellation_date']
|
49
|
+
@cancellation_date_ms = Time.zone.at(attributes['cancellation_date_ms'].to_i / 1000) if attributes['cancellation_date_ms']
|
50
|
+
@cancellation_date_pst = DateTime.parse(attributes['cancellation_date_pst'].gsub("America/Los_Angeles","PST")) if attributes['cancellation_date_pst']
|
39
51
|
|
40
52
|
if attributes['expires_date']
|
41
53
|
begin
|
@@ -57,8 +69,8 @@ module Monza
|
|
57
69
|
if attributes['is_trial_period']
|
58
70
|
@is_trial_period = attributes['is_trial_period'].to_bool
|
59
71
|
end
|
60
|
-
if attributes['
|
61
|
-
@
|
72
|
+
if attributes['is_in_intro_offer_period']
|
73
|
+
@is_in_intro_offer_period = attributes['is_in_intro_offer_period'].to_bool
|
62
74
|
end
|
63
75
|
end # end initialize
|
64
76
|
|
@@ -19,13 +19,16 @@ module Monza
|
|
19
19
|
@environment = attributes['environment']
|
20
20
|
@receipt = Receipt.new(attributes['receipt'])
|
21
21
|
@latest_receipt_info = []
|
22
|
-
|
22
|
+
|
23
|
+
latest_receipt_info = attributes['latest_receipt_info'] || attributes.dig('unified_receipt', 'latest_receipt_info')
|
24
|
+
|
25
|
+
case latest_receipt_info
|
23
26
|
when Array
|
24
|
-
|
27
|
+
latest_receipt_info.each do |transaction_receipt_attributes|
|
25
28
|
@latest_receipt_info << TransactionReceipt.new(transaction_receipt_attributes)
|
26
29
|
end
|
27
30
|
when Hash
|
28
|
-
@latest_receipt_info << TransactionReceipt.new(
|
31
|
+
@latest_receipt_info << TransactionReceipt.new(latest_receipt_info)
|
29
32
|
end
|
30
33
|
@renewal_info = []
|
31
34
|
if attributes['pending_renewal_info']
|
@@ -33,34 +36,23 @@ module Monza
|
|
33
36
|
@renewal_info << RenewalInfo.new(renewal_info_attributes)
|
34
37
|
end
|
35
38
|
end
|
36
|
-
@latest_receipt = attributes['latest_receipt']
|
39
|
+
@latest_receipt = attributes['latest_receipt'] || attributes.dig('unified_receipt', 'latest_receipt')
|
37
40
|
end
|
38
41
|
|
39
42
|
def is_subscription_active?
|
40
|
-
|
41
|
-
if @latest_receipt_info.last.cancellation_date
|
42
|
-
false
|
43
|
-
else
|
44
|
-
@latest_receipt_info.last.expires_date_ms >= Time.zone.now
|
45
|
-
end
|
46
|
-
else
|
47
|
-
false
|
48
|
-
end
|
43
|
+
latest_active_transaction_receipt.present?
|
49
44
|
end
|
50
45
|
|
46
|
+
# Deprecated, only left here for backwards compatibility, please use is_subscription_active?
|
51
47
|
def is_any_subscription_active?
|
52
|
-
|
53
|
-
latest_expires_date_ms = expires_dates_ms.max
|
54
|
-
|
55
|
-
if latest_expires_date_ms
|
56
|
-
latest_expires_date_ms >= Time.zone.now
|
57
|
-
else
|
58
|
-
false
|
59
|
-
end
|
48
|
+
is_subscription_active?
|
60
49
|
end
|
61
50
|
|
62
51
|
def latest_active_transaction_receipt
|
63
|
-
latest_active_sub = @latest_receipt_info
|
52
|
+
latest_active_sub = @latest_receipt_info
|
53
|
+
.reject(&:cancellation_date)
|
54
|
+
.select(&:expires_date_ms)
|
55
|
+
.max_by(&:expires_date_ms)
|
64
56
|
|
65
57
|
if latest_active_sub && latest_active_sub.expires_date_ms >= Time.zone.now
|
66
58
|
return latest_active_sub
|
data/lib/monza/version.rb
CHANGED
data/monza.gemspec
CHANGED
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.add_dependency "json"
|
31
31
|
spec.add_dependency "activesupport"
|
32
32
|
|
33
|
-
spec.add_development_dependency "bundler", "~> 1
|
33
|
+
spec.add_development_dependency "bundler", "~> 2.1"
|
34
34
|
spec.add_development_dependency "rake", "~> 10.0"
|
35
35
|
spec.add_development_dependency "rspec"
|
36
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monza
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Garza
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1
|
47
|
+
version: '2.1'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1
|
54
|
+
version: '2.1'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|