venice 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +26 -22
- data/LICENSE +1 -1
- data/README.md +60 -25
- data/Rakefile +1 -2
- data/bin/iap +13 -0
- data/coverage/assets/0.10.0/application.css +799 -0
- data/coverage/assets/0.10.0/application.js +1707 -0
- data/coverage/assets/0.10.0/colorbox/border.png +0 -0
- data/coverage/assets/0.10.0/colorbox/controls.png +0 -0
- data/coverage/assets/0.10.0/colorbox/loading.gif +0 -0
- data/coverage/assets/0.10.0/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.10.0/favicon_green.png +0 -0
- data/coverage/assets/0.10.0/favicon_red.png +0 -0
- data/coverage/assets/0.10.0/favicon_yellow.png +0 -0
- data/coverage/assets/0.10.0/loading.gif +0 -0
- data/coverage/assets/0.10.0/magnify.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/index.html +2152 -0
- data/lib/venice.rb +1 -0
- data/lib/venice/client.rb +16 -8
- data/lib/venice/in_app_receipt.rb +92 -0
- data/lib/venice/receipt.rb +62 -58
- data/lib/venice/version.rb +1 -1
- data/spec/client_spec.rb +73 -6
- data/spec/in_app_receipt_spec.rb +58 -0
- data/spec/receipt_spec.rb +47 -70
- data/spec/spec_helper.rb +9 -1
- data/venice.gemspec +2 -2
- metadata +59 -35
- data/spec/receipt_verification_spec.rb +0 -19
- data/venice-0.1.0.gem +0 -0
- data/venice-0.1.1.gem +0 -0
data/spec/receipt_spec.rb
CHANGED
@@ -2,54 +2,61 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Venice::Receipt do
|
4
4
|
describe "parsing the response" do
|
5
|
-
let(:response)
|
5
|
+
let(:response) do
|
6
6
|
{
|
7
|
+
"status" => 0,
|
8
|
+
"environment" => "Production",
|
7
9
|
"receipt" => {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
10
|
+
"receipt_type" => "Production",
|
11
|
+
"adam_id" => 7654321,
|
12
|
+
"bundle_id" => "com.foo.bar",
|
13
|
+
"application_version" => "2",
|
14
|
+
"download_id" => 1234567,
|
15
|
+
"request_date" => "2014-06-04 23:20:47 Etc/GMT",
|
16
|
+
"request_date_ms" => "1401924047883",
|
17
|
+
"request_date_pst" => "2014-06-04 16:20:47 America/Los_Angeles",
|
18
|
+
"original_purchase_date" => "2014-05-17 02:09:45 Etc/GMT",
|
19
|
+
"original_purchase_date_ms" => "1400292585000",
|
20
|
+
"original_purchase_date_pst" => "2014-05-16 19:09:45 America/Los_Angeles",
|
21
|
+
"original_application_version" => "1",
|
22
|
+
"expiration_date" => "1401924047883",
|
23
|
+
"in_app" => [
|
24
|
+
{
|
25
|
+
"quantity" => "1",
|
26
|
+
"product_id" => "com.foo.product1",
|
27
|
+
"transaction_id" => "1000000070107111",
|
28
|
+
"original_transaction_id" => "1000000061051111",
|
29
|
+
"purchase_date" => "2014-05-28 14:47:53 Etc/GMT",
|
30
|
+
"purchase_date_ms" => "1401288473000",
|
31
|
+
"purchase_date_pst" => "2014-05-28 07:47:53 America/Los_Angeles",
|
32
|
+
"original_purchase_date" => "2014-05-28 14:47:53 Etc/GMT",
|
33
|
+
"original_purchase_date_ms" => "1401288473000",
|
34
|
+
"original_purchase_date_pst" => "2014-05-28 07:47:53 America/Los_Angeles",
|
35
|
+
"expires_date" => "2014-06-28 14:47:53 Etc/GMT",
|
36
|
+
"is_trial_period" => "false"
|
37
|
+
}
|
38
|
+
]
|
39
|
+
}
|
29
40
|
}
|
30
|
-
|
41
|
+
end
|
42
|
+
|
31
43
|
subject { Venice::Receipt.new(response['receipt']) }
|
32
44
|
|
33
|
-
its(:
|
34
|
-
its(:
|
35
|
-
its(:
|
36
|
-
its(:
|
37
|
-
its(:
|
38
|
-
its(:
|
39
|
-
its(:
|
40
|
-
its(:
|
41
|
-
its(:
|
42
|
-
|
43
|
-
it "should parse the origin attributes" do
|
44
|
-
subject.original.transaction_id.should == "1000000061051565"
|
45
|
-
subject.original.purchase_date.should be_instance_of DateTime
|
46
|
-
end
|
45
|
+
its(:bundle_id) { "com.foo.bar" }
|
46
|
+
its(:application_version) { "2" }
|
47
|
+
its(:in_app) { should be_instance_of Array }
|
48
|
+
its(:original_application_version) { "1" }
|
49
|
+
its(:original_purchase_date) { should be_instance_of DateTime }
|
50
|
+
its(:expires_at) { should be_instance_of DateTime }
|
51
|
+
its(:receipt_type) { "Production" }
|
52
|
+
its(:adam_id) { 7654321 }
|
53
|
+
its(:download_id) { 1234567 }
|
54
|
+
its(:requested_at) { should be_instance_of DateTime }
|
47
55
|
|
48
56
|
describe "#verify!" do
|
57
|
+
|
49
58
|
before do
|
50
|
-
|
51
|
-
Venice::Client.stub(:production).and_return(client)
|
52
|
-
client.stub(:verify!).and_return(response)
|
59
|
+
Venice::Client.any_instance.stub(:json_response_from_verifying_data).and_return(response)
|
53
60
|
end
|
54
61
|
|
55
62
|
let(:receipt) { Venice::Receipt.verify("asdf") }
|
@@ -57,37 +64,7 @@ describe Venice::Receipt do
|
|
57
64
|
it "should create the receipt" do
|
58
65
|
receipt.should_not be_nil
|
59
66
|
end
|
60
|
-
|
61
|
-
context "with a latest expired receipt attribute" do
|
62
|
-
before do
|
63
|
-
response['latest_expired_receipt_info'] = {
|
64
|
-
"original_purchase_date_pst" => "2012-12-30 09:39:24 America/Los_Angeles",
|
65
|
-
"unique_identifier" => "0000b01147b8",
|
66
|
-
"original_transaction_id" => "1000000061051565",
|
67
|
-
"expires_date" => "1365114731000",
|
68
|
-
"transaction_id" => "1000000070104252",
|
69
|
-
"quantity" => "1",
|
70
|
-
"product_id" => "com.ficklebits.nsscreencast.monthly_sub",
|
71
|
-
"original_purchase_date_ms" => "1356889164000",
|
72
|
-
"bid" => "com.ficklebits.nsscreencast",
|
73
|
-
"web_order_line_item_id" => "1000000026812043",
|
74
|
-
"bvrs" => "0.1",
|
75
|
-
"expires_date_formatted" => "2013-04-04 22:32:11 Etc/GMT",
|
76
|
-
"purchase_date" => "2013-04-04 22:27:11 Etc/GMT",
|
77
|
-
"purchase_date_ms" => "1365114431000",
|
78
|
-
"expires_date_formatted_pst" => "2013-04-04 15:32:11 America/Los_Angeles",
|
79
|
-
"purchase_date_pst" => "2013-04-04 15:27:11 America/Los_Angeles",
|
80
|
-
"original_purchase_date" => "2012-12-30 17:39:24 Etc/GMT",
|
81
|
-
"item_id" => "590265423"
|
82
|
-
}
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should create a latest expired receipt" do
|
86
|
-
receipt.latest_expired.should_not be_nil
|
87
|
-
end
|
88
|
-
end
|
89
67
|
end
|
90
68
|
|
91
69
|
end
|
92
|
-
|
93
70
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
unless ENV['CI']
|
2
2
|
require 'simplecov'
|
3
|
-
|
3
|
+
|
4
4
|
SimpleCov.start do
|
5
5
|
add_filter 'spec'
|
6
6
|
add_filter '.bundle'
|
@@ -9,3 +9,11 @@ end
|
|
9
9
|
|
10
10
|
require 'venice'
|
11
11
|
require 'rspec'
|
12
|
+
|
13
|
+
RSpec.configure do |config|
|
14
|
+
|
15
|
+
config.mock_with :rspec do |mocks|
|
16
|
+
mocks.yield_receiver_to_any_instance_implementation_blocks = false
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/venice.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.authors = ["Mattt Thompson"]
|
8
8
|
s.email = "m@mattt.me"
|
9
9
|
s.license = "MIT"
|
10
|
-
s.homepage = "http://
|
10
|
+
s.homepage = "http://nomad-cli.com"
|
11
11
|
s.version = Venice::VERSION
|
12
12
|
s.platform = Gem::Platform::RUBY
|
13
13
|
s.summary = "iTunes In-App Purchase Receipt Verification"
|
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.add_dependency "commander", "~> 4.1"
|
18
18
|
s.add_dependency "terminal-table", "~> 1.4"
|
19
19
|
|
20
|
-
s.add_development_dependency "rspec"
|
20
|
+
s.add_development_dependency "rspec", "~> 2.99.0"
|
21
21
|
s.add_development_dependency "rake"
|
22
22
|
s.add_development_dependency "simplecov"
|
23
23
|
|
metadata
CHANGED
@@ -1,97 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: venice
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattt Thompson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: commander
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '4.1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '4.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: terminal-table
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '1.4'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 2.99.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 2.99.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: simplecov
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
description: ''
|
@@ -101,25 +101,49 @@ executables:
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
- ./Gemfile
|
105
|
-
- ./Gemfile.lock
|
106
|
-
- ./
|
107
|
-
- ./
|
108
|
-
- ./
|
109
|
-
- ./
|
110
|
-
- ./
|
111
|
-
- ./
|
112
|
-
- ./
|
113
|
-
- ./
|
114
|
-
- ./
|
115
|
-
- ./
|
104
|
+
- "./Gemfile"
|
105
|
+
- "./Gemfile.lock"
|
106
|
+
- "./LICENSE"
|
107
|
+
- "./README.md"
|
108
|
+
- "./Rakefile"
|
109
|
+
- "./coverage/assets/0.10.0/application.css"
|
110
|
+
- "./coverage/assets/0.10.0/application.js"
|
111
|
+
- "./coverage/assets/0.10.0/colorbox/border.png"
|
112
|
+
- "./coverage/assets/0.10.0/colorbox/controls.png"
|
113
|
+
- "./coverage/assets/0.10.0/colorbox/loading.gif"
|
114
|
+
- "./coverage/assets/0.10.0/colorbox/loading_background.png"
|
115
|
+
- "./coverage/assets/0.10.0/favicon_green.png"
|
116
|
+
- "./coverage/assets/0.10.0/favicon_red.png"
|
117
|
+
- "./coverage/assets/0.10.0/favicon_yellow.png"
|
118
|
+
- "./coverage/assets/0.10.0/loading.gif"
|
119
|
+
- "./coverage/assets/0.10.0/magnify.png"
|
120
|
+
- "./coverage/assets/0.10.0/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png"
|
121
|
+
- "./coverage/assets/0.10.0/smoothness/images/ui-bg_flat_75_ffffff_40x100.png"
|
122
|
+
- "./coverage/assets/0.10.0/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png"
|
123
|
+
- "./coverage/assets/0.10.0/smoothness/images/ui-bg_glass_65_ffffff_1x400.png"
|
124
|
+
- "./coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_dadada_1x400.png"
|
125
|
+
- "./coverage/assets/0.10.0/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png"
|
126
|
+
- "./coverage/assets/0.10.0/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png"
|
127
|
+
- "./coverage/assets/0.10.0/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png"
|
128
|
+
- "./coverage/assets/0.10.0/smoothness/images/ui-icons_222222_256x240.png"
|
129
|
+
- "./coverage/assets/0.10.0/smoothness/images/ui-icons_2e83ff_256x240.png"
|
130
|
+
- "./coverage/assets/0.10.0/smoothness/images/ui-icons_454545_256x240.png"
|
131
|
+
- "./coverage/assets/0.10.0/smoothness/images/ui-icons_888888_256x240.png"
|
132
|
+
- "./coverage/assets/0.10.0/smoothness/images/ui-icons_cd0a0a_256x240.png"
|
133
|
+
- "./coverage/index.html"
|
134
|
+
- "./lib/venice.rb"
|
135
|
+
- "./lib/venice/client.rb"
|
136
|
+
- "./lib/venice/in_app_receipt.rb"
|
137
|
+
- "./lib/venice/receipt.rb"
|
138
|
+
- "./lib/venice/version.rb"
|
139
|
+
- "./venice.gemspec"
|
140
|
+
- bin/iap
|
116
141
|
- spec/client_spec.rb
|
142
|
+
- spec/in_app_receipt_spec.rb
|
117
143
|
- spec/receipt
|
118
144
|
- spec/receipt_spec.rb
|
119
|
-
- spec/receipt_verification_spec.rb
|
120
145
|
- spec/spec_helper.rb
|
121
|
-
-
|
122
|
-
homepage: http://github.com/mattt/venice
|
146
|
+
homepage: http://nomad-cli.com
|
123
147
|
licenses:
|
124
148
|
- MIT
|
125
149
|
metadata: {}
|
@@ -129,23 +153,23 @@ require_paths:
|
|
129
153
|
- lib
|
130
154
|
required_ruby_version: !ruby/object:Gem::Requirement
|
131
155
|
requirements:
|
132
|
-
- -
|
156
|
+
- - ">="
|
133
157
|
- !ruby/object:Gem::Version
|
134
158
|
version: '0'
|
135
159
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
160
|
requirements:
|
137
|
-
- -
|
161
|
+
- - ">="
|
138
162
|
- !ruby/object:Gem::Version
|
139
163
|
version: '0'
|
140
164
|
requirements: []
|
141
165
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
166
|
+
rubygems_version: 2.4.5
|
143
167
|
signing_key:
|
144
168
|
specification_version: 4
|
145
169
|
summary: iTunes In-App Purchase Receipt Verification
|
146
170
|
test_files:
|
147
171
|
- spec/client_spec.rb
|
172
|
+
- spec/in_app_receipt_spec.rb
|
148
173
|
- spec/receipt
|
149
174
|
- spec/receipt_spec.rb
|
150
|
-
- spec/receipt_verification_spec.rb
|
151
175
|
- spec/spec_helper.rb
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RECEIPT_DATA = File.read(File.join(File.dirname(__FILE__), "receipt"))
|
4
|
-
|
5
|
-
describe 'Receipt Verification' do
|
6
|
-
describe 'production' do
|
7
|
-
it 'verifies a receipt' do
|
8
|
-
|
9
|
-
lambda {
|
10
|
-
receipt = Venice::Receipt.verify!(RECEIPT_DATA)
|
11
|
-
|
12
|
-
receipt.quantity.should == 1
|
13
|
-
receipt.product_id.should == "com.mindmobapp.download"
|
14
|
-
receipt.transaction_id.should == "1000000046178817"
|
15
|
-
receipt.original.should_not be nil
|
16
|
-
}.should_not raise_error
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/venice-0.1.0.gem
DELETED
Binary file
|
data/venice-0.1.1.gem
DELETED
Binary file
|