itunes-receipt 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -0
- data/VERSION +1 -1
- data/lib/itunes/receipt.rb +13 -0
- data/spec/fake_json/autorenew_subscription_expired.json +2 -0
- data/spec/fake_json/offline.json +1 -0
- data/spec/itunes/receipt_spec.rb +29 -0
- metadata +13 -3
data/README.rdoc
CHANGED
@@ -23,6 +23,7 @@ With <code>allow_sandbox_receipt</code> option specified, this gem post given re
|
|
23
23
|
Without this option, this gem just raises an exception.
|
24
24
|
|
25
25
|
receipt = Itunes::Receipt.verify! 'ewoJInNpZ25hdHVyZSIgPSAi...', :allow_sandbox_receipt
|
26
|
+
receipt.sandbox? # => true/false
|
26
27
|
|
27
28
|
If you want to accept ONLY iTunes sandbox receipts (in your stable server etc.), call <code>Itunes.sandbox!</code> somewhere before you call <code>Itunes::Receipt.verify!</code>.
|
28
29
|
Then all verification call after that goes to iTunes sandbox, until you do <code>Itunes.sandbox = false</code>.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/lib/itunes/receipt.rb
CHANGED
@@ -11,7 +11,16 @@ module Itunes
|
|
11
11
|
end
|
12
12
|
|
13
13
|
class SandboxReceiptReceived < VerificationFailed; end;
|
14
|
+
|
15
|
+
class ReceiptServerOffline < VerificationFailed; end;
|
14
16
|
|
17
|
+
class ExpiredReceiptReceived < VerificationFailed
|
18
|
+
attr_reader :receipt
|
19
|
+
def initialize(attributes = {})
|
20
|
+
@receipt = attributes[:receipt]
|
21
|
+
super attributes
|
22
|
+
end
|
23
|
+
end
|
15
24
|
|
16
25
|
# expires_date, receipt_data, and latest (receipt) will only appear for autorenew subscription products
|
17
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
|
@@ -88,6 +97,10 @@ module Itunes
|
|
88
97
|
case response[:status]
|
89
98
|
when 0
|
90
99
|
new response
|
100
|
+
when 21005
|
101
|
+
raise ReceiptServerOffline.new(response)
|
102
|
+
when 21006
|
103
|
+
raise ExpiredReceiptReceived.new(response)
|
91
104
|
when 21007
|
92
105
|
raise SandboxReceiptReceived.new(response)
|
93
106
|
else
|
@@ -0,0 +1,2 @@
|
|
1
|
+
{"receipt":{"original_purchase_date_pst":"2012-10-11 07:45:40 America/Los_Angeles", "unique_identifier":"4d69cc362c5c58ce62da68ee43721ea670907bad", "original_transaction_id":"1000000057005439", "expires_date":"1350157508197", "transaction_id":"1000000055076747", "quantity":"1", "product_id":"com.notkeepingitreal.fizzbuzz.subscription.autorenew1m", "original_purchase_date_ms":"1349966740000", "bid":"com.notkeepingitreal.fizzbuzz", "web_order_line_item_id":"1000000026553289", "bvrs":"1.0", "expires_date_formatted":"2012-10-13 19:45:08 Etc/GMT", "purchase_date":"2012-10-13 19:40:08 Etc/GMT", "purchase_date_ms":"1350157208197", "expires_date_formatted_pst":"2012-10-13 12:45:08 America/Los_Angeles", "purchase_date_pst":"2012-10-13 12:40:08 America/Los_Angeles", "original_purchase_date":"2012-10-11 14:45:40 Etc/GMT", "item_id":"570504929"}, "latest_receipt_info":{"original_purchase_date_pst":"2012-10-11 07:45:40 America/Los_Angeles", "unique_identifier":"4d79cc562c5c58ce62da68ee43721ea670907bad", "original_transaction_id":"1000000057005439", "expires_date":"1350157808000", "transaction_id":"1000000052076747", "quantity":"1", "product_id":"com.notkeepingitreal.fizzbuzz.subscription.autorenew1m", "original_purchase_date_ms":"1349966740000", "bid":"com.notkeepingitreal.fizzbuzz", "web_order_line_item_id":"1000000027293289", "bvrs":"1.0", "expires_date_formatted":"2012-10-13 19:50:08 Etc/GMT", "purchase_date":"2012-10-13 19:40:08 Etc/GMT", "purchase_date_ms":"1350157208000", "expires_date_formatted_pst":"2012-10-13 12:50:08 America/Los_Angeles", "purchase_date_pst":"2012-10-13 12:40:08 America/Los_Angeles", "original_purchase_date":"2012-10-11 14:45:40 Etc/GMT", "item_id":"570504929"}, "status":21006, "latest_receipt":"junk="}
|
2
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
{"status":21005}
|
data/spec/itunes/receipt_spec.rb
CHANGED
@@ -54,6 +54,7 @@ describe Itunes::Receipt do
|
|
54
54
|
receipt.should be_instance_of Itunes::Receipt
|
55
55
|
receipt.transaction_id.should == '1000000001479608'
|
56
56
|
receipt.itunes_env.should == :sandbox
|
57
|
+
receipt.sandbox?.should eq true
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
@@ -139,5 +140,33 @@ describe Itunes::Receipt do
|
|
139
140
|
latest.version_external_identifier.should be_nil
|
140
141
|
end
|
141
142
|
end
|
143
|
+
|
144
|
+
context 'when expired autorenew subscription' do
|
145
|
+
before do
|
146
|
+
fake_json :autorenew_subscription_expired
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should raise ExpiredReceiptReceived exception' do
|
150
|
+
expect do
|
151
|
+
Itunes::Receipt.verify! 'autorenew_subscription_expired'
|
152
|
+
end.to raise_error Itunes::Receipt::ExpiredReceiptReceived do |e|
|
153
|
+
e.receipt.should_not be_nil
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
context 'when offline' do
|
160
|
+
before do
|
161
|
+
fake_json :offline
|
162
|
+
end
|
163
|
+
|
164
|
+
it 'should raise ReceiptServerOffline exception' do
|
165
|
+
expect do
|
166
|
+
Itunes::Receipt.verify! 'offline'
|
167
|
+
end.to raise_error Itunes::Receipt::ReceiptServerOffline
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
142
171
|
end
|
143
172
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itunes-receipt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -157,7 +157,9 @@ files:
|
|
157
157
|
- lib/itunes.rb
|
158
158
|
- lib/itunes/receipt.rb
|
159
159
|
- spec/fake_json/autorenew_subscription.json
|
160
|
+
- spec/fake_json/autorenew_subscription_expired.json
|
160
161
|
- spec/fake_json/invalid.json
|
162
|
+
- spec/fake_json/offline.json
|
161
163
|
- spec/fake_json/sandboxed.json
|
162
164
|
- spec/fake_json/valid.json
|
163
165
|
- spec/helpers/fake_json_helper.rb
|
@@ -176,21 +178,29 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
178
|
- - ! '>='
|
177
179
|
- !ruby/object:Gem::Version
|
178
180
|
version: '0'
|
181
|
+
segments:
|
182
|
+
- 0
|
183
|
+
hash: 4014229086916728256
|
179
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
185
|
none: false
|
181
186
|
requirements:
|
182
187
|
- - ! '>='
|
183
188
|
- !ruby/object:Gem::Version
|
184
189
|
version: '0'
|
190
|
+
segments:
|
191
|
+
- 0
|
192
|
+
hash: 4014229086916728256
|
185
193
|
requirements: []
|
186
194
|
rubyforge_project:
|
187
|
-
rubygems_version: 1.8.
|
195
|
+
rubygems_version: 1.8.25
|
188
196
|
signing_key:
|
189
197
|
specification_version: 3
|
190
198
|
summary: Handle iTunes In App Purchase Receipt Verification
|
191
199
|
test_files:
|
192
200
|
- spec/fake_json/autorenew_subscription.json
|
201
|
+
- spec/fake_json/autorenew_subscription_expired.json
|
193
202
|
- spec/fake_json/invalid.json
|
203
|
+
- spec/fake_json/offline.json
|
194
204
|
- spec/fake_json/sandboxed.json
|
195
205
|
- spec/fake_json/valid.json
|
196
206
|
- spec/helpers/fake_json_helper.rb
|