venice 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +29 -18
  3. data/README.md +1 -1
  4. data/Rakefile +4 -7
  5. data/coverage/assets/{0.10.0 → 0.10.2}/application.css +0 -0
  6. data/coverage/assets/{0.10.0 → 0.10.2}/application.js +0 -0
  7. data/coverage/assets/{0.10.0 → 0.10.2}/colorbox/border.png +0 -0
  8. data/coverage/assets/{0.10.0 → 0.10.2}/colorbox/controls.png +0 -0
  9. data/coverage/assets/{0.10.0 → 0.10.2}/colorbox/loading.gif +0 -0
  10. data/coverage/assets/{0.10.0 → 0.10.2}/colorbox/loading_background.png +0 -0
  11. data/coverage/assets/{0.10.0 → 0.10.2}/favicon_green.png +0 -0
  12. data/coverage/assets/{0.10.0 → 0.10.2}/favicon_red.png +0 -0
  13. data/coverage/assets/{0.10.0 → 0.10.2}/favicon_yellow.png +0 -0
  14. data/coverage/assets/{0.10.0 → 0.10.2}/loading.gif +0 -0
  15. data/coverage/assets/{0.10.0 → 0.10.2}/magnify.png +0 -0
  16. data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  17. data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  18. data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  19. data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  20. data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  21. data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  22. data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  23. data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  24. data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-icons_222222_256x240.png +0 -0
  25. data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  26. data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-icons_454545_256x240.png +0 -0
  27. data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-icons_888888_256x240.png +0 -0
  28. data/coverage/assets/{0.10.0 → 0.10.2}/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  29. data/coverage/index.html +874 -320
  30. data/lib/venice/in_app_receipt.rb +1 -1
  31. data/lib/venice/pending_renewal_info.rb +66 -0
  32. data/lib/venice/receipt.rb +13 -1
  33. data/lib/venice/version.rb +1 -1
  34. data/lib/venice.rb +1 -0
  35. data/spec/pending_renewal_info_spec.rb +41 -0
  36. data/spec/receipt_spec.rb +24 -1
  37. data/spec/spec_helper.rb +1 -0
  38. data/venice.gemspec +2 -1
  39. metadata +46 -29
@@ -55,7 +55,7 @@ module Venice
55
55
  @expires_at = Time.at(attributes['expires_date_ms'].to_i / 1000) if attributes['expires_date_ms']
56
56
 
57
57
  # cancellation_date is in ms since the Epoch, Time.at expects seconds
58
- @cancellation_date = Time.at(attributes['cancellation_date'].to_i / 1000) if attributes['cancellation_date']
58
+ @cancellation_at = Time.at(attributes['cancellation_date_ms'].to_i / 1000) if attributes['cancellation_date_ms']
59
59
 
60
60
  if attributes['original_transaction_id'] || attributes['original_purchase_date']
61
61
  original_attributes = {
@@ -0,0 +1,66 @@
1
+ module Venice
2
+ class PendingRenewalInfo
3
+
4
+ # For an expired subscription, the reason for the subscription expiration.
5
+ # This key is only present for a receipt containing an expired auto-renewable subscription.
6
+ attr_reader :expiration_intent
7
+
8
+ # The current renewal status for the auto-renewable subscription.
9
+ # This key is only present for auto-renewable subscription receipts, for active or expired subscriptions
10
+ attr_reader :auto_renew_status
11
+
12
+ # The current renewal preference for the auto-renewable subscription.
13
+ # The value for this key corresponds to the productIdentifier property of the product that the customer’s subscription renews.
14
+ attr_reader :auto_renew_product_id
15
+
16
+ # For an expired subscription, whether or not Apple is still attempting to automatically renew the subscription.
17
+ # If the customer’s subscription failed to renew because the App Store was unable to complete the transaction, this value will reflect whether or not the App Store is still trying to renew the subscription.
18
+ attr_reader :is_in_billing_retry_period
19
+
20
+ # The product identifier of the item that was purchased.
21
+ # This value corresponds to the productIdentifier property of the SKPayment object stored in the transaction’s payment property.
22
+ attr_reader :product_id
23
+
24
+ # The current price consent status for a subscription price increase
25
+ # This key is only present for auto-renewable subscription receipts if the subscription price was increased without keeping the existing price for active subscribers
26
+ attr_reader :price_consent_status
27
+
28
+ # For a transaction that was cancelled, the reason for cancellation.
29
+ # Use this value along with the cancellation date to identify possible issues in your app that may lead customers to contact Apple customer support.
30
+ attr_reader :cancellation_reason
31
+
32
+
33
+ def initialize(attributes)
34
+ @expiration_intent = Integer(attributes['expiration_intent']) if attributes['expiration_intent']
35
+ @auto_renew_status = Integer(attributes['auto_renew_status']) if attributes['auto_renew_status']
36
+ @auto_renew_product_id = attributes['auto_renew_product_id']
37
+
38
+ if attributes['is_in_billing_retry_period']
39
+ @is_in_billing_retry_period = (attributes[is_in_billing_retry_period] == "1" ? true : false)
40
+ end
41
+
42
+ @product_id = attributes['product_id']
43
+
44
+ @price_consent_status = Integer(attributes['price_consent_status']) if attributes['price_consent_status']
45
+ @cancellation_reason = Integer(attributes['cancellation_reason']) if attributes['cancellation_reason']
46
+ end
47
+
48
+ def to_hash
49
+ {
50
+ expiration_intent: @expiration_intent,
51
+ auto_renew_status: @auto_renew_status,
52
+ auto_renew_product_id: @auto_renew_product_id,
53
+ is_in_billing_retry_period: @is_in_billing_retry_period,
54
+ product_id: @product_id,
55
+ price_consent_status: @price_consent_status,
56
+ cancellation_reason: @cancellation_reason
57
+ }
58
+ end
59
+
60
+ alias_method :to_h, :to_hash
61
+
62
+ def to_json
63
+ self.to_hash.to_json
64
+ end
65
+ end
66
+ end
@@ -32,9 +32,11 @@ module Venice
32
32
  # Original json response from AppStore
33
33
  attr_reader :original_json_response
34
34
 
35
-
36
35
  attr_accessor :latest_receipt_info
37
36
 
37
+ # Information about the status of the customer's auto-renewable subscriptions
38
+ attr_reader :pending_renewal_info
39
+
38
40
  def initialize(attributes = {})
39
41
  @original_json_response = attributes['original_json_response']
40
42
 
@@ -60,6 +62,13 @@ module Venice
60
62
  end
61
63
  end
62
64
 
65
+ @pending_renewal_info = []
66
+ if original_json_response && original_json_response['pending_renewal_info']
67
+ original_json_response['pending_renewal_info'].each do |pending_renewal_attributes|
68
+ @pending_renewal_info << PendingRenewalInfo.new(pending_renewal_attributes)
69
+ end
70
+ end
71
+
63
72
  end
64
73
 
65
74
  def to_hash
@@ -74,6 +83,7 @@ module Venice
74
83
  :download_id => @download_id,
75
84
  :requested_at => (@requested_at.httpdate rescue nil),
76
85
  :in_app => @in_app.map{|iap| iap.to_h },
86
+ :pending_renewal_info => @pending_renewal_info.map { |pend_info| pend_info.to_h },
77
87
  :latest_receipt_info => @latest_receipt_info
78
88
  }
79
89
  end
@@ -138,6 +148,8 @@ module Venice
138
148
  "This receipt is a sandbox receipt, but it was sent to the production service for verification."
139
149
  when 21008
140
150
  "This receipt is a production receipt, but it was sent to the sandbox service for verification."
151
+ when 21010
152
+ "This receipt could not be authorized. Treat this the same as if a purchase was never made."
141
153
  else
142
154
  "Unknown Error: #{@code}"
143
155
  end
@@ -1,3 +1,3 @@
1
1
  module Venice
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/venice.rb CHANGED
@@ -2,3 +2,4 @@ require 'venice/version'
2
2
  require 'venice/client'
3
3
  require 'venice/in_app_receipt'
4
4
  require 'venice/receipt'
5
+ require 'venice/pending_renewal_info'
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ describe Venice::PendingRenewalInfo do
4
+
5
+ describe ".new" do
6
+
7
+ let(:attributes) {
8
+ {
9
+ "auto_renew_product_id"=>"com.foo.product1",
10
+ "original_transaction_id"=>"37xxxxxxxxx89",
11
+ "product_id"=>"com.foo.product1",
12
+ "auto_renew_status"=>"0",
13
+ "is_in_billing_retry_period"=>"0",
14
+ "expiration_intent"=>"1"
15
+ }
16
+ }
17
+
18
+ subject(:pending_info) do
19
+ described_class.new(attributes)
20
+ end
21
+
22
+ it "parses the attributes correctly" do
23
+ expect(subject.expiration_intent).to eql(1)
24
+ expect(subject.auto_renew_status).to eql(0)
25
+ expect(subject.auto_renew_product_id).to eql("com.foo.product1")
26
+ expect(subject.is_in_billing_retry_period).to eql(false)
27
+ expect(subject.product_id).to eql("com.foo.product1")
28
+ end
29
+
30
+ it "outputs attributes in hash" do
31
+ expect(subject.to_hash).to eql({ :expiration_intent => 1,
32
+ :auto_renew_status => 0,
33
+ :auto_renew_product_id => "com.foo.product1",
34
+ :is_in_billing_retry_period => false,
35
+ :product_id => "com.foo.product1",
36
+ :price_consent_status => nil,
37
+ :cancellation_reason => nil
38
+ })
39
+ end
40
+ end
41
+ end
data/spec/receipt_spec.rb CHANGED
@@ -35,7 +35,19 @@ describe Venice::Receipt do
35
35
  "expires_date" => "2014-06-28 14:47:53 Etc/GMT",
36
36
  "is_trial_period" => "false"
37
37
  }
38
- ]
38
+ ],
39
+ "original_json_response" => {
40
+ "pending_renewal_info" => [
41
+ {
42
+ "auto_renew_product_id"=>"com.foo.product1",
43
+ "original_transaction_id"=>"37xxxxxxxxx89",
44
+ "product_id"=>"com.foo.product1",
45
+ "auto_renew_status"=>"0",
46
+ "is_in_billing_retry_period"=>"0",
47
+ "expiration_intent"=>"1"
48
+ }
49
+ ]
50
+ }
39
51
  }
40
52
  }
41
53
  end
@@ -66,5 +78,16 @@ describe Venice::Receipt do
66
78
  end
67
79
  end
68
80
 
81
+ it "parses the pending rerenewal information" do
82
+ expect(subject.to_hash[:pending_renewal_info]).to eql([{ :expiration_intent => 1,
83
+ :auto_renew_status => 0,
84
+ :auto_renew_product_id=>"com.foo.product1",
85
+ :is_in_billing_retry_period=>false,
86
+ :product_id=>"com.foo.product1",
87
+ :price_consent_status=>nil,
88
+ :cancellation_reason=>nil
89
+ }])
90
+ end
91
+
69
92
  end
70
93
  end
data/spec/spec_helper.rb CHANGED
@@ -9,6 +9,7 @@ end
9
9
 
10
10
  require 'venice'
11
11
  require 'rspec'
12
+ require 'rspec/its'
12
13
 
13
14
  RSpec.configure do |config|
14
15
 
data/venice.gemspec CHANGED
@@ -17,7 +17,8 @@ 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", "~> 2.99.0"
20
+ s.add_development_dependency "rspec", "~> 3.6"
21
+ s.add_development_dependency "rspec-its", "~> 1.2"
21
22
  s.add_development_dependency "rake"
22
23
  s.add_development_dependency "simplecov"
23
24
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: venice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.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: 2016-08-08 00:00:00.000000000 Z
11
+ date: 2017-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -58,14 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.99.0
61
+ version: '3.6'
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: 2.99.0
68
+ version: '3.6'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-its
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.2'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.2'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rake
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -106,40 +120,42 @@ files:
106
120
  - "./LICENSE"
107
121
  - "./README.md"
108
122
  - "./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"
123
+ - "./coverage/assets/0.10.2/application.css"
124
+ - "./coverage/assets/0.10.2/application.js"
125
+ - "./coverage/assets/0.10.2/colorbox/border.png"
126
+ - "./coverage/assets/0.10.2/colorbox/controls.png"
127
+ - "./coverage/assets/0.10.2/colorbox/loading.gif"
128
+ - "./coverage/assets/0.10.2/colorbox/loading_background.png"
129
+ - "./coverage/assets/0.10.2/favicon_green.png"
130
+ - "./coverage/assets/0.10.2/favicon_red.png"
131
+ - "./coverage/assets/0.10.2/favicon_yellow.png"
132
+ - "./coverage/assets/0.10.2/loading.gif"
133
+ - "./coverage/assets/0.10.2/magnify.png"
134
+ - "./coverage/assets/0.10.2/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png"
135
+ - "./coverage/assets/0.10.2/smoothness/images/ui-bg_flat_75_ffffff_40x100.png"
136
+ - "./coverage/assets/0.10.2/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png"
137
+ - "./coverage/assets/0.10.2/smoothness/images/ui-bg_glass_65_ffffff_1x400.png"
138
+ - "./coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_dadada_1x400.png"
139
+ - "./coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png"
140
+ - "./coverage/assets/0.10.2/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png"
141
+ - "./coverage/assets/0.10.2/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png"
142
+ - "./coverage/assets/0.10.2/smoothness/images/ui-icons_222222_256x240.png"
143
+ - "./coverage/assets/0.10.2/smoothness/images/ui-icons_2e83ff_256x240.png"
144
+ - "./coverage/assets/0.10.2/smoothness/images/ui-icons_454545_256x240.png"
145
+ - "./coverage/assets/0.10.2/smoothness/images/ui-icons_888888_256x240.png"
146
+ - "./coverage/assets/0.10.2/smoothness/images/ui-icons_cd0a0a_256x240.png"
133
147
  - "./coverage/index.html"
134
148
  - "./lib/venice.rb"
135
149
  - "./lib/venice/client.rb"
136
150
  - "./lib/venice/in_app_receipt.rb"
151
+ - "./lib/venice/pending_renewal_info.rb"
137
152
  - "./lib/venice/receipt.rb"
138
153
  - "./lib/venice/version.rb"
139
154
  - "./venice.gemspec"
140
155
  - bin/iap
141
156
  - spec/client_spec.rb
142
157
  - spec/in_app_receipt_spec.rb
158
+ - spec/pending_renewal_info_spec.rb
143
159
  - spec/receipt
144
160
  - spec/receipt_spec.rb
145
161
  - spec/spec_helper.rb
@@ -163,13 +179,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
179
  version: '0'
164
180
  requirements: []
165
181
  rubyforge_project:
166
- rubygems_version: 2.4.5
182
+ rubygems_version: 2.6.13
167
183
  signing_key:
168
184
  specification_version: 4
169
185
  summary: iTunes In-App Purchase Receipt Verification
170
186
  test_files:
171
187
  - spec/client_spec.rb
172
188
  - spec/in_app_receipt_spec.rb
189
+ - spec/pending_renewal_info_spec.rb
173
190
  - spec/receipt
174
191
  - spec/receipt_spec.rb
175
192
  - spec/spec_helper.rb