monza 1.3.3 → 1.3.8
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 +5 -5
- data/README.md +0 -8
- data/lib/monza/renewal_info.rb +13 -1
- data/lib/monza/transaction_receipt.rb +4 -0
- data/lib/monza/verification_response.rb +7 -18
- data/lib/monza/version.rb +3 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fac0efa28ee221749882e9916647707b5bc971b4e69d2130b060fe4edae76116
|
4
|
+
data.tar.gz: c868069c62c1d57b6e1342c7461913f098784ef78fa4a0ee49918154b8ce996e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb65d134815099da534f82ca3209b5a5c829ba911b5b6c51e9fb8b0b9d8eea6fbb42229342a2071726fa99380848d9b7523c5abea1218fb5ba57ac69d39ebbf3
|
7
|
+
data.tar.gz: bfb32460c257fc67f167faaedeba680b9045f6fa9b4a67be10418739536ea181956c5005a08c7f923fa649949644ad9f3fedecb2f4fed983522c783f99c3bcdf
|
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
|
|
@@ -188,9 +183,6 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
188
183
|
|
189
184
|
Bug reports and pull requests are welcome on GitHub at https://github.com/gabrielgarza/monza. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
190
185
|
|
191
|
-
TODO:
|
192
|
-
- Need help with testing using rspec
|
193
|
-
|
194
186
|
|
195
187
|
## License
|
196
188
|
|
data/lib/monza/renewal_info.rb
CHANGED
@@ -9,6 +9,9 @@ module Monza
|
|
9
9
|
attr_reader :original_transaction_id
|
10
10
|
attr_reader :is_in_billing_retry_period
|
11
11
|
attr_reader :will_renew
|
12
|
+
attr_reader :grace_period_expires_date
|
13
|
+
attr_reader :grace_period_expires_date_ms
|
14
|
+
attr_reader :grace_period_expires_date_pst
|
12
15
|
|
13
16
|
def initialize(attributes)
|
14
17
|
|
@@ -16,6 +19,15 @@ module Monza
|
|
16
19
|
@auto_renew_product_id = attributes['auto_renew_product_id']
|
17
20
|
@original_transaction_id = attributes['original_transaction_id']
|
18
21
|
|
22
|
+
if attributes['grace_period_expires_date']
|
23
|
+
@grace_period_expires_date = DateTime.parse(attributes['grace_period_expires_date'])
|
24
|
+
end
|
25
|
+
if attributes['grace_period_expires_date_ms']
|
26
|
+
@grace_period_expires_date_ms = Time.zone.at(attributes['grace_period_expires_date_ms'].to_i / 1000)
|
27
|
+
end
|
28
|
+
if attributes['grace_period_expires_date_pst']
|
29
|
+
@grace_period_expires_date_pst = DateTime.parse(attributes['grace_period_expires_date_pst'].gsub("America/Los_Angeles","PST"))
|
30
|
+
end
|
19
31
|
if attributes['expiration_intent']
|
20
32
|
@expiration_intent = attributes['expiration_intent']
|
21
33
|
end
|
@@ -25,7 +37,7 @@ module Monza
|
|
25
37
|
end
|
26
38
|
|
27
39
|
if attributes['auto_renew_status']
|
28
|
-
@will_renew = attributes['auto_renew_status'].to_bool
|
40
|
+
@will_renew = attributes['auto_renew_status'].to_bool
|
29
41
|
end
|
30
42
|
end # end initialize
|
31
43
|
|
@@ -23,6 +23,7 @@ module Monza
|
|
23
23
|
attr_reader :expires_date_pst
|
24
24
|
attr_reader :is_trial_period
|
25
25
|
attr_reader :cancellation_date
|
26
|
+
attr_reader :is_in_intro_offer_period
|
26
27
|
|
27
28
|
def initialize(attributes)
|
28
29
|
@quantity = attributes['quantity'].to_i
|
@@ -57,6 +58,9 @@ module Monza
|
|
57
58
|
if attributes['is_trial_period']
|
58
59
|
@is_trial_period = attributes['is_trial_period'].to_bool
|
59
60
|
end
|
61
|
+
if attributes['is_in_intro_offer_period']
|
62
|
+
@is_in_intro_offer_period = attributes['is_in_intro_offer_period'].to_bool
|
63
|
+
end
|
60
64
|
if attributes['cancellation_date']
|
61
65
|
@cancellation_date = DateTime.parse(attributes['cancellation_date'])
|
62
66
|
end
|
@@ -37,30 +37,19 @@ module Monza
|
|
37
37
|
end
|
38
38
|
|
39
39
|
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
|
40
|
+
latest_active_transaction_receipt.present?
|
49
41
|
end
|
50
42
|
|
43
|
+
# Deprecated, only left here for backwards compatibility, please use is_subscription_active?
|
51
44
|
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
|
45
|
+
is_subscription_active?
|
60
46
|
end
|
61
47
|
|
62
48
|
def latest_active_transaction_receipt
|
63
|
-
latest_active_sub = @latest_receipt_info
|
49
|
+
latest_active_sub = @latest_receipt_info
|
50
|
+
.reject(&:cancellation_date)
|
51
|
+
.select(&:expires_date_ms)
|
52
|
+
.max_by(&:expires_date_ms)
|
64
53
|
|
65
54
|
if latest_active_sub && latest_active_sub.expires_date_ms >= Time.zone.now
|
66
55
|
return latest_active_sub
|
data/lib/monza/version.rb
CHANGED
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.3.
|
4
|
+
version: 1.3.8
|
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: 2020-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -128,8 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
128
|
- !ruby/object:Gem::Version
|
129
129
|
version: '0'
|
130
130
|
requirements: []
|
131
|
-
|
132
|
-
rubygems_version: 2.5.2.3
|
131
|
+
rubygems_version: 3.0.3
|
133
132
|
signing_key:
|
134
133
|
specification_version: 4
|
135
134
|
summary: Validate iTunes In-App purchase receipts, including auto-renewable subscriptions,
|