monza 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +110 -4
- data/lib/monza/client.rb +2 -68
- data/lib/monza/transaction_receipt.rb +2 -2
- data/lib/monza/verification_response.rb +2 -2
- data/lib/monza/version.rb +1 -1
- data/monza.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fa36dc467fdcd4797100c38bc33e1e73e4943a5
|
4
|
+
data.tar.gz: 40848a3dc7e1ff71077a145a3fc237f642d16af0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae687422e035e2d0521527a0e58801d20b0668cba34add4df3b19173733c107a968f9effd243d0c386acefd1e62b44d28b09a3659df9baa8b401dc3c885aba22
|
7
|
+
data.tar.gz: ca1fa5580c50e1416004a4f68ddb06bca3ddd6f588eb3636176041c8a52419cb082affd8f37a9aa3862bfb36a1129a551c84a7a49e4d9e7a2aaa9b3f43072658
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Monza
|
2
2
|
|
3
|
-
Monza is a ruby gem that makes App Store in app purchase receipt validation and auto-renewable subscription validation easy.
|
3
|
+
Monza is a ruby gem that makes iTunes App Store in app purchase receipt validation and auto-renewable subscription validation easy.
|
4
4
|
|
5
5
|
You should always validate receipts on the server, in [Apple's words] (https://developer.apple.com/library/ios/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateRemotely.html#//apple_ref/doc/uid/TP40010573-CH104-SW1):
|
6
6
|
> Use a trusted server to communicate with the App Store. Using your own server lets you design your app to recognize and trust only your server, and lets you ensure that your server connects with the App Store server. It is not possible to build a trusted connection between a user’s device and the App Store directly because you don’t control either end of that connection.
|
@@ -23,20 +23,29 @@ Or install it yourself as:
|
|
23
23
|
|
24
24
|
## Usage
|
25
25
|
|
26
|
-
Basic Usage:
|
26
|
+
##### Basic Usage:
|
27
27
|
```ruby
|
28
28
|
|
29
29
|
data = "base64 receipt data string"
|
30
30
|
options = { shared_secret: "your shared secret" }
|
31
31
|
response = Monza::Receipt.verify(data, options)
|
32
32
|
|
33
|
+
```
|
34
|
+
|
35
|
+
##### Useful Methods
|
36
|
+
```ruby
|
33
37
|
# Check if subscription is active
|
34
38
|
# this checks if latest transaction receipt expiry_date is in today or the future
|
35
39
|
response.is_subscription_active? # => true or false
|
36
40
|
|
37
41
|
# Check most recent expiry date
|
38
|
-
|
42
|
+
# DateTime
|
43
|
+
response.latest_expiry_date # => Fri, 17 Jun 2016 01:57:28 +0000
|
39
44
|
|
45
|
+
```
|
46
|
+
|
47
|
+
##### Response Objects
|
48
|
+
```ruby
|
40
49
|
# Receipt object
|
41
50
|
# See Receipt class
|
42
51
|
response.receipt
|
@@ -47,11 +56,108 @@ response.receipt.in_app
|
|
47
56
|
|
48
57
|
# Receipt Latest Transactions List, use these instead if in_app to ensure you always have the latest
|
49
58
|
# Returns array of TransactionReceipt objects, see TransactionReceipt class
|
50
|
-
response.latest_receipt_info
|
59
|
+
response.latest_receipt_info # => Array of TransactionReceipt objects
|
60
|
+
|
61
|
+
# Expires date of a transaction
|
62
|
+
# DateTime
|
63
|
+
response.latest_receipt_info.last.expires_date => # Fri, 17 Jun 2016 01:57:28 +0000
|
64
|
+
|
65
|
+
# Check if latest transaction was trial period
|
66
|
+
response.latest_receipt_info.last.is_trial_period # => true or false
|
51
67
|
|
52
68
|
# Latest receipt base64 string
|
53
69
|
response.latest_receipt
|
54
70
|
|
71
|
+
```
|
72
|
+
|
73
|
+
##### Sample JSON Response Schema
|
74
|
+
```json
|
75
|
+
|
76
|
+
{
|
77
|
+
"status": 0,
|
78
|
+
"environment": "Sandbox",
|
79
|
+
"receipt": {
|
80
|
+
"receipt_type": "ProductionSandbox",
|
81
|
+
"adam_id": 0,
|
82
|
+
"app_item_id": 0,
|
83
|
+
"bundle_id": "your_product_id",
|
84
|
+
"application_version": "58",
|
85
|
+
"download_id": 0,
|
86
|
+
"version_external_identifier": 0,
|
87
|
+
"receipt_creation_date": "2016-06-17 01:54:26 Etc/GMT",
|
88
|
+
"receipt_creation_date_ms": "1466128466000",
|
89
|
+
"receipt_creation_date_pst": "2016-06-16 18:54:26 America/Los_Angeles",
|
90
|
+
"request_date": "2016-06-17 17:34:41 Etc/GMT",
|
91
|
+
"request_date_ms": "1466184881174",
|
92
|
+
"request_date_pst": "2016-06-17 10:34:41 America/Los_Angeles",
|
93
|
+
"original_purchase_date": "2013-08-01 07:00:00 Etc/GMT",
|
94
|
+
"original_purchase_date_ms": "1375340400000",
|
95
|
+
"original_purchase_date_pst": "2013-08-01 00:00:00 America/Los_Angeles",
|
96
|
+
"original_application_version": "1.0",
|
97
|
+
"in_app": [
|
98
|
+
{
|
99
|
+
"quantity": "1",
|
100
|
+
"product_id": "product_id",
|
101
|
+
"transaction_id": "1000000218147651",
|
102
|
+
"original_transaction_id": "1000000218147500",
|
103
|
+
"purchase_date": "2016-06-17 01:32:28 Etc/GMT",
|
104
|
+
"purchase_date_ms": "1466127148000",
|
105
|
+
"purchase_date_pst": "2016-06-16 18:32:28 America/Los_Angeles",
|
106
|
+
"original_purchase_date": "2016-06-17 01:30:33 Etc/GMT",
|
107
|
+
"original_purchase_date_ms": "1466127033000",
|
108
|
+
"original_purchase_date_pst": "2016-06-16 18:30:33 America/Los_Angeles",
|
109
|
+
"expires_date": "2016-06-17 01:37:28 Etc/GMT",
|
110
|
+
"expires_date_ms": "1466127448000",
|
111
|
+
"expires_date_pst": "2016-06-16 18:37:28 America/Los_Angeles",
|
112
|
+
"web_order_line_item_id": "1000000032727764",
|
113
|
+
"is_trial_period": "false"
|
114
|
+
}
|
115
|
+
]
|
116
|
+
},
|
117
|
+
"latest_receipt_info": [
|
118
|
+
{
|
119
|
+
"quantity": "1",
|
120
|
+
"product_id": "product_id",
|
121
|
+
"transaction_id": "1000000218147500",
|
122
|
+
"original_transaction_id": "1000000218147500",
|
123
|
+
"purchase_date": "2016-06-17 01:27:28 Etc/GMT",
|
124
|
+
"purchase_date_ms": "1466126848000",
|
125
|
+
"purchase_date_pst": "2016-06-16 18:27:28 America/Los_Angeles",
|
126
|
+
"original_purchase_date": "2016-06-17 01:27:28 Etc/GMT",
|
127
|
+
"original_purchase_date_ms": "1466126848000",
|
128
|
+
"original_purchase_date_pst": "2016-06-16 18:27:28 America/Los_Angeles",
|
129
|
+
"expires_date": "2016-06-17 01:32:28 Etc/GMT",
|
130
|
+
"expires_date_ms": "1466127148000",
|
131
|
+
"expires_date_pst": "2016-06-16 18:32:28 America/Los_Angeles",
|
132
|
+
"web_order_line_item_id": "1000000032727765",
|
133
|
+
"is_trial_period": "true"
|
134
|
+
}
|
135
|
+
],
|
136
|
+
"latest_receipt": "base 64 string"
|
137
|
+
}
|
138
|
+
|
139
|
+
```
|
140
|
+
|
141
|
+
##### TransactionReceipt Object
|
142
|
+
An array TransactionReceipt objects will come inside the `receipt.in_app` and `latest_receipt_info` keys of the `response`
|
143
|
+
```json
|
144
|
+
{
|
145
|
+
"quantity": "1",
|
146
|
+
"product_id": "product_id",
|
147
|
+
"transaction_id": "1000000218147500",
|
148
|
+
"original_transaction_id": "1000000218147500",
|
149
|
+
"purchase_date": "2016-06-17 01:27:28 Etc/GMT",
|
150
|
+
"purchase_date_ms": "1466126848000",
|
151
|
+
"purchase_date_pst": "2016-06-16 18:27:28 America/Los_Angeles",
|
152
|
+
"original_purchase_date": "2016-06-17 01:27:28 Etc/GMT",
|
153
|
+
"original_purchase_date_ms": "1466126848000",
|
154
|
+
"original_purchase_date_pst": "2016-06-16 18:27:28 America/Los_Angeles",
|
155
|
+
"expires_date": "2016-06-17 01:32:28 Etc/GMT",
|
156
|
+
"expires_date_ms": "1466127148000",
|
157
|
+
"expires_date_pst": "2016-06-16 18:32:28 America/Los_Angeles",
|
158
|
+
"web_order_line_item_id": "1000000032727765",
|
159
|
+
"is_trial_period": "true"
|
160
|
+
}
|
55
161
|
|
56
162
|
```
|
57
163
|
|
data/lib/monza/client.rb
CHANGED
@@ -12,13 +12,13 @@ module Monza
|
|
12
12
|
|
13
13
|
def self.development
|
14
14
|
client = self.new
|
15
|
-
client.verification_url =
|
15
|
+
client.verification_url = DEVELOPMENT_URL
|
16
16
|
client
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.production
|
20
20
|
client = self.new
|
21
|
-
client.verification_url =
|
21
|
+
client.verification_url = PRODUCTION_URL
|
22
22
|
client
|
23
23
|
end
|
24
24
|
|
@@ -66,69 +66,3 @@ module Monza
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
|
-
|
70
|
-
|
71
|
-
# Sample JSON Response
|
72
|
-
#
|
73
|
-
# {
|
74
|
-
# "status": 0,
|
75
|
-
# "environment": "Sandbox",
|
76
|
-
# "receipt": {
|
77
|
-
# "receipt_type": "ProductionSandbox",
|
78
|
-
# "adam_id": 0,
|
79
|
-
# "app_item_id": 0,
|
80
|
-
# "bundle_id": "your_product_id",
|
81
|
-
# "application_version": "58",
|
82
|
-
# "download_id": 0,
|
83
|
-
# "version_external_identifier": 0,
|
84
|
-
# "receipt_creation_date": "2016-06-17 01:54:26 Etc/GMT",
|
85
|
-
# "receipt_creation_date_ms": "1466128466000",
|
86
|
-
# "receipt_creation_date_pst": "2016-06-16 18:54:26 America/Los_Angeles",
|
87
|
-
# "request_date": "2016-06-17 17:34:41 Etc/GMT",
|
88
|
-
# "request_date_ms": "1466184881174",
|
89
|
-
# "request_date_pst": "2016-06-17 10:34:41 America/Los_Angeles",
|
90
|
-
# "original_purchase_date": "2013-08-01 07:00:00 Etc/GMT",
|
91
|
-
# "original_purchase_date_ms": "1375340400000",
|
92
|
-
# "original_purchase_date_pst": "2013-08-01 00:00:00 America/Los_Angeles",
|
93
|
-
# "original_application_version": "1.0",
|
94
|
-
# "in_app": [
|
95
|
-
# {
|
96
|
-
# "quantity": "1",
|
97
|
-
# "product_id": "com.everlance.everlance.pro.monthly.test",
|
98
|
-
# "transaction_id": "1000000218147651",
|
99
|
-
# "original_transaction_id": "1000000218147500",
|
100
|
-
# "purchase_date": "2016-06-17 01:32:28 Etc/GMT",
|
101
|
-
# "purchase_date_ms": "1466127148000",
|
102
|
-
# "purchase_date_pst": "2016-06-16 18:32:28 America/Los_Angeles",
|
103
|
-
# "original_purchase_date": "2016-06-17 01:30:33 Etc/GMT",
|
104
|
-
# "original_purchase_date_ms": "1466127033000",
|
105
|
-
# "original_purchase_date_pst": "2016-06-16 18:30:33 America/Los_Angeles",
|
106
|
-
# "expires_date": "2016-06-17 01:37:28 Etc/GMT",
|
107
|
-
# "expires_date_ms": "1466127448000",
|
108
|
-
# "expires_date_pst": "2016-06-16 18:37:28 America/Los_Angeles",
|
109
|
-
# "web_order_line_item_id": "1000000032727764",
|
110
|
-
# "is_trial_period": "false"
|
111
|
-
# }
|
112
|
-
# ]
|
113
|
-
# },
|
114
|
-
# "latest_receipt_info": [
|
115
|
-
# {
|
116
|
-
# "quantity": "1",
|
117
|
-
# "product_id": "com.everlance.everlance.pro.monthly.test",
|
118
|
-
# "transaction_id": "1000000218147500",
|
119
|
-
# "original_transaction_id": "1000000218147500",
|
120
|
-
# "purchase_date": "2016-06-17 01:27:28 Etc/GMT",
|
121
|
-
# "purchase_date_ms": "1466126848000",
|
122
|
-
# "purchase_date_pst": "2016-06-16 18:27:28 America/Los_Angeles",
|
123
|
-
# "original_purchase_date": "2016-06-17 01:27:28 Etc/GMT",
|
124
|
-
# "original_purchase_date_ms": "1466126848000",
|
125
|
-
# "original_purchase_date_pst": "2016-06-16 18:27:28 America/Los_Angeles",
|
126
|
-
# "expires_date": "2016-06-17 01:32:28 Etc/GMT",
|
127
|
-
# "expires_date_ms": "1466127148000",
|
128
|
-
# "expires_date_pst": "2016-06-16 18:32:28 America/Los_Angeles",
|
129
|
-
# "web_order_line_item_id": "1000000032727765",
|
130
|
-
# "is_trial_period": "true"
|
131
|
-
# }
|
132
|
-
# ],
|
133
|
-
# "latest_receipt": "base 64"
|
134
|
-
# }
|
@@ -45,7 +45,7 @@ module Monza
|
|
45
45
|
@expires_date_pst = DateTime.parse(attributes['expires_date_pst'])
|
46
46
|
end
|
47
47
|
if attributes['is_trial_period']
|
48
|
-
@is_trial_period = attributes['is_trial_period']
|
48
|
+
@is_trial_period = attributes['is_trial_period'].to_bool
|
49
49
|
end
|
50
50
|
end # end initialize
|
51
51
|
|
@@ -66,7 +66,7 @@ end # end module
|
|
66
66
|
#
|
67
67
|
# {
|
68
68
|
# "quantity": "1",
|
69
|
-
# "product_id": "
|
69
|
+
# "product_id": "product_id",
|
70
70
|
# "transaction_id": "1000000218147651",
|
71
71
|
# "original_transaction_id": "1000000218147500",
|
72
72
|
# "purchase_date": "2016-06-17 01:32:28 Etc/GMT",
|
@@ -97,7 +97,7 @@ end # module
|
|
97
97
|
# "in_app": [
|
98
98
|
# {
|
99
99
|
# "quantity": "1",
|
100
|
-
# "product_id": "
|
100
|
+
# "product_id": "product_id",
|
101
101
|
# "transaction_id": "1000000218147651",
|
102
102
|
# "original_transaction_id": "1000000218147500",
|
103
103
|
# "purchase_date": "2016-06-17 01:32:28 Etc/GMT",
|
@@ -117,7 +117,7 @@ end # module
|
|
117
117
|
# "latest_receipt_info": [
|
118
118
|
# {
|
119
119
|
# "quantity": "1",
|
120
|
-
# "product_id": "
|
120
|
+
# "product_id": "product_id",
|
121
121
|
# "transaction_id": "1000000218147500",
|
122
122
|
# "original_transaction_id": "1000000218147500",
|
123
123
|
# "purchase_date": "2016-06-17 01:27:28 Etc/GMT",
|
data/lib/monza/version.rb
CHANGED
data/monza.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ["Gabriel Garza"]
|
10
10
|
spec.email = ["garzagabriel@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary = %q{Validate In-App purchase receipts, including auto-renewable subscriptions, with the App Store.}
|
13
|
-
spec.description = %q{Validate In-App purchase receipts, including auto-renewable subscriptions, with the App Store.}
|
12
|
+
spec.summary = %q{Validate iTunes In-App purchase receipts, including auto-renewable subscriptions, with the App Store.}
|
13
|
+
spec.description = %q{Validate iTunes In-App purchase receipts, including auto-renewable subscriptions, with the App Store.}
|
14
14
|
spec.homepage = "https://github.com/gabrielgarza/monza"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
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: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Garza
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description: Validate In-App purchase receipts, including auto-renewable subscriptions,
|
69
|
+
description: Validate iTunes In-App purchase receipts, including auto-renewable subscriptions,
|
70
70
|
with the App Store.
|
71
71
|
email:
|
72
72
|
- garzagabriel@gmail.com
|
@@ -114,6 +114,6 @@ rubyforge_project:
|
|
114
114
|
rubygems_version: 2.4.6
|
115
115
|
signing_key:
|
116
116
|
specification_version: 4
|
117
|
-
summary: Validate In-App purchase receipts, including auto-renewable subscriptions,
|
117
|
+
summary: Validate iTunes In-App purchase receipts, including auto-renewable subscriptions,
|
118
118
|
with the App Store.
|
119
119
|
test_files: []
|