google4r-checkout 1.0.6.1 → 1.1.beta1
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/lib/google4r/checkout/commands.rb +17 -4
- data/lib/google4r/checkout/notifications.rb +14 -13
- data/lib/google4r/checkout/shared.rb +25 -10
- data/lib/google4r/checkout/xml_generation.rb +24 -4
- data/test/unit/add_merchant_order_number_command_test.rb +1 -6
- data/test/unit/add_tracking_data_command_test.rb +2 -9
- data/test/unit/archive_order_command_test.rb +1 -4
- data/test/unit/authorize_order_command_test.rb +1 -4
- data/test/unit/backorder_items_command_test.rb +1 -15
- data/test/unit/cancel_items_command_test.rb +3 -16
- data/test/unit/cancel_order_command_test.rb +4 -13
- data/test/unit/charge_order_command_test.rb +3 -11
- data/test/unit/checkout_command_xml_generator_test.rb +18 -20
- data/test/unit/deliver_order_command_test.rb +1 -6
- data/test/unit/flat_rate_shipping_test.rb +3 -2
- data/test/unit/merchant_calculated_shipping_test.rb +2 -1
- data/test/unit/merchant_calculation_callback_test.rb +1 -1
- data/test/unit/merchant_calculation_result_test.rb +7 -7
- data/test/unit/merchant_calculation_results_test.rb +27 -2
- data/test/unit/order_report_command_test.rb +6 -8
- data/test/unit/pickup_shipping_test.rb +1 -1
- data/test/unit/refund_order_command_test.rb +8 -15
- data/test/unit/reset_items_shipping_information_command_test.rb +1 -15
- data/test/unit/return_items_command_test.rb +1 -15
- data/test/unit/risk_information_notification_test.rb +1 -1
- data/test/unit/send_buyer_message_command_test.rb +2 -7
- data/test/unit/ship_items_command_test.rb +12 -32
- data/test/unit/tax_table_test.rb +6 -0
- data/test/unit/unarchive_order_command_test.rb +1 -4
- metadata +15 -14
@@ -110,6 +110,15 @@ module Google4R #:nodoc:
|
|
110
110
|
https.cert_store = self.class.x509_store
|
111
111
|
https.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
112
112
|
https.verify_depth = 5
|
113
|
+
https.verify_callback = Proc.new do |ok, ctx|
|
114
|
+
domain = ctx.chain.first.subject.to_a.select { |part| part.first == "CN" }.first[1]
|
115
|
+
|
116
|
+
domain == if frontend.configuration[:use_sandbox]
|
117
|
+
"sandbox.google.com"
|
118
|
+
else
|
119
|
+
"checkout.google.com"
|
120
|
+
end
|
121
|
+
end
|
113
122
|
|
114
123
|
# Send the request to Google.
|
115
124
|
result = https.request(request, self.to_xml)
|
@@ -588,15 +597,19 @@ module Google4R #:nodoc:
|
|
588
597
|
end
|
589
598
|
|
590
599
|
def financial_state=(financial_state)
|
600
|
+
financial_state_name = financial_state.to_s
|
601
|
+
|
591
602
|
raise 'Invalid financial state %s' % financial_state unless
|
592
|
-
FinancialState.constants.
|
593
|
-
@financial_state =
|
603
|
+
FinancialState.constants.any? { |state_name| state_name.to_s == financial_state_name }
|
604
|
+
@financial_state = financial_state_name
|
594
605
|
end
|
595
606
|
|
596
607
|
def fulfillment_state=(fulfillment_state)
|
608
|
+
fulfillment_state_name = fulfillment_state.to_s
|
609
|
+
|
597
610
|
raise 'Invalid fulfillment state %s' % fulfillment_state unless
|
598
|
-
FulfillmentState.constants.
|
599
|
-
@fulfillment_state =
|
611
|
+
FulfillmentState.constants.any? { |state_name| state_name.to_s == fulfillment_state_name }
|
612
|
+
@fulfillment_state = fulfillment_state_name
|
600
613
|
end
|
601
614
|
|
602
615
|
def to_xml
|
@@ -29,6 +29,7 @@
|
|
29
29
|
# handling code.
|
30
30
|
|
31
31
|
require 'rexml/document'
|
32
|
+
require 'bigdecimal'
|
32
33
|
|
33
34
|
module Google4R #:nodoc:
|
34
35
|
module Checkout #:nodoc:
|
@@ -230,7 +231,7 @@ module Google4R #:nodoc:
|
|
230
231
|
result.order_adjustment = OrderAdjustment.create_from_element(element.elements['order-adjustment'])
|
231
232
|
result.shopping_cart = ShoppingCart.create_from_element(element.elements['shopping-cart'], result)
|
232
233
|
|
233
|
-
amount = (element.elements['order-total'].text
|
234
|
+
amount = (BigDecimal.new(element.elements['order-total'].text)*100).to_i
|
234
235
|
currency = element.elements['order-total'].attributes['currency']
|
235
236
|
result.order_total = Money.new(amount, currency)
|
236
237
|
|
@@ -311,11 +312,11 @@ module Google4R #:nodoc:
|
|
311
312
|
charge.google_order_number = element.elements['google-order-number'].text
|
312
313
|
|
313
314
|
currency = element.elements['latest-charge-amount'].attributes['currency']
|
314
|
-
amount = (element.elements['latest-charge-amount'].text
|
315
|
+
amount = (BigDecimal.new(element.elements['latest-charge-amount'].text)*100).to_i
|
315
316
|
charge.latest_charge_amount = Money.new(amount, currency)
|
316
317
|
|
317
318
|
currency = element.elements['total-charge-amount'].attributes['currency']
|
318
|
-
amount = (element.elements['total-charge-amount'].text
|
319
|
+
amount = (BigDecimal.new(element.elements['total-charge-amount'].text)*100).to_i
|
319
320
|
charge.total_charge_amount = Money.new(amount, currency)
|
320
321
|
|
321
322
|
charge.timestamp = Time.parse(element.elements['timestamp'].text)
|
@@ -347,11 +348,11 @@ module Google4R #:nodoc:
|
|
347
348
|
refund.google_order_number = element.elements['google-order-number'].text
|
348
349
|
|
349
350
|
currency = element.elements['latest-refund-amount'].attributes['currency']
|
350
|
-
amount = (element.elements['latest-refund-amount'].text
|
351
|
+
amount = (BigDecimal.new(element.elements['latest-refund-amount'].text)*100).to_i
|
351
352
|
refund.latest_refund_amount = Money.new(amount, currency)
|
352
353
|
|
353
354
|
currency = element.elements['total-refund-amount'].attributes['currency']
|
354
|
-
amount = (element.elements['total-refund-amount'].text
|
355
|
+
amount = (BigDecimal.new(element.elements['total-refund-amount'].text)*100).to_i
|
355
356
|
refund.total_refund_amount = Money.new(amount, currency)
|
356
357
|
|
357
358
|
refund.timestamp = Time.parse(element.elements['timestamp'].text)
|
@@ -384,11 +385,11 @@ module Google4R #:nodoc:
|
|
384
385
|
chargeback.google_order_number = element.elements['google-order-number'].text
|
385
386
|
|
386
387
|
currency = element.elements['latest-chargeback-amount'].attributes['currency']
|
387
|
-
amount = (element.elements['latest-chargeback-amount'].text
|
388
|
+
amount = (BigDecimal.new(element.elements['latest-chargeback-amount'].text)*100).to_i
|
388
389
|
chargeback.latest_chargeback_amount = Money.new(amount, currency)
|
389
390
|
|
390
391
|
currency = element.elements['total-chargeback-amount'].attributes['currency']
|
391
|
-
amount = (element.elements['total-chargeback-amount'].text
|
392
|
+
amount = (BigDecimal.new(element.elements['total-chargeback-amount'].text)*100).to_i
|
392
393
|
chargeback.total_chargeback_amount = Money.new(amount, currency)
|
393
394
|
|
394
395
|
chargeback.timestamp = Time.parse(element.elements['timestamp'].text)
|
@@ -427,7 +428,7 @@ module Google4R #:nodoc:
|
|
427
428
|
authorization.google_order_number = element.elements['google-order-number'].text
|
428
429
|
|
429
430
|
currency = element.elements['authorization-amount'].attributes['currency']
|
430
|
-
amount = (element.elements['authorization-amount'].text
|
431
|
+
amount = (BigDecimal.new(element.elements['authorization-amount'].text)*100).to_i
|
431
432
|
authorization.authorization_amount = Money.new(amount, currency)
|
432
433
|
|
433
434
|
authorization.authorization_expiration_date = Time.parse(element.elements['authorization-expiration-date'].text)
|
@@ -592,11 +593,11 @@ module Google4R #:nodoc:
|
|
592
593
|
|
593
594
|
result.code = element.elements['code'].text
|
594
595
|
|
595
|
-
amount = (element.elements['calculated-amount'].text
|
596
|
+
amount = (BigDecimal.new(element.elements['calculated-amount'].text)*100).to_i rescue nil
|
596
597
|
currency = element.elements['calculated-amount'].attributes['currency'] rescue nil
|
597
598
|
result.calculated_amount = Money.new(amount, currency) unless amount.nil?
|
598
599
|
|
599
|
-
amount = (element.elements['applied-amount'].text
|
600
|
+
amount = (BigDecimal.new(element.elements['applied-amount'].text)*100).to_i
|
600
601
|
currency = element.elements['applied-amount'].attributes['currency']
|
601
602
|
result.applied_amount = Money.new(amount, currency)
|
602
603
|
|
@@ -642,7 +643,7 @@ module Google4R #:nodoc:
|
|
642
643
|
|
643
644
|
result.name = element.elements['shipping-name'].text
|
644
645
|
|
645
|
-
amount = (element.elements['shipping-cost'].text
|
646
|
+
amount = (BigDecimal.new(element.elements['shipping-cost'].text)*100).to_i
|
646
647
|
currency = element.elements['shipping-cost'].attributes['currency']
|
647
648
|
result.cost = Money.new(amount, currency)
|
648
649
|
|
@@ -674,7 +675,7 @@ module Google4R #:nodoc:
|
|
674
675
|
def self.create_from_element(element)
|
675
676
|
result = OrderAdjustment.new
|
676
677
|
|
677
|
-
amount = (element.elements['total-tax'].text
|
678
|
+
amount = (BigDecimal.new(element.elements['total-tax'].text)*100).to_i rescue nil
|
678
679
|
currency = element.elements['total-tax'].attributes['currency'] rescue nil
|
679
680
|
result.total_tax = Money.new(amount, currency) unless amount.nil?
|
680
681
|
|
@@ -686,7 +687,7 @@ module Google4R #:nodoc:
|
|
686
687
|
|
687
688
|
result.merchant_calculation_successful = (element.elements['merchant-calculation-successful'].text.downcase == 'true') rescue nil
|
688
689
|
|
689
|
-
amount = (element.elements['adjustment-total'].text
|
690
|
+
amount = (BigDecimal.new(element.elements['adjustment-total'].text)*100).to_i rescue nil
|
690
691
|
currency = element.elements['adjustment-total'].attributes['currency'] rescue nil
|
691
692
|
result.adjustment_total = Money.new(amount, currency) unless amount.nil?
|
692
693
|
|
@@ -27,6 +27,8 @@
|
|
27
27
|
# This file contains the classes and modules that are shared by the notification
|
28
28
|
# handling and parsing as well as the command generating code.
|
29
29
|
|
30
|
+
require 'bigdecimal'
|
31
|
+
|
30
32
|
#--
|
31
33
|
# TODO: Make the optional attributes return defaults that make sense, i.e. Money.new(0)?
|
32
34
|
#++
|
@@ -317,7 +319,7 @@ module Google4R #:nodoc:
|
|
317
319
|
result.tax_table = shopping_cart.owner.tax_tables.find {|table| table.name == table_selector }
|
318
320
|
end
|
319
321
|
|
320
|
-
unit_price = (element.elements['unit-price'].text
|
322
|
+
unit_price = (BigDecimal.new(element.elements['unit-price'].text) * 100).to_i
|
321
323
|
unit_price_currency = element.elements['unit-price'].attributes['currency']
|
322
324
|
result.unit_price = Money.new(unit_price, unit_price_currency)
|
323
325
|
|
@@ -523,7 +525,7 @@ module Google4R #:nodoc:
|
|
523
525
|
result.subscription = subscription
|
524
526
|
result.times = element.attributes['times'].to_i rescue nil
|
525
527
|
|
526
|
-
maximum_charge = (element.elements['maximum-charge'].text
|
528
|
+
maximum_charge = (BigDecimal.new(element.elements['maximum-charge'].text) * 100).to_i
|
527
529
|
maximum_charge_currency = element.elements['maximum-charge'].attributes['currency']
|
528
530
|
result.maximum_charge = Money.new(maximum_charge, maximum_charge_currency)
|
529
531
|
|
@@ -589,10 +591,14 @@ module Google4R #:nodoc:
|
|
589
591
|
# Boolean, true iff the table's standalone attribute is to be set to "true".
|
590
592
|
attr_reader :standalone
|
591
593
|
|
594
|
+
# indicates whether tax for the order is calculated using a special process. default "false"
|
595
|
+
attr_accessor :merchant_calculated
|
596
|
+
|
592
597
|
def initialize(standalone)
|
593
598
|
@rules = Array.new
|
594
599
|
|
595
600
|
@standalone = standalone
|
601
|
+
@merchant_calculated = false
|
596
602
|
end
|
597
603
|
|
598
604
|
# Use this method to add a new TaxRule to the table. If you use a block with
|
@@ -855,6 +861,9 @@ module Google4R #:nodoc:
|
|
855
861
|
|
856
862
|
# A class that represents the "flat_rate" shipping method.
|
857
863
|
class FlatRateShipping < ShippingMethod
|
864
|
+
# (boolean, optional, default true)
|
865
|
+
attr_accessor :shipping_restrictions_allow_us_po_box
|
866
|
+
|
858
867
|
def initialize
|
859
868
|
super
|
860
869
|
end
|
@@ -871,6 +880,12 @@ module Google4R #:nodoc:
|
|
871
880
|
# #create_excluded_area to add to this area but do not change it directly.
|
872
881
|
attr_reader :address_filters_excluded_areas
|
873
882
|
|
883
|
+
# (boolean, optional, default true)
|
884
|
+
attr_accessor :address_filters_allow_us_po_box
|
885
|
+
|
886
|
+
# (boolean, optional, default true)
|
887
|
+
attr_accessor :shipping_restrictions_allow_us_po_box
|
888
|
+
|
874
889
|
def initialize
|
875
890
|
super
|
876
891
|
@address_filters_allowed_areas = Array.new
|
@@ -889,7 +904,7 @@ module Google4R #:nodoc:
|
|
889
904
|
# === Example
|
890
905
|
#
|
891
906
|
# method = FlatRateShipping.new
|
892
|
-
# method.
|
907
|
+
# method.create_address_filters_allowed_area(UsCountryArea) do |area|
|
893
908
|
# area.area = UsCountryArea::ALL
|
894
909
|
# end
|
895
910
|
def create_address_filters_allowed_area(clazz, &block)
|
@@ -908,11 +923,11 @@ module Google4R #:nodoc:
|
|
908
923
|
# === Example
|
909
924
|
#
|
910
925
|
# method = FlatRateShipping.new
|
911
|
-
# method.
|
926
|
+
# method.create_address_filters_excluded_area(UsCountryArea) do |area|
|
912
927
|
# area.area = UsCountryArea::ALL
|
913
928
|
# end
|
914
|
-
def
|
915
|
-
return create_area(:address_filters, :
|
929
|
+
def create_address_filters_excluded_area(clazz, &block)
|
930
|
+
return create_area(:address_filters, :excluded_areas, clazz, &block)
|
916
931
|
end
|
917
932
|
end
|
918
933
|
|
@@ -1015,7 +1030,7 @@ module Google4R #:nodoc:
|
|
1015
1030
|
def self.create_from_element(this_shipping, element)
|
1016
1031
|
result = CarrierCalculatedShippingOption.new(this_shipping)
|
1017
1032
|
result.shipping_company = element.elements['shipping-company'].text
|
1018
|
-
price = (element.elements['price'].text
|
1033
|
+
price = (BigDecimal.new(element.elements['price'].text) * 100).to_i
|
1019
1034
|
price_currency = element.elements['price'].attributes['currency']
|
1020
1035
|
result.price = Money.new(price, price_currency)
|
1021
1036
|
result.shipping_type = element.elements['shipping-type']
|
@@ -1091,7 +1106,7 @@ module Google4R #:nodoc:
|
|
1091
1106
|
|
1092
1107
|
# Creates a new Unit from the given REXML::Element instance.
|
1093
1108
|
def self.create_from_element(element)
|
1094
|
-
result = self.new(element.attributes['value'].
|
1109
|
+
result = self.new(BigDecimal.new(element.attributes['value'].to_s))
|
1095
1110
|
return result
|
1096
1111
|
end
|
1097
1112
|
end
|
@@ -1104,7 +1119,7 @@ module Google4R #:nodoc:
|
|
1104
1119
|
|
1105
1120
|
def initialize(value, unit=INCH)
|
1106
1121
|
@unit = unit
|
1107
|
-
@value = value.
|
1122
|
+
@value = BigDecimal.new(value.to_s)
|
1108
1123
|
end
|
1109
1124
|
end
|
1110
1125
|
|
@@ -1115,7 +1130,7 @@ module Google4R #:nodoc:
|
|
1115
1130
|
|
1116
1131
|
def initialize(value, unit=LB)
|
1117
1132
|
@unit = unit
|
1118
|
-
@value = value.
|
1133
|
+
@value = BigDecimal.new(value.to_s)
|
1119
1134
|
end
|
1120
1135
|
end
|
1121
1136
|
|
@@ -90,7 +90,7 @@ module Google4R #:nodoc:
|
|
90
90
|
super
|
91
91
|
self.process_command(@command)
|
92
92
|
io = StringIO.new
|
93
|
-
@document.write(io,
|
93
|
+
@document.write(io, -1)
|
94
94
|
return io.string
|
95
95
|
end
|
96
96
|
|
@@ -99,7 +99,7 @@ module Google4R #:nodoc:
|
|
99
99
|
end
|
100
100
|
|
101
101
|
protected
|
102
|
-
|
102
|
+
|
103
103
|
# Base method to generate root tag of a command
|
104
104
|
def process_command(command)
|
105
105
|
tag_name = self.tag_name_for_command(command.class)
|
@@ -204,10 +204,16 @@ module Google4R #:nodoc:
|
|
204
204
|
# and that all others are alternate tax rules
|
205
205
|
def process_tax_tables(tax_tables, parent)
|
206
206
|
tax_tables_element = parent.add_element('tax-tables')
|
207
|
-
|
207
|
+
|
208
208
|
# assumes that the first tax table is the default
|
209
209
|
default_table = tax_tables.first
|
210
210
|
|
211
|
+
if default_table.merchant_calculated
|
212
|
+
tax_tables_element.add_attribute('merchant-calculated', 'true')
|
213
|
+
else
|
214
|
+
tax_tables_element.add_attribute('merchant-calculated', 'false')
|
215
|
+
end
|
216
|
+
|
211
217
|
default_table_element = tax_tables_element.add_element('default-tax-table')
|
212
218
|
rules_element = default_table_element.add_element('tax-rules')
|
213
219
|
|
@@ -401,6 +407,13 @@ module Google4R #:nodoc:
|
|
401
407
|
shipping.shipping_restrictions_allowed_areas.length > 0 then
|
402
408
|
shipping_restrictions_tag = element.add_element('shipping-restrictions')
|
403
409
|
|
410
|
+
allow_us_po_box = shipping_restrictions_tag.add_element('allow-us-po-box')
|
411
|
+
if shipping.shipping_restrictions_allow_us_po_box
|
412
|
+
allow_us_po_box.text = 'true'
|
413
|
+
else
|
414
|
+
allow_us_po_box.text = 'false'
|
415
|
+
end
|
416
|
+
|
404
417
|
if shipping.shipping_restrictions_allowed_areas.length > 0 then
|
405
418
|
allowed_tag = shipping_restrictions_tag.add_element('allowed-areas')
|
406
419
|
|
@@ -423,6 +436,13 @@ module Google4R #:nodoc:
|
|
423
436
|
shipping.address_filters_allowed_areas.length > 0 then
|
424
437
|
address_filters_tag = element.add_element('address-filters')
|
425
438
|
|
439
|
+
allow_us_po_box = address_filters_tag.add_element('allow-us-po-box')
|
440
|
+
if shipping.address_filters_allow_us_po_box
|
441
|
+
allow_us_po_box.text = 'true'
|
442
|
+
else
|
443
|
+
allow_us_po_box.text = 'false'
|
444
|
+
end
|
445
|
+
|
426
446
|
if shipping.address_filters_allowed_areas.length > 0 then
|
427
447
|
allowed_tag = address_filters_tag.add_element('allowed-areas')
|
428
448
|
|
@@ -771,7 +791,7 @@ module Google4R #:nodoc:
|
|
771
791
|
super
|
772
792
|
process_results(@merchant_calculation_results.merchant_calculation_results)
|
773
793
|
io = StringIO.new
|
774
|
-
@document.write(io,
|
794
|
+
@document.write(io, -1)
|
775
795
|
return io.string
|
776
796
|
end
|
777
797
|
|
@@ -41,11 +41,6 @@ class Google4R::Checkout::AddMerchantOrderNumberCommandTest < Test::Unit::TestCa
|
|
41
41
|
|
42
42
|
@command.google_order_number = '841171949013218'
|
43
43
|
@command.merchant_order_number = 'P6502-53-7861SBJD'
|
44
|
-
|
45
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
46
|
-
<add-merchant-order-number xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
47
|
-
<merchant-order-number>P6502-53-7861SBJD</merchant-order-number>
|
48
|
-
</add-merchant-order-number>}
|
49
44
|
end
|
50
45
|
|
51
46
|
def test_behaves_correctly
|
@@ -55,7 +50,7 @@ class Google4R::Checkout::AddMerchantOrderNumberCommandTest < Test::Unit::TestCa
|
|
55
50
|
end
|
56
51
|
|
57
52
|
def test_xml
|
58
|
-
|
53
|
+
assert_command_element_text_equals(@command.merchant_order_number, "> merchant-order-number", @command)
|
59
54
|
end
|
60
55
|
|
61
56
|
def test_accessors
|
@@ -42,14 +42,6 @@ class Google4R::Checkout::AddTrackingDataCommandTest < Test::Unit::TestCase
|
|
42
42
|
@command.google_order_number = '841171949013218'
|
43
43
|
@command.carrier = 'UPS'
|
44
44
|
@command.tracking_number = 'Z9842W69871281267'
|
45
|
-
|
46
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
47
|
-
<add-tracking-data xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
48
|
-
<tracking-data>
|
49
|
-
<carrier>UPS</carrier>
|
50
|
-
<tracking-number>Z9842W69871281267</tracking-number>
|
51
|
-
</tracking-data>
|
52
|
-
</add-tracking-data>}
|
53
45
|
end
|
54
46
|
|
55
47
|
def test_behaves_correctly
|
@@ -59,7 +51,8 @@ class Google4R::Checkout::AddTrackingDataCommandTest < Test::Unit::TestCase
|
|
59
51
|
end
|
60
52
|
|
61
53
|
def test_xml
|
62
|
-
|
54
|
+
assert_command_element_text_equals(@command.carrier, "> tracking-data > carrier", @command)
|
55
|
+
assert_command_element_text_equals(@command.tracking_number, "> tracking-data > tracking-number", @command)
|
63
56
|
end
|
64
57
|
|
65
58
|
def test_accessors
|
@@ -40,9 +40,6 @@ class Google4R::Checkout::ArchiveOrderCommandTest < Test::Unit::TestCase
|
|
40
40
|
@command = @frontend.create_archive_order_command
|
41
41
|
|
42
42
|
@command.google_order_number = '841171949013218'
|
43
|
-
|
44
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
45
|
-
<archive-order xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'/>}
|
46
43
|
end
|
47
44
|
|
48
45
|
def test_behaves_correctly
|
@@ -52,7 +49,7 @@ class Google4R::Checkout::ArchiveOrderCommandTest < Test::Unit::TestCase
|
|
52
49
|
end
|
53
50
|
|
54
51
|
def test_xml
|
55
|
-
|
52
|
+
assert_element_exists(command_selector(@command), @command.to_xml)
|
56
53
|
end
|
57
54
|
|
58
55
|
def test_accessors
|
@@ -40,9 +40,6 @@ class Google4R::Checkout::AuthorizeOrderCommandTest < Test::Unit::TestCase
|
|
40
40
|
@command = @frontend.create_authorize_order_command
|
41
41
|
|
42
42
|
@command.google_order_number = '841171949013218'
|
43
|
-
|
44
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
45
|
-
<authorize-order xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'/>}
|
46
43
|
end
|
47
44
|
|
48
45
|
def test_behaves_correctly
|
@@ -52,7 +49,7 @@ class Google4R::Checkout::AuthorizeOrderCommandTest < Test::Unit::TestCase
|
|
52
49
|
end
|
53
50
|
|
54
51
|
def test_xml
|
55
|
-
|
52
|
+
assert_element_exists(command_selector(@command), @command.to_xml)
|
56
53
|
end
|
57
54
|
|
58
55
|
def test_accessors
|
@@ -44,20 +44,6 @@ class Google4R::Checkout::BackorderItemsCommandTest < Test::Unit::TestCase
|
|
44
44
|
@item_info1 = ItemInfo.new('A1')
|
45
45
|
@item_info2 = ItemInfo.new('B2')
|
46
46
|
@command.item_info_arr = [@item_info1, @item_info2]
|
47
|
-
|
48
|
-
|
49
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
50
|
-
<backorder-items xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
51
|
-
<item-ids>
|
52
|
-
<item-id>
|
53
|
-
<merchant-item-id>A1</merchant-item-id>
|
54
|
-
</item-id>
|
55
|
-
<item-id>
|
56
|
-
<merchant-item-id>B2</merchant-item-id>
|
57
|
-
</item-id>
|
58
|
-
</item-ids>
|
59
|
-
<send-email>true</send-email>
|
60
|
-
</backorder-items>}
|
61
47
|
end
|
62
48
|
|
63
49
|
def test_behaves_correctly
|
@@ -68,7 +54,7 @@ class Google4R::Checkout::BackorderItemsCommandTest < Test::Unit::TestCase
|
|
68
54
|
end
|
69
55
|
|
70
56
|
def test_xml_send_email
|
71
|
-
|
57
|
+
assert_command_element_text_equals("true", "> send-email", @command)
|
72
58
|
end
|
73
59
|
|
74
60
|
def test_accessors
|
@@ -46,21 +46,6 @@ class Google4R::Checkout::CancelItemsCommandTest < Test::Unit::TestCase
|
|
46
46
|
@command.item_info_arr = [@item_info1, @item_info2]
|
47
47
|
@command.reason = 'This item is no longer manufactured.'
|
48
48
|
@command.comment = 'Suggested replacement is model XBR2700.'
|
49
|
-
|
50
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
51
|
-
<cancel-items xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
52
|
-
<item-ids>
|
53
|
-
<item-id>
|
54
|
-
<merchant-item-id>A1</merchant-item-id>
|
55
|
-
</item-id>
|
56
|
-
<item-id>
|
57
|
-
<merchant-item-id>B2</merchant-item-id>
|
58
|
-
</item-id>
|
59
|
-
</item-ids>
|
60
|
-
<send-email>true</send-email>
|
61
|
-
<reason>This item is no longer manufactured.</reason>
|
62
|
-
<comment>Suggested replacement is model XBR2700.</comment>
|
63
|
-
</cancel-items>}
|
64
49
|
end
|
65
50
|
|
66
51
|
def test_behaves_correctly
|
@@ -72,7 +57,9 @@ class Google4R::Checkout::CancelItemsCommandTest < Test::Unit::TestCase
|
|
72
57
|
end
|
73
58
|
|
74
59
|
def test_xml_send_email
|
75
|
-
|
60
|
+
assert_command_element_text_equals("true", "> send-email", @command)
|
61
|
+
assert_command_element_text_equals(@command.reason, "> reason", @command)
|
62
|
+
assert_command_element_text_equals(@command.comment, "> comment", @command)
|
76
63
|
end
|
77
64
|
|
78
65
|
def test_accessors
|
@@ -42,17 +42,6 @@ class Google4R::Checkout::CancelOrderCommandTest < Test::Unit::TestCase
|
|
42
42
|
@command.google_order_number = '841171949013218'
|
43
43
|
@command.reason = 'Buyer cancelled the order'
|
44
44
|
@command.comment = 'Buyer ordered another item'
|
45
|
-
|
46
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
47
|
-
<cancel-order xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
48
|
-
<reason>Buyer cancelled the order</reason>
|
49
|
-
<comment>Buyer ordered another item</comment>
|
50
|
-
</cancel-order>}
|
51
|
-
|
52
|
-
@sample_xml_no_comment=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
53
|
-
<cancel-order xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
54
|
-
<reason>Buyer cancelled the order</reason>
|
55
|
-
</cancel-order>}
|
56
45
|
end
|
57
46
|
|
58
47
|
def test_behaves_correctly
|
@@ -68,12 +57,14 @@ class Google4R::Checkout::CancelOrderCommandTest < Test::Unit::TestCase
|
|
68
57
|
end
|
69
58
|
|
70
59
|
def test_xml
|
71
|
-
|
60
|
+
assert_command_element_text_equals(@command.reason, "> reason", @command)
|
61
|
+
assert_command_element_text_equals(@command.comment, "> comment", @command)
|
72
62
|
end
|
73
63
|
|
74
64
|
def test_xml_when_comment_not_used
|
75
65
|
@command.comment = nil
|
76
|
-
|
66
|
+
assert_command_element_text_equals(@command.reason, "> reason", @command)
|
67
|
+
assert_no_command_element_exists("> comment", @command)
|
77
68
|
end
|
78
69
|
|
79
70
|
def test_to_xml_does_not_raise_exception
|
@@ -40,14 +40,6 @@ class Google4R::Checkout::ChargeOrderCommandTest < Test::Unit::TestCase
|
|
40
40
|
@command = @frontend.create_charge_order_command
|
41
41
|
@command.google_order_number = '1234-5678-ABCD-1234'
|
42
42
|
@command.amount = Money.new(1000, 'GBP')
|
43
|
-
|
44
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
45
|
-
<charge-order xmlns='http://checkout.google.com/schema/2' google-order-number='1234-5678-ABCD-1234'>
|
46
|
-
<amount currency='GBP'>10.00</amount>
|
47
|
-
</charge-order>}
|
48
|
-
|
49
|
-
@sample_no_amount=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
50
|
-
<charge-order xmlns='http://checkout.google.com/schema/2' google-order-number='1234-5678-ABCD-1234'/>}
|
51
43
|
end
|
52
44
|
|
53
45
|
def test_behaves_correctly
|
@@ -56,9 +48,9 @@ class Google4R::Checkout::ChargeOrderCommandTest < Test::Unit::TestCase
|
|
56
48
|
end
|
57
49
|
end
|
58
50
|
|
59
|
-
def
|
51
|
+
def test_xml_without_amount
|
60
52
|
@command.amount = nil
|
61
|
-
|
53
|
+
assert_no_command_element_exists("amount", @command)
|
62
54
|
end
|
63
55
|
|
64
56
|
def test_accessors
|
@@ -67,7 +59,7 @@ class Google4R::Checkout::ChargeOrderCommandTest < Test::Unit::TestCase
|
|
67
59
|
end
|
68
60
|
|
69
61
|
def test_xml_generation
|
70
|
-
|
62
|
+
assert_command_element_text_equals("10.00", "> amount[currency=GBP]", @command)
|
71
63
|
end
|
72
64
|
|
73
65
|
def test_to_xml_does_not_raise_exception
|
@@ -38,6 +38,9 @@ require 'open3' rescue require 'win32/open3'
|
|
38
38
|
|
39
39
|
require 'rexml/document'
|
40
40
|
|
41
|
+
require 'net/http'
|
42
|
+
require 'net/https'
|
43
|
+
|
41
44
|
# Test for the class UsZipArea.
|
42
45
|
#
|
43
46
|
# TODO: Make the tests querying Google Checkout's diagnose service and the XSD validation optional.
|
@@ -156,7 +159,6 @@ class Google4R::Checkout::CheckoutCommandXmlGeneratorTest < Test::Unit::TestCase
|
|
156
159
|
|
157
160
|
xml_str = @generator.generate
|
158
161
|
assert_xml_validates_against_xml_schema(@schema_path, xml_str)
|
159
|
-
assert_string_equals_file_contents(@expected_path, xml_str)
|
160
162
|
assert_google_checkout_diagnose_returns_no_warnings(xml_str)
|
161
163
|
end
|
162
164
|
|
@@ -170,25 +172,26 @@ class Google4R::Checkout::CheckoutCommandXmlGeneratorTest < Test::Unit::TestCase
|
|
170
172
|
protected
|
171
173
|
|
172
174
|
def assert_google_checkout_diagnose_returns_no_warnings(xml_str)
|
173
|
-
tmpfile = Tempfile.new('xml_output')
|
174
|
-
tmpfile << xml_str
|
175
|
-
tmpfile.flush
|
176
|
-
|
177
175
|
url = "https://%s:%s@sandbox.google.com/checkout/cws/v2/Merchant/%s/request/diagnose" %
|
178
176
|
[ FRONTEND_CONFIGURATION[:merchant_id], FRONTEND_CONFIGURATION[:merchant_key],
|
179
177
|
FRONTEND_CONFIGURATION[:merchant_id] ]
|
180
178
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
179
|
+
http = Net::HTTP.new('sandbox.google.com', 443)
|
180
|
+
http.use_ssl = true
|
181
|
+
|
182
|
+
http.start do
|
183
|
+
req = Net::HTTP::Post.new("/checkout/cws/v2/Merchant/%s/request/diagnose" %
|
184
|
+
[ FRONTEND_CONFIGURATION[:merchant_id] ])
|
185
|
+
req.basic_auth(FRONTEND_CONFIGURATION[:merchant_id], FRONTEND_CONFIGURATION[:merchant_key])
|
186
|
+
req.body = xml_str
|
187
|
+
|
188
|
+
res = http.request(req)
|
189
|
+
assert res.kind_of?(Net::HTTPSuccess), res.inspect
|
190
190
|
|
191
|
-
|
191
|
+
# Check that there is no <warnings> tag in the XML.
|
192
|
+
xml_document = REXML::Document.new(res.body)
|
193
|
+
assert 0, xml_document.root.elements.to_a('//warnings').size
|
194
|
+
end
|
192
195
|
end
|
193
196
|
|
194
197
|
def assert_xml_validates_against_xml_schema(schema_path, xml_str)
|
@@ -210,9 +213,4 @@ class Google4R::Checkout::CheckoutCommandXmlGeneratorTest < Test::Unit::TestCase
|
|
210
213
|
|
211
214
|
tmpfile.close!
|
212
215
|
end
|
213
|
-
|
214
|
-
def assert_string_equals_file_contents(expected_path, xml_str)
|
215
|
-
file_contents = File.open(expected_path, 'r') { |f| f.read }
|
216
|
-
assert_strings_equal file_contents, xml_str
|
217
|
-
end
|
218
216
|
end
|
@@ -41,11 +41,6 @@ class Google4R::Checkout::DeliverOrderCommandTest < Test::Unit::TestCase
|
|
41
41
|
|
42
42
|
@command.google_order_number = '841171949013218'
|
43
43
|
@command.send_email = true
|
44
|
-
|
45
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
46
|
-
<deliver-order xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
47
|
-
<send-email>true</send-email>
|
48
|
-
</deliver-order>}
|
49
44
|
end
|
50
45
|
|
51
46
|
def test_behaves_correctly
|
@@ -55,7 +50,7 @@ class Google4R::Checkout::DeliverOrderCommandTest < Test::Unit::TestCase
|
|
55
50
|
end
|
56
51
|
|
57
52
|
def test_xml_send_email
|
58
|
-
|
53
|
+
assert_command_element_text_equals("true", "> send-email", @command)
|
59
54
|
end
|
60
55
|
|
61
56
|
def test_accessors
|
@@ -43,7 +43,8 @@ class Google4R::Checkout::FlatRateShippingMethodTest < Test::Unit::TestCase
|
|
43
43
|
def test_flat_rate_shipping_method_behaves_correctly
|
44
44
|
[ :name, :name=, :price, :price=,
|
45
45
|
:shipping_restrictions_allowed_areas, :shipping_restrictions_excluded_areas,
|
46
|
-
:create_allowed_area, :create_excluded_area, :create_area
|
46
|
+
:create_allowed_area, :create_excluded_area, :create_area,
|
47
|
+
:shipping_restrictions_allow_us_po_box
|
47
48
|
].each do |symbol|
|
48
49
|
assert_respond_to @shipping, symbol
|
49
50
|
end
|
@@ -63,7 +64,7 @@ class Google4R::Checkout::FlatRateShippingMethodTest < Test::Unit::TestCase
|
|
63
64
|
@shipping.price = Money.new(100, "EUR")
|
64
65
|
assert_kind_of Money, @shipping.price
|
65
66
|
assert_equal 100, @shipping.price.cents
|
66
|
-
assert_equal "EUR", @shipping.price.currency
|
67
|
+
assert_equal "EUR", @shipping.price.currency.iso_code
|
67
68
|
end
|
68
69
|
|
69
70
|
def test_flat_rate_shipping_method_price_is_validated
|
@@ -43,6 +43,7 @@ class Google4R::Checkout::MerchantCalculatedShippingTest < Test::Unit::TestCase
|
|
43
43
|
[ :name, :name=, :price, :price=,
|
44
44
|
:shipping_restrictions_allowed_areas, :shipping_restrictions_excluded_areas,
|
45
45
|
:address_filters_allowed_areas, :address_filters_excluded_areas,
|
46
|
+
:address_filters_allow_us_po_box, :shipping_restrictions_allow_us_po_box,
|
46
47
|
:create_allowed_area, :create_excluded_area, :create_area
|
47
48
|
].each do |symbol|
|
48
49
|
assert_respond_to @shipping, symbol
|
@@ -65,7 +66,7 @@ class Google4R::Checkout::MerchantCalculatedShippingTest < Test::Unit::TestCase
|
|
65
66
|
@shipping.price = Money.new(100, "EUR")
|
66
67
|
assert_kind_of Money, @shipping.price
|
67
68
|
assert_equal 100, @shipping.price.cents
|
68
|
-
assert_equal "EUR", @shipping.price.currency
|
69
|
+
assert_equal "EUR", @shipping.price.currency.iso_code
|
69
70
|
end
|
70
71
|
|
71
72
|
def test_merchant_calculated_shipping_price_is_validated
|
@@ -120,7 +120,7 @@ class Google4R::Checkout::MerchantCalculationCallbackTest < Test::Unit::TestCase
|
|
120
120
|
expect.with { |element, owner| element.name == 'shopping-cart' and owner.kind_of?(MerchantCalculationCallback) }
|
121
121
|
|
122
122
|
expect = AnonymousAddress.stubs(:create_from_element)
|
123
|
-
expect.times(
|
123
|
+
expect.times(2).returns(:anonymous_address, :anonymous_address2)
|
124
124
|
expect.with { |element| element.name == 'anonymous-address' }
|
125
125
|
|
126
126
|
# Create the new notification.
|
@@ -37,14 +37,8 @@ class Google4R::Checkout::MerchantCalculationResultTest < Test::Unit::TestCase
|
|
37
37
|
|
38
38
|
def setup
|
39
39
|
# Build up some Mocha expectations.
|
40
|
-
expect = CouponResult.stubs(:new)
|
41
|
-
expect.times(1).returns(:coupon_result)
|
42
|
-
|
43
|
-
expect = GiftCertificateResult.stubs(:new)
|
44
|
-
expect.times(1).returns(:gift_certificate_result)
|
45
|
-
|
46
40
|
expect = Money.stubs(:new)
|
47
|
-
expect.times(
|
41
|
+
expect.times(2).returns(:shipping_rate, :total_tax)
|
48
42
|
|
49
43
|
@result = MerchantCalculationResult.new('UPS Ground', '1234567890', Money.new(1000, 'USD'), true, Money.new(2000, 'USD'))
|
50
44
|
end
|
@@ -63,6 +57,12 @@ class Google4R::Checkout::MerchantCalculationResultTest < Test::Unit::TestCase
|
|
63
57
|
end
|
64
58
|
|
65
59
|
def test_create_merchant_code_result_works_correctly
|
60
|
+
expect = CouponResult.stubs(:new)
|
61
|
+
expect.times(1).returns(:coupon_result)
|
62
|
+
|
63
|
+
expect = GiftCertificateResult.stubs(:new)
|
64
|
+
expect.times(1).returns(:gift_certificate_result)
|
65
|
+
|
66
66
|
# Create the new CouponResult and GiftCertificationResult instances.
|
67
67
|
@result.create_merchant_code_result(CouponResult)
|
68
68
|
@result.create_merchant_code_result(GiftCertificateResult)
|
@@ -172,7 +172,32 @@ class Google4R::Checkout::MerchantCalculationResultsTest < Test::Unit::TestCase
|
|
172
172
|
result.create_merchant_code_result(@gift_certificate_result)
|
173
173
|
end
|
174
174
|
|
175
|
-
|
176
|
-
|
175
|
+
xml = @results.to_xml
|
176
|
+
@results.merchant_calculation_results.each do |result|
|
177
|
+
selector = "merchant-calculation-results > results"
|
178
|
+
selector << " > result[address-id='#{result.address_id}'][shipping-name='#{result.shipping_name}']"
|
179
|
+
|
180
|
+
assert_element_text_equals(result.shipping_rate.to_s,
|
181
|
+
"#{selector} > shipping-rate[currency='#{result.shipping_rate.currency.iso_code}']", xml)
|
182
|
+
assert_element_text_equals(result.shippable ? "true" : "false", "#{selector} > shippable", xml)
|
183
|
+
|
184
|
+
selector << " > merchant-code-results"
|
185
|
+
|
186
|
+
cr_selector = "#{selector} > coupon-result"
|
187
|
+
cr = result.merchant_code_results.select { |r| r.kind_of? CouponResult }.first
|
188
|
+
assert_element_text_equals(cr.valid ? "true" : "false", "#{cr_selector} > valid", xml)
|
189
|
+
assert_element_text_equals(cr.code, "#{cr_selector} > code", xml)
|
190
|
+
assert_element_text_equals(cr.calculated_amount.to_s,
|
191
|
+
"#{cr_selector} > calculated-amount[currency='#{cr.calculated_amount.currency.iso_code}']", xml)
|
192
|
+
assert_element_text_equals(cr.message, "#{cr_selector} > message", xml)
|
193
|
+
|
194
|
+
gc_selector = "#{selector} > gift-certificate-result"
|
195
|
+
gc = result.merchant_code_results.select { |r| r.kind_of? GiftCertificateResult }.first
|
196
|
+
assert_element_text_equals(gc.valid ? "true" : "false", "#{gc_selector} > valid", xml)
|
197
|
+
assert_element_text_equals(gc.code, "#{gc_selector} > code", xml)
|
198
|
+
assert_element_text_equals(gc.calculated_amount.to_s,
|
199
|
+
"#{gc_selector} > calculated-amount[currency='#{gc.calculated_amount.currency.iso_code}']", xml)
|
200
|
+
assert_element_text_equals(gc.message, "#{gc_selector} > message", xml)
|
201
|
+
end
|
177
202
|
end
|
178
203
|
end
|
@@ -43,13 +43,6 @@ class Google4R::Checkout::OrderReportCommandTest < Test::Unit::TestCase
|
|
43
43
|
@command.financial_state = 'CHARGED'
|
44
44
|
@command.fulfillment_state = 'NEW'
|
45
45
|
@command.date_time_zone = 'America/New_York'
|
46
|
-
|
47
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
48
|
-
<order-list-request end-date='2007-09-30T23:59:59' start-date='2007-09-01T00:00:00' xmlns='http://checkout.google.com/schema/2'>
|
49
|
-
<financial-state>CHARGED</financial-state>
|
50
|
-
<fulfillment-state>NEW</fulfillment-state>
|
51
|
-
<date-time-zone>America/New_York</date-time-zone>
|
52
|
-
</order-list-request>}
|
53
46
|
end
|
54
47
|
|
55
48
|
def test_behaves_correctly
|
@@ -62,7 +55,12 @@ class Google4R::Checkout::OrderReportCommandTest < Test::Unit::TestCase
|
|
62
55
|
end
|
63
56
|
|
64
57
|
def test_to_xml
|
65
|
-
|
58
|
+
selector = "order-list-request[start-date='#{@command.start_date}'][end-date='#{@command.end_date}']"
|
59
|
+
xml = @command.to_xml
|
60
|
+
|
61
|
+
assert_element_text_equals(@command.financial_state, "#{selector} > financial-state", xml)
|
62
|
+
assert_element_text_equals(@command.fulfillment_state, "#{selector} > fulfillment-state", xml)
|
63
|
+
assert_element_text_equals(@command.date_time_zone, "#{selector} > date-time-zone", xml)
|
66
64
|
end
|
67
65
|
|
68
66
|
def test_accessors
|
@@ -57,7 +57,7 @@ class Google4R::Checkout::PickupShippingMethodTest < Test::Unit::TestCase
|
|
57
57
|
@shipping.price = Money.new(100, "EUR")
|
58
58
|
assert_kind_of Money, @shipping.price
|
59
59
|
assert_equal 100, @shipping.price.cents
|
60
|
-
assert_equal "EUR", @shipping.price.currency
|
60
|
+
assert_equal "EUR", @shipping.price.currency.iso_code
|
61
61
|
end
|
62
62
|
|
63
63
|
def test_pickup_shipping_method_price_is_validated
|
@@ -42,18 +42,6 @@ class Google4R::Checkout::RefundOrderCommandTest < Test::Unit::TestCase
|
|
42
42
|
@command.amount = Money.new(1000, 'USD')
|
43
43
|
@command.comment = 'Discount for inconvenience; ship replacement item'
|
44
44
|
@command.reason = 'Damaged Merchandise'
|
45
|
-
|
46
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
47
|
-
<refund-order xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
48
|
-
<amount currency='USD'>10.00</amount>
|
49
|
-
<comment>Discount for inconvenience; ship replacement item</comment>
|
50
|
-
<reason>Damaged Merchandise</reason>
|
51
|
-
</refund-order>}
|
52
|
-
|
53
|
-
@sample_reason_only=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
54
|
-
<refund-order xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
55
|
-
<reason>Damaged Merchandise</reason>
|
56
|
-
</refund-order>}
|
57
45
|
end
|
58
46
|
|
59
47
|
def test_behaves_correctly
|
@@ -62,10 +50,13 @@ class Google4R::Checkout::RefundOrderCommandTest < Test::Unit::TestCase
|
|
62
50
|
end
|
63
51
|
end
|
64
52
|
|
65
|
-
def
|
53
|
+
def test_xml_without_amount
|
66
54
|
@command.amount = nil
|
67
55
|
@command.comment = nil
|
68
|
-
|
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)
|
69
60
|
end
|
70
61
|
|
71
62
|
def test_accessors
|
@@ -76,7 +67,9 @@ class Google4R::Checkout::RefundOrderCommandTest < Test::Unit::TestCase
|
|
76
67
|
end
|
77
68
|
|
78
69
|
def test_xml_generation
|
79
|
-
|
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)
|
80
73
|
end
|
81
74
|
|
82
75
|
def test_to_xml_does_not_raise_exception
|
@@ -44,20 +44,6 @@ class Google4R::Checkout::ResetItemsShippingInformationCommandTest < Test::Unit:
|
|
44
44
|
@item_info1 = ItemInfo.new('A1')
|
45
45
|
@item_info2 = ItemInfo.new('B2')
|
46
46
|
@command.item_info_arr = [@item_info1, @item_info2]
|
47
|
-
|
48
|
-
|
49
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
50
|
-
<reset-items-shipping-information xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
51
|
-
<item-ids>
|
52
|
-
<item-id>
|
53
|
-
<merchant-item-id>A1</merchant-item-id>
|
54
|
-
</item-id>
|
55
|
-
<item-id>
|
56
|
-
<merchant-item-id>B2</merchant-item-id>
|
57
|
-
</item-id>
|
58
|
-
</item-ids>
|
59
|
-
<send-email>true</send-email>
|
60
|
-
</reset-items-shipping-information>}
|
61
47
|
end
|
62
48
|
|
63
49
|
def test_behaves_correctly
|
@@ -68,7 +54,7 @@ class Google4R::Checkout::ResetItemsShippingInformationCommandTest < Test::Unit:
|
|
68
54
|
end
|
69
55
|
|
70
56
|
def test_xml_send_email
|
71
|
-
|
57
|
+
assert_command_element_text_equals("true", "> send-email", @command)
|
72
58
|
end
|
73
59
|
|
74
60
|
def test_accessors
|
@@ -44,20 +44,6 @@ class Google4R::Checkout::ReturnItemsCommandTest < Test::Unit::TestCase
|
|
44
44
|
@item_info1 = ItemInfo.new('A1')
|
45
45
|
@item_info2 = ItemInfo.new('B2')
|
46
46
|
@command.item_info_arr = [@item_info1, @item_info2]
|
47
|
-
|
48
|
-
|
49
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
50
|
-
<return-items xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
51
|
-
<item-ids>
|
52
|
-
<item-id>
|
53
|
-
<merchant-item-id>A1</merchant-item-id>
|
54
|
-
</item-id>
|
55
|
-
<item-id>
|
56
|
-
<merchant-item-id>B2</merchant-item-id>
|
57
|
-
</item-id>
|
58
|
-
</item-ids>
|
59
|
-
<send-email>true</send-email>
|
60
|
-
</return-items>}
|
61
47
|
end
|
62
48
|
|
63
49
|
def test_behaves_correctly
|
@@ -68,7 +54,7 @@ class Google4R::Checkout::ReturnItemsCommandTest < Test::Unit::TestCase
|
|
68
54
|
end
|
69
55
|
|
70
56
|
def test_xml_send_email
|
71
|
-
|
57
|
+
assert_command_element_text_equals("true", "> send-email", @command)
|
72
58
|
end
|
73
59
|
|
74
60
|
def test_accessors
|
@@ -46,7 +46,7 @@ class Google4R::Checkout::RiskInformationNotificationTest < Test::Unit::TestCase
|
|
46
46
|
<google-order-number>1564645586934214</google-order-number>
|
47
47
|
<risk-information>
|
48
48
|
<billing-address>
|
49
|
-
<!-- Not to be tested here but in Address
|
49
|
+
<!-- Not to be tested here but in Address -->
|
50
50
|
<!--
|
51
51
|
<contact-name>Mr Contact Smith</contact-name>
|
52
52
|
<company-name>ACME Products</company-name>
|
@@ -42,12 +42,6 @@ class Google4R::Checkout::SendBuyerMessageCommandTest < Test::Unit::TestCase
|
|
42
42
|
@command.google_order_number = '841171949013218'
|
43
43
|
@command.message = 'Due to high volume, your order will ship next week. Thank you for your patience.'
|
44
44
|
@command.send_email = true
|
45
|
-
|
46
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
47
|
-
<send-buyer-message xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
48
|
-
<message>Due to high volume, your order will ship next week. Thank you for your patience.</message>
|
49
|
-
<send-email>true</send-email>
|
50
|
-
</send-buyer-message>}
|
51
45
|
end
|
52
46
|
|
53
47
|
def test_behaves_correctly
|
@@ -57,7 +51,8 @@ class Google4R::Checkout::SendBuyerMessageCommandTest < Test::Unit::TestCase
|
|
57
51
|
end
|
58
52
|
|
59
53
|
def test_xml_send_email
|
60
|
-
|
54
|
+
assert_command_element_text_equals("true", "> send-email", @command)
|
55
|
+
assert_command_element_text_equals(@command.message, "> message", @command)
|
61
56
|
end
|
62
57
|
|
63
58
|
def test_accessors
|
@@ -46,36 +46,6 @@ class Google4R::Checkout::ShipItemsCommandTest < Test::Unit::TestCase
|
|
46
46
|
@item_info_2 = ItemInfo.new('A2')
|
47
47
|
@item_info_2.create_tracking_data('FedEx', 12345678)
|
48
48
|
@command.item_info_arr = [@item_info_1, @item_info_2]
|
49
|
-
|
50
|
-
|
51
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
52
|
-
<ship-items xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'>
|
53
|
-
<item-shipping-information-list>
|
54
|
-
<item-shipping-information>
|
55
|
-
<item-id>
|
56
|
-
<merchant-item-id>A1</merchant-item-id>
|
57
|
-
</item-id>
|
58
|
-
<tracking-data-list>
|
59
|
-
<tracking-data>
|
60
|
-
<carrier>UPS</carrier>
|
61
|
-
<tracking-number>55555555</tracking-number>
|
62
|
-
</tracking-data>
|
63
|
-
</tracking-data-list>
|
64
|
-
</item-shipping-information>
|
65
|
-
<item-shipping-information>
|
66
|
-
<item-id>
|
67
|
-
<merchant-item-id>A2</merchant-item-id>
|
68
|
-
</item-id>
|
69
|
-
<tracking-data-list>
|
70
|
-
<tracking-data>
|
71
|
-
<carrier>FedEx</carrier>
|
72
|
-
<tracking-number>12345678</tracking-number>
|
73
|
-
</tracking-data>
|
74
|
-
</tracking-data-list>
|
75
|
-
</item-shipping-information>
|
76
|
-
</item-shipping-information-list>
|
77
|
-
<send-email>true</send-email>
|
78
|
-
</ship-items>}
|
79
49
|
end
|
80
50
|
|
81
51
|
def test_behaves_correctly
|
@@ -85,8 +55,18 @@ class Google4R::Checkout::ShipItemsCommandTest < Test::Unit::TestCase
|
|
85
55
|
end
|
86
56
|
end
|
87
57
|
|
88
|
-
def
|
89
|
-
|
58
|
+
def test_xml_generation
|
59
|
+
assert_command_element_text_equals("true", "> send-email", @command)
|
60
|
+
@command.item_info_arr.each do |item_info|
|
61
|
+
selector = "> item-shipping-information-list > item-shipping-information"
|
62
|
+
item_info_elt = find_command_elements(selector, @command).select do |element|
|
63
|
+
element.css("item-id > merchant-item-id").first.text == item_info.merchant_item_id
|
64
|
+
end.first
|
65
|
+
|
66
|
+
selector = "tracking-data-list > tracking-data"
|
67
|
+
assert_equal item_info.tracking_data_arr.first.carrier, item_info_elt.css("#{selector} > carrier").first.text
|
68
|
+
assert_equal item_info.tracking_data_arr.first.tracking_number, item_info_elt.css("#{selector} > tracking-number").first.text
|
69
|
+
end
|
90
70
|
end
|
91
71
|
|
92
72
|
def test_accessors
|
data/test/unit/tax_table_test.rb
CHANGED
@@ -44,17 +44,23 @@ class Google4R::Checkout::TaxTableTest < Test::Unit::TestCase
|
|
44
44
|
assert_respond_to @table, :name
|
45
45
|
assert_respond_to @table, :name=
|
46
46
|
assert_respond_to @table, :standalone
|
47
|
+
assert_respond_to @table, :merchant_calculated
|
48
|
+
assert_respond_to @table, :merchant_calculated=
|
47
49
|
end
|
48
50
|
|
49
51
|
def test_initialized_correctly
|
50
52
|
assert_nil @table.name
|
51
53
|
assert_equal [], @table.rules
|
52
54
|
assert_equal false, @table.standalone
|
55
|
+
assert_equal false, @table.merchant_calculated
|
53
56
|
end
|
54
57
|
|
55
58
|
def test_accessors_work_correctly
|
56
59
|
@table.name = "name"
|
57
60
|
assert_equal "name", @table.name
|
61
|
+
|
62
|
+
@table.merchant_calculated = true
|
63
|
+
assert_equal true, @table.merchant_calculated
|
58
64
|
end
|
59
65
|
|
60
66
|
def test_create_rule_works_correctly_with_block
|
@@ -40,9 +40,6 @@ class Google4R::Checkout::UnarchiveOrderCommandTest < Test::Unit::TestCase
|
|
40
40
|
@command = @frontend.create_unarchive_order_command
|
41
41
|
|
42
42
|
@command.google_order_number = '841171949013218'
|
43
|
-
|
44
|
-
@sample_xml=%Q{<?xml version='1.0' encoding='UTF-8'?>
|
45
|
-
<unarchive-order xmlns='http://checkout.google.com/schema/2' google-order-number='841171949013218'/>}
|
46
43
|
end
|
47
44
|
|
48
45
|
def test_behaves_correctly
|
@@ -52,7 +49,7 @@ class Google4R::Checkout::UnarchiveOrderCommandTest < Test::Unit::TestCase
|
|
52
49
|
end
|
53
50
|
|
54
51
|
def test_xml
|
55
|
-
|
52
|
+
assert_element_exists(command_selector(@command), @command.to_xml)
|
56
53
|
end
|
57
54
|
|
58
55
|
def test_accessors
|
metadata
CHANGED
@@ -1,21 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google4r-checkout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: true
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
- 0
|
8
|
-
- 6
|
9
7
|
- 1
|
10
|
-
|
8
|
+
- beta1
|
9
|
+
version: 1.1.beta1
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Tony Chan
|
14
|
-
autorequire:
|
13
|
+
autorequire:
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-21 00:00:00 -04:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -23,13 +22,13 @@ dependencies:
|
|
23
22
|
prerelease: false
|
24
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
requirements:
|
26
|
-
- -
|
25
|
+
- - ~>
|
27
26
|
- !ruby/object:Gem::Version
|
28
27
|
segments:
|
29
|
-
-
|
30
|
-
-
|
31
|
-
-
|
32
|
-
version:
|
28
|
+
- 2
|
29
|
+
- 3
|
30
|
+
- 0
|
31
|
+
version: 2.3.0
|
33
32
|
type: :runtime
|
34
33
|
version_requirements: *id001
|
35
34
|
description: Ruby library to access the Google Checkout service and implement notification handlers.
|
@@ -75,11 +74,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
75
74
|
version: 1.8.4
|
76
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
76
|
requirements:
|
78
|
-
- - "
|
77
|
+
- - ">"
|
79
78
|
- !ruby/object:Gem::Version
|
80
79
|
segments:
|
81
|
-
-
|
82
|
-
|
80
|
+
- 1
|
81
|
+
- 3
|
82
|
+
- 1
|
83
|
+
version: 1.3.1
|
83
84
|
requirements: []
|
84
85
|
|
85
86
|
rubyforge_project:
|