spreedly 2.0.13 → 2.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +2 -0
- data/lib/spreedly/environment.rb +13 -0
- data/lib/spreedly/transactions/gateway_transaction.rb +19 -1
- data/lib/spreedly/version.rb +1 -1
- data/test/remote/remote_purchase_test.rb +21 -0
- data/test/unit/authorize_test.rb +7 -0
- data/test/unit/response_stubs/authorization_stubs.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab2b935117b1a317e75e3a6d4047b286b9ed06e7
|
4
|
+
data.tar.gz: eaeb49ca9cf5fac4fc679a7147d4acc108d554e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a656bb8873f3a8d476ab0760bb63d1e804392bf65e0aa0ce06ebbd9a4351e081ea81a4129d958b237ed5e32aae645f1a097c155856b0b97d03e8fa585d3bb3a9
|
7
|
+
data.tar.gz: 673025cc11a94db65ffd22e86a99e6967c7797e1b3072a95e676e02e4657949f72fac988efe33ece8c4b9163ba65379207060bf93c0882f66cc5de1c62a11cef
|
data/HISTORY.md
CHANGED
data/lib/spreedly/environment.rb
CHANGED
@@ -256,10 +256,23 @@ module Spreedly
|
|
256
256
|
end
|
257
257
|
|
258
258
|
def add_extra_options_for_basic_ops(doc, options)
|
259
|
+
add_gateway_specific_fields(doc, options)
|
259
260
|
add_to_doc(doc, options, :order_id, :description, :ip, :merchant_name_descriptor,
|
260
261
|
:merchant_location_descriptor)
|
261
262
|
end
|
262
263
|
|
264
|
+
def add_gateway_specific_fields(doc, options)
|
265
|
+
return unless options[:gateway_specific_fields].kind_of?(Hash)
|
266
|
+
doc << "<gateway_specific_fields>#{xml_for_hash(options[:gateway_specific_fields])}</gateway_specific_fields>"
|
267
|
+
end
|
268
|
+
|
269
|
+
def xml_for_hash(hash)
|
270
|
+
hash.map do |key, value|
|
271
|
+
text = value.kind_of?(Hash) ? xml_for_hash(value) : value
|
272
|
+
"<#{key}>#{text}</#{key}>"
|
273
|
+
end.join
|
274
|
+
end
|
275
|
+
|
263
276
|
def build_xml_request(root)
|
264
277
|
builder = Nokogiri::XML::Builder.new
|
265
278
|
builder.__send__(root) do |doc|
|
@@ -6,14 +6,32 @@ module Spreedly
|
|
6
6
|
field :merchant_name_descriptor, :merchant_location_descriptor
|
7
7
|
field :on_test_gateway, type: :boolean
|
8
8
|
|
9
|
-
attr_reader :response
|
9
|
+
attr_reader :response, :gateway_specific_fields
|
10
10
|
|
11
11
|
def initialize(xml_doc)
|
12
12
|
super
|
13
13
|
response_xml_doc = xml_doc.at_xpath('.//response')
|
14
14
|
@response = response_xml_doc ? Response.new(response_xml_doc) : nil
|
15
|
+
@gateway_specific_fields = parse_gateway_specific_fields(xml_doc)
|
15
16
|
end
|
16
17
|
|
18
|
+
def parse_gateway_specific_fields(xml_doc)
|
19
|
+
result = {}
|
20
|
+
|
21
|
+
xml_doc.at_xpath('.//gateway_specific_fields').xpath('*').each do |node|
|
22
|
+
node_name = node.name.to_sym
|
23
|
+
if (node.elements.empty?)
|
24
|
+
result[node_name] = node.text
|
25
|
+
else
|
26
|
+
node.elements.each do |childnode|
|
27
|
+
result[node_name] ||= {}
|
28
|
+
result[node_name][childnode.name.to_sym] = childnode.text
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
result
|
34
|
+
end
|
17
35
|
end
|
18
36
|
|
19
37
|
class Response
|
data/lib/spreedly/version.rb
CHANGED
@@ -67,4 +67,25 @@ class RemotePurchaseTest < Test::Unit::TestCase
|
|
67
67
|
assert_match /\d/, transaction.gateway_transaction_id
|
68
68
|
end
|
69
69
|
|
70
|
+
def test_gateway_specific_fields
|
71
|
+
gateway_token = @environment.add_gateway(:test).token
|
72
|
+
card_token = create_card_on(@environment, retained: false).token
|
73
|
+
|
74
|
+
t = @environment.purchase_on_gateway(gateway_token, card_token, 344,
|
75
|
+
gateway_specific_fields:
|
76
|
+
{
|
77
|
+
litle: {
|
78
|
+
descriptor_name: "CompanyName",
|
79
|
+
descriptor_phone: "1331131131"
|
80
|
+
},
|
81
|
+
stripe: {
|
82
|
+
application_fee: 411
|
83
|
+
}
|
84
|
+
})
|
85
|
+
|
86
|
+
assert t.succeeded?
|
87
|
+
assert_equal "CompanyName", t.gateway_specific_fields[:litle][:descriptor_name]
|
88
|
+
assert_equal "411", t.gateway_specific_fields[:stripe][:application_fee]
|
89
|
+
end
|
90
|
+
|
70
91
|
end
|
data/test/unit/authorize_test.rb
CHANGED
@@ -28,6 +28,9 @@ class AuthorizeTest < Test::Unit::TestCase
|
|
28
28
|
assert_equal 'Tax Free Zone', t.merchant_location_descriptor
|
29
29
|
assert_equal 'YjWxOjbpeieXsZFdAsbhM2DFgLe', t.gateway_token
|
30
30
|
assert_equal "44", t.gateway_transaction_id
|
31
|
+
assert_equal "TheName", t.gateway_specific_fields[:litle][:descriptor_name]
|
32
|
+
assert_equal "33411441", t.gateway_specific_fields[:litle][:descriptor_phone]
|
33
|
+
assert_equal "844", t.gateway_specific_fields[:stripe][:application_fee]
|
31
34
|
|
32
35
|
assert_equal 'Nh2Vw0kAoSQvcJDpK52q4dZlrVJ', t.payment_method.token
|
33
36
|
assert_equal 'Forthrast', t.payment_method.last_name
|
@@ -63,6 +66,7 @@ class AuthorizeTest < Test::Unit::TestCase
|
|
63
66
|
[ './ip', '183.128.100.102' ],
|
64
67
|
[ './merchant_name_descriptor', 'TRain' ],
|
65
68
|
[ './merchant_location_descriptor', 'British Colombia' ],
|
69
|
+
[ './gateway_specific_fields/braintree/customer_id', '1143' ],
|
66
70
|
[ './retain_on_success', 'true' ]
|
67
71
|
end
|
68
72
|
|
@@ -81,6 +85,9 @@ class AuthorizeTest < Test::Unit::TestCase
|
|
81
85
|
ip: "183.128.100.102",
|
82
86
|
merchant_name_descriptor: "TRain",
|
83
87
|
merchant_location_descriptor: "British Colombia",
|
88
|
+
gateway_specific_fields: {
|
89
|
+
braintree: { customer_id: "1143" }
|
90
|
+
},
|
84
91
|
retain_on_success: true
|
85
92
|
}
|
86
93
|
end
|
@@ -17,6 +17,15 @@ module AuthorizationStubs
|
|
17
17
|
<description>LotsOCoffee</description>
|
18
18
|
<merchant_name_descriptor>My Writeoff Inc.</merchant_name_descriptor>
|
19
19
|
<merchant_location_descriptor>Tax Free Zone</merchant_location_descriptor>
|
20
|
+
<gateway_specific_fields>
|
21
|
+
<litle>
|
22
|
+
<descriptor_name>TheName</descriptor_name>
|
23
|
+
<descriptor_phone>33411441</descriptor_blah>
|
24
|
+
</litle>
|
25
|
+
<stripe>
|
26
|
+
<application_fee>844</application_fee>
|
27
|
+
</stripe>
|
28
|
+
</gateway_specific_fields>
|
20
29
|
<gateway_specific_fields nil="true"/>
|
21
30
|
<gateway_specific_response_fields nil="true"/>
|
22
31
|
<message key="messages.transaction_succeeded">Succeeded!</message>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spreedly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spreedly
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|