docdata 0.2.2 → 0.2.3

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
  SHA1:
3
- metadata.gz: badfb82c6e3355001e9dd1dcb11dc3c30ce04d45
4
- data.tar.gz: 8efef93668be088abb0ffaffc347b5376892c5e5
3
+ metadata.gz: 747dd96a09532d085cf48ee29e156dd5784251a7
4
+ data.tar.gz: 4572f54bbab9226edd09caa51e0eef9a70048144
5
5
  SHA512:
6
- metadata.gz: 13681d573d5e88e6e7b09d8a53db6b4c7eaf6648604573d4dcac239a2b6ed8040609c6d438bd61f4e2aa62f28a80f780be9107f47fe2406dac7017e681a3bcfd
7
- data.tar.gz: 119ce034481911bc7ad2881e5be1448ee258db29f8e3419bf8fa15095c52702eae0bec939bfb0e9b70e3a36ac19a27b87496d49b23db93d0312077abfe2d36b2
6
+ metadata.gz: 08c8f2ea6390f2ac8d885422fef582e4b4cb3ffd5afb4765056a4976bf31af74464936075f149740fd2b16b15b2390e0e59940ad9674ca0b9b5583df62495669
7
+ data.tar.gz: 0ea23b6929003eb5563806b78c0717bbeac42ecd346969cf19bcf108eb8a29cf4753a5b5bc692393b505fb904566999f01d9a71a33c7a12ecd5606d342f84697
@@ -1,3 +1,6 @@
1
+ ## v0.2.3
2
+ * Fixed amount calculation in case of multiple payments in one transaction (giftcard+ideal for example)
3
+
1
4
  ## v0.2.2
2
5
  * Minor bugfixes (dependency issues)
3
6
 
@@ -58,10 +58,25 @@ module Docdata
58
58
  end
59
59
  end
60
60
 
61
+
62
+ # [Integer] the amount to set, calculated from the multiple payment nodes
63
+ def amount_to_set
64
+ # if (report && Response.payment_node(report) && Response.payment_node(report)[:authorization] && Response.payment_node(report)[:authorization][:amount].present?)
65
+ if (report && Response.payment_node(report) && Response.payment_node(report)[:authorization] && Response.payment_node(report)[:authorization][:amount].present?)
66
+ if canceled
67
+ return Response.payment_node(report)[:authorization][:amount].to_i
68
+ else
69
+ return total_acquirer_pending + total_acquirer_approved
70
+ end
71
+ else
72
+ return false
73
+ end
74
+ end
75
+
61
76
  # Set the attributes based on the API response
62
77
  def set_attributes
63
78
  self.paid = is_paid?
64
- self.amount = Response.payment_node(report)[:authorization][:amount].to_i if (report && Response.payment_node(report) && Response.payment_node(report)[:authorization] && Response.payment_node(report)[:authorization][:amount].present?)
79
+ self.amount = amount_to_set if amount_to_set
65
80
  self.status = capture_status if capture_status
66
81
  self.currency = currency_to_set
67
82
  end
@@ -103,7 +118,7 @@ module Docdata
103
118
  return body, xml
104
119
  end
105
120
 
106
- methods = [:total_registered, :total_shopper_pending, :total_acquier_pending, :total_acquirer_approved, :total_captured, :total_refunded, :total_chargedback]
121
+ methods = [:total_registered, :total_shopper_pending, :total_acquirer_pending, :total_acquirer_approved, :total_captured, :total_refunded, :total_chargedback]
107
122
  methods.each do |method|
108
123
  define_method method do
109
124
  report[:approximate_totals][method].to_i
@@ -1,3 +1,3 @@
1
1
  module Docdata
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -79,6 +79,27 @@ describe Docdata::Response do
79
79
  end
80
80
 
81
81
 
82
+ describe "response with multiple payment nodes (partial payments)" do
83
+ before(:each) do
84
+ file = "#{File.dirname(__FILE__)}/xml/status-multiple-paid.xml"
85
+ @xml = open(file)
86
+ @response = Docdata::Response.parse(:status, @xml)
87
+ end
88
+
89
+ it "returs a response object" do
90
+ expect(@response).to be_kind_of(Docdata::Response)
91
+ end
92
+
93
+ it "is paid" do
94
+ expect(@response.paid).to eq(true)
95
+ end
96
+
97
+ it "is for 300 cents" do
98
+ expect(@response.amount).to eq(300)
99
+ end
100
+ end
101
+
102
+
82
103
  describe "different payment methods" do
83
104
  context ":status, paid iDeal" do
84
105
  before(:each) do
@@ -0,0 +1,46 @@
1
+ <S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
2
+ <S:Body>
3
+ <statusResponse xmlns="http://www.docdatapayments.com/services/paymentservice/1_1/">
4
+ <statusSuccess>
5
+ <success code="SUCCESS">Operation successful.</success>
6
+ <report>
7
+ <approximateTotals exchangedTo="EUR" exchangeRateDate="2015-04-29 14:48:58">
8
+ <totalRegistered>300</totalRegistered>
9
+ <totalShopperPending>0</totalShopperPending>
10
+ <totalAcquirerPending>216</totalAcquirerPending>
11
+ <totalAcquirerApproved>84</totalAcquirerApproved>
12
+ <totalCaptured>300</totalCaptured>
13
+ <totalRefunded>0</totalRefunded>
14
+ <totalChargedback>0</totalChargedback>
15
+ </approximateTotals>
16
+ <payment>
17
+ <id>2570795670</id>
18
+ <paymentMethod>IDEAL</paymentMethod>
19
+ <authorization>
20
+ <status>AUTHORIZED</status>
21
+ <amount currency="EUR">84</amount>
22
+ <confidenceLevel>ACQUIRER_APPROVED</confidenceLevel>
23
+ <capture>
24
+ <status>CAPTURED</status>
25
+ <amount currency="EUR">84</amount>
26
+ </capture>
27
+ </authorization>
28
+ </payment>
29
+ <payment>
30
+ <id>2570795160</id>
31
+ <paymentMethod>PODIUM_GIFTCARD</paymentMethod>
32
+ <authorization>
33
+ <status>AUTHORIZED</status>
34
+ <amount currency="EUR">216</amount>
35
+ <confidenceLevel>ACQUIRER_PENDING</confidenceLevel>
36
+ <capture>
37
+ <status>CAPTURED</status>
38
+ <amount currency="EUR">216</amount>
39
+ </capture>
40
+ </authorization>
41
+ </payment>
42
+ </report>
43
+ </statusSuccess>
44
+ </statusResponse>
45
+ </S:Body>
46
+ </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.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henk Meijer
@@ -288,6 +288,7 @@ files:
288
288
  - spec/xml/refund_success.xml
289
289
  - spec/xml/status-canceled-creditcard.xml
290
290
  - spec/xml/status-canceled-ideal.xml
291
+ - spec/xml/status-multiple-paid.xml
291
292
  - spec/xml/status-new.xml
292
293
  - spec/xml/status-paid-canceled-ideal-multiple.xml
293
294
  - spec/xml/status-paid-creditcard.xml
@@ -335,6 +336,7 @@ test_files:
335
336
  - spec/xml/refund_success.xml
336
337
  - spec/xml/status-canceled-creditcard.xml
337
338
  - spec/xml/status-canceled-ideal.xml
339
+ - spec/xml/status-multiple-paid.xml
338
340
  - spec/xml/status-new.xml
339
341
  - spec/xml/status-paid-canceled-ideal-multiple.xml
340
342
  - spec/xml/status-paid-creditcard.xml