docdata 0.1.8 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b7fce0fc2d60f3333084ba16516eb7ad414b728
4
- data.tar.gz: 52f071c31314b98fd530bb62b3f0fb007c4d4b33
3
+ metadata.gz: 1649a0341e1a2bab71fffe7312e8164eac76ad28
4
+ data.tar.gz: c2669f29aaa9e3d413103d6853c176e70d9a9c8e
5
5
  SHA512:
6
- metadata.gz: 25d68049043573abdbd864625135dab093f86cd2cba3ce5095f9de81bca2b3d6429859e29f63bd2211aae374ada25d8c03d8a8614e0fb21600a6915812f53514
7
- data.tar.gz: fe7766f96151b852e3fcb4702f977e6b84fbbd73810ac0d969f814cb62b685a1aaed37e65b55cc609403c2b6714fcdfb6f57625260e579fc1959cf2865d52d1c
6
+ metadata.gz: 09ae4da69d1e3863169b627dc658bd7a225e5682fdc33d13a3fd30767c7d5e2470af19b88bfa9f748bca4e5fe805fdf58074adbe440c7252a5c428fd874f6e5f
7
+ data.tar.gz: 7557feaa5bfed0907f872693f5699e8966928e01f5d5f7111d9921d0b0fe0374db73cfc8e5b4dbd048204ce605978c5f7c223ebd6c008b193c4b7aa098df9aa0
@@ -1,3 +1,9 @@
1
+ ## v0.2.0
2
+ * We now assume a payment to be paid when total_registered == total_acquirer_approved
3
+
4
+ ## v0.1.9
5
+ * Bug fixed where 'paid?' returned false if respons status had both 'paid' and 'canceled' node in response XML.
6
+
1
7
  ## v0.1.8
2
8
  * You can now make refunds. See documentation.
3
9
  * Updated README
@@ -149,12 +149,31 @@ module Docdata
149
149
  # a different 'paid'.
150
150
  # @note This method is never 100% reliable. If you need to finetune this, please implement your own method, using
151
151
  # the available data (total_captured, total_registered, etc.)
152
+ ## from the Docs:
153
+ ### Safe route:
154
+ # The safest route to check whether all payments were made is for the merchants
155
+ # to refer to the “Total captured” amount to see whether this equals the “Total registered
156
+ # amount”. While this may be the safest indicator, the downside is that it can sometimes take a
157
+ # long time for acquirers or shoppers to actually have the money transferred and it can be
158
+ # captured.
159
+ ### Quick route:
160
+ # Another option is to see whether the sum of “total shopper pending”, “total
161
+ # acquirer pending” and “total acquirer authorized” matches the “total registered sum”. This
162
+ # implies that everyone responsible has indicated that they are going to make the payment and
163
+ # that the merchant is trusting that everyone will indeed make this. While this route will be
164
+ # faster, it does also have the risk that some payments will actually not have been made.
165
+ ### Balanced route:
166
+ # Depending on the merchant's situation, it can be a good option to only refer
167
+ # to certain totals. For instance, if the merchant only makes use of credit card payments it
168
+ # could be a good route to only look at “Total acquirer approved”, since this will be rather safe
169
+ # but quicker than looking at the captures.
152
170
  def is_paid?
171
+
153
172
  if payment_method
154
173
  case payment_method
155
174
  # ideal (dutch)
156
175
  when "IDEAL"
157
- (total_registered == total_captured) && (capture_status == "CAPTURED")
176
+ (total_registered == total_captured) ## && (capture_status == "CAPTURED")
158
177
  # creditcard
159
178
  when "MASTERCARD", "VISA", "AMEX"
160
179
  (total_registered == total_acquirer_approved)
@@ -164,7 +183,7 @@ module Docdata
164
183
  # fallback: if total_registered equals total_caputured,
165
184
  # we can assume that this order is paid. No 100% guarantee.
166
185
  else
167
- total_registered == total_captured
186
+ total_registered == total_acquirer_approved
168
187
  end
169
188
  else
170
189
  false
@@ -222,6 +241,8 @@ module Docdata
222
241
 
223
242
  # Sometimes a single response has multiple payment nodes. When a payment fails first and
224
243
  # succeeds later, for example. In that case, always use the newest (== highest id) node.
244
+ # UPDATE (2/3/2015) this is not always the case: a payment can receive a 'canceled' payment
245
+ # later on with a higher ID, but the order is still paid.
225
246
  def self.payment_node(hash)
226
247
  if hash[:payment] && hash[:payment].is_a?(Hash)
227
248
  hash[:payment]
@@ -1,3 +1,3 @@
1
1
  module Docdata
2
- VERSION = "0.1.8"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -33,6 +33,35 @@ describe Docdata::Response do
33
33
  end
34
34
  end
35
35
 
36
+
37
+ describe "response with multiple payment nodes (paid first, canceled later)" do
38
+ before(:each) do
39
+ file = "#{File.dirname(__FILE__)}/xml/status-paid-multiple-and-canceled.xml"
40
+ @xml = open(file)
41
+ @response = Docdata::Response.parse(:status, @xml)
42
+ end
43
+
44
+ it "returs a response object" do
45
+ expect(@response).to be_kind_of(Docdata::Response)
46
+ end
47
+
48
+ it "is of method IDEAL" do
49
+ expect(@response.payment_method).to eq("IDEAL")
50
+ end
51
+
52
+ it "is paid?" do
53
+ expect(@response.paid?).to eq(true)
54
+ end
55
+
56
+ it "is paid" do
57
+ # puts "IS PAID: #{total_registered} && #{total_captured}"
58
+ expect(@response.total_registered).to eq(2600)
59
+ expect(@response.total_captured).to eq(2600)
60
+ expect(@response.paid).to eq(true)
61
+ end
62
+ end
63
+
64
+
36
65
  describe "response with multiple payment nodes (paid first, canceled later)" do
37
66
  before(:each) do
38
67
  file = "#{File.dirname(__FILE__)}/xml/status-paid-canceled-ideal-multiple.xml"
@@ -0,0 +1,42 @@
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-03-02 11:14:59">
8
+ <totalRegistered>2600</totalRegistered>
9
+ <totalShopperPending>0</totalShopperPending>
10
+ <totalAcquirerPending>0</totalAcquirerPending>
11
+ <totalAcquirerApproved>2600</totalAcquirerApproved>
12
+ <totalCaptured>2600</totalCaptured>
13
+ <totalRefunded>0</totalRefunded>
14
+ <totalChargedback>0</totalChargedback>
15
+ </approximateTotals>
16
+ <payment>
17
+ <id>2551456273</id>
18
+ <paymentMethod>IDEAL</paymentMethod>
19
+ <authorization>
20
+ <status>CANCELED</status>
21
+ <amount currency="EUR">2600</amount>
22
+ <confidenceLevel/>
23
+ </authorization>
24
+ </payment>
25
+ <payment>
26
+ <id>2551456260</id>
27
+ <paymentMethod>IDEAL</paymentMethod>
28
+ <authorization>
29
+ <status>AUTHORIZED</status>
30
+ <amount currency="EUR">2600</amount>
31
+ <confidenceLevel>ACQUIRER_APPROVED</confidenceLevel>
32
+ <capture>
33
+ <status>CAPTURED</status>
34
+ <amount currency="EUR">2600</amount>
35
+ </capture>
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.8
4
+ version: 0.2.0
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-10-23 00:00:00.000000000 Z
12
+ date: 2015-03-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -293,6 +293,7 @@ files:
293
293
  - spec/xml/status-paid-creditcard.xml
294
294
  - spec/xml/status-paid-ideal-multiple.xml
295
295
  - spec/xml/status-paid-ideal.xml
296
+ - spec/xml/status-paid-multiple-and-canceled.xml
296
297
  - spec/xml/status-paid-sofort.xml
297
298
  homepage: http://rdoc.info/github/henkm/docdata/
298
299
  licenses:
@@ -339,5 +340,6 @@ test_files:
339
340
  - spec/xml/status-paid-creditcard.xml
340
341
  - spec/xml/status-paid-ideal-multiple.xml
341
342
  - spec/xml/status-paid-ideal.xml
343
+ - spec/xml/status-paid-multiple-and-canceled.xml
342
344
  - spec/xml/status-paid-sofort.xml
343
345
  has_rdoc: