itunes-receipt 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +1 -1
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/lib/itunes/receipt.rb +16 -1
- data/spec/fake_json/valid_application.json +38 -0
- data/spec/itunes/receipt_spec.rb +57 -0
- metadata +25 -47
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a56aa2df0293a47cd466a461d92e0549fe556dac
|
4
|
+
data.tar.gz: 2e17d9e6fc166fbbc768eabdf6ae54fedf3d4cb3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 505a4bab9cdf6a84e7e47ff2fc2181078cdec24f38ca17adb87d91a7b34aa41e8c90a67e4ce8c68bfe801bb371c3887523c3db273764e4fa56c342a3f0f2b94b
|
7
|
+
data.tar.gz: f213f409d049054afec8f03696614fc9e08d18926a5607561a2ea29b7e83e03bec68c81cdfca9611765ec1be694dff2df66dc447b9974e5f85805522f091a44a
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/lib/itunes/receipt.rb
CHANGED
@@ -25,6 +25,8 @@ module Itunes
|
|
25
25
|
# expires_date, receipt_data, and latest (receipt) will only appear for autorenew subscription products
|
26
26
|
attr_reader :quantity, :product_id, :transaction_id, :purchase_date, :app_item_id, :version_external_identifier, :bid, :bvrs, :original, :expires_date, :receipt_data, :latest, :itunes_env
|
27
27
|
|
28
|
+
attr_reader :bundle_id, :application_version, :in_app
|
29
|
+
|
28
30
|
def initialize(attributes = {})
|
29
31
|
receipt_attributes = attributes.with_indifferent_access[:receipt]
|
30
32
|
if receipt_attributes[:quantity]
|
@@ -42,10 +44,18 @@ module Itunes
|
|
42
44
|
if receipt_attributes[:original_transaction_id] || receipt_attributes[:original_purchase_date]
|
43
45
|
@original = self.class.new(:receipt => {
|
44
46
|
:transaction_id => receipt_attributes[:original_transaction_id],
|
45
|
-
:purchase_date => receipt_attributes[:original_purchase_date]
|
47
|
+
:purchase_date => receipt_attributes[:original_purchase_date],
|
48
|
+
:application_version => receipt_attributes[:original_application_version]
|
46
49
|
})
|
47
50
|
end
|
48
51
|
|
52
|
+
@bundle_id = receipt_attributes[:bundle_id]
|
53
|
+
@application_version = receipt_attributes[:application_version]
|
54
|
+
|
55
|
+
if receipt_attributes[:in_app]
|
56
|
+
@in_app = receipt_attributes[:in_app].map { |ia| self.class.new(:receipt => ia) }
|
57
|
+
end
|
58
|
+
|
49
59
|
# autorenew subscription handling
|
50
60
|
# attributes[:latest_receipt_info] and attributes[:latest_receipt] will be nil if you already have the receipt for the most recent renewal.
|
51
61
|
if attributes[:latest_receipt_info]
|
@@ -58,6 +68,11 @@ module Itunes
|
|
58
68
|
@itunes_env = attributes[:itunes_env] || Itunes.itunes_env
|
59
69
|
end
|
60
70
|
|
71
|
+
|
72
|
+
def application_receipt?
|
73
|
+
!@bundle_id.nil?
|
74
|
+
end
|
75
|
+
|
61
76
|
def sandbox?
|
62
77
|
itunes_env == :sandbox
|
63
78
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
{"status":0,
|
2
|
+
"environment":"Sandbox",
|
3
|
+
"receipt":{
|
4
|
+
"receipt_type":"ProductionSandbox",
|
5
|
+
"adam_id":0,
|
6
|
+
"bundle_id":"com.tekkinnovations.fars",
|
7
|
+
"application_version":"1.80",
|
8
|
+
"download_id":0,
|
9
|
+
"request_date":"2013-11-26 14:49:09 Etc/GMT",
|
10
|
+
"request_date_ms":"1385477349878",
|
11
|
+
"request_date_pst":"2013-11-26 06:49:09 America/Los_Angeles",
|
12
|
+
"original_purchase_date":"2013-08-01 07:00:00 Etc/GMT",
|
13
|
+
"original_purchase_date_ms":"1375340400000",
|
14
|
+
"original_purchase_date_pst":"2013-08-01 00:00:00 America/Los_Angeles",
|
15
|
+
"original_application_version":"1.0",
|
16
|
+
"in_app":[{"quantity":"1",
|
17
|
+
"product_id":"com.tekkinnovations.fars.subscription.6.months",
|
18
|
+
"transaction_id":"1000000091176126",
|
19
|
+
"original_transaction_id":"1000000091176126",
|
20
|
+
"purchase_date":"2013-11-26 05:58:48 Etc/GMT",
|
21
|
+
"purchase_date_ms":"1385445528000",
|
22
|
+
"purchase_date_pst":"2013-11-25 21:58:48 America/Los_Angeles",
|
23
|
+
"original_purchase_date":"2013-10-24 04:55:56 Etc/GMT",
|
24
|
+
"original_purchase_date_ms":"1382590556000",
|
25
|
+
"original_purchase_date_pst":"2013-10-23 21:55:56 America/Los_Angeles",
|
26
|
+
"is_trial_period":"false"},
|
27
|
+
{"quantity":"1",
|
28
|
+
"product_id":"com.tekkinnovations.fars.subscription.3.months",
|
29
|
+
"transaction_id":"1000000091221097",
|
30
|
+
"original_transaction_id":"1000000091221097",
|
31
|
+
"purchase_date":"2013-11-26 05:58:48 Etc/GMT",
|
32
|
+
"purchase_date_ms":"1385445528000",
|
33
|
+
"purchase_date_pst":"2013-11-25 21:58:48 America/Los_Angeles",
|
34
|
+
"original_purchase_date":"2013-10-24 09:40:22 Etc/GMT",
|
35
|
+
"original_purchase_date_ms":"1382607622000",
|
36
|
+
"original_purchase_date_pst":"2013-10-24 02:40:22 America/Los_Angeles",
|
37
|
+
"is_trial_period":"false"}
|
38
|
+
]}}
|
data/spec/itunes/receipt_spec.rb
CHANGED
@@ -73,6 +73,11 @@ describe Itunes::Receipt do
|
|
73
73
|
fake_json :valid
|
74
74
|
end
|
75
75
|
|
76
|
+
it 'should not be an application receipt' do
|
77
|
+
receipt = Itunes::Receipt.verify! 'valid_application'
|
78
|
+
receipt.application_receipt?.should be_false
|
79
|
+
end
|
80
|
+
|
76
81
|
it 'should return valid Receipt instance' do
|
77
82
|
receipt = Itunes::Receipt.verify! 'valid'
|
78
83
|
receipt.should be_instance_of Itunes::Receipt
|
@@ -95,6 +100,58 @@ describe Itunes::Receipt do
|
|
95
100
|
end
|
96
101
|
end
|
97
102
|
|
103
|
+
context 'when application receipt' do
|
104
|
+
before do
|
105
|
+
fake_json :valid_application
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should be an application receipt' do
|
109
|
+
receipt = Itunes::Receipt.verify! 'valid_application'
|
110
|
+
receipt.application_receipt?.should be_true
|
111
|
+
end
|
112
|
+
|
113
|
+
it 'should return valid Receipt instance' do
|
114
|
+
receipt = Itunes::Receipt.verify! 'valid_application'
|
115
|
+
receipt.bundle_id.should == 'com.tekkinnovations.fars'
|
116
|
+
receipt.application_version.should == '1.80'
|
117
|
+
receipt.in_app.should be_instance_of Array
|
118
|
+
|
119
|
+
receipt.in_app[0].should be_instance_of Itunes::Receipt
|
120
|
+
receipt.in_app[0].quantity.should == 1
|
121
|
+
receipt.in_app[0].product_id.should == "com.tekkinnovations.fars.subscription.6.months"
|
122
|
+
receipt.in_app[0].transaction_id.should == "1000000091176126"
|
123
|
+
receipt.in_app[0].purchase_date.should == Time.utc(2013, 11, 26, 5, 58, 48)
|
124
|
+
receipt.in_app[0].original.purchase_date.should == Time.utc(2013, 10, 24, 4, 55, 56)
|
125
|
+
|
126
|
+
receipt.in_app[1].should be_instance_of Itunes::Receipt
|
127
|
+
receipt.in_app[1].quantity.should == 1
|
128
|
+
receipt.in_app[1].product_id.should == "com.tekkinnovations.fars.subscription.3.months"
|
129
|
+
receipt.in_app[1].transaction_id.should == "1000000091221097"
|
130
|
+
receipt.in_app[1].purchase_date.should == Time.utc(2013, 11, 26, 5, 58, 48)
|
131
|
+
receipt.in_app[1].original.purchase_date.should == Time.utc(2013, 10, 24, 9, 40, 22)
|
132
|
+
|
133
|
+
receipt.original.quantity.should be_nil
|
134
|
+
receipt.original.transaction_id.should be_nil
|
135
|
+
receipt.original.purchase_date.should == Time.utc(2013, 8, 1, 7, 00, 00)
|
136
|
+
receipt.original.application_version.should == '1.0'
|
137
|
+
|
138
|
+
receipt.should be_instance_of Itunes::Receipt
|
139
|
+
receipt.quantity.should be_nil
|
140
|
+
receipt.product_id.should be_nil
|
141
|
+
receipt.transaction_id.should be_nil
|
142
|
+
receipt.purchase_date.should be_nil
|
143
|
+
receipt.bid.should be_nil
|
144
|
+
receipt.bvrs.should be_nil
|
145
|
+
receipt.expires_date.should be_nil
|
146
|
+
receipt.receipt_data.should be_nil
|
147
|
+
receipt.itunes_env.should == :production
|
148
|
+
|
149
|
+
# Those attributes are not returned from iTunes Connect Sandbox
|
150
|
+
receipt.app_item_id.should be_nil
|
151
|
+
receipt.version_external_identifier.should be_nil
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
98
155
|
context 'when autorenew subscription' do
|
99
156
|
before do
|
100
157
|
fake_json :autorenew_subscription
|
metadata
CHANGED
@@ -1,142 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itunes-receipt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- nov matake
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-11-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: json
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 1.4.3
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 1.4.3
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: restclient_with_cert
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - '>='
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - '>='
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: activesupport
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - '>='
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '2.3'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - '>='
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '2.3'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: i18n
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - '>='
|
68
60
|
- !ruby/object:Gem::Version
|
69
61
|
version: '0'
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - '>='
|
76
67
|
- !ruby/object:Gem::Version
|
77
68
|
version: '0'
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: rake
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - '>='
|
84
74
|
- !ruby/object:Gem::Version
|
85
75
|
version: '0.8'
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - '>='
|
92
81
|
- !ruby/object:Gem::Version
|
93
82
|
version: '0.8'
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rspec
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - '>='
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '2'
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - '>='
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '2'
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: fakeweb
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
|
-
- -
|
101
|
+
- - '>='
|
116
102
|
- !ruby/object:Gem::Version
|
117
103
|
version: 1.3.0
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
|
-
- -
|
108
|
+
- - '>='
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: 1.3.0
|
126
111
|
- !ruby/object:Gem::Dependency
|
127
112
|
name: cover_me
|
128
113
|
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
114
|
requirements:
|
131
|
-
- -
|
115
|
+
- - '>='
|
132
116
|
- !ruby/object:Gem::Version
|
133
117
|
version: 1.2.0
|
134
118
|
type: :development
|
135
119
|
prerelease: false
|
136
120
|
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
121
|
requirements:
|
139
|
-
- -
|
122
|
+
- - '>='
|
140
123
|
- !ruby/object:Gem::Version
|
141
124
|
version: 1.2.0
|
142
125
|
description: Handle iTunes In App Purchase Receipt Verification
|
@@ -162,39 +145,33 @@ files:
|
|
162
145
|
- spec/fake_json/offline.json
|
163
146
|
- spec/fake_json/sandboxed.json
|
164
147
|
- spec/fake_json/valid.json
|
148
|
+
- spec/fake_json/valid_application.json
|
165
149
|
- spec/helpers/fake_json_helper.rb
|
166
150
|
- spec/itunes/receipt_spec.rb
|
167
151
|
- spec/itunes_spec.rb
|
168
152
|
- spec/spec_helper.rb
|
169
153
|
homepage: http://github.com/nov/itunes-receipt
|
170
154
|
licenses: []
|
155
|
+
metadata: {}
|
171
156
|
post_install_message:
|
172
157
|
rdoc_options: []
|
173
158
|
require_paths:
|
174
159
|
- lib
|
175
160
|
required_ruby_version: !ruby/object:Gem::Requirement
|
176
|
-
none: false
|
177
161
|
requirements:
|
178
|
-
- -
|
162
|
+
- - '>='
|
179
163
|
- !ruby/object:Gem::Version
|
180
164
|
version: '0'
|
181
|
-
segments:
|
182
|
-
- 0
|
183
|
-
hash: 4014229086916728256
|
184
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
166
|
requirements:
|
187
|
-
- -
|
167
|
+
- - '>='
|
188
168
|
- !ruby/object:Gem::Version
|
189
169
|
version: '0'
|
190
|
-
segments:
|
191
|
-
- 0
|
192
|
-
hash: 4014229086916728256
|
193
170
|
requirements: []
|
194
171
|
rubyforge_project:
|
195
|
-
rubygems_version:
|
172
|
+
rubygems_version: 2.0.3
|
196
173
|
signing_key:
|
197
|
-
specification_version:
|
174
|
+
specification_version: 4
|
198
175
|
summary: Handle iTunes In App Purchase Receipt Verification
|
199
176
|
test_files:
|
200
177
|
- spec/fake_json/autorenew_subscription.json
|
@@ -203,6 +180,7 @@ test_files:
|
|
203
180
|
- spec/fake_json/offline.json
|
204
181
|
- spec/fake_json/sandboxed.json
|
205
182
|
- spec/fake_json/valid.json
|
183
|
+
- spec/fake_json/valid_application.json
|
206
184
|
- spec/helpers/fake_json_helper.rb
|
207
185
|
- spec/itunes/receipt_spec.rb
|
208
186
|
- spec/itunes_spec.rb
|