monza 1.3.9 → 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/lib/monza/status_response.rb +58 -41
- data/lib/monza/verification_response.rb +7 -4
- data/lib/monza/version.rb +1 -1
- metadata +2 -2
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
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'time'
|
3
4
|
|
4
5
|
module Monza
|
@@ -7,7 +8,7 @@ module Monza
|
|
7
8
|
|
8
9
|
# https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html
|
9
10
|
# https://developer.apple.com/documentation/appstoreservernotifications/responsebody
|
10
|
-
module Type
|
11
|
+
module Type
|
11
12
|
CANCEL = 'CANCEL'
|
12
13
|
DID_CHANGE_RENEWAL_PREF = 'DID_CHANGE_RENEWAL_PREF'
|
13
14
|
DID_CHANGE_RENEWAL_STATUS = 'DID_CHANGE_RENEWAL_STATUS'
|
@@ -19,7 +20,6 @@ module Monza
|
|
19
20
|
REFUND = 'REFUND'
|
20
21
|
end
|
21
22
|
|
22
|
-
|
23
23
|
attr_reader :auto_renew_product_id
|
24
24
|
attr_reader :auto_renew_status
|
25
25
|
attr_reader :auto_renew_status_change_date
|
@@ -78,21 +78,27 @@ module Monza
|
|
78
78
|
@environment = attributes['environment']
|
79
79
|
@expiration_intent = attributes['expiration_intent']
|
80
80
|
|
81
|
-
@latest_receipt = attributes
|
81
|
+
@latest_receipt = attributes.dig('unified_receipt', 'latest_receipt')
|
82
82
|
@notification_type = attributes['notification_type']
|
83
83
|
|
84
|
-
if attributes['password']
|
85
|
-
@password = attributes['password']
|
86
|
-
end
|
87
|
-
|
88
|
-
# There'll only be one latest receipt info, so lets just flatten it out here
|
89
|
-
latest_receipt_info = attributes['latest_receipt_info']
|
84
|
+
@password = attributes['password'] if attributes['password']
|
90
85
|
|
91
|
-
|
92
|
-
|
93
|
-
|
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)
|
94
98
|
end
|
95
99
|
|
100
|
+
latest_receipt_info = latest_receipt_info.first
|
101
|
+
|
96
102
|
@bundle_id = latest_receipt_info['bid']
|
97
103
|
@bvrs = latest_receipt_info['bvrs'].to_i
|
98
104
|
@item_id = latest_receipt_info['item_id'].to_i
|
@@ -101,10 +107,16 @@ module Monza
|
|
101
107
|
@original_transaction_id = latest_receipt_info['original_transaction_id']
|
102
108
|
@purchase_date = DateTime.parse(latest_receipt_info['purchase_date']) if latest_receipt_info['purchase_date']
|
103
109
|
@purchase_date_ms = Time.zone.at(latest_receipt_info['purchase_date_ms'].to_i / 1000)
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
108
120
|
@web_order_line_item_id = latest_receipt_info['web_order_line_item_id']
|
109
121
|
@quantity = latest_receipt_info['quantity'].to_i
|
110
122
|
|
@@ -116,10 +128,14 @@ module Monza
|
|
116
128
|
@expires_date = DateTime.parse(latest_receipt_info['expires_date_formatted'])
|
117
129
|
end
|
118
130
|
if latest_receipt_info['expires_date']
|
119
|
-
@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
|
120
136
|
end
|
121
137
|
if latest_receipt_info['expires_date_formatted_pst']
|
122
|
-
@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'])
|
123
139
|
end
|
124
140
|
if latest_receipt_info['is_in_intro_offer_period']
|
125
141
|
@is_in_intro_offer_period = latest_receipt_info['is_in_intro_offer_period'].to_bool
|
@@ -189,7 +205,6 @@ module Monza
|
|
189
205
|
def refund?
|
190
206
|
notification_type == Type::REFUND
|
191
207
|
end
|
192
|
-
|
193
208
|
end # class
|
194
209
|
end # module
|
195
210
|
|
@@ -199,29 +214,31 @@ end # module
|
|
199
214
|
# "auto_renew_product_id": "product_id.quarterly",
|
200
215
|
# "auto_renew_status": "true",
|
201
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
|
+
# },
|
202
241
|
# "latest_receipt": "<base 64>",
|
203
|
-
# "latest_receipt_info": {
|
204
|
-
# "bid": "co.bundle.id",
|
205
|
-
# "bvrs": "1004",
|
206
|
-
# "expires_date": "1521161603000",
|
207
|
-
# "expires_date_formatted": "2018-03-16 00:53:23 Etc/GMT",
|
208
|
-
# "expires_date_formatted_pst": "2018-03-15 17:53:23 America/Los_Angeles",
|
209
|
-
# "is_in_intro_offer_period": "false",
|
210
|
-
# "is_trial_period": "false",
|
211
|
-
# "item_id": "1359908036",
|
212
|
-
# "original_purchase_date": "2018-03-15 23:23:05 Etc/GMT",
|
213
|
-
# "original_purchase_date_ms": "1521156185000",
|
214
|
-
# "original_purchase_date_pst": "2018-03-15 16:23:05 America/Los_Angeles",
|
215
|
-
# "original_transaction_id": "1000000383185294",
|
216
|
-
# "product_id": "product_id.quarterly",
|
217
|
-
# "purchase_date": "2018-03-16 00:38:23 Etc/GMT",
|
218
|
-
# "purchase_date_ms": "1521160703000",
|
219
|
-
# "purchase_date_pst": "2018-03-15 17:38:23 America/Los_Angeles",
|
220
|
-
# "quantity": "1",
|
221
|
-
# "transaction_id": "1000000383189543",
|
222
|
-
# "unique_identifier": "3a142176fee52ba64ddc3ba3b685786bd58cb4fe",
|
223
|
-
# "unique_vendor_identifier": "D8E8B1EB-7A35-4E88-A21C-584E4FEB6543",
|
224
|
-
# "web_order_line_item_id": "1000000038128465"
|
225
242
|
# },
|
226
243
|
# "notification_type": "RENEWAL",
|
227
244
|
# "password": "password"
|
@@ -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,7 +36,7 @@ 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?
|
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.
|
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
|