nbudin-google4r-checkout 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. data/.gitignore +3 -0
  2. data/CHANGES +83 -0
  3. data/LICENSE +22 -0
  4. data/README +58 -0
  5. data/Rakefile +80 -0
  6. data/VERSION +1 -0
  7. data/lib/google4r/checkout/commands.rb +515 -0
  8. data/lib/google4r/checkout/frontend.rb +204 -0
  9. data/lib/google4r/checkout/merchant_calculation.rb +321 -0
  10. data/lib/google4r/checkout/notifications.rb +708 -0
  11. data/lib/google4r/checkout/shared.rb +1249 -0
  12. data/lib/google4r/checkout/utils.rb +94 -0
  13. data/lib/google4r/checkout/xml_generation.rb +920 -0
  14. data/lib/google4r/checkout.rb +34 -0
  15. data/test/frontend_configuration.rb +13 -0
  16. data/test/integration/checkout_command_test.rb +246 -0
  17. data/test/test_helper.rb +115 -0
  18. data/test/unit/add_merchant_order_number_command_test.rb +70 -0
  19. data/test/unit/add_tracking_data_command_test.rb +75 -0
  20. data/test/unit/address_test.rb +131 -0
  21. data/test/unit/anonymous_address_test.rb +75 -0
  22. data/test/unit/archive_order_command_test.rb +66 -0
  23. data/test/unit/area_test.rb +44 -0
  24. data/test/unit/authorization_amount_notification_test.rb +69 -0
  25. data/test/unit/authorize_order_command_test.rb +66 -0
  26. data/test/unit/backorder_items_command_test.rb +83 -0
  27. data/test/unit/callback_handler_test.rb +83 -0
  28. data/test/unit/cancel_items_command_test.rb +89 -0
  29. data/test/unit/cancel_order_command_test.rb +83 -0
  30. data/test/unit/carrier_calculated_shipping_test.rb +57 -0
  31. data/test/unit/charge_amount_notification_test.rb +64 -0
  32. data/test/unit/charge_order_command_test.rb +77 -0
  33. data/test/unit/chargeback_amount_notification_test.rb +65 -0
  34. data/test/unit/checkout_command_test.rb +125 -0
  35. data/test/unit/checkout_command_xml_generator_test.rb +218 -0
  36. data/test/unit/command_test.rb +116 -0
  37. data/test/unit/deliver_order_command_test.rb +70 -0
  38. data/test/unit/delivery_method_test.rb +42 -0
  39. data/test/unit/digital_content_test.rb +105 -0
  40. data/test/unit/flat_rate_shipping_test.rb +132 -0
  41. data/test/unit/frontend_test.rb +136 -0
  42. data/test/unit/item_info_test.rb +69 -0
  43. data/test/unit/item_test.rb +171 -0
  44. data/test/unit/marketing_preferences_test.rb +65 -0
  45. data/test/unit/merchant_calculated_shipping_test.rb +172 -0
  46. data/test/unit/merchant_calculation_callback_test.rb +137 -0
  47. data/test/unit/merchant_calculation_result_test.rb +78 -0
  48. data/test/unit/merchant_calculation_results_test.rb +178 -0
  49. data/test/unit/merchant_code_result_test.rb +51 -0
  50. data/test/unit/merchant_code_test.rb +122 -0
  51. data/test/unit/new_order_notification_test.rb +115 -0
  52. data/test/unit/notification_acknowledgement_test.rb +67 -0
  53. data/test/unit/notification_handler_test.rb +113 -0
  54. data/test/unit/order_adjustment_test.rb +119 -0
  55. data/test/unit/order_state_change_notification_test.rb +158 -0
  56. data/test/unit/pickup_shipping_test.rb +70 -0
  57. data/test/unit/postal_area_test.rb +71 -0
  58. data/test/unit/private_data_parser_test.rb +68 -0
  59. data/test/unit/refund_amount_notification_test.rb +65 -0
  60. data/test/unit/refund_order_command_test.rb +86 -0
  61. data/test/unit/reset_items_shipping_information_command_test.rb +83 -0
  62. data/test/unit/return_items_command_test.rb +83 -0
  63. data/test/unit/risk_information_notification_test.rb +98 -0
  64. data/test/unit/send_buyer_message_command_test.rb +73 -0
  65. data/test/unit/ship_items_command_test.rb +101 -0
  66. data/test/unit/shipping_adjustment_test.rb +100 -0
  67. data/test/unit/shopping_cart_test.rb +146 -0
  68. data/test/unit/tax_rule_test.rb +70 -0
  69. data/test/unit/tax_table_test.rb +82 -0
  70. data/test/unit/tracking_data_test.rb +54 -0
  71. data/test/unit/unarchive_order_command_test.rb +66 -0
  72. data/test/unit/us_country_area_test.rb +76 -0
  73. data/test/unit/us_state_area_test.rb +70 -0
  74. data/test/unit/us_zip_area_test.rb +66 -0
  75. data/test/unit/world_area_test.rb +48 -0
  76. data/test/xml/apiv2.xsd +997 -0
  77. data/test/xml/test_check_persisting_works_expected.xml +213 -0
  78. data/var/cacert.pem +7815 -0
  79. metadata +200 -0
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ test/frontend_configuration.rb
2
+ .loadpath
3
+ .project
data/CHANGES ADDED
@@ -0,0 +1,83 @@
1
+ =google4r-checkout Changelog
2
+
3
+ == 1.0.3 (2008-08-08)
4
+
5
+ * Added analytics_data support. Thanks to Will Schwenk!
6
+ * Added create_address_filters_allowed_area and create_address_filters_excluded_area method to the MerchantCalculatedShipping class.
7
+ * Created two aliases create_shipping_restrictions_allowed_area and create_shipping_restrictions_excluded_area to facilitate deprecation of create_allowed_area and create_excluded_area.
8
+ * country_code in PostalArea class is now optional in the initialize method so it can be called properly in the create_area method in shared.rb.
9
+ * Added line-item shipping support.
10
+ * Refactor notifications to extract a base notification class that has the front_end, serial_number, google_order_number and timestamp.
11
+ * Added notification handshake support (i.e. serial-number) for notifciation-acknowledgement.
12
+ * Added digital delivery support. Thanks to Andy Kim and Matthew Moore!
13
+ * Added Carrier Calculated Shipping support.
14
+ * Added unit tests - carrier_calculated_shipping_test.rb, digital_content_test.rb, *_items_*commands.rb
15
+ * Updated unit tests - item_test.rb, merchant_calculated_shipping_test.rb, notification_acknowledgement_test.rb
16
+ * Updated integration test - checkout_command_test.rb
17
+ * Added HTML Form API Signature support. It is included in utils.rb.
18
+
19
+ == 1.0.2 (2007-08-18)
20
+
21
+ * Moved Address from notifications.rb to shared.rb
22
+ * Added AnonymousAddress class, now Address is extended from it
23
+ * Added merchant calcuations callback and result support
24
+ * Added unit tests for merchant calculation callback and result
25
+ * Added merchant calculations tag support in Shopping Cart XML
26
+ * Updated checkout_command_test.rb and checkout_command_xml_generator_test.rb after for testing merchant calculations tag support
27
+
28
+ == 1.0.1 (2007-08-16)
29
+
30
+ * Fixed text.to_s.gsub(/[^0-9]/, '') to (...text.to_f*100).to_i so dollar amount is now handled correctly
31
+
32
+ == 1.0.0 (2007-08-04)
33
+
34
+ * Added refund-amount-notification
35
+ * Added chargeback-amount-notification
36
+ * Added authorization-amount-notification
37
+ * Added refund command
38
+ * Added authorize command
39
+ * Added add-merchant-number command
40
+ * Added add-tracking-data command
41
+ * Added send-buyer-message command
42
+ * Added archive-order command
43
+ * Added unarchive-order command
44
+ * Refactored to_xml in the Command class
45
+ * Added CommandXmlGenerator base class
46
+ * Added ChargeOrderCommand, DeliverOrderCommand, CancelOrderCommand, ChargeAmountNotification and RiskInfoNotification (all contributed by Dan Dukeson).
47
+ * Attributes are not retrieved via XPaths with "tag/@attribute" any more but with REXML's Element#attributes. This should fix problems with Ruby 1.8.6.
48
+
49
+ == 0.1.0 (2007-05-12)
50
+ * Added property "shipping_taxed" to TaxRule (contributed by Dan Dukeson).
51
+ * Added XML generation for the tax tables in the shopping cart (contributed by Dan Dukeson).
52
+ * Added Area subclasses WorldArea and PostalArea (contributed by Dan Dukeson).
53
+ * Changed time zones in tests to UTC.
54
+ * Added Test::Unit::TestCase#assert_strings_equal to test_helper.rb.
55
+ * Added "rake test" (alias of "rake test:all")
56
+ * Added GoogleCheckoutError#to_s to return verbose representation.
57
+ * Split google4r into google4r-checkout and google4r-maps.
58
+ * MerchantCode#create_from_element raises an ArgumentError instead of a RuntimeError on invalid elements now.
59
+ * Changed the #create_from_element code to set the properties directly into the objects instead of building Hashes to collect the values first.
60
+ * "Resolved" the problem of converting currency amounts which are fractional numbers into the amount of the minor currency to be passed into the Money class: Instead of converting the fractional number into a float and multiplying by 100, all nonnumeric characters are stripped from the string, the resulting number is converted into an integer and this integer is then passed to Money.new.
61
+ * Added example to NotificationHandler of how to use the class.
62
+ * Added link to simple_http_auth plugin in NotificationHandler which allows for easy HTTP Auth Basic protection of Rails controllers.
63
+ * Renamed CheckoutCommand#cart to CheckoutCommand#shopping_cart
64
+ * CheckoutCommand raises ArgumentError instead of RuntimeError on invalid clazz parameter.
65
+ * Added "Howto freeze google4r in a Rails project" to README
66
+ * Google4R::Checkout::Command#to_xml raises an NotImplementedError instead of a RuntimeError now.
67
+ * Geocoder returns nil on 603 (G_UNAVAILABLE_ADDRESS) results now.
68
+ * Added support for registering GUnload() to be called on window's unload event.
69
+ * The generated Javascript that creates the GMap2() instance (and thus modifies the map div) has been put into a function <var name>_loader that is called in an onload handler. This should remove a problem with MSIE.
70
+ * Using Syck as the YAML parser now. However, a workaround is needed because of http://code.whytheluckystiff.net/syck/ticket/27.
71
+ * Only require the json gem if objects have no "to_json" method already added to them. This solves a problem with converting arbitrary objects to json because the json gem seemingly only converts simple types.
72
+ * Added GMarker#info_window_html.
73
+ * Added support for onclick handlers in markers.
74
+ * Added support for the value :auto of GMap2#zoom and GMap2#center.
75
+ * Fixed buggy generation of GMarker Javascript.
76
+ * Adding website folder to contain a webgen based website.
77
+ * Fixed a problem with generating XML from Hashes in the "private" data of shopping carts and items.
78
+ * The parse for the <order-adjustment> tag does not expect to see a <shipping> tag in every case any more.
79
+ * Extending Google4R::Maps by the classes GMap2, GIcon and GMarker to allow for easy Google Maps HTML generation.
80
+
81
+ == 0.0.1 (2007-02-17)
82
+
83
+ * initial release, be prepared for some API changes that move the API closer to the XML API
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Unless noted otherwise, the files of this projects are licensed under a MIT
2
+ style license:
3
+
4
+ Copyright (c) 2007 Manuel Holtgrewe
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to
8
+ deal in the Software without restriction, including without limitation the
9
+ rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
+ sell copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in
14
+ all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
+ IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,58 @@
1
+ = google4r/checkout
2
+
3
+ google4r/checkout is a library to access the Google Checkout API.
4
+
5
+ === License
6
+
7
+ google4r itself is distributed under an MIT style license.
8
+
9
+ However, the library includes the cacert.pem:http://curl.haxx.se/ca/cacert.pem file from the Mozilla project. This file is distributed under the MPL:http://www.mozilla.org/MPL/.
10
+
11
+ == More Information
12
+
13
+ You can find more information on the Google Checkout API here:http://code.google.com/apis/checkout/developer/index.html. Note that the API documentation assumes an understanding of the Google Checkout XML API.
14
+
15
+ == Google Checkout Tests
16
+
17
+ You have to place a file called 'frontend_configuration.rb' in the directory'test' with the configuration for the Google4R::Checkout::Frontend class to use for running the tests.
18
+
19
+ The file should contain content similar to:
20
+
21
+ # Uncomment the following line if you are using Google Checkout in Great Britain
22
+ # and adjust it if you want to test google4r-checkout against any other (future)
23
+ # Google Checkout service.
24
+
25
+ # Money.default_currency = 'GBP'
26
+
27
+ # The test configuration for the Google4R::Checkout::Frontend class.
28
+ FRONTEND_CONFIGURATION =
29
+ {
30
+ :merchant_id => '<your merchant id>',
31
+ :merchant_key => '<your merchant key>',
32
+ :use_sandbox => true
33
+ }
34
+
35
+ == Dependencies
36
+
37
+ The unit tests use Mocha so you have to install the gem "mocha" to run the tests. You will also need the money gem library.
38
+
39
+ == How To: Freeze a google4r version in a Rails project
40
+
41
+ <code>rake rails:freeze:gems</code> only works for the Rails gems. So, how do you freeze your own gems like google4r? It turns out to be pretty straightforward:
42
+
43
+ cd RAILS_ROOT
44
+ cd vendor
45
+ gem unpack google4r-checkout
46
+ ls
47
+ # ... google4r-checkout-0.1.1 ...
48
+
49
+ Then, open RAILS_ROOT/config/environment.rb in your favourite text editor and add the following lines at the top of the file just below <code>require File.join(File.dirname(__FILE__), 'boot')</code>:
50
+
51
+ # Freeze non-Rails gem.
52
+ Dir.glob(File.join(RAILS_ROOT, 'vendor', '*', 'lib')) do |path|
53
+ $LOAD_PATH << path
54
+ end
55
+
56
+ Now you can use the following in your own code:
57
+
58
+ require 'google4r/checkout'
data/Rakefile ADDED
@@ -0,0 +1,80 @@
1
+ # google4r-checkout Rakefile
2
+
3
+ require 'rake'
4
+ require 'rake/testtask'
5
+ require 'rake/gempackagetask'
6
+ require 'rake/rdoctask'
7
+
8
+ desc 'Default: run all tests tests.'
9
+ task :default => :'test:all'
10
+
11
+ desc 'Runs all tests (alias of test:all)'
12
+ task :test => :'test:all'
13
+
14
+ #
15
+ # File sets
16
+ #
17
+ RUBY_FILES = FileList['lib/**/*.rb', 'lib/**/vendor/**']
18
+ RDOC_EXTRA = FileList['README','LICENSE', 'CHANGES']
19
+ EXTRA_FILES = FileList['var/cacert.pem']
20
+
21
+ #
22
+ # Documentation
23
+ #
24
+
25
+ desc 'Generate documentation for the google4r library.'
26
+ Rake::RDocTask.new(:rdoc) do |rdoc|
27
+ rdoc.rdoc_dir = 'docs'
28
+ rdoc.title = 'google4r/checkout'
29
+ rdoc.main = 'README'
30
+ rdoc.options << '--line-numbers' << '--inline-source'
31
+ rdoc.rdoc_files = RUBY_FILES + RDOC_EXTRA
32
+ end
33
+
34
+ #
35
+ # Test, test, test! I love saying the word "test"!
36
+ #
37
+
38
+ namespace :test do
39
+ desc 'Run all tests on the Google4R::Checkout::* classes.'
40
+ task :all => [ :integration, :unit, :system ]
41
+
42
+ desc 'Run unit tests on the Google4R::Checkout::* classes.'
43
+ Rake::TestTask.new(:unit) do |t|
44
+ t.libs << 'lib'
45
+ t.pattern = 'test/unit/*_test.rb'
46
+ t.verbose = true
47
+ end
48
+
49
+ desc 'Run integration tests on the Google4R::Checkout::* classes.'
50
+ Rake::TestTask.new(:integration) do |t|
51
+ t.libs << 'lib'
52
+ t.pattern = 'test/integration/*_test.rb'
53
+ t.verbose = true
54
+ end
55
+
56
+ desc 'Run system tests on the Google4R::Checkout::* classes.'
57
+ Rake::TestTask.new(:system) do |t|
58
+ t.libs << 'lib'
59
+ t.pattern = 'test/system/*_test.rb'
60
+ t.verbose = true
61
+ end
62
+ end
63
+
64
+ #
65
+ # Rubygem creation.
66
+ #
67
+
68
+ begin
69
+ require 'jeweler'
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."
73
+ spec.description = spec.summary
74
+ spec.authors = ["Tony Chan"]
75
+
76
+ spec.add_dependency('money', '>= 1.7.1')
77
+ end
78
+ rescue LoadError
79
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
80
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.6