exact4r 0.9.1 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,174 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../test_helper"
|
2
|
+
|
3
|
+
class RestEncodingTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_basic_request_encoding
|
6
|
+
r = EWS::Transaction::Request.new(basic_params)
|
7
|
+
|
8
|
+
rest = EWS::Transaction::Mapping.request_to_rest(r)
|
9
|
+
|
10
|
+
xml = REXML::Document.new(rest)
|
11
|
+
txn = REXML::XPath.first(xml, "//Transaction")
|
12
|
+
assert_equal "4111111111111111", REXML::XPath.first(txn, "Card_Number").text
|
13
|
+
assert_equal "Simon Brown", REXML::XPath.first(txn, "CardHoldersName").text
|
14
|
+
assert_equal "00", REXML::XPath.first(txn, "Transaction_Type").text
|
15
|
+
assert_equal "1012", REXML::XPath.first(txn, "Expiry_Date").text
|
16
|
+
assert_equal "10.13", REXML::XPath.first(txn, "DollarAmount").text
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_request_encoding_everything
|
20
|
+
request = EWS::Transaction::Request.new(sample_everything_params)
|
21
|
+
|
22
|
+
rest = EWS::Transaction::Mapping.request_to_rest(request)
|
23
|
+
|
24
|
+
xml = REXML::Document.new(rest)
|
25
|
+
txn = REXML::XPath.first(xml, "//Transaction")
|
26
|
+
|
27
|
+
assert_equal request.amount.to_s, REXML::XPath.first(txn, "DollarAmount").text
|
28
|
+
assert_equal request.authorization_num.to_s, REXML::XPath.first(txn, "Authorization_Num").text
|
29
|
+
assert_equal request.cardholder_name.to_s, REXML::XPath.first(txn, "CardHoldersName").text
|
30
|
+
assert_equal request.cavv.to_s, REXML::XPath.first(txn, "CAVV").text
|
31
|
+
assert_equal request.cavv_algorithm.to_s, REXML::XPath.first(txn, "CAVV_Algorithm").text
|
32
|
+
assert_equal request.cc_expiry.to_s, REXML::XPath.first(txn, "Expiry_Date").text
|
33
|
+
assert_equal request.cc_number.to_s, REXML::XPath.first(txn, "Card_Number").text
|
34
|
+
assert_equal request.cc_verification_str1.to_s, REXML::XPath.first(txn, "VerificationStr1").text
|
35
|
+
assert_equal request.cc_verification_str2.to_s, REXML::XPath.first(txn, "VerificationStr2").text
|
36
|
+
assert_equal request.client_email.to_s, REXML::XPath.first(txn, "Client_Email").text
|
37
|
+
assert_equal request.client_ip.to_s, REXML::XPath.first(txn, "Client_IP").text
|
38
|
+
assert_equal request.customer_ref.to_s, REXML::XPath.first(txn, "Customer_Ref").text
|
39
|
+
assert_equal request.cvd_presence_ind.to_s, REXML::XPath.first(txn, "CVD_Presence_Ind").text
|
40
|
+
assert_equal request.ecommerce_flag.to_s, REXML::XPath.first(txn, "Ecommerce_Flag").text
|
41
|
+
assert_equal request.gateway_id.to_s, REXML::XPath.first(txn, "ExactID").text
|
42
|
+
assert_equal request.language.to_s, REXML::XPath.first(txn, "Language").text
|
43
|
+
assert_equal request.password.to_s, REXML::XPath.first(txn, "Password").text
|
44
|
+
assert_equal request.pan.to_s, REXML::XPath.first(txn, "PAN").text
|
45
|
+
assert_equal request.reference_3.to_s, REXML::XPath.first(txn, "Reference_3").text
|
46
|
+
assert_equal request.reference_no.to_s, REXML::XPath.first(txn, "Reference_No").text
|
47
|
+
assert_equal request.secure_auth_required.to_s, REXML::XPath.first(txn, "Secure_AuthRequired").text
|
48
|
+
assert_equal request.secure_auth_result.to_s, REXML::XPath.first(txn, "Secure_AuthResult").text
|
49
|
+
assert_equal request.surcharge_amount.to_s, REXML::XPath.first(txn, "SurchargeAmount").text
|
50
|
+
assert_equal request.tax1_amount.to_s, REXML::XPath.first(txn, "Tax1Amount").text
|
51
|
+
assert_equal request.tax1_number.to_s, REXML::XPath.first(txn, "Tax1Number").text
|
52
|
+
assert_equal request.tax2_amount.to_s, REXML::XPath.first(txn, "Tax2Amount").text
|
53
|
+
assert_equal request.tax2_number.to_s, REXML::XPath.first(txn, "Tax2Number").text
|
54
|
+
assert_equal request.track1.to_s, REXML::XPath.first(txn, "Track1").text
|
55
|
+
assert_equal request.track2.to_s, REXML::XPath.first(txn, "Track2").text
|
56
|
+
assert_equal request.transaction_tag.to_s, REXML::XPath.first(txn, "Transaction_Tag").text
|
57
|
+
assert_equal request.user_name.to_s, REXML::XPath.first(txn, "User_Name").text
|
58
|
+
assert_equal request.xid.to_s, REXML::XPath.first(txn, "XID").text
|
59
|
+
assert_equal request.zip_code.to_s, REXML::XPath.first(txn, "ZipCode").text
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_basic_response_decoding
|
63
|
+
filename = File.dirname(__FILE__) + "/../samples/rest.response.xml"
|
64
|
+
payload = IO.read(filename)
|
65
|
+
|
66
|
+
r = nil
|
67
|
+
assert_nothing_raised do
|
68
|
+
r = EWS::Transaction::Mapping.rest_to_response(payload)
|
69
|
+
end
|
70
|
+
assert_not_nil r
|
71
|
+
|
72
|
+
assert_equal "Transaction Normal", r.exact_message
|
73
|
+
assert_nil r.error_description
|
74
|
+
assert_equal "APPROVED", r.bank_message
|
75
|
+
assert_equal 2516, r.transaction_tag
|
76
|
+
assert_equal "00", r.transaction_type
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_dodgy_response_decoding
|
80
|
+
filename = File.dirname(__FILE__) + "/../samples/rest.dodgy.response.xml"
|
81
|
+
payload = IO.read(filename)
|
82
|
+
|
83
|
+
r = nil
|
84
|
+
assert_nothing_raised do
|
85
|
+
r = EWS::Transaction::Mapping.rest_to_response(payload)
|
86
|
+
end
|
87
|
+
assert_not_nil r
|
88
|
+
|
89
|
+
assert_equal "Transaction Normal", r.exact_message
|
90
|
+
assert_nil r.error_description
|
91
|
+
assert_equal "APPROVED", r.bank_message
|
92
|
+
assert_equal 2516, r.transaction_tag
|
93
|
+
assert_equal "00", r.transaction_type
|
94
|
+
|
95
|
+
# the following are all invalid examples of the relevant fields, so ensure we
|
96
|
+
# decode them without complaint.
|
97
|
+
assert_equal "Simon Brown Is Not A Really Long Name But This Is", r.cardholder_name
|
98
|
+
assert_equal "nonsense", r.cc_number
|
99
|
+
assert_equal "This Is A Really LONG Customer Reference", r.customer_ref
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_response_decoding_everything
|
103
|
+
filename = File.dirname(__FILE__) + "/../samples/rest.everything.response.xml"
|
104
|
+
payload = IO.read(filename)
|
105
|
+
|
106
|
+
r = nil
|
107
|
+
assert_nothing_raised do
|
108
|
+
r = EWS::Transaction::Mapping.rest_to_response(payload)
|
109
|
+
end
|
110
|
+
assert_not_nil r
|
111
|
+
|
112
|
+
assert !r.transaction_error?
|
113
|
+
assert r.approved?
|
114
|
+
|
115
|
+
assert_equal 'Z', r.avs
|
116
|
+
assert_equal "APPROVED", r.bank_message
|
117
|
+
assert_equal "000", r.bank_resp_code
|
118
|
+
assert_equal "12", r.bank_resp_code_2
|
119
|
+
assert_equal "0", r.cavv_response
|
120
|
+
assert_equal "This is\na CTR", r.ctr
|
121
|
+
assert_equal "U", r.cvv2
|
122
|
+
assert_equal "Something", r.error_description
|
123
|
+
assert_equal "650", r.error_number
|
124
|
+
assert_equal "Transaction Normal", r.exact_message
|
125
|
+
assert_equal "00", r.exact_resp_code
|
126
|
+
assert_equal "Processed by E-Xact", r.logon_message
|
127
|
+
assert_equal "07203434", r.retrieval_ref_no
|
128
|
+
assert_equal "258", r.sequence_no
|
129
|
+
|
130
|
+
assert_equal "Paymentech Goods Buy and Sell(Calgary) 5300003", r.merchant_name
|
131
|
+
assert_equal "4567 8th ave SE.", r.merchant_address
|
132
|
+
assert_equal "Calgary", r.merchant_city
|
133
|
+
assert_equal "United States", r.merchant_country
|
134
|
+
assert_equal "V6B 2K4", r.merchant_postal
|
135
|
+
assert_equal "Alabama", r.merchant_province
|
136
|
+
assert_equal "http://somewhere.com/somehow/", r.merchant_url
|
137
|
+
|
138
|
+
assert_equal "ET3434", r.authorization_num
|
139
|
+
assert_equal "Simon Brown", r.cardholder_name
|
140
|
+
assert_equal "4111111111111111", r.cc_number
|
141
|
+
assert_equal "123", r.cavv
|
142
|
+
assert_equal "8", r.cavv_algorithm
|
143
|
+
assert_equal "simon@example.com", r.client_email
|
144
|
+
assert_equal "127.0.0.1", r.client_ip
|
145
|
+
assert_equal "REF-123", r.customer_ref
|
146
|
+
assert_equal "0", r.cvd_presence_ind
|
147
|
+
assert_equal "4", r.ecommerce_flag
|
148
|
+
assert_equal "1210", r.cc_expiry
|
149
|
+
assert_equal "4", r.language
|
150
|
+
assert_equal "12345678900987654321", r.pan
|
151
|
+
assert_equal "AD0009-01", r.gateway_id
|
152
|
+
assert_equal "passw0rd", r.password
|
153
|
+
assert_equal "REF-456", r.reference_3
|
154
|
+
assert_equal "987987", r.reference_no
|
155
|
+
assert_equal "1", r.secure_auth_required
|
156
|
+
assert_equal "9", r.secure_auth_result
|
157
|
+
assert_equal "11.12", r.surcharge_amount
|
158
|
+
assert_equal "23.23", r.tax1_amount
|
159
|
+
assert_equal "987654", r.tax1_number
|
160
|
+
assert_equal "34.34", r.tax2_amount
|
161
|
+
assert_equal "123456", r.tax2_number
|
162
|
+
assert_equal "%B4111111111111111^Jones/Simon ^1309101063510010000000306000000?", r.track1
|
163
|
+
assert_equal ";4111111111111111=1309101420320192611?", r.track2
|
164
|
+
assert_equal 2516, r.transaction_tag
|
165
|
+
assert_equal "00", r.transaction_type
|
166
|
+
assert_equal "Superman", r.user_name
|
167
|
+
assert_equal "verified", r.cc_verification_str1
|
168
|
+
assert_equal "6785", r.cc_verification_str2
|
169
|
+
assert_equal "x678", r.xid
|
170
|
+
assert_equal "10100", r.zip_code
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
@@ -0,0 +1,211 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../test_helper"
|
2
|
+
|
3
|
+
class SoapEncodingTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_basic_request_encoding
|
6
|
+
r = EWS::Transaction::Request.new(basic_params)
|
7
|
+
|
8
|
+
soap = EWS::Transaction::Mapping.request_to_soap(r)
|
9
|
+
|
10
|
+
xml = REXML::Document.new(soap)
|
11
|
+
txn = REXML::XPath.first(xml, "//SendAndCommitSource")
|
12
|
+
assert_equal "4111111111111111", REXML::XPath.first(txn, "Card_Number").text
|
13
|
+
assert_equal "Simon Brown", REXML::XPath.first(txn, "CardHoldersName").text
|
14
|
+
assert_equal "00", REXML::XPath.first(txn, "Transaction_Type").text
|
15
|
+
assert_equal "1012", REXML::XPath.first(txn, "Expiry_Date").text
|
16
|
+
assert_equal "10.13", REXML::XPath.first(txn, "DollarAmount").text
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_request_encoding_everything
|
20
|
+
request = EWS::Transaction::Request.new(sample_everything_params)
|
21
|
+
|
22
|
+
soap = EWS::Transaction::Mapping.request_to_soap(request)
|
23
|
+
|
24
|
+
xml = REXML::Document.new(soap)
|
25
|
+
txn = REXML::XPath.first(xml, "//SendAndCommitSource")
|
26
|
+
|
27
|
+
assert_equal request.amount.to_s, REXML::XPath.first(txn, "DollarAmount").text
|
28
|
+
assert_equal request.authorization_num.to_s, REXML::XPath.first(txn, "Authorization_Num").text
|
29
|
+
assert_equal request.cardholder_name.to_s, REXML::XPath.first(txn, "CardHoldersName").text
|
30
|
+
assert_equal request.cavv.to_s, REXML::XPath.first(txn, "CAVV").text
|
31
|
+
assert_equal request.cavv_algorithm.to_s, REXML::XPath.first(txn, "CAVV_Algorithm").text
|
32
|
+
assert_equal request.cc_expiry.to_s, REXML::XPath.first(txn, "Expiry_Date").text
|
33
|
+
assert_equal request.cc_number.to_s, REXML::XPath.first(txn, "Card_Number").text
|
34
|
+
assert_equal request.cc_verification_str1.to_s, REXML::XPath.first(txn, "VerificationStr1").text
|
35
|
+
assert_equal request.cc_verification_str2.to_s, REXML::XPath.first(txn, "VerificationStr2").text
|
36
|
+
assert_equal request.client_email.to_s, REXML::XPath.first(txn, "Client_Email").text
|
37
|
+
assert_equal request.client_ip.to_s, REXML::XPath.first(txn, "Client_IP").text
|
38
|
+
assert_equal request.customer_ref.to_s, REXML::XPath.first(txn, "Customer_Ref").text
|
39
|
+
assert_equal request.cvd_presence_ind.to_s, REXML::XPath.first(txn, "CVD_Presence_Ind").text
|
40
|
+
assert_equal request.ecommerce_flag.to_s, REXML::XPath.first(txn, "Ecommerce_Flag").text
|
41
|
+
assert_equal request.gateway_id.to_s, REXML::XPath.first(txn, "ExactID").text
|
42
|
+
assert_equal request.language.to_s, REXML::XPath.first(txn, "Language").text
|
43
|
+
assert_equal request.password.to_s, REXML::XPath.first(txn, "Password").text
|
44
|
+
assert_equal request.pan.to_s, REXML::XPath.first(txn, "PAN").text
|
45
|
+
assert_equal request.reference_3.to_s, REXML::XPath.first(txn, "Reference_3").text
|
46
|
+
assert_equal request.reference_no.to_s, REXML::XPath.first(txn, "Reference_No").text
|
47
|
+
assert_equal request.secure_auth_required.to_s, REXML::XPath.first(txn, "Secure_AuthRequired").text
|
48
|
+
assert_equal request.secure_auth_result.to_s, REXML::XPath.first(txn, "Secure_AuthResult").text
|
49
|
+
assert_equal request.surcharge_amount.to_s, REXML::XPath.first(txn, "SurchargeAmount").text
|
50
|
+
assert_equal request.tax1_amount.to_s, REXML::XPath.first(txn, "Tax1Amount").text
|
51
|
+
assert_equal request.tax1_number.to_s, REXML::XPath.first(txn, "Tax1Number").text
|
52
|
+
assert_equal request.tax2_amount.to_s, REXML::XPath.first(txn, "Tax2Amount").text
|
53
|
+
assert_equal request.tax2_number.to_s, REXML::XPath.first(txn, "Tax2Number").text
|
54
|
+
assert_equal request.track1.to_s, REXML::XPath.first(txn, "Track1").text
|
55
|
+
assert_equal request.track2.to_s, REXML::XPath.first(txn, "Track2").text
|
56
|
+
assert_equal request.transaction_tag.to_s, REXML::XPath.first(txn, "Transaction_Tag").text
|
57
|
+
assert_equal request.user_name.to_s, REXML::XPath.first(txn, "User_Name").text
|
58
|
+
assert_equal request.xid.to_s, REXML::XPath.first(txn, "XID").text
|
59
|
+
assert_equal request.zip_code.to_s, REXML::XPath.first(txn, "ZipCode").text
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_basic_response_decoding
|
63
|
+
filename = File.dirname(__FILE__) + "/../samples/soap.response.xml"
|
64
|
+
payload = IO.read(filename)
|
65
|
+
|
66
|
+
r = nil
|
67
|
+
assert_nothing_raised do
|
68
|
+
r = EWS::Transaction::Mapping.soap_to_response(payload)
|
69
|
+
end
|
70
|
+
assert_not_nil r
|
71
|
+
|
72
|
+
assert_equal "Transaction Normal", r.exact_message
|
73
|
+
assert_nil r.error_description
|
74
|
+
assert_equal "APPROVED", r.bank_message
|
75
|
+
assert_equal 2517, r.transaction_tag
|
76
|
+
assert_equal "00", r.transaction_type
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_dodgy_response_decoding
|
80
|
+
filename = File.dirname(__FILE__) + "/../samples/soap.dodgy.response.xml"
|
81
|
+
payload = IO.read(filename)
|
82
|
+
|
83
|
+
r = nil
|
84
|
+
assert_nothing_raised do
|
85
|
+
r = EWS::Transaction::Mapping.soap_to_response(payload)
|
86
|
+
end
|
87
|
+
assert_not_nil r
|
88
|
+
|
89
|
+
assert_equal "Transaction Normal", r.exact_message
|
90
|
+
assert_nil r.error_description
|
91
|
+
assert_equal "APPROVED", r.bank_message
|
92
|
+
assert_equal 2517, r.transaction_tag
|
93
|
+
assert_equal "00", r.transaction_type
|
94
|
+
|
95
|
+
# the following are all invalid examples of the relevant fields, so ensure we
|
96
|
+
# decode them without complaint.
|
97
|
+
assert_equal "Simon Brown Is Not A Really Long Name But This Is", r.cardholder_name
|
98
|
+
assert_equal "4111111111111111666666", r.cc_number
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_response_decoding_everything
|
102
|
+
filename = File.dirname(__FILE__) + "/../samples/soap.everything.response.xml"
|
103
|
+
payload = IO.read(filename)
|
104
|
+
|
105
|
+
r = nil
|
106
|
+
assert_nothing_raised do
|
107
|
+
r = EWS::Transaction::Mapping.soap_to_response(payload)
|
108
|
+
end
|
109
|
+
assert_not_nil r
|
110
|
+
|
111
|
+
assert !r.transaction_error?
|
112
|
+
assert r.approved?
|
113
|
+
|
114
|
+
assert_equal 'Z', r.avs
|
115
|
+
assert_equal "APPROVED", r.bank_message
|
116
|
+
assert_equal "000", r.bank_resp_code
|
117
|
+
assert_equal "12", r.bank_resp_code_2
|
118
|
+
assert_equal "0", r.cavv_response
|
119
|
+
assert_equal "This is\na CTR", r.ctr
|
120
|
+
assert_equal "U", r.cvv2
|
121
|
+
assert_equal "Something", r.error_description
|
122
|
+
assert_equal "650", r.error_number
|
123
|
+
assert_equal "Transaction Normal", r.exact_message
|
124
|
+
assert_equal "00", r.exact_resp_code
|
125
|
+
assert_equal "Processed by E-Xact", r.logon_message
|
126
|
+
assert_equal "07203434", r.retrieval_ref_no
|
127
|
+
assert_equal "258", r.sequence_no
|
128
|
+
|
129
|
+
assert_equal "Paymentech Goods Buy and Sell(Calgary) 5300003", r.merchant_name
|
130
|
+
assert_equal "4567 8th ave SE.", r.merchant_address
|
131
|
+
assert_equal "Calgary", r.merchant_city
|
132
|
+
assert_equal "United States", r.merchant_country
|
133
|
+
assert_equal "V6B 2K4", r.merchant_postal
|
134
|
+
assert_equal "Alabama", r.merchant_province
|
135
|
+
assert_equal "http://somewhere.com/somehow/", r.merchant_url
|
136
|
+
|
137
|
+
assert_equal "ET3434", r.authorization_num
|
138
|
+
assert_equal "Simon Brown", r.cardholder_name
|
139
|
+
assert_equal "4111111111111111", r.cc_number
|
140
|
+
assert_equal "123", r.cavv
|
141
|
+
assert_equal "8", r.cavv_algorithm
|
142
|
+
assert_equal "simon@example.com", r.client_email
|
143
|
+
assert_equal "127.0.0.1", r.client_ip
|
144
|
+
assert_equal "REF-123", r.customer_ref
|
145
|
+
assert_equal "0", r.cvd_presence_ind
|
146
|
+
assert_equal "4", r.ecommerce_flag
|
147
|
+
assert_equal "1210", r.cc_expiry
|
148
|
+
assert_equal "4", r.language
|
149
|
+
assert_equal "12345678900987654321", r.pan
|
150
|
+
assert_equal "AD0009-01", r.gateway_id
|
151
|
+
assert_equal "passw0rd", r.password
|
152
|
+
assert_equal "REF-456", r.reference_3
|
153
|
+
assert_equal "987987", r.reference_no
|
154
|
+
assert_equal "1", r.secure_auth_required
|
155
|
+
assert_equal "9", r.secure_auth_result
|
156
|
+
assert_equal "11.12", r.surcharge_amount
|
157
|
+
assert_equal "23.23", r.tax1_amount
|
158
|
+
assert_equal "987654", r.tax1_number
|
159
|
+
assert_equal "34.34", r.tax2_amount
|
160
|
+
assert_equal "123456", r.tax2_number
|
161
|
+
assert_equal "%B4111111111111111^Jones/Simon ^1309101063510010000000306000000?", r.track1
|
162
|
+
assert_equal ";4111111111111111=1309101420320192611?", r.track2
|
163
|
+
assert_equal 2516, r.transaction_tag
|
164
|
+
assert_equal "00", r.transaction_type
|
165
|
+
assert_equal "Superman", r.user_name
|
166
|
+
assert_equal "verified", r.cc_verification_str1
|
167
|
+
assert_equal "6785", r.cc_verification_str2
|
168
|
+
assert_equal "x678", r.xid
|
169
|
+
assert_equal "10100", r.zip_code
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_fault_decoding_with_details
|
174
|
+
filename = File.dirname(__FILE__) + "/../samples/soap.generalfailure.fault.xml"
|
175
|
+
payload = IO.read(filename)
|
176
|
+
|
177
|
+
r = nil
|
178
|
+
assert_nothing_raised do
|
179
|
+
r = EWS::Transaction::Mapping.soap_to_response(payload)
|
180
|
+
end
|
181
|
+
assert_not_nil r
|
182
|
+
|
183
|
+
assert_equal 500, r.error_number
|
184
|
+
assert_equal "Internal Server Error. An unknown error occurred.", r.error_description
|
185
|
+
assert !r.approved?
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_fault_decoding_with_no_details
|
189
|
+
filename = File.dirname(__FILE__) + "/../samples/soap.deserialization.fault.xml"
|
190
|
+
payload = IO.read(filename)
|
191
|
+
|
192
|
+
assert_raises(RuntimeError) {
|
193
|
+
EWS::Transaction::Mapping.soap_to_response(payload)
|
194
|
+
}
|
195
|
+
end
|
196
|
+
|
197
|
+
def test_null_transaction_fault_decoding
|
198
|
+
filename = File.dirname(__FILE__) + "/../samples/soap.nulltransaction.fault.xml"
|
199
|
+
payload = IO.read(filename)
|
200
|
+
|
201
|
+
r = nil
|
202
|
+
assert_nothing_raised do
|
203
|
+
r = EWS::Transaction::Mapping.soap_to_response(payload)
|
204
|
+
end
|
205
|
+
assert_not_nil r
|
206
|
+
|
207
|
+
assert_equal 400, r.error_number
|
208
|
+
assert_equal "Bad Request. Object reference not set to an instance of a Transaction object.", r.error_description
|
209
|
+
assert !r.approved?
|
210
|
+
end
|
211
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../test_helper"
|
2
|
+
|
3
|
+
class TransporterTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_invalid_transport_type
|
6
|
+
txn = ::EWS::Transaction::Request.new({
|
7
|
+
:transaction_type => :purchase,
|
8
|
+
:amount => "10.13",
|
9
|
+
:cardholder_name => "Simon Brown",
|
10
|
+
:cc_number => "4111111111111111",
|
11
|
+
:cc_expiry => "1012",
|
12
|
+
:reference_no => "987987",
|
13
|
+
}.merge(EMERGIS_BASIC_AUTH))
|
14
|
+
|
15
|
+
tr = ::EWS::Transporter.new(LOCATION)
|
16
|
+
|
17
|
+
# should raise an exception when transport_type is not one of :json, :rest or :soap
|
18
|
+
assert_raises(ArgumentError) {
|
19
|
+
tr.submit(txn, :banana)
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_no_errors_thrown
|
24
|
+
txn = ::EWS::Transaction::Request.new({
|
25
|
+
:transaction_type => :purchase,
|
26
|
+
:amount => "10.13",
|
27
|
+
:cardholder_name => "Simon Brown",
|
28
|
+
:cc_number => "4111111111111111",
|
29
|
+
:cc_expiry => "1012",
|
30
|
+
:reference_no => "987987",
|
31
|
+
}.merge(EMERGIS_BASIC_AUTH))
|
32
|
+
|
33
|
+
assert_nothing_raised {
|
34
|
+
tr = ::EWS::Transporter.new(LOCATION)
|
35
|
+
tr.submit(txn)
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_returns_response_object_on_server_failure
|
40
|
+
req = ::EWS::Transaction::Request.new({
|
41
|
+
:transaction_type => :transaction_details
|
42
|
+
}.merge(EMERGIS_BASIC_AUTH))
|
43
|
+
|
44
|
+
req.transaction_tag = 9000 # non-existent txn
|
45
|
+
|
46
|
+
tr = ::EWS::Transporter.new(LOCATION)
|
47
|
+
resp = tr.submit(req, :json)
|
48
|
+
|
49
|
+
assert_not_nil resp
|
50
|
+
assert_equal 404, resp.error_number
|
51
|
+
assert_equal "Not Found", resp.error_description
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,150 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../test_helper"
|
2
|
+
|
3
|
+
class ValidatorTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_strings_invalid_when_too_long
|
6
|
+
assert EWS::Transaction::Request.new(basic_params).valid?
|
7
|
+
|
8
|
+
assert EWS::Transaction::Request.new(basic_params(:authorization_num => 'a'*8)).valid?
|
9
|
+
assert !EWS::Transaction::Request.new(basic_params(:authorization_num => 'a'*9)).valid?
|
10
|
+
|
11
|
+
assert EWS::Transaction::Request.new(basic_params(:cardholder_name => 'a'*30)).valid?
|
12
|
+
assert !EWS::Transaction::Request.new(basic_params(:cardholder_name => 'a'*31)).valid?
|
13
|
+
|
14
|
+
assert EWS::Transaction::Request.new(basic_params(:cc_number => 'a'*19)).valid?
|
15
|
+
assert !EWS::Transaction::Request.new(basic_params(:cc_number => 'a'*20)).valid?
|
16
|
+
|
17
|
+
assert EWS::Transaction::Request.new(basic_params(:cc_expiry => "0909")).valid?
|
18
|
+
assert !EWS::Transaction::Request.new(basic_params(:cc_expiry => "09091")).valid?
|
19
|
+
|
20
|
+
assert EWS::Transaction::Request.new(basic_params(:cavv => 'a'*40)).valid?
|
21
|
+
assert !EWS::Transaction::Request.new(basic_params(:cavv => 'a'*41)).valid?
|
22
|
+
|
23
|
+
assert EWS::Transaction::Request.new(basic_params(:client_email => 'a'*30)).valid?
|
24
|
+
assert !EWS::Transaction::Request.new(basic_params(:client_email => 'a'*31)).valid?
|
25
|
+
|
26
|
+
assert EWS::Transaction::Request.new(basic_params(:customer_ref => 'a'*20)).valid?
|
27
|
+
assert !EWS::Transaction::Request.new(basic_params(:customer_ref => 'a'*21)).valid?
|
28
|
+
|
29
|
+
assert EWS::Transaction::Request.new(basic_params(:gateway_id => 'a'*10)).valid?
|
30
|
+
assert !EWS::Transaction::Request.new(basic_params(:gateway_id => 'a'*11)).valid?
|
31
|
+
|
32
|
+
assert EWS::Transaction::Request.new(basic_params(:pan => 'a'*39)).valid?
|
33
|
+
assert !EWS::Transaction::Request.new(basic_params(:pan => 'a'*40)).valid?
|
34
|
+
|
35
|
+
assert EWS::Transaction::Request.new(basic_params(:password => 'a'*30)).valid?
|
36
|
+
assert !EWS::Transaction::Request.new(basic_params(:password => 'a'*31)).valid?
|
37
|
+
|
38
|
+
assert EWS::Transaction::Request.new(basic_params(:reference_3 => 'a'*30)).valid?
|
39
|
+
assert !EWS::Transaction::Request.new(basic_params(:reference_3 => 'a'*31)).valid?
|
40
|
+
|
41
|
+
assert EWS::Transaction::Request.new(basic_params(:reference_no => 'a'*20)).valid?
|
42
|
+
assert !EWS::Transaction::Request.new(basic_params(:reference_no => 'a'*21)).valid?
|
43
|
+
|
44
|
+
assert EWS::Transaction::Request.new(basic_params(:tax1_number => 'a'*20)).valid?
|
45
|
+
assert !EWS::Transaction::Request.new(basic_params(:tax1_number => 'a'*21)).valid?
|
46
|
+
|
47
|
+
assert EWS::Transaction::Request.new(basic_params(:tax2_number => 'a'*20)).valid?
|
48
|
+
assert !EWS::Transaction::Request.new(basic_params(:tax2_number => 'a'*21)).valid?
|
49
|
+
|
50
|
+
assert EWS::Transaction::Request.new(basic_params(:track1 => 'a'*79)).valid?
|
51
|
+
assert !EWS::Transaction::Request.new(basic_params(:track1 => 'a'*80)).valid?
|
52
|
+
|
53
|
+
assert EWS::Transaction::Request.new(basic_params(:track2 => 'a'*40)).valid?
|
54
|
+
assert !EWS::Transaction::Request.new(basic_params(:track2 => 'a'*41)).valid?
|
55
|
+
|
56
|
+
assert EWS::Transaction::Request.new(basic_params(:cc_verification_str1 => 'a'*40)).valid?
|
57
|
+
assert !EWS::Transaction::Request.new(basic_params(:cc_verification_str1 => 'a'*41)).valid?
|
58
|
+
|
59
|
+
assert EWS::Transaction::Request.new(basic_params(:cc_verification_str2 => 'a'*4)).valid?
|
60
|
+
assert !EWS::Transaction::Request.new(basic_params(:cc_verification_str2 => 'a'*5)).valid?
|
61
|
+
|
62
|
+
assert EWS::Transaction::Request.new(basic_params(:xid => 'a'*40)).valid?
|
63
|
+
assert !EWS::Transaction::Request.new(basic_params(:xid => 'a'*41)).valid?
|
64
|
+
|
65
|
+
assert EWS::Transaction::Request.new(basic_params(:zip_code => 'a'*10)).valid?
|
66
|
+
assert !EWS::Transaction::Request.new(basic_params(:zip_code => 'a'*11)).valid?
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_requires_gateway_and_password
|
70
|
+
assert EWS::Transaction::Request.new(basic_params).valid?
|
71
|
+
|
72
|
+
assert !EWS::Transaction::Request.new(basic_params(:gateway_id => nil)).valid?
|
73
|
+
assert !EWS::Transaction::Request.new(basic_params(:gateway_id => "")).valid?
|
74
|
+
|
75
|
+
assert !EWS::Transaction::Request.new(basic_params(:password => nil)).valid?
|
76
|
+
assert !EWS::Transaction::Request.new(basic_params(:password => "")).valid?
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_amount_validation
|
80
|
+
# validation: amounts
|
81
|
+
[:amount, :surcharge_amount, :tax1_amount, :tax2_amount].each do |amount_attr|
|
82
|
+
assert EWS::Transaction::Request.new(basic_params(amount_attr => "10.13")).valid?
|
83
|
+
assert EWS::Transaction::Request.new(basic_params(amount_attr => "10.")).valid?
|
84
|
+
assert EWS::Transaction::Request.new(basic_params(amount_attr => "0.13")).valid?
|
85
|
+
assert EWS::Transaction::Request.new(basic_params(amount_attr => 10.13)).valid?
|
86
|
+
assert EWS::Transaction::Request.new(basic_params(amount_attr => 0.13)).valid?
|
87
|
+
assert EWS::Transaction::Request.new(basic_params(amount_attr => 10)).valid?
|
88
|
+
|
89
|
+
r = EWS::Transaction::Request.new(basic_params(amount_attr => "10.1s3"))
|
90
|
+
assert !r.valid?
|
91
|
+
assert !r.errors[amount_attr].blank?
|
92
|
+
|
93
|
+
r = EWS::Transaction::Request.new(basic_params(amount_attr => "1s0.13"))
|
94
|
+
assert !r.valid?
|
95
|
+
assert !r.errors[amount_attr].blank?
|
96
|
+
|
97
|
+
r = EWS::Transaction::Request.new(basic_params(amount_attr => "dopey"))
|
98
|
+
assert !r.valid?
|
99
|
+
assert !r.errors[amount_attr].blank?
|
100
|
+
|
101
|
+
r = EWS::Transaction::Request.new(basic_params(amount_attr => 100000))
|
102
|
+
assert !r.valid?
|
103
|
+
assert !r.errors[amount_attr].blank?
|
104
|
+
|
105
|
+
r = EWS::Transaction::Request.new(basic_params(amount_attr => 99999.99))
|
106
|
+
assert r.valid?
|
107
|
+
assert_nil r.errors[amount_attr]
|
108
|
+
|
109
|
+
r = EWS::Transaction::Request.new(basic_params(amount_attr => -0.01))
|
110
|
+
assert !r.valid?
|
111
|
+
assert !r.errors[amount_attr].blank?
|
112
|
+
|
113
|
+
r = EWS::Transaction::Request.new(basic_params(amount_attr => 0.0))
|
114
|
+
assert r.valid?
|
115
|
+
assert r.errors[amount_attr].blank?
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_card_validation
|
120
|
+
# validation: card number
|
121
|
+
assert EWS::Transaction::Request.new(basic_params(:cc_number => "4111111111111111")).valid?
|
122
|
+
assert !EWS::Transaction::Request.new(basic_params(:cc_number => "4111111111111112")).valid?
|
123
|
+
|
124
|
+
# validation: card expiry (should be in MMYY format)
|
125
|
+
assert EWS::Transaction::Request.new(basic_params(:cc_expiry => "1009")).valid?
|
126
|
+
assert !EWS::Transaction::Request.new(basic_params(:cc_expiry => nil)).valid?
|
127
|
+
assert !EWS::Transaction::Request.new(basic_params(:cc_expiry => "")).valid?
|
128
|
+
assert !EWS::Transaction::Request.new(basic_params(:cc_expiry => "708")).valid?
|
129
|
+
assert !EWS::Transaction::Request.new(basic_params(:cc_expiry => "07089")).valid?
|
130
|
+
assert !EWS::Transaction::Request.new(basic_params(:cc_expiry => "07f")).valid?
|
131
|
+
assert !EWS::Transaction::Request.new(basic_params(:cc_expiry => "1308")).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
|
+
assert !EWS::Transaction::Request.new(basic_params(:cc_expiry => sprintf("%02d%02d", month, year-1))).valid?
|
139
|
+
assert !EWS::Transaction::Request.new(basic_params(:cc_expiry => sprintf("%02d%02d", month-1, year))).valid?
|
140
|
+
# in the present or future
|
141
|
+
assert EWS::Transaction::Request.new(basic_params(:cc_expiry => sprintf("%02d%02d", month, year))).valid?
|
142
|
+
assert EWS::Transaction::Request.new(basic_params(:cc_expiry => sprintf("%02d%02d", month+1, year))).valid?
|
143
|
+
assert EWS::Transaction::Request.new(basic_params(:cc_expiry => sprintf("%02d%02d", month, year+1))).valid?
|
144
|
+
|
145
|
+
# we've chosen 1980 as our cutoff in the past, so check around this date
|
146
|
+
assert EWS::Transaction::Request.new(basic_params(:cc_expiry => "1279")).valid? # Dec 2079
|
147
|
+
assert !EWS::Transaction::Request.new(basic_params(:cc_expiry => "0180")).valid? # Jan 1980
|
148
|
+
assert !EWS::Transaction::Request.new(basic_params(:cc_expiry => "0199")).valid? # Jan 1999
|
149
|
+
end
|
150
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<TransactionResult>
|
3
|
+
<Authorization_Num>ET3434</Authorization_Num>
|
4
|
+
<AVS></AVS>
|
5
|
+
<Bank_Message>APPROVED</Bank_Message>
|
6
|
+
<Bank_Resp_Code>000</Bank_Resp_Code>
|
7
|
+
<Bank_Resp_Code_2></Bank_Resp_Code_2>
|
8
|
+
<CardHoldersName>Simon Brown Is Not A Really Long Name But This Is</CardHoldersName>
|
9
|
+
<Card_Number>nonsense</Card_Number>
|
10
|
+
<CAVV></CAVV>
|
11
|
+
<CAVV_Algorithm></CAVV_Algorithm>
|
12
|
+
<CAVV_Response>0</CAVV_Response>
|
13
|
+
<Client_Email></Client_Email>
|
14
|
+
<Client_IP></Client_IP>
|
15
|
+
<CTR></CTR>
|
16
|
+
<Customer_Ref>This Is A Really LONG Customer Reference</Customer_Ref>
|
17
|
+
<CVD_Presence_Ind>0</CVD_Presence_Ind>
|
18
|
+
<CVV2></CVV2>
|
19
|
+
<DollarAmount>10.13</DollarAmount>
|
20
|
+
<Ecommerce_Flag>0</Ecommerce_Flag>
|
21
|
+
<Error_Description></Error_Description>
|
22
|
+
<Error_Number></Error_Number>
|
23
|
+
<ExactID>AD0008-01</ExactID>
|
24
|
+
<EXact_Message>Transaction Normal</EXact_Message>
|
25
|
+
<EXact_Resp_Code>00</EXact_Resp_Code>
|
26
|
+
<Expiry_Date>0000</Expiry_Date>
|
27
|
+
<Language></Language>
|
28
|
+
<LogonMessage></LogonMessage>
|
29
|
+
<MerchantAddress>4567 8th ave SE.</MerchantAddress>
|
30
|
+
<MerchantCity>Calgary</MerchantCity>
|
31
|
+
<MerchantCountry>United States</MerchantCountry>
|
32
|
+
<MerchantName>Paymentech Goods Buy and Sell(Calgary) 5300003</MerchantName>
|
33
|
+
<MerchantPostal>V6B 2K4</MerchantPostal>
|
34
|
+
<MerchantProvince>Alabama</MerchantProvince>
|
35
|
+
<MerchantURL></MerchantURL>
|
36
|
+
<PAN></PAN>
|
37
|
+
<Password></Password>
|
38
|
+
<Reference_3></Reference_3>
|
39
|
+
<Reference_No>987987</Reference_No>
|
40
|
+
<Retrieval_Ref_No>07203434</Retrieval_Ref_No>
|
41
|
+
<Secure_AuthRequired></Secure_AuthRequired>
|
42
|
+
<Secure_AuthResult></Secure_AuthResult>
|
43
|
+
<SequenceNo>258</SequenceNo>
|
44
|
+
<SurchargeAmount></SurchargeAmount>
|
45
|
+
<Tax1Amount></Tax1Amount>
|
46
|
+
<Tax1Number></Tax1Number>
|
47
|
+
<Tax2Amount></Tax2Amount>
|
48
|
+
<Tax2Number></Tax2Number>
|
49
|
+
<Track1></Track1>
|
50
|
+
<Track2></Track2>
|
51
|
+
<Transaction_Approved>true</Transaction_Approved>
|
52
|
+
<Transaction_Error></Transaction_Error>
|
53
|
+
<Transaction_Tag>2516</Transaction_Tag>
|
54
|
+
<Transaction_Type>00</Transaction_Type>
|
55
|
+
<User_Name></User_Name>
|
56
|
+
<VerificationStr1></VerificationStr1>
|
57
|
+
<VerificationStr2></VerificationStr2>
|
58
|
+
<XID></XID>
|
59
|
+
<ZipCode></ZipCode>
|
60
|
+
</TransactionResult>
|