nbudin-google4r-checkout 1.0.10 → 1.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -68,8 +68,8 @@ end
68
68
  begin
69
69
  require 'jeweler'
70
70
  Jeweler::Tasks.new do |spec|
71
- spec.name = "google4r-checkout"
72
- spec.summary = "Ruby library to access the Google Checkout service and implement notification handlers."
71
+ spec.name = "nbudin-google4r-checkout"
72
+ spec.summary = "Nat Budin's branch of the Ruby library to access the Google Checkout service and implement notification handlers."
73
73
  spec.description = spec.summary
74
74
  spec.authors = ["Tony Chan"]
75
75
 
@@ -77,4 +77,4 @@ begin
77
77
  end
78
78
  rescue LoadError
79
79
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
80
- end
80
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.10
1
+ 1.0.11
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{google4r-checkout}
8
- s.version = "1.0.10"
8
+ s.version = "1.0.11"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Tony Chan"]
12
- s.date = %q{2009-09-03}
12
+ s.date = %q{2009-11-02}
13
13
  s.description = %q{Ruby library to access the Google Checkout service and implement notification handlers.}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -98,7 +98,7 @@ Gem::Specification.new do |s|
98
98
  ]
99
99
  s.rdoc_options = ["--charset=UTF-8"]
100
100
  s.require_paths = ["lib"]
101
- s.rubygems_version = %q{1.3.4}
101
+ s.rubygems_version = %q{1.3.5}
102
102
  s.summary = %q{Ruby library to access the Google Checkout service and implement notification handlers.}
103
103
  s.test_files = [
104
104
  "test/integration/checkout_command_test.rb",
@@ -132,6 +132,8 @@ module Google4R #:nodoc:
132
132
  ChargebackAmountNotification.create_from_element(root, frontend)
133
133
  when 'authorization-amount-notification' then
134
134
  AuthorizationAmountNotification.create_from_element(root, frontend)
135
+ when 'cancelled-subscription-notification' then
136
+ CancelledSubscriptionNotification.create_from_element(root, frontend)
135
137
  else
136
138
  raise UnknownNotificationType, "Unknown notification type: #{root.name}"
137
139
  end
@@ -487,6 +489,33 @@ module Google4R #:nodoc:
487
489
  end
488
490
  end
489
491
 
492
+ # CancelledSubscriptionNotification objects contain information about the
493
+ # cancellation of a subscription, including the item-ids, google order number,
494
+ # reason, and timestamp.
495
+ class CancelledSubscriptionNotification < Notification
496
+
497
+ # The reason for the cancellation (String, can be nil.)
498
+ attr_accessor :reason
499
+
500
+ # The ids of the items being cancelled (Array of Strings)
501
+ attr_accessor :item_ids
502
+
503
+ # The google order number of the subscription being cancelled
504
+ attr_accessor :google_order_number
505
+
506
+ def self.create_from_element(element, frontend)
507
+ csn = CancelledSubscriptionNotification.new(frontend)
508
+
509
+ csn.serial_number = element.attributes['serial-number']
510
+ csn.timestamp = Time.parse(element.elements['timestamp'].text)
511
+ csn.reason = element.elements['reason'].text rescue nil
512
+ csn.item_ids = element.elements['item-ids/item-id/merchant-item-id'].collect {|i| i.text} rescue []
513
+ csn.google_order_number = element.elements['google-order-number'].text
514
+
515
+ return csn
516
+ end
517
+ end
518
+
490
519
  # Container for the valid financial order states as defined in the
491
520
  # Google Checkout API.
492
521
  module FinancialOrderState
@@ -147,6 +147,84 @@ class Google4R::Checkout::CheckoutCommandIntegrationTest < Test::Unit::TestCase
147
147
  assert_kind_of CheckoutRedirectResponse, result
148
148
  end
149
149
 
150
+ def test_sending_to_google_works_with_google_handled_subscription
151
+ setup_command(@command)
152
+
153
+ @command.shopping_cart.create_item do |item|
154
+ item.name = "Test subscription"
155
+ item.description = "12 month subscription"
156
+ item.unit_price = Money.us_dollar(0)
157
+ item.quantity = 1
158
+ item.private_data = { :id => 123456 }
159
+
160
+ item.create_subscription do |subscription|
161
+ subscription.type = "google"
162
+ subscription.period = "MONTHLY"
163
+
164
+ subscription.add_payment do |payment|
165
+ payment.times = 12
166
+ payment.maximum_charge = Money.us_dollar(1200)
167
+ end
168
+
169
+ subscription.add_recurrent_item do |rec_item|
170
+ rec_item.name = "Usage of My Awesome Website for One Month"
171
+ rec_item.description = "Your flat charge for accessing my web site"
172
+ rec_item.quantity = 1
173
+ rec_item.unit_price = Money.us_dollar(1200)
174
+
175
+ rec_item.create_digital_content do |content|
176
+ content.display_disposition = "OPTIMISTIC"
177
+ content.url = "http://mywebsite.example.com"
178
+ content.description = "Pie is found at this web site!"
179
+ end
180
+ end
181
+
182
+ item.create_digital_content do |content|
183
+ content.display_disposition = "OPTIMISTIC"
184
+ content.description = "Congratulations! Your subscription is being set up. Feel free to log onto" +
185
+ "<a href=\"http://mywebsite.example.com\">My website</a>."
186
+ end
187
+ end
188
+ end
189
+
190
+ result = @command.send_to_google_checkout
191
+ assert_kind_of CheckoutRedirectResponse, result
192
+ end
193
+
194
+ def test_sending_to_google_works_with_merchant_handled_subscription
195
+ setup_command(@command)
196
+
197
+ @command.shopping_cart.create_item do |item|
198
+ item.name = "Test subscription"
199
+ item.description = "12 month subscription"
200
+ item.unit_price = Money.us_dollar(0)
201
+ item.quantity = 1
202
+ item.private_data = { :id => 123456 }
203
+
204
+ item.create_subscription do |subscription|
205
+ subscription.type = "merchant"
206
+ subscription.period = "MONTHLY"
207
+ subscription.start_date = Time.new
208
+ subscription.start_date += (60 * 60 * 24 * 30)
209
+ subscription.no_charge_after = subscription.start_date + (60 * 60 * 24 * 365)
210
+
211
+ subscription.add_payment do |payment|
212
+ payment.times = 12
213
+ payment.maximum_charge = Money.us_dollar(1200)
214
+ end
215
+
216
+ item.create_digital_content do |content|
217
+ content.display_disposition = "OPTIMISTIC"
218
+ content.description = "Congratulations! Your subscription is being set up. Feel free to log onto" +
219
+ "<a href=\"http://mywebsite.example.com\">My website</a>."
220
+ end
221
+ end
222
+ end
223
+
224
+ result = @command.send_to_google_checkout
225
+ assert_kind_of CheckoutRedirectResponse, result
226
+ end
227
+
150
228
  def test_using_invalid_credentials_raise_google_checkout_error
151
229
  invalid_patches = [ [ :merchant_id, 'invalid' ], [ :merchant_key, 'invalid' ] ]
152
230
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nbudin-google4r-checkout
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.10
4
+ version: 1.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Chan
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-03 00:00:00 -07:00
12
+ date: 2009-11-02 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,7 +22,7 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 1.7.1
24
24
  version:
25
- description: Ruby library to access the Google Checkout service and implement notification handlers.
25
+ description: Nat Budin's branch of the Ruby library to access the Google Checkout service and implement notification handlers.
26
26
  email:
27
27
  executables: []
28
28
 
@@ -111,8 +111,10 @@ files:
111
111
  - test/xml/apiv2.xsd
112
112
  - test/xml/test_check_persisting_works_expected.xml
113
113
  - var/cacert.pem
114
- has_rdoc: false
114
+ has_rdoc: true
115
115
  homepage:
116
+ licenses: []
117
+
116
118
  post_install_message:
117
119
  rdoc_options:
118
120
  - --charset=UTF-8
@@ -133,10 +135,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
135
  requirements: []
134
136
 
135
137
  rubyforge_project:
136
- rubygems_version: 1.2.0
138
+ rubygems_version: 1.3.5
137
139
  signing_key:
138
140
  specification_version: 3
139
- summary: Ruby library to access the Google Checkout service and implement notification handlers.
141
+ summary: Nat Budin's branch of the Ruby library to access the Google Checkout service and implement notification handlers.
140
142
  test_files:
141
143
  - test/integration/checkout_command_test.rb
142
144
  - test/unit/order_adjustment_test.rb