vizjerai-google-checkout 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -88,7 +88,7 @@ module GoogleCheckout
88
88
  def initialize(merchant_id, merchant_key, *items)
89
89
  super(merchant_id, merchant_key)
90
90
  @contents = []
91
- @merchant_private_data = {}
91
+ @merchant_private_data = ''
92
92
  @shipping_methods = []
93
93
  items.each { |i| add_item i }
94
94
  end
@@ -97,6 +97,18 @@ module GoogleCheckout
97
97
  @contents.empty?
98
98
  end
99
99
 
100
+ def merchant_private_data=(value)
101
+ if value.is_a?(Hash)
102
+ xml = Builder::XmlMarkup.new
103
+ value.each do |key, value|
104
+ xml.tag!(key, value)
105
+ end
106
+ @merchant_private_data = xml.target!
107
+ elsif value.is_a?(String)
108
+ @merchant_private_data = value
109
+ end
110
+ end
111
+
100
112
  # Number of items in the cart.
101
113
  def size
102
114
  @contents.size
@@ -258,9 +270,7 @@ module GoogleCheckout
258
270
  }
259
271
  unless @merchant_private_data.blank?
260
272
  xml.tag!("merchant-private-data") {
261
- @merchant_private_data.each do |key, value|
262
- xml.tag!(key, value)
263
- end
273
+ xml << @merchant_private_data
264
274
  }
265
275
  end
266
276
  }
@@ -69,16 +69,26 @@ describe GoogleCheckout, "Cart Post" do
69
69
  response.redirect_url.should == 'https://checkout.google.com/buy?foo=bar&id=8572098456'
70
70
  end
71
71
 
72
- it "should set merchant private data" do
72
+ it "should set merchant private data with a Hash" do
73
73
  @cart.merchant_private_data = { "merchant-order-number" => "1234-5678-9012" }
74
- @cart.merchant_private_data["merchant-order-number"].should == "1234-5678-9012"
74
+ @cart.merchant_private_data.should == "<merchant-order-number>1234-5678-9012</merchant-order-number>"
75
75
  end
76
76
 
77
- it "should include merchant private in the generated xml" do
77
+ it "should include merchant private data in the generated xml with a Hash" do
78
78
  @cart.merchant_private_data = { "merchant-order-number" => "1234-5678-9012" }
79
79
  @cart.to_xml.should match(/<merchant-order-number>1234-5678-9012<\/merchant-order-number>/)
80
80
  end
81
81
 
82
+ it "should set merchant private data with a String" do
83
+ @cart.merchant_private_data = "<merchant-order-number>1234-5678-9012</merchant-order-number>"
84
+ @cart.merchant_private_data.should == "<merchant-order-number>1234-5678-9012</merchant-order-number>"
85
+ end
86
+
87
+ it "should include merchant private data in the generated xml with a String" do
88
+ @cart.merchant_private_data = "<merchant-order-number>1234-5678-9012</merchant-order-number>"
89
+ @cart.to_xml.should match(/<merchant-order-number>1234-5678-9012<\/merchant-order-number>/)
90
+ end
91
+
82
92
  it "should not include merchant private data if none is set" do
83
93
  @cart.to_xml.should_not match(/<merchant-private-data>/)
84
94
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vizjerai-google-checkout
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Peter Elmore
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2011-02-11 00:00:00 -06:00
22
+ date: 2011-02-14 00:00:00 -06:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency