docdata 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/docdata/response.rb +4 -2
- data/lib/docdata/version.rb +1 -1
- data/spec/response_spec.rb +18 -1
- data/spec/xml/status-paid-canceled-ideal-multiple.xml +42 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4760635525904b78d47e8390f2c371e45f316a18
|
4
|
+
data.tar.gz: a91306598ed4b29b5adf81eb172da822ac4e3b3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ad18cf614968cb60eccb8abc1c9577462ee8b9e67bfe701d9887f092d9a42cb55da399d80ac6932578431b81b62d53ffe8fbebde142719b78349f2fb79129b6
|
7
|
+
data.tar.gz: 9f31c54925a1b75fd2bda0ddc6341438256a6de96817153204a7be24121470b7665a9793401a08ca1df93c4eed5fb39875eb0a351b6fe63933a95eb2c971a876
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
## v0.1.7
|
2
|
+
* Bug fixed where the gem didn't handle docdata XML response with multiple 'payment' nodes well. The gem assumed that the nodes where in chronological order, but they aren't.
|
3
|
+
|
1
4
|
## v0.1.6
|
2
5
|
* Bug fixed where a description contained an illegal character (& in this case)
|
3
6
|
|
data/lib/docdata/response.rb
CHANGED
@@ -212,12 +212,14 @@ module Docdata
|
|
212
212
|
private
|
213
213
|
|
214
214
|
# Sometimes a single response has multiple payment nodes. When a payment fails first and
|
215
|
-
# succeeds later, for example. In that case, always use the
|
215
|
+
# succeeds later, for example. In that case, always use the newest (== highest id) node.
|
216
216
|
def self.payment_node(hash)
|
217
217
|
if hash[:payment] && hash[:payment].is_a?(Hash)
|
218
218
|
hash[:payment]
|
219
219
|
elsif hash[:payment] && hash[:payment].is_a?(Array)
|
220
|
-
|
220
|
+
# use the node with the highest ID, for it is the newest
|
221
|
+
list = hash[:payment].sort_by { |k| k[:id] }
|
222
|
+
return list.last
|
221
223
|
else
|
222
224
|
false
|
223
225
|
end
|
data/lib/docdata/version.rb
CHANGED
data/spec/response_spec.rb
CHANGED
@@ -17,7 +17,7 @@ describe Docdata::Response do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
describe "response with multiple payment nodes" do
|
20
|
+
describe "response with multiple payment nodes (canceled first, paid later)" do
|
21
21
|
before(:each) do
|
22
22
|
file = "#{File.dirname(__FILE__)}/xml/status-paid-ideal-multiple.xml"
|
23
23
|
@xml = open(file)
|
@@ -33,6 +33,23 @@ describe Docdata::Response do
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
+
describe "response with multiple payment nodes (paid first, canceled later)" do
|
37
|
+
before(:each) do
|
38
|
+
file = "#{File.dirname(__FILE__)}/xml/status-paid-canceled-ideal-multiple.xml"
|
39
|
+
@xml = open(file)
|
40
|
+
@response = Docdata::Response.parse(:status, @xml)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "returs a response object" do
|
44
|
+
expect(@response).to be_kind_of(Docdata::Response)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "is paid" do
|
48
|
+
expect(@response.paid).to eq(true)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
36
53
|
describe "different payment methods" do
|
37
54
|
context ":status, paid iDeal" do
|
38
55
|
before(:each) do
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
2
|
+
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
|
3
|
+
<S:Body>
|
4
|
+
<statusResponse xmlns="http://www.docdatapayments.com/services/paymentservice/1_1/"><statusSuccess>
|
5
|
+
<success code="SUCCESS">Operation successful.</success>
|
6
|
+
<report>
|
7
|
+
<approximateTotals exchangedTo="EUR" exchangeRateDate="2014-09-24 09:29:54">
|
8
|
+
<totalRegistered>2000</totalRegistered>
|
9
|
+
<totalShopperPending>0</totalShopperPending>
|
10
|
+
<totalAcquirerPending>0</totalAcquirerPending>
|
11
|
+
<totalAcquirerApproved>2000</totalAcquirerApproved>
|
12
|
+
<totalCaptured>2000</totalCaptured>
|
13
|
+
<totalRefunded>0</totalRefunded>
|
14
|
+
<totalChargedback>0</totalChargedback>
|
15
|
+
</approximateTotals>
|
16
|
+
<payment>
|
17
|
+
<id>2502836079</id>
|
18
|
+
<paymentMethod>IDEAL</paymentMethod>
|
19
|
+
<authorization>
|
20
|
+
<status>AUTHORIZED</status>
|
21
|
+
<amount currency="EUR">2000</amount>
|
22
|
+
<confidenceLevel>ACQUIRER_APPROVED</confidenceLevel>
|
23
|
+
<capture>
|
24
|
+
<status>CAPTURED</status>
|
25
|
+
<amount currency="EUR">2000</amount>
|
26
|
+
</capture>
|
27
|
+
</authorization>
|
28
|
+
</payment>
|
29
|
+
<payment>
|
30
|
+
<id>2502835583</id>
|
31
|
+
<paymentMethod>IDEAL</paymentMethod>
|
32
|
+
<authorization>
|
33
|
+
<status>CANCELED</status>
|
34
|
+
<amount currency="EUR">2000</amount>
|
35
|
+
<confidenceLevel></confidenceLevel>
|
36
|
+
</authorization>
|
37
|
+
</payment>
|
38
|
+
</report>
|
39
|
+
</statusSuccess>
|
40
|
+
</statusResponse>
|
41
|
+
</S:Body>
|
42
|
+
</S:Envelope>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docdata
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henk Meijer
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-09-
|
12
|
+
date: 2014-09-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -283,6 +283,7 @@ files:
|
|
283
283
|
- spec/xml/status-canceled-creditcard.xml
|
284
284
|
- spec/xml/status-canceled-ideal.xml
|
285
285
|
- spec/xml/status-new.xml
|
286
|
+
- spec/xml/status-paid-canceled-ideal-multiple.xml
|
286
287
|
- spec/xml/status-paid-creditcard.xml
|
287
288
|
- spec/xml/status-paid-ideal-multiple.xml
|
288
289
|
- spec/xml/status-paid-ideal.xml
|
@@ -324,6 +325,7 @@ test_files:
|
|
324
325
|
- spec/xml/status-canceled-creditcard.xml
|
325
326
|
- spec/xml/status-canceled-ideal.xml
|
326
327
|
- spec/xml/status-new.xml
|
328
|
+
- spec/xml/status-paid-canceled-ideal-multiple.xml
|
327
329
|
- spec/xml/status-paid-creditcard.xml
|
328
330
|
- spec/xml/status-paid-ideal-multiple.xml
|
329
331
|
- spec/xml/status-paid-ideal.xml
|