exact4r 0.9.1 → 0.9.2
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 +6 -1
- data/README +71 -3
- data/Rakefile +8 -7
- data/VERSION +1 -1
- data/doc/classes/EWS/Transaction/FakeResponse.html +451 -0
- data/doc/classes/EWS/Transaction/Request.html +61 -80
- data/doc/classes/EWS/Transaction/Response.html +206 -14
- data/doc/classes/EWS/Transaction/Validator.html +182 -0
- data/doc/classes/EWS/Transporter.html +269 -0
- data/doc/classes/REXML/Document.html +176 -0
- data/doc/classes/REXML/Entity.html +150 -0
- data/doc/classes/REXML.html +112 -0
- data/doc/created.rid +1 -1
- data/doc/files/CHANGELOG.html +156 -0
- data/doc/files/LICENCE.html +109 -0
- data/doc/files/README.html +164 -23
- data/doc/files/VERSION.html +107 -0
- data/doc/files/lib/ews/transaction/fake_response_rb.html +101 -0
- data/doc/files/lib/ews/transaction/mapping_rb.html +1 -1
- data/doc/files/lib/ews/transaction/request_rb.html +8 -1
- data/doc/files/lib/ews/transaction/response_rb.html +1 -1
- data/doc/files/lib/ews/transaction/validator_rb.html +101 -0
- data/doc/files/lib/ews/{transaction/transporter_rb.html → transporter_rb.html} +3 -3
- data/doc/files/lib/exact4r_rb.html +6 -2
- data/doc/fr_class_index.html +6 -1
- data/doc/fr_file_index.html +6 -1
- data/doc/fr_method_index.html +22 -7
- data/lib/ews/transaction/mapping.rb +41 -40
- data/lib/ews/transaction/request.rb +3 -4
- data/lib/ews/transaction/response.rb +5 -0
- data/lib/ews/transaction/validator.rb +44 -34
- data/lib/ews/transporter.rb +3 -3
- data/lib/exact4r.rb +1 -1
- data/test/exhaustive/forced_post_test.rb +75 -0
- data/test/exhaustive/online_debit_purchase_test.rb +66 -0
- data/test/exhaustive/online_debit_refund_test.rb +66 -0
- data/test/exhaustive/pre_auth_completion_test.rb +99 -0
- data/test/exhaustive/pre_auth_only_test.rb +68 -0
- data/test/exhaustive/pre_auth_test.rb +68 -0
- data/test/exhaustive/purchase_correction_test.rb +79 -0
- data/test/exhaustive/purchase_test.rb +68 -0
- data/test/exhaustive/recurring_seed_pre_auth_test.rb +68 -0
- data/test/exhaustive/recurring_seed_purchase_test.rb +68 -0
- data/test/exhaustive/refund_correction_test.rb +79 -0
- data/test/exhaustive/refund_test.rb +68 -0
- data/test/exhaustive/secure_storage_test.rb +75 -0
- data/test/exhaustive/tagged_online_debit_refund_test.rb +168 -0
- data/test/exhaustive/tagged_pre_auth_completion_test.rb +119 -0
- data/test/exhaustive/tagged_pre_auth_test.rb +116 -0
- data/test/exhaustive/tagged_purchase_test.rb +116 -0
- data/test/exhaustive/tagged_refund_test.rb +144 -0
- data/test/exhaustive/transaction_details_test.rb +86 -0
- data/test/exhaustive/void_test.rb +75 -0
- data/{spec/avs_spec.rb → test/general/avs_test.rb} +33 -44
- data/test/general/json_encoding_test.rb +62 -0
- data/test/general/request_test.rb +185 -0
- data/test/general/rest_encoding_test.rb +174 -0
- data/test/general/soap_encoding_test.rb +211 -0
- data/test/general/transporter_test.rb +54 -0
- data/test/general/validator_test.rb +150 -0
- data/test/samples/rest.dodgy.response.xml +60 -0
- data/test/samples/rest.everything.response.xml +67 -0
- data/test/samples/rest.response.xml +60 -0
- data/test/samples/soap.deserialization.fault.xml +10 -0
- data/test/samples/soap.dodgy.response.xml +95 -0
- data/test/samples/soap.everything.response.xml +75 -0
- data/test/samples/soap.generalfailure.fault.xml +13 -0
- data/test/samples/soap.nulltransaction.fault.xml +14 -0
- data/test/samples/soap.response.xml +95 -0
- data/test/test_helper.rb +115 -0
- metadata +52 -12
- data/doc/classes/EWS/Transaction/Transporter.html +0 -251
- data/pkg/exact4r-0.5.gem +0 -0
- data/spec/mapping_spec.rb +0 -126
- data/spec/request_spec.rb +0 -154
- data/spec/spec_helper.rb +0 -55
- data/spec/transporter_spec.rb +0 -43
- data/spec/validator_spec.rb +0 -150
data/spec/spec_helper.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
|
2
|
-
|
3
|
-
require 'spec'
|
4
|
-
require 'lib/exact4r'
|
5
|
-
require 'ruby-debug'
|
6
|
-
|
7
|
-
REPLICATION_TIME = 20
|
8
|
-
|
9
|
-
# address & authentication for testing against api.e-xact.com
|
10
|
-
# LOCATION = "https://api.e-xact.com/"
|
11
|
-
# BASIC_AUTH = {:gateway_id => "A00049-01", :password => "test1"}
|
12
|
-
|
13
|
-
# address & authentication for local testing
|
14
|
-
# LOCATION = "http://ws.local/" # I am a Passenger...
|
15
|
-
LOCATION = "http://localhost:3000/" # old skool
|
16
|
-
BASIC_AUTH = {:gateway_id => "AD0008-01", :password => "7nfcpc7n"}
|
17
|
-
|
18
|
-
Spec::Runner.configure do |config|
|
19
|
-
include EWS::Transaction
|
20
|
-
|
21
|
-
config.mock_with :mocha
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
def basic_params(options = {})
|
26
|
-
{
|
27
|
-
:transaction_type => :purchase,
|
28
|
-
:amount => "10.13",
|
29
|
-
:cardholder_name => "Simon Brown",
|
30
|
-
:cc_number => "4111111111111111",
|
31
|
-
:cc_expiry => "1012",
|
32
|
-
:gateway_id => "someone", :password => "somehow"
|
33
|
-
}.merge(options)
|
34
|
-
end
|
35
|
-
|
36
|
-
def basic_find_transaction(options = {})
|
37
|
-
params = {
|
38
|
-
:transaction_type => :transaction_details,
|
39
|
-
}.merge(options)
|
40
|
-
|
41
|
-
::EWS::Transaction::Request.new(params.merge(BASIC_AUTH))
|
42
|
-
end
|
43
|
-
|
44
|
-
def basic_new_transaction(options = {})
|
45
|
-
params = {
|
46
|
-
:transaction_type => :purchase,
|
47
|
-
:amount => "10.13",
|
48
|
-
:cardholder_name => "Simon Brown",
|
49
|
-
:cc_number => "4111111111111111",
|
50
|
-
:cc_expiry => "1012",
|
51
|
-
:reference_no => "987987",
|
52
|
-
}.merge(options)
|
53
|
-
|
54
|
-
::EWS::Transaction::Request.new(params.merge(BASIC_AUTH))
|
55
|
-
end
|
data/spec/transporter_spec.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
-
|
3
|
-
describe "Transporter creating transactions" do
|
4
|
-
|
5
|
-
it "should raise an exception when transport_type is not one of :json, :rest or :soap" do
|
6
|
-
lambda {
|
7
|
-
tr = ::EWS::Transporter.new(LOCATION)
|
8
|
-
tr.submit(basic_new_transaction, :banana)
|
9
|
-
}.should raise_error
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should not throw errors" do
|
13
|
-
txn = basic_new_transaction
|
14
|
-
|
15
|
-
lambda {
|
16
|
-
tr = ::EWS::Transporter.new(LOCATION)
|
17
|
-
tr.submit(txn)
|
18
|
-
}.should_not raise_error(RuntimeError)
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should return a Response object on server failure" do
|
22
|
-
req = basic_find_transaction
|
23
|
-
req.transaction_tag = 9000 # non-existent txn
|
24
|
-
|
25
|
-
tr = ::EWS::Transporter.new(LOCATION)
|
26
|
-
resp = tr.submit(req, :json)
|
27
|
-
|
28
|
-
resp.should_not be_nil
|
29
|
-
resp.error_number.should == 404
|
30
|
-
resp.error_description.should == "Not Found"
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should correctly decode error when sending nonsense SOAP" do
|
34
|
-
req = basic_find_transaction
|
35
|
-
|
36
|
-
EWS::Transaction::Mapping.stubs(:request_to_soap).returns("Complete and utter rubbish. It's not even XML!!")
|
37
|
-
tr = ::EWS::Transporter.new(LOCATION)
|
38
|
-
r = tr.submit(req, :soap)
|
39
|
-
r.error_number.should == 401
|
40
|
-
r.error_description.should == "Malformed XML Request."
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
data/spec/validator_spec.rb
DELETED
@@ -1,150 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + "/spec_helper"
|
2
|
-
|
3
|
-
describe "length validation" do
|
4
|
-
it "should invalidate strings which are too long" do
|
5
|
-
EWS::Transaction::Request.new(basic_params).should be_valid
|
6
|
-
EWS::Transaction::Request.new(basic_params(:authorization_num => 'a'*8)).should be_valid
|
7
|
-
EWS::Transaction::Request.new(basic_params(:authorization_num => 'a'*9)).should_not be_valid
|
8
|
-
|
9
|
-
EWS::Transaction::Request.new(basic_params(:cardholder_name => 'a'*30)).should be_valid
|
10
|
-
EWS::Transaction::Request.new(basic_params(:cardholder_name => 'a'*31)).should_not be_valid
|
11
|
-
|
12
|
-
EWS::Transaction::Request.new(basic_params(:cc_number => 'a'*19)).should be_valid
|
13
|
-
EWS::Transaction::Request.new(basic_params(:cc_number => 'a'*20)).should_not be_valid
|
14
|
-
|
15
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => "0909")).should be_valid
|
16
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => "09091")).should_not be_valid
|
17
|
-
|
18
|
-
EWS::Transaction::Request.new(basic_params(:cavv => 'a'*40)).should be_valid
|
19
|
-
EWS::Transaction::Request.new(basic_params(:cavv => 'a'*41)).should_not be_valid
|
20
|
-
|
21
|
-
EWS::Transaction::Request.new(basic_params(:client_email => 'a'*30)).should be_valid
|
22
|
-
EWS::Transaction::Request.new(basic_params(:client_email => 'a'*31)).should_not be_valid
|
23
|
-
|
24
|
-
EWS::Transaction::Request.new(basic_params(:customer_ref => 'a'*20)).should be_valid
|
25
|
-
EWS::Transaction::Request.new(basic_params(:customer_ref => 'a'*21)).should_not be_valid
|
26
|
-
|
27
|
-
EWS::Transaction::Request.new(basic_params(:gateway_id => 'a'*10)).should be_valid
|
28
|
-
EWS::Transaction::Request.new(basic_params(:gateway_id => 'a'*11)).should_not be_valid
|
29
|
-
|
30
|
-
EWS::Transaction::Request.new(basic_params(:pan => 'a'*39)).should be_valid
|
31
|
-
EWS::Transaction::Request.new(basic_params(:pan => 'a'*40)).should_not be_valid
|
32
|
-
|
33
|
-
EWS::Transaction::Request.new(basic_params(:password => 'a'*30)).should be_valid
|
34
|
-
EWS::Transaction::Request.new(basic_params(:password => 'a'*31)).should_not be_valid
|
35
|
-
|
36
|
-
EWS::Transaction::Request.new(basic_params(:reference_3 => 'a'*30)).should be_valid
|
37
|
-
EWS::Transaction::Request.new(basic_params(:reference_3 => 'a'*31)).should_not be_valid
|
38
|
-
|
39
|
-
EWS::Transaction::Request.new(basic_params(:reference_no => 'a'*20)).should be_valid
|
40
|
-
EWS::Transaction::Request.new(basic_params(:reference_no => 'a'*21)).should_not be_valid
|
41
|
-
|
42
|
-
EWS::Transaction::Request.new(basic_params(:tax1_number => 'a'*20)).should be_valid
|
43
|
-
EWS::Transaction::Request.new(basic_params(:tax1_number => 'a'*21)).should_not be_valid
|
44
|
-
|
45
|
-
EWS::Transaction::Request.new(basic_params(:tax2_number => 'a'*20)).should be_valid
|
46
|
-
EWS::Transaction::Request.new(basic_params(:tax2_number => 'a'*21)).should_not be_valid
|
47
|
-
|
48
|
-
EWS::Transaction::Request.new(basic_params(:track1 => 'a'*79)).should be_valid
|
49
|
-
EWS::Transaction::Request.new(basic_params(:track1 => 'a'*80)).should_not be_valid
|
50
|
-
|
51
|
-
EWS::Transaction::Request.new(basic_params(:track2 => 'a'*40)).should be_valid
|
52
|
-
EWS::Transaction::Request.new(basic_params(:track2 => 'a'*41)).should_not be_valid
|
53
|
-
|
54
|
-
EWS::Transaction::Request.new(basic_params(:cc_verification_str1 => 'a'*40)).should be_valid
|
55
|
-
EWS::Transaction::Request.new(basic_params(:cc_verification_str1 => 'a'*41)).should_not be_valid
|
56
|
-
|
57
|
-
EWS::Transaction::Request.new(basic_params(:cc_verification_str2 => 'a'*4)).should be_valid
|
58
|
-
EWS::Transaction::Request.new(basic_params(:cc_verification_str2 => 'a'*5)).should_not be_valid
|
59
|
-
|
60
|
-
EWS::Transaction::Request.new(basic_params(:xid => 'a'*40)).should be_valid
|
61
|
-
EWS::Transaction::Request.new(basic_params(:xid => 'a'*41)).should_not be_valid
|
62
|
-
|
63
|
-
EWS::Transaction::Request.new(basic_params(:zip_code => 'a'*10)).should be_valid
|
64
|
-
EWS::Transaction::Request.new(basic_params(:zip_code => 'a'*11)).should_not be_valid
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "authentication info validation" do
|
69
|
-
it "should require gateway_id and password " do
|
70
|
-
EWS::Transaction::Request.new(basic_params).should be_valid
|
71
|
-
|
72
|
-
EWS::Transaction::Request.new(basic_params(:gateway_id => nil)).should_not be_valid
|
73
|
-
EWS::Transaction::Request.new(basic_params(:gateway_id => "")).should_not be_valid
|
74
|
-
|
75
|
-
EWS::Transaction::Request.new(basic_params(:password => nil)).should_not be_valid
|
76
|
-
EWS::Transaction::Request.new(basic_params(:password => "")).should_not be_valid
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "amount validation" do
|
81
|
-
it "should validate amounts" do
|
82
|
-
# validation: amounts
|
83
|
-
[:amount, :surcharge_amount, :tax1_amount, :tax2_amount].each do |amount_attr|
|
84
|
-
EWS::Transaction::Request.new(basic_params(amount_attr => "10.13")).should be_valid
|
85
|
-
EWS::Transaction::Request.new(basic_params(amount_attr => "10.")).should be_valid
|
86
|
-
EWS::Transaction::Request.new(basic_params(amount_attr => "0.13")).should be_valid
|
87
|
-
EWS::Transaction::Request.new(basic_params(amount_attr => 10.13)).should be_valid
|
88
|
-
EWS::Transaction::Request.new(basic_params(amount_attr => 0.13)).should be_valid
|
89
|
-
EWS::Transaction::Request.new(basic_params(amount_attr => 10)).should be_valid
|
90
|
-
|
91
|
-
r = EWS::Transaction::Request.new(basic_params(amount_attr => "10.1s3"))
|
92
|
-
r.should_not be_valid
|
93
|
-
r.errors[amount_attr].should_not be_blank
|
94
|
-
|
95
|
-
r = EWS::Transaction::Request.new(basic_params(amount_attr => "1s0.13"))
|
96
|
-
r.should_not be_valid
|
97
|
-
r.errors[amount_attr].should_not be_blank
|
98
|
-
|
99
|
-
r = EWS::Transaction::Request.new(basic_params(amount_attr => "dopey"))
|
100
|
-
r.should_not be_valid
|
101
|
-
r.errors[amount_attr].should_not be_blank
|
102
|
-
|
103
|
-
r = EWS::Transaction::Request.new(basic_params(amount_attr => 100000))
|
104
|
-
r.should_not be_valid
|
105
|
-
r.errors[amount_attr].should_not be_blank
|
106
|
-
|
107
|
-
r = EWS::Transaction::Request.new(basic_params(amount_attr => 99999.99)).should be_valid
|
108
|
-
|
109
|
-
r = EWS::Transaction::Request.new(basic_params(amount_attr => -0.01))
|
110
|
-
r.should_not be_valid
|
111
|
-
r.errors[amount_attr].should_not be_blank
|
112
|
-
|
113
|
-
EWS::Transaction::Request.new(basic_params(amount_attr => 0.0)).should be_valid
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
describe "credit card validation" do
|
119
|
-
it "should validate cc_number and cc_expiry" do
|
120
|
-
# validation: card number
|
121
|
-
EWS::Transaction::Request.new(basic_params(:cc_number => "4111111111111111")).should be_valid
|
122
|
-
EWS::Transaction::Request.new(basic_params(:cc_number => "4111111111111112")).should_not be_valid
|
123
|
-
|
124
|
-
# validation: card expiry (should be in MMYY format)
|
125
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => "1009")).should be_valid
|
126
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => nil)).should_not be_valid
|
127
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => "")).should_not be_valid
|
128
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => "708")).should_not be_valid
|
129
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => "07089")).should_not be_valid
|
130
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => "07f")).should_not be_valid
|
131
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => "1308")).should_not be_valid # invalid month
|
132
|
-
|
133
|
-
# ensure we don't accept dates in the past
|
134
|
-
t = Time.new
|
135
|
-
month = t.month
|
136
|
-
year = t.year - 2000
|
137
|
-
# in the past
|
138
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => sprintf("%02d%02d", month, year-1))).should_not be_valid
|
139
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => sprintf("%02d%02d", month-1, year))).should_not be_valid
|
140
|
-
# in the present or future
|
141
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => sprintf("%02d%02d", month, year))).should be_valid
|
142
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => sprintf("%02d%02d", month+1, year))).should be_valid
|
143
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => sprintf("%02d%02d", month, year+1))).should be_valid
|
144
|
-
|
145
|
-
# we've chosen 1980 as our cutoff in the past, so check around this date
|
146
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => "1279")).should be_valid # Dec 2079
|
147
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => "0180")).should_not be_valid # Jan 1980
|
148
|
-
EWS::Transaction::Request.new(basic_params(:cc_expiry => "0199")).should_not be_valid # Jan 1999
|
149
|
-
end
|
150
|
-
end
|