exact4r 0.9.2 → 0.9.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.
- data/CHANGELOG +3 -0
- data/VERSION +1 -1
- data/lib/ews/transaction/mapping.rb +1 -0
- data/lib/ews/transaction/request.rb +1 -0
- data/lib/ews/transaction/rexml-expansion-fix.rb +42 -0
- data/lib/ews/transaction/validator.rb +5 -5
- data/lib/exact4r.rb +1 -1
- data/test/exhaustive/tagged_online_debit_refund_test.rb +6 -6
- data/test/exhaustive/tagged_pre_auth_completion_test.rb +2 -2
- data/test/exhaustive/tagged_pre_auth_test.rb +2 -2
- data/test/exhaustive/tagged_purchase_test.rb +2 -2
- data/test/exhaustive/tagged_refund_test.rb +4 -6
- data/test/exhaustive/tagged_void_test.rb +160 -0
- metadata +4 -2
data/CHANGELOG
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.3
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Copyright (c) 2008 Michael Koziarski <michael@koziarski.com>
|
2
|
+
#
|
3
|
+
# Permission to use, copy, modify, and/or distribute this software for any
|
4
|
+
# purpose with or without fee is hereby granted, provided that the above
|
5
|
+
# copyright notice and this permission notice appear in all copies.
|
6
|
+
#
|
7
|
+
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
8
|
+
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
9
|
+
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
10
|
+
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
11
|
+
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
12
|
+
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
13
|
+
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
14
|
+
|
15
|
+
require 'rexml/document'
|
16
|
+
require 'rexml/entity'
|
17
|
+
|
18
|
+
module REXML
|
19
|
+
class Entity < Child
|
20
|
+
def unnormalized
|
21
|
+
document.record_entity_expansion!
|
22
|
+
v = value()
|
23
|
+
return nil if v.nil?
|
24
|
+
@unnormalized = Text::unnormalize(v, parent)
|
25
|
+
@unnormalized
|
26
|
+
end
|
27
|
+
end
|
28
|
+
class Document < Element
|
29
|
+
@@entity_expansion_limit = 10_000
|
30
|
+
def self.entity_expansion_limit= val
|
31
|
+
@@entity_expansion_limit = val
|
32
|
+
end
|
33
|
+
|
34
|
+
def record_entity_expansion!
|
35
|
+
@number_of_expansions ||= 0
|
36
|
+
@number_of_expansions += 1
|
37
|
+
if @number_of_expansions > @@entity_expansion_limit
|
38
|
+
raise "Number of entity expansions exceeded, processing aborted."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -146,7 +146,7 @@ module EWS # :nodoc:
|
|
146
146
|
tt = self.transaction_type.to_i
|
147
147
|
|
148
148
|
# mandatory: transaction_type must != (30, 31, 32, 34, 35)
|
149
|
-
append_error(:cc_number, "cc_number must not be set for tagged transactions") if [30,31,32,34,35].include?(tt)
|
149
|
+
append_error(:cc_number, "cc_number must not be set for tagged transactions") if [30,31,32,33,34,35].include?(tt)
|
150
150
|
append_error(:cc_number, "cc_number must not be set for debit transactions") if [50,54].include?(tt)
|
151
151
|
|
152
152
|
# amount, cardholder_name always mandaory
|
@@ -164,8 +164,8 @@ module EWS # :nodoc:
|
|
164
164
|
def validate_for_transaction_tag
|
165
165
|
tt = self.transaction_type
|
166
166
|
|
167
|
-
# mandatory: transaction_type must == (30, 31, 32, 34, 35)
|
168
|
-
append_error(:transaction_tag, "transaction_tag must only be set for tagged transactions") unless
|
167
|
+
# mandatory: transaction_type must == (30, 31, 32, 33, 34, 35)
|
168
|
+
append_error(:transaction_tag, "transaction_tag must only be set for tagged transactions") unless %w(30 31 32 33 34 35 CR).include?(tt)
|
169
169
|
|
170
170
|
# transaction_tag, auth_num & amount mandatory
|
171
171
|
mandatory = [:transaction_tag]
|
@@ -183,7 +183,7 @@ module EWS # :nodoc:
|
|
183
183
|
tt = self.transaction_type.to_i
|
184
184
|
|
185
185
|
# mandatory: transaction_type must != (30, 31, 32, 34, 35)
|
186
|
-
append_error(:track1, "track1 must not be set for tagged transactions") if [30,31,32,34,35].include?(tt)
|
186
|
+
append_error(:track1, "track1 must not be set for tagged transactions") if [30,31,32,33,34,35].include?(tt)
|
187
187
|
append_error(:track1, "track1 must not be set for debit transactions") if [50,54].include?(tt)
|
188
188
|
|
189
189
|
# amount mandatory for all
|
@@ -201,7 +201,7 @@ module EWS # :nodoc:
|
|
201
201
|
tt = self.transaction_type.to_i
|
202
202
|
|
203
203
|
# mandatory: transaction_type must != (30, 31, 32, 34, 35, 50, 54)
|
204
|
-
append_error(:track2, "track2 must not be set for tagged transactions") if [30,31,32,34,35].include?(tt)
|
204
|
+
append_error(:track2, "track2 must not be set for tagged transactions") if [30,31,32,33,34,35].include?(tt)
|
205
205
|
append_error(:track2, "track2 must not be set for debit transactions") if [50,54].include?(tt)
|
206
206
|
|
207
207
|
# track2, expiry_date, cardholder_name, amount mandatory
|
data/lib/exact4r.rb
CHANGED
@@ -114,8 +114,8 @@ class TaggedRefundTest < Test::Unit::TestCase
|
|
114
114
|
request = EWS::Transaction::Request.new({
|
115
115
|
:transaction_type => :tagged_online_debit_refund,
|
116
116
|
:amount => 12.50,
|
117
|
-
:transaction_tag =>
|
118
|
-
:authorization_num =>
|
117
|
+
:transaction_tag => pre_response.transaction_tag,
|
118
|
+
:authorization_num => pre_response.authorization_num
|
119
119
|
}.merge(CHASE_BASIC_AUTH))
|
120
120
|
assert request.valid?, request.errors.inspect
|
121
121
|
|
@@ -136,8 +136,8 @@ class TaggedRefundTest < Test::Unit::TestCase
|
|
136
136
|
request = EWS::Transaction::Request.new({
|
137
137
|
:transaction_type => :tagged_online_debit_refund,
|
138
138
|
:amount => 12.50,
|
139
|
-
:transaction_tag =>
|
140
|
-
:authorization_num =>
|
139
|
+
:transaction_tag => pre_response.transaction_tag,
|
140
|
+
:authorization_num => pre_response.authorization_num
|
141
141
|
}.merge(CHASE_BASIC_AUTH))
|
142
142
|
assert request.valid?, request.errors.inspect
|
143
143
|
|
@@ -158,8 +158,8 @@ class TaggedRefundTest < Test::Unit::TestCase
|
|
158
158
|
request = EWS::Transaction::Request.new({
|
159
159
|
:transaction_type => :tagged_refund,
|
160
160
|
:amount => 12.50,
|
161
|
-
:transaction_tag =>
|
162
|
-
:authorization_num =>
|
161
|
+
:transaction_tag => pre_response.transaction_tag,
|
162
|
+
:authorization_num => pre_response.authorization_num
|
163
163
|
}.merge(CHASE_BASIC_AUTH))
|
164
164
|
assert request.valid?, request.errors.inspect
|
165
165
|
|
@@ -108,8 +108,8 @@ class TaggedPreAuthCompletionTest < Test::Unit::TestCase
|
|
108
108
|
request = EWS::Transaction::Request.new({
|
109
109
|
:transaction_type => :tagged_pre_auth_completion,
|
110
110
|
:amount => 12.50,
|
111
|
-
:transaction_tag =>
|
112
|
-
:authorization_num =>
|
111
|
+
:transaction_tag => pre_response.transaction_tag,
|
112
|
+
:authorization_num => pre_response.authorization_num
|
113
113
|
}.merge(EMERGIS_BASIC_AUTH))
|
114
114
|
assert request.valid?, request.errors.inspect
|
115
115
|
|
@@ -106,8 +106,8 @@ class TaggedPreAuthTest < Test::Unit::TestCase
|
|
106
106
|
request = EWS::Transaction::Request.new({
|
107
107
|
:transaction_type => :tagged_pre_auth,
|
108
108
|
:amount => 12.50,
|
109
|
-
:transaction_tag =>
|
110
|
-
:authorization_num =>
|
109
|
+
:transaction_tag => pre_response.transaction_tag,
|
110
|
+
:authorization_num => pre_response.authorization_num
|
111
111
|
}.merge(EMERGIS_BASIC_AUTH))
|
112
112
|
assert request.valid?, request.errors.inspect
|
113
113
|
|
@@ -106,8 +106,8 @@ class TaggedPurchaseTest < Test::Unit::TestCase
|
|
106
106
|
request = EWS::Transaction::Request.new({
|
107
107
|
:transaction_type => :tagged_purchase,
|
108
108
|
:amount => 12.50,
|
109
|
-
:transaction_tag =>
|
110
|
-
:authorization_num =>
|
109
|
+
:transaction_tag => pre_response.transaction_tag,
|
110
|
+
:authorization_num => pre_response.authorization_num
|
111
111
|
}.merge(EMERGIS_BASIC_AUTH))
|
112
112
|
assert request.valid?, request.errors.inspect
|
113
113
|
|
@@ -2,8 +2,6 @@ require File.dirname(__FILE__) + "/../test_helper"
|
|
2
2
|
|
3
3
|
class TaggedRefundTest < Test::Unit::TestCase
|
4
4
|
|
5
|
-
# NOTE: INTERAC Online Debit transactions are ONLY supported by Chase merchants
|
6
|
-
|
7
5
|
def setup
|
8
6
|
@transporter = EWS::Transporter.new(LOCATION)
|
9
7
|
|
@@ -112,8 +110,8 @@ class TaggedRefundTest < Test::Unit::TestCase
|
|
112
110
|
request = EWS::Transaction::Request.new({
|
113
111
|
:transaction_type => :tagged_refund,
|
114
112
|
:amount => 11.25,
|
115
|
-
:transaction_tag =>
|
116
|
-
:authorization_num =>
|
113
|
+
:transaction_tag => pre_response.transaction_tag,
|
114
|
+
:authorization_num => pre_response.authorization_num
|
117
115
|
}.merge(EMERGIS_BASIC_AUTH))
|
118
116
|
assert request.valid?, request.errors.inspect
|
119
117
|
|
@@ -134,8 +132,8 @@ class TaggedRefundTest < Test::Unit::TestCase
|
|
134
132
|
request = EWS::Transaction::Request.new({
|
135
133
|
:transaction_type => :tagged_refund,
|
136
134
|
:amount => 11.25,
|
137
|
-
:transaction_tag =>
|
138
|
-
:authorization_num =>
|
135
|
+
:transaction_tag => pre_response.transaction_tag,
|
136
|
+
:authorization_num => pre_response.authorization_num
|
139
137
|
}.merge(EMERGIS_BASIC_AUTH))
|
140
138
|
assert request.valid?, request.errors.inspect
|
141
139
|
|
@@ -0,0 +1,160 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../test_helper"
|
2
|
+
|
3
|
+
class TaggedVoidTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
@transporter = EWS::Transporter.new(LOCATION)
|
7
|
+
|
8
|
+
# do initial recurring seed
|
9
|
+
request = EWS::Transaction::Request.new(cc_number_params.merge(:transaction_type => :recurring_seed_purchase))
|
10
|
+
request.amount = 11.25
|
11
|
+
assert request.valid?, request.errors.inspect
|
12
|
+
|
13
|
+
@response = @transporter.submit(request, :json)
|
14
|
+
assert @response.approved?
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_mandatory
|
18
|
+
request = EWS::Transaction::Request.new(:transaction_type => :tagged_void)
|
19
|
+
assert !request.valid?
|
20
|
+
assert_equal "gateway_id must be supplied", request.errors[:gateway_id]
|
21
|
+
|
22
|
+
request.gateway_id = EMERGIS_BASIC_AUTH[:gateway_id]
|
23
|
+
assert !request.valid?
|
24
|
+
assert_equal "password must be supplied", request.errors[:password]
|
25
|
+
|
26
|
+
request.password = EMERGIS_BASIC_AUTH[:password]
|
27
|
+
assert !request.valid?
|
28
|
+
assert_equal "One of the following must be supplied: cc_number, track1, track2 or transaction_tag.", request.errors[:base]
|
29
|
+
|
30
|
+
request.transaction_tag = 1234
|
31
|
+
assert !request.valid?
|
32
|
+
assert_equal "authorization_num must be supplied", request.errors[:authorization_num]
|
33
|
+
|
34
|
+
request.authorization_num = "TH6754"
|
35
|
+
assert !request.valid?
|
36
|
+
assert_equal "amount must be supplied", request.errors[:amount]
|
37
|
+
|
38
|
+
request.amount = 11.25
|
39
|
+
assert request.valid?
|
40
|
+
|
41
|
+
request.cc_number = "4111111111111111"
|
42
|
+
assert !request.valid?
|
43
|
+
assert_equal "do not set cc_number for tagged transactions", request.errors[:cc_number]
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_json
|
47
|
+
request = EWS::Transaction::Request.new({
|
48
|
+
:transaction_type => :tagged_void,
|
49
|
+
:amount => 11.25,
|
50
|
+
:transaction_tag => @response.transaction_tag,
|
51
|
+
:authorization_num => @response.authorization_num
|
52
|
+
}.merge(EMERGIS_BASIC_AUTH))
|
53
|
+
assert request.valid?, request.errors.inspect
|
54
|
+
|
55
|
+
assert_details_correct request, @transporter.submit(request, :json)
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_rest
|
59
|
+
request = EWS::Transaction::Request.new({
|
60
|
+
:transaction_type => :tagged_void,
|
61
|
+
:amount => 11.25,
|
62
|
+
:transaction_tag => @response.transaction_tag,
|
63
|
+
:authorization_num => @response.authorization_num
|
64
|
+
}.merge(EMERGIS_BASIC_AUTH))
|
65
|
+
assert request.valid?, request.errors.inspect
|
66
|
+
|
67
|
+
assert_details_correct request, @transporter.submit(request, :rest)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_soap
|
71
|
+
request = EWS::Transaction::Request.new({
|
72
|
+
:transaction_type => :tagged_void,
|
73
|
+
:amount => 11.25,
|
74
|
+
:transaction_tag => @response.transaction_tag,
|
75
|
+
:authorization_num => @response.authorization_num
|
76
|
+
}.merge(EMERGIS_BASIC_AUTH))
|
77
|
+
assert request.valid?, request.errors.inspect
|
78
|
+
|
79
|
+
assert_details_correct request, @transporter.submit(request, :soap)
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_requires_correct_amount
|
83
|
+
request = EWS::Transaction::Request.new({
|
84
|
+
:transaction_type => :tagged_void,
|
85
|
+
:amount => 3.50,
|
86
|
+
:transaction_tag => @response.transaction_tag,
|
87
|
+
:authorization_num => @response.authorization_num
|
88
|
+
}.merge(EMERGIS_BASIC_AUTH))
|
89
|
+
assert request.valid?, request.errors.inspect
|
90
|
+
|
91
|
+
response = @transporter.submit(request, :json)
|
92
|
+
assert !response.approved?
|
93
|
+
|
94
|
+
request.amount = 13.50
|
95
|
+
response = @transporter.submit(request, :rest)
|
96
|
+
assert !response.approved?
|
97
|
+
|
98
|
+
request.amount = 11.25
|
99
|
+
assert_details_correct request, @transporter.submit(request, :soap)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_multiple_voids_against_one_seed
|
103
|
+
request = EWS::Transaction::Request.new({
|
104
|
+
:transaction_type => :tagged_void,
|
105
|
+
:amount => 11.25,
|
106
|
+
:transaction_tag => @response.transaction_tag,
|
107
|
+
:authorization_num => @response.authorization_num
|
108
|
+
}.merge(EMERGIS_BASIC_AUTH))
|
109
|
+
assert request.valid?, request.errors.inspect
|
110
|
+
|
111
|
+
assert_details_correct request, @transporter.submit(request, :json)
|
112
|
+
|
113
|
+
# can't void an already-voided transaction
|
114
|
+
response = @transporter.submit(request, :json)
|
115
|
+
assert !response.approved?
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_not_permitted_after_recurring_seed_pre_auth
|
119
|
+
# do initial recurring seed pre auth
|
120
|
+
pre_request = EWS::Transaction::Request.new(cc_number_params.merge(:transaction_type => :recurring_seed_pre_auth))
|
121
|
+
pre_request.amount = 11.25
|
122
|
+
assert pre_request.valid?, pre_request.errors.inspect
|
123
|
+
|
124
|
+
pre_response = @transporter.submit(pre_request, :json)
|
125
|
+
assert pre_response.approved?
|
126
|
+
|
127
|
+
# now do the tagged refund
|
128
|
+
request = EWS::Transaction::Request.new({
|
129
|
+
:transaction_type => :tagged_void,
|
130
|
+
:amount => 11.25,
|
131
|
+
:transaction_tag => pre_response.transaction_tag,
|
132
|
+
:authorization_num => pre_response.authorization_num
|
133
|
+
}.merge(EMERGIS_BASIC_AUTH))
|
134
|
+
assert request.valid?, request.errors.inspect
|
135
|
+
|
136
|
+
response = @transporter.submit(request, :json)
|
137
|
+
assert !response.approved?
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_permitted_after_plain_purchase
|
141
|
+
# do initial purchase
|
142
|
+
pre_request = EWS::Transaction::Request.new(cc_number_params.merge(:transaction_type => :purchase))
|
143
|
+
pre_request.amount = 11.25
|
144
|
+
assert pre_request.valid?, pre_request.errors.inspect
|
145
|
+
|
146
|
+
pre_response = @transporter.submit(pre_request, :json)
|
147
|
+
assert pre_response.approved?
|
148
|
+
|
149
|
+
# now do the tagged refund
|
150
|
+
request = EWS::Transaction::Request.new({
|
151
|
+
:transaction_type => :tagged_void,
|
152
|
+
:amount => 11.25,
|
153
|
+
:transaction_tag => pre_response.transaction_tag,
|
154
|
+
:authorization_num => pre_response.authorization_num
|
155
|
+
}.merge(EMERGIS_BASIC_AUTH))
|
156
|
+
assert request.valid?, request.errors.inspect
|
157
|
+
|
158
|
+
assert_details_correct request, @transporter.submit(request, :json)
|
159
|
+
end
|
160
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exact4r
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- E-xact Transactions Ltd.
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-30 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- ./lib/ews/transaction/mapping.rb
|
77
77
|
- ./lib/ews/transaction/request.rb
|
78
78
|
- ./lib/ews/transaction/response.rb
|
79
|
+
- ./lib/ews/transaction/rexml-expansion-fix.rb
|
79
80
|
- ./lib/ews/transaction/validator.rb
|
80
81
|
- ./lib/ews/transporter.rb
|
81
82
|
- ./lib/exact4r.rb
|
@@ -100,6 +101,7 @@ files:
|
|
100
101
|
- ./test/exhaustive/tagged_pre_auth_test.rb
|
101
102
|
- ./test/exhaustive/tagged_purchase_test.rb
|
102
103
|
- ./test/exhaustive/tagged_refund_test.rb
|
104
|
+
- ./test/exhaustive/tagged_void_test.rb
|
103
105
|
- ./test/exhaustive/transaction_details_test.rb
|
104
106
|
- ./test/exhaustive/void_test.rb
|
105
107
|
- ./test/general/avs_test.rb
|