braintree 4.33.0 → 4.33.1
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.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4e90519d70f62c557f0f25c54d7c481854711c5206ae20a24d09ca3c7ea77970
|
|
4
|
+
data.tar.gz: f07cc386365888000e3e44f6083b24f1d8fec0e25bba465f0e157a97c9d54e51
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c801cf89c35d0f835fa9f8513e3cffb39e19cd5e3aee3e004db2047a129bf3519ee2f00396ae47ef4ce01bf95f2abc56719ead396733cf5977eb4d9ad8323d80
|
|
7
|
+
data.tar.gz: 57112741f710b8e08c8d03ebba98e1e385be46a6dcac917c52f717f6e1007a3bfeda9a329c7973ed32d3f4e9a1da5669a1ca7b518491cf643d643c88cc81f7ed
|
data/lib/braintree/version.rb
CHANGED
|
@@ -12,12 +12,14 @@ module Braintree
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def self._node_to_hash(node, hash = {})
|
|
15
|
+
sub_hash = node.text? ? hash : _build_sub_hash(hash, node.name)
|
|
16
|
+
|
|
15
17
|
if node.text? || (node.children.size == 1 && node.children.first.text?)
|
|
16
18
|
content = node.text? ? node.content : node.children.first.content
|
|
17
19
|
raise "Content too large" if content.length >= NOKOGIRI_XML_LIMIT
|
|
18
|
-
|
|
20
|
+
sub_hash[CONTENT_ROOT] = content
|
|
21
|
+
_attributes_to_hash(node, sub_hash) unless node.text?
|
|
19
22
|
else
|
|
20
|
-
sub_hash = _build_sub_hash(hash, node.name)
|
|
21
23
|
_attributes_to_hash(node, sub_hash)
|
|
22
24
|
if _array?(node)
|
|
23
25
|
_children_array_to_hash(node, sub_hash)
|
|
@@ -66,4 +68,4 @@ module Braintree
|
|
|
66
68
|
end
|
|
67
69
|
end
|
|
68
70
|
end
|
|
69
|
-
end
|
|
71
|
+
end
|
|
@@ -33,5 +33,16 @@ module Braintree
|
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
|
+
|
|
37
|
+
describe "error response handling" do
|
|
38
|
+
it "correctly parses error response with nested structure" do
|
|
39
|
+
error_xml = "<api-error-response><message>Invalid request</message><errors><errors type=\"array\"></errors></errors></api-error-response>"
|
|
40
|
+
result = Braintree::Xml::Parser.hash_from_xml(error_xml)
|
|
41
|
+
|
|
42
|
+
expect(result[:api_error_response]).to be_a(Hash)
|
|
43
|
+
expect(result[:api_error_response][:message]).to eq("Invalid request")
|
|
44
|
+
expect(result[:api_error_response][:errors]).to be_a(Hash)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
36
47
|
end
|
|
37
48
|
end
|
|
@@ -14,6 +14,34 @@ describe Braintree::ErrorResult do
|
|
|
14
14
|
)
|
|
15
15
|
end.to_not raise_error
|
|
16
16
|
end
|
|
17
|
+
|
|
18
|
+
it "handles parsed XML error response structure correctly" do
|
|
19
|
+
data = {
|
|
20
|
+
:message => "Validation failed",
|
|
21
|
+
:errors => {
|
|
22
|
+
:errors => [{:code => "81234", :message => "Field is required"}]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
expect do
|
|
27
|
+
result = Braintree::ErrorResult.new(:gateway, data)
|
|
28
|
+
expect(result.message).to eq("Validation failed")
|
|
29
|
+
expect(result.errors.inspect).to eq("#<Braintree::Errors :[(81234) Field is required]>")
|
|
30
|
+
end.to_not raise_error
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "handles empty error array in parsed XML response" do
|
|
34
|
+
data = {
|
|
35
|
+
:message => "Invalid request",
|
|
36
|
+
:errors => {:errors => []}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
expect do
|
|
40
|
+
result = Braintree::ErrorResult.new(:gateway, data)
|
|
41
|
+
expect(result.message).to eq("Invalid request")
|
|
42
|
+
expect(result.errors).to be_a(Braintree::Errors)
|
|
43
|
+
end.to_not raise_error
|
|
44
|
+
end
|
|
17
45
|
end
|
|
18
46
|
|
|
19
47
|
describe "inspect" do
|
|
@@ -81,5 +81,62 @@ describe Braintree::Xml::Parser do
|
|
|
81
81
|
END
|
|
82
82
|
expect(xml).to parse_to(:root => {:paypal_details => {:deets => [{:secret_code => "1234"}], :payer_email => "abc@test.com", :payment_id => "1234567890"}})
|
|
83
83
|
end
|
|
84
|
+
|
|
85
|
+
it "does not collapse nested structures with single-child elements" do
|
|
86
|
+
xml = "<api-error-response><message>Test</message><errors><errors type=\"array\"></errors></errors></api-error-response>"
|
|
87
|
+
expect(xml).to parse_to({:api_error_response=>{:message=>"Test", :errors=>{:errors=>[]}}})
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
it "preserves hash structure when one key has array value" do
|
|
91
|
+
xml = <<-END
|
|
92
|
+
<root>
|
|
93
|
+
<message>Error message</message>
|
|
94
|
+
<items type="array">
|
|
95
|
+
<item>Value1</item>
|
|
96
|
+
</items>
|
|
97
|
+
</root>
|
|
98
|
+
END
|
|
99
|
+
expect(xml).to parse_to({:root => {:message => "Error message", :items => ["Value1"]}})
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "handles error response with nested errors correctly" do
|
|
103
|
+
xml = <<-END
|
|
104
|
+
<api-error-response>
|
|
105
|
+
<message>Validation failed</message>
|
|
106
|
+
<errors>
|
|
107
|
+
<errors type="array">
|
|
108
|
+
<error>
|
|
109
|
+
<code>81234</code>
|
|
110
|
+
<message>Field is required</message>
|
|
111
|
+
</error>
|
|
112
|
+
</errors>
|
|
113
|
+
</errors>
|
|
114
|
+
</api-error-response>
|
|
115
|
+
END
|
|
116
|
+
expect(xml).to parse_to({
|
|
117
|
+
:api_error_response => {
|
|
118
|
+
:message => "Validation failed",
|
|
119
|
+
:errors => {
|
|
120
|
+
:errors => [{:code => "81234", :message => "Field is required"}]
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
it "handles client token error response structure" do
|
|
127
|
+
xml = <<-END
|
|
128
|
+
<api-error-response>
|
|
129
|
+
<message>Invalid request</message>
|
|
130
|
+
<errors>
|
|
131
|
+
<errors type="array"></errors>
|
|
132
|
+
</errors>
|
|
133
|
+
</api-error-response>
|
|
134
|
+
END
|
|
135
|
+
result = Braintree::Xml::Parser.hash_from_xml(xml)
|
|
136
|
+
expect(result[:api_error_response]).to be_a(Hash)
|
|
137
|
+
expect(result[:api_error_response][:message]).to eq("Invalid request")
|
|
138
|
+
expect(result[:api_error_response][:errors]).to be_a(Hash)
|
|
139
|
+
expect(result[:api_error_response][:errors][:errors]).to eq([])
|
|
140
|
+
end
|
|
84
141
|
end
|
|
85
142
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: braintree
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.33.
|
|
4
|
+
version: 4.33.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Braintree
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2025-10-
|
|
11
|
+
date: 2025-10-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: builder
|
|
@@ -405,7 +405,7 @@ metadata:
|
|
|
405
405
|
changelog_uri: https://github.com/braintree/braintree_ruby/blob/master/CHANGELOG.md
|
|
406
406
|
source_code_uri: https://github.com/braintree/braintree_ruby
|
|
407
407
|
documentation_uri: https://developer.paypal.com/braintree/docs
|
|
408
|
-
post_install_message:
|
|
408
|
+
post_install_message:
|
|
409
409
|
rdoc_options: []
|
|
410
410
|
require_paths:
|
|
411
411
|
- lib
|
|
@@ -420,8 +420,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
420
420
|
- !ruby/object:Gem::Version
|
|
421
421
|
version: '0'
|
|
422
422
|
requirements: []
|
|
423
|
-
rubygems_version: 3.
|
|
424
|
-
signing_key:
|
|
423
|
+
rubygems_version: 3.3.15
|
|
424
|
+
signing_key:
|
|
425
425
|
specification_version: 4
|
|
426
426
|
summary: Braintree Ruby Server SDK
|
|
427
427
|
test_files: []
|