google4r-checkout-jn 1.1.jniziol
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +136 -0
- data/LICENSE +22 -0
- data/README.md +72 -0
- data/lib/google4r/checkout.rb +34 -0
- data/lib/google4r/checkout/commands.rb +665 -0
- data/lib/google4r/checkout/frontend.rb +222 -0
- data/lib/google4r/checkout/merchant_calculation.rb +323 -0
- data/lib/google4r/checkout/notifications.rb +774 -0
- data/lib/google4r/checkout/shared.rb +1386 -0
- data/lib/google4r/checkout/utils.rb +94 -0
- data/lib/google4r/checkout/xml_generation.rb +1023 -0
- data/test/frontend_configuration_example.rb +13 -0
- data/test/integration/checkout_command_test.rb +261 -0
- data/test/test_helper.rb +105 -0
- data/test/unit/add_merchant_order_number_command_test.rb +65 -0
- data/test/unit/add_tracking_data_command_test.rb +68 -0
- data/test/unit/address_test.rb +131 -0
- data/test/unit/anonymous_address_test.rb +75 -0
- data/test/unit/archive_order_command_test.rb +63 -0
- data/test/unit/area_test.rb +44 -0
- data/test/unit/authorization_amount_notification_test.rb +69 -0
- data/test/unit/authorize_order_command_test.rb +63 -0
- data/test/unit/backorder_items_command_test.rb +69 -0
- data/test/unit/callback_handler_test.rb +83 -0
- data/test/unit/cancel_items_command_test.rb +76 -0
- data/test/unit/cancel_order_command_test.rb +74 -0
- data/test/unit/carrier_calculated_shipping_test.rb +57 -0
- data/test/unit/charge_amount_notification_test.rb +72 -0
- data/test/unit/charge_and_ship_order_command_test.rb +69 -0
- data/test/unit/charge_fee_test.rb +53 -0
- data/test/unit/charge_order_command_test.rb +69 -0
- data/test/unit/chargeback_amount_notification_test.rb +69 -0
- data/test/unit/checkout_command_test.rb +149 -0
- data/test/unit/checkout_command_xml_generator_test.rb +216 -0
- data/test/unit/command_test.rb +116 -0
- data/test/unit/deliver_order_command_test.rb +65 -0
- data/test/unit/delivery_method_test.rb +42 -0
- data/test/unit/digital_content_test.rb +105 -0
- data/test/unit/flat_rate_shipping_test.rb +133 -0
- data/test/unit/frontend_test.rb +144 -0
- data/test/unit/item_info_test.rb +69 -0
- data/test/unit/item_test.rb +171 -0
- data/test/unit/marketing_preferences_test.rb +65 -0
- data/test/unit/merchant_calculated_shipping_test.rb +173 -0
- data/test/unit/merchant_calculation_callback_test.rb +137 -0
- data/test/unit/merchant_calculation_result_test.rb +78 -0
- data/test/unit/merchant_calculation_results_test.rb +203 -0
- data/test/unit/merchant_code_result_test.rb +51 -0
- data/test/unit/merchant_code_test.rb +122 -0
- data/test/unit/new_order_notification_test.rb +115 -0
- data/test/unit/notification_acknowledgement_test.rb +67 -0
- data/test/unit/notification_handler_test.rb +113 -0
- data/test/unit/order_adjustment_test.rb +119 -0
- data/test/unit/order_report_command_test.rb +109 -0
- data/test/unit/order_state_change_notification_test.rb +158 -0
- data/test/unit/parameterized_url_test.rb +57 -0
- data/test/unit/pickup_shipping_test.rb +70 -0
- data/test/unit/postal_area_test.rb +71 -0
- data/test/unit/private_data_parser_test.rb +68 -0
- data/test/unit/refund_amount_notification_test.rb +67 -0
- data/test/unit/refund_order_command_test.rb +79 -0
- data/test/unit/reset_items_shipping_information_command_test.rb +69 -0
- data/test/unit/return_items_command_test.rb +69 -0
- data/test/unit/risk_information_notification_test.rb +98 -0
- data/test/unit/send_buyer_message_command_test.rb +68 -0
- data/test/unit/ship_items_command_test.rb +81 -0
- data/test/unit/shipping_adjustment_test.rb +100 -0
- data/test/unit/shopping_cart_test.rb +146 -0
- data/test/unit/tax_rule_test.rb +70 -0
- data/test/unit/tax_table_test.rb +88 -0
- data/test/unit/tracking_data_test.rb +54 -0
- data/test/unit/unarchive_order_command_test.rb +63 -0
- data/test/unit/url_parameter_test.rb +55 -0
- data/test/unit/us_country_area_test.rb +76 -0
- data/test/unit/us_state_area_test.rb +70 -0
- data/test/unit/us_zip_area_test.rb +66 -0
- data/test/unit/world_area_test.rb +48 -0
- data/var/cacert.pem +7815 -0
- metadata +230 -0
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'google4r/checkout'
|
2
|
+
|
3
|
+
require 'test/frontend_configuration'
|
4
|
+
#--
|
5
|
+
# Project: google_checkout4r
|
6
|
+
# File: test/unit/area_test.rb
|
7
|
+
# Author: Manuel Holtgrewe <purestorm at ggnore dot net>
|
8
|
+
# Copyright: (c) 2007 by Manuel Holtgrewe
|
9
|
+
# License: MIT License as follows:
|
10
|
+
#
|
11
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
12
|
+
# a copy of this software and associated documentation files (the
|
13
|
+
# "Software"), to deal in the Software without restriction, including
|
14
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
15
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
16
|
+
# persons to whom the Software is furnished to do so, subject to the
|
17
|
+
# following conditions:
|
18
|
+
#
|
19
|
+
# The above copyright notice and this permission notice shall be included
|
20
|
+
# in all copies or substantial portions of the Software.
|
21
|
+
#
|
22
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
23
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
24
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
25
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
26
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
27
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
28
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
29
|
+
#++
|
30
|
+
|
31
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
32
|
+
|
33
|
+
require 'google4r/checkout'
|
34
|
+
|
35
|
+
require 'test/frontend_configuration'
|
36
|
+
|
37
|
+
# Test for the class Area.
|
38
|
+
class Google4R::Checkout::PostalAreaTest < Test::Unit::TestCase
|
39
|
+
include Google4R::Checkout
|
40
|
+
|
41
|
+
def setup
|
42
|
+
@area = PostalArea.new('GB', 'S6*')
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_initialization_works
|
46
|
+
assert_equal 'GB' , @area.country_code
|
47
|
+
assert_equal 'S6*', @area.postal_code_pattern
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_us_state_area_behaves_correctly
|
51
|
+
assert_respond_to @area, :country_code
|
52
|
+
assert_respond_to @area, :country_code=
|
53
|
+
assert_respond_to @area, :postal_code_pattern
|
54
|
+
assert_respond_to @area, :postal_code_pattern=
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_accessors_should_work
|
58
|
+
@area.postal_code_pattern = '100*'
|
59
|
+
assert_equal '100*', @area.postal_code_pattern
|
60
|
+
|
61
|
+
@area.country_code = 'DE'
|
62
|
+
assert_equal 'DE', @area.country_code
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_initialize_without_postcode_works
|
66
|
+
pa = PostalArea.new('DE')
|
67
|
+
assert_equal 'DE', pa.country_code
|
68
|
+
assert_nil pa.postal_code_pattern
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/private_data_parser_test.rb
|
4
|
+
# Author: Manuel Holtgrewe <purestorm at ggnore dot net>
|
5
|
+
# Copyright: (c) 2007 by Manuel Holtgrewe
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Test for the class PrivateDataParser.
|
35
|
+
class Google4R::Checkout::PrivateDataParserTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@xml_str1 = %q{<merchant-private-item-data>
|
40
|
+
<item-note>Text 1</item-note>
|
41
|
+
<item-note>Text 2</item-note>
|
42
|
+
<nested>
|
43
|
+
<tags>value</tags>
|
44
|
+
</nested>
|
45
|
+
</merchant-private-item-data>}
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_responds_correctly
|
49
|
+
assert_respond_to PrivateDataParser, :element_to_value
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_parser_works_in_simple_example
|
53
|
+
element = REXML::Document.new(@xml_str1).root.elements['//tags']
|
54
|
+
|
55
|
+
assert_equal 'value', PrivateDataParser.element_to_value(element)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_parser_works_in_complex_example
|
59
|
+
doc = REXML::Document.new(@xml_str1)
|
60
|
+
|
61
|
+
hash =
|
62
|
+
{
|
63
|
+
'item-note' => [ 'Text 1', 'Text 2' ],
|
64
|
+
'nested' => { 'tags' => 'value' }
|
65
|
+
}
|
66
|
+
assert_equal hash, PrivateDataParser.element_to_value(doc.root)
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/refund_amount_notification_test.rb
|
4
|
+
# Author: Tony Chan <api.htchan AT gmail.com>
|
5
|
+
# Copyright: (c) 2007 by Tony Chan
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
require 'rexml/document'
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Test for the class RefundAmountNotification
|
35
|
+
class Google4R::Checkout::RefundAmountNotificationTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
40
|
+
@frontend.tax_table_factory = TestTaxTableFactory.new
|
41
|
+
|
42
|
+
@example_xml = %q{
|
43
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
44
|
+
<refund-amount-notification xmlns="http://checkout.google.com/schema/2"
|
45
|
+
serial-number="d669f8c7-6d75-4ad6-9278-d2fc997d15f2">
|
46
|
+
<google-order-number>841171949013218</google-order-number>
|
47
|
+
<latest-refund-amount currency="GBP">226.06</latest-refund-amount>
|
48
|
+
<total-refund-amount currency="GBP">226.06</total-refund-amount>
|
49
|
+
<latest-fee-refund-amount>5.04</latest-fee-refund-amount>
|
50
|
+
<timestamp>2006-03-18T20:25:31</timestamp>
|
51
|
+
</refund-amount-notification>
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_create_from_element_works_correctly
|
56
|
+
root = REXML::Document.new(@example_xml).root
|
57
|
+
|
58
|
+
notification = RefundAmountNotification.create_from_element(root, @frontend)
|
59
|
+
|
60
|
+
assert_equal 'd669f8c7-6d75-4ad6-9278-d2fc997d15f2', notification.serial_number
|
61
|
+
assert_equal '841171949013218', notification.google_order_number
|
62
|
+
assert_equal Time.parse('2006-03-18T20:25:31'), notification.timestamp
|
63
|
+
assert_equal(Money.new(22606, 'GBP'), notification.total_refund_amount)
|
64
|
+
assert_equal(Money.new(22606, 'GBP'), notification.latest_refund_amount)
|
65
|
+
assert_equal(Money.new(504, nil), notification.latest_fee_refund_amount)
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/refund_order_command_test.rb
|
4
|
+
# Author: Tony Chan <api.htchan at gmail dot com>
|
5
|
+
# Copyright: (c) 2007 by Tony Chan
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Tests for the RefundOrderCommand class.
|
35
|
+
class Google4R::Checkout::RefundOrderCommandTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
40
|
+
@command = @frontend.create_refund_order_command
|
41
|
+
@command.google_order_number = '841171949013218'
|
42
|
+
@command.amount = Money.new(1000, 'USD')
|
43
|
+
@command.comment = 'Discount for inconvenience; ship replacement item'
|
44
|
+
@command.reason = 'Damaged Merchandise'
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_behaves_correctly
|
48
|
+
[ :google_order_number, :amount, :reason, :comment ].each do |symbol|
|
49
|
+
assert_respond_to @command, symbol
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_xml_without_amount
|
54
|
+
@command.amount = nil
|
55
|
+
@command.comment = nil
|
56
|
+
|
57
|
+
assert_command_element_text_equals(@command.reason, "> reason", @command)
|
58
|
+
assert_no_command_element_exists("amount", @command)
|
59
|
+
assert_no_command_element_exists("comment", @command)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_accessors
|
63
|
+
assert_equal('841171949013218', @command.google_order_number)
|
64
|
+
assert_equal(Money.new(1000, 'USD'), @command.amount)
|
65
|
+
assert_equal('Discount for inconvenience; ship replacement item', @command.comment)
|
66
|
+
assert_equal('Damaged Merchandise', @command.reason)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_xml_generation
|
70
|
+
assert_command_element_text_equals(@command.reason, "> reason", @command)
|
71
|
+
assert_command_element_text_equals(@command.amount, "> amount[currency='USD']", @command)
|
72
|
+
assert_command_element_text_equals(@command.comment, "> comment", @command)
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_to_xml_does_not_raise_exception
|
76
|
+
assert_nothing_raised { @command.to_xml }
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/reset_items_shipping_information_command_test.rb
|
4
|
+
# Author: Tony Chan <api.htchan at gmail dot com>
|
5
|
+
# Copyright: (c) 2007 by Dan Dukeson
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Tests for the ResetItemsShippingInformationCommand class.
|
35
|
+
class Google4R::Checkout::ResetItemsShippingInformationCommandTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
40
|
+
@command = @frontend.create_reset_items_shipping_information_command
|
41
|
+
|
42
|
+
@command.google_order_number = '841171949013218'
|
43
|
+
@command.send_email = true
|
44
|
+
@item_info1 = ItemInfo.new('A1')
|
45
|
+
@item_info2 = ItemInfo.new('B2')
|
46
|
+
@command.item_info_arr = [@item_info1, @item_info2]
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_behaves_correctly
|
50
|
+
[ :google_order_number, :item_info_arr, :send_email,
|
51
|
+
:google_order_number=, :item_info_arr=, :send_email= ].each do |symbol|
|
52
|
+
assert_respond_to @command, symbol
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_xml_send_email
|
57
|
+
assert_command_element_text_equals("true", "> send-email", @command)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_accessors
|
61
|
+
assert_equal('841171949013218', @command.google_order_number)
|
62
|
+
assert @command.send_email
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_to_xml_does_not_raise_exception
|
66
|
+
assert_nothing_raised { @command.to_xml }
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/return_items_command_test.rb
|
4
|
+
# Author: Tony Chan <api.htchan at gmail dot com>
|
5
|
+
# Copyright: (c) 2007 by Dan Dukeson
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Tests for the ReturnItemsCommand class.
|
35
|
+
class Google4R::Checkout::ReturnItemsCommandTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
40
|
+
@command = @frontend.create_return_items_command
|
41
|
+
|
42
|
+
@command.google_order_number = '841171949013218'
|
43
|
+
@command.send_email = true
|
44
|
+
@item_info1 = ItemInfo.new('A1')
|
45
|
+
@item_info2 = ItemInfo.new('B2')
|
46
|
+
@command.item_info_arr = [@item_info1, @item_info2]
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_behaves_correctly
|
50
|
+
[ :google_order_number, :item_info_arr, :send_email,
|
51
|
+
:google_order_number=, :item_info_arr=, :send_email= ].each do |symbol|
|
52
|
+
assert_respond_to @command, symbol
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_xml_send_email
|
57
|
+
assert_command_element_text_equals("true", "> send-email", @command)
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_accessors
|
61
|
+
assert_equal('841171949013218', @command.google_order_number)
|
62
|
+
assert @command.send_email
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_to_xml_does_not_raise_exception
|
66
|
+
assert_nothing_raised { @command.to_xml }
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
#--
|
2
|
+
# Project: google_checkout4r
|
3
|
+
# File: test/unit/risk_info_notification_test.rb
|
4
|
+
# Author: Dan Dukeson <dandukeson AT gmail.com>
|
5
|
+
# Copyright: (c) 2007 by Dan Dukeson
|
6
|
+
# License: MIT License as follows:
|
7
|
+
#
|
8
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
9
|
+
# a copy of this software and associated documentation files (the
|
10
|
+
# "Software"), to deal in the Software without restriction, including
|
11
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
12
|
+
# distribute, sublicense, and/or sell copies of the Software, and to permit
|
13
|
+
# persons to whom the Software is furnished to do so, subject to the
|
14
|
+
# following conditions:
|
15
|
+
#
|
16
|
+
# The above copyright notice and this permission notice shall be included
|
17
|
+
# in all copies or substantial portions of the Software.
|
18
|
+
#
|
19
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
20
|
+
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
21
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
22
|
+
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
23
|
+
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
24
|
+
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
|
25
|
+
# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
26
|
+
#++
|
27
|
+
|
28
|
+
require File.expand_path(File.dirname(__FILE__)) + '/../test_helper'
|
29
|
+
|
30
|
+
require 'google4r/checkout'
|
31
|
+
require 'rexml/document'
|
32
|
+
require 'test/frontend_configuration'
|
33
|
+
|
34
|
+
# Test for the class Area.
|
35
|
+
class Google4R::Checkout::RiskInformationNotificationTest < Test::Unit::TestCase
|
36
|
+
include Google4R::Checkout
|
37
|
+
|
38
|
+
def setup
|
39
|
+
@frontend = Frontend.new(FRONTEND_CONFIGURATION)
|
40
|
+
@frontend.tax_table_factory = TestTaxTableFactory.new
|
41
|
+
|
42
|
+
@example_xml = %q{
|
43
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
44
|
+
<risk-information-notification xmlns="http://checkout.google.com/schema/2" serial-number="4f5adc5b-aac5-4618-9e3b-75e60eaf29cd">
|
45
|
+
<timestamp>2007-04-30T08:03:57.000Z</timestamp>
|
46
|
+
<google-order-number>1564645586934214</google-order-number>
|
47
|
+
<risk-information>
|
48
|
+
<billing-address>
|
49
|
+
<!-- Not to be tested here but in Address -->
|
50
|
+
<!--
|
51
|
+
<contact-name>Mr Contact Smith</contact-name>
|
52
|
+
<company-name>ACME Products</company-name>
|
53
|
+
<email>contact_smith@example.com</email>
|
54
|
+
<phone>012345 234567</phone>
|
55
|
+
<fax>012345 345678</fax>
|
56
|
+
<address1>123 Testing Road</address1>
|
57
|
+
<address2>Test Village</address2>
|
58
|
+
<country-code>GB</country-code>
|
59
|
+
<city>Testcity</city>
|
60
|
+
<region>South Testshire</region>
|
61
|
+
<postal-code>S6 1TT</postal-code>
|
62
|
+
-->
|
63
|
+
</billing-address>
|
64
|
+
<ip-address>123.456.123.456</ip-address>
|
65
|
+
<avs-response>Y</avs-response>
|
66
|
+
<cvn-response>M</cvn-response>
|
67
|
+
<eligible-for-protection>true</eligible-for-protection>
|
68
|
+
<partial-cc-number>6789</partial-cc-number>
|
69
|
+
<buyer-account-age>61</buyer-account-age>
|
70
|
+
</risk-information>
|
71
|
+
</risk-information-notification>
|
72
|
+
}
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_create_from_element_works_correctly
|
77
|
+
# Stub out Address creation.
|
78
|
+
expectation = Address.stubs(:create_from_element).times(1).returns(:address)
|
79
|
+
expectation.with { |param| param.name == 'billing-address' }
|
80
|
+
|
81
|
+
root = REXML::Document.new(@example_xml).root
|
82
|
+
|
83
|
+
notification = RiskInformationNotification.create_from_element(root, @frontend)
|
84
|
+
|
85
|
+
assert_equal '4f5adc5b-aac5-4618-9e3b-75e60eaf29cd', notification.serial_number
|
86
|
+
assert_equal '1564645586934214', notification.google_order_number
|
87
|
+
assert_equal true, notification.eligible_for_protection
|
88
|
+
|
89
|
+
assert_equal :address, notification.buyer_billing_address
|
90
|
+
|
91
|
+
assert_equal 'Y', notification.avs_response
|
92
|
+
assert_equal 'M', notification.cvn_response
|
93
|
+
assert_equal '6789', notification.partial_card_number
|
94
|
+
assert_equal '123.456.123.456', notification.ip_address
|
95
|
+
assert_equal 61, notification.buyer_account_age
|
96
|
+
assert_equal Time.parse('2007-04-30T08:03:57.000Z'), notification.timestamp
|
97
|
+
end
|
98
|
+
end
|