exact4r 0.5 → 0.5.1
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 +8 -0
- data/LICENCE +3 -0
- data/README +122 -0
- data/Rakefile +41 -0
- data/VERSION +1 -0
- data/doc/classes/EWS/Transaction/Request.html +38 -38
- data/doc/classes/EWS/Transaction/Response.html +4 -4
- data/doc/classes/EWS/Transaction/Transporter.html +32 -33
- data/doc/created.rid +1 -1
- data/doc/files/CHANGELOG.html +115 -0
- data/doc/files/LICENCE.html +109 -0
- data/doc/files/README.html +23 -18
- data/doc/files/VERSION.html +107 -0
- data/doc/files/lib/ews/transaction/mapping_rb.html +2 -1
- data/doc/files/lib/ews/transaction/request_rb.html +1 -1
- data/doc/files/lib/ews/transaction/transporter_rb.html +1 -1
- data/doc/files/lib/exact4r_rb.html +1 -2
- data/doc/fr_file_index.html +3 -0
- data/doc/fr_method_index.html +1 -1
- data/lib/ews/transaction/mapping.rb +1 -0
- data/lib/ews/transaction/request.rb +3 -3
- data/lib/ews/transaction/transporter.rb +20 -18
- data/lib/exact4r.rb +0 -1
- data/spec/donncha.rb +46 -0
- data/spec/mapping_spec.rb +85 -0
- data/spec/request_spec.rb +123 -0
- data/spec/spec_helper.rb +41 -0
- data/spec/transporter_spec.rb +62 -0
- metadata +72 -36
@@ -0,0 +1,109 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>File: LICENCE</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="fileHeader">
|
50
|
+
<h1>LICENCE</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>LICENCE
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Fri May 30 11:01:37 +1000 2008</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<h1>Licence Terms</h1>
|
73
|
+
<p>
|
74
|
+
Distributed under the Ruby software <a
|
75
|
+
href="http://www.ruby-lang.org/en/LICENSE.txt">licence</a>
|
76
|
+
</p>
|
77
|
+
|
78
|
+
</div>
|
79
|
+
|
80
|
+
|
81
|
+
</div>
|
82
|
+
|
83
|
+
|
84
|
+
</div>
|
85
|
+
|
86
|
+
|
87
|
+
<!-- if includes -->
|
88
|
+
|
89
|
+
<div id="section">
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
<!-- if method_list -->
|
99
|
+
|
100
|
+
|
101
|
+
</div>
|
102
|
+
|
103
|
+
|
104
|
+
<div id="validator-badges">
|
105
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
106
|
+
</div>
|
107
|
+
|
108
|
+
</body>
|
109
|
+
</html>
|
data/doc/files/README.html
CHANGED
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Fri May 30 12:36:55 +1000 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -71,12 +71,15 @@
|
|
71
71
|
<div id="description">
|
72
72
|
<h1>exact4r</h1>
|
73
73
|
<p>
|
74
|
-
|
75
|
-
REST, JSON or SOAP.
|
74
|
+
A gem which rrovides access to E-xact‘s Web Services API, allowing
|
75
|
+
the submission of financial transactions via REST, JSON or SOAP.
|
76
76
|
</p>
|
77
77
|
<h2>Getting Started</h2>
|
78
78
|
<h1>1. Submit a transaction</h1>
|
79
79
|
<pre>
|
80
|
+
require 'rubygems'
|
81
|
+
require 'exact4r'
|
82
|
+
|
80
83
|
# build a purchase request
|
81
84
|
request = EWS::Transaction::Request.new({
|
82
85
|
:transaction_type => :purchase,
|
@@ -89,16 +92,16 @@ REST, JSON or SOAP.
|
|
89
92
|
})
|
90
93
|
|
91
94
|
transporter = EWS::Transaction::Transporter.new
|
92
|
-
response = transporter.
|
95
|
+
response = transporter.submit(request) # submits using REST (XML) by default
|
93
96
|
|
94
97
|
# submit using JSON, or
|
95
|
-
response = transporter.
|
98
|
+
response = transporter.submit(request, :json)
|
96
99
|
|
97
100
|
# submit using SOAP, or
|
98
|
-
response = transporter.
|
101
|
+
response = transporter.submit(request, :soap)
|
99
102
|
|
100
103
|
# submit explicitly via REST
|
101
|
-
response = transporter.
|
104
|
+
response = transporter.submit(request, :rest)
|
102
105
|
|
103
106
|
# The response object is independent of type of transport chosen.
|
104
107
|
# We decode the payload into a regular object
|
@@ -110,6 +113,9 @@ REST, JSON or SOAP.
|
|
110
113
|
</pre>
|
111
114
|
<h1>2. Find information on an existing transaction</h1>
|
112
115
|
<pre>
|
116
|
+
require 'rubygems'
|
117
|
+
require 'exact4r'
|
118
|
+
|
113
119
|
# build a purchase request
|
114
120
|
request = EWS::Transaction::Request.new({
|
115
121
|
:transaction_type => :purchase,
|
@@ -122,7 +128,7 @@ REST, JSON or SOAP.
|
|
122
128
|
})
|
123
129
|
|
124
130
|
transporter = EWS::Transaction::Transporter.new
|
125
|
-
response = transporter.
|
131
|
+
response = transporter.submit(request) # submits using REST (XML) by default
|
126
132
|
|
127
133
|
# you need to know the transaction tag of the transaction you are looking for
|
128
134
|
find_request = EWS::Transaction::Request.new({
|
@@ -132,15 +138,20 @@ REST, JSON or SOAP.
|
|
132
138
|
:password => "YYYYYY"
|
133
139
|
})
|
134
140
|
|
135
|
-
find_response = transporter.
|
141
|
+
find_response = transporter.submit(find_request, :json) # again, can choose your transport type as before
|
136
142
|
find_response.cc_number # 4111111111111111
|
137
143
|
find_response.amount # 10.50
|
138
144
|
</pre>
|
139
145
|
<h1>3. Re-using a Transporter</h1>
|
140
146
|
<pre>
|
147
|
+
require 'rubygems'
|
148
|
+
require 'exact4r'
|
149
|
+
|
141
150
|
# The transporter object can be re-used across multiple transactions, so set it up once
|
142
151
|
# and forget about it.
|
143
|
-
|
152
|
+
# In this example, we will continue to use E-xact's default web-service URL, but we
|
153
|
+
# will specify a default transport_type of :soap
|
154
|
+
transporter = EWS::Transaction::Transporter.new(nil, {:transaction_type => :soap})
|
144
155
|
|
145
156
|
# now let's submit do a recurring seed purchase...
|
146
157
|
rsp_req = EWS::Transaction::Request.new({
|
@@ -153,7 +164,7 @@ REST, JSON or SOAP.
|
|
153
164
|
:password => "YYYYYY"
|
154
165
|
})
|
155
166
|
|
156
|
-
rsp_resp = transporter.
|
167
|
+
rsp_resp = transporter.submit(rsp_req)
|
157
168
|
raise "Seed Purchase failed" unless rsp_resp.approved?
|
158
169
|
|
159
170
|
# ...then do multiple refunds against it
|
@@ -166,7 +177,7 @@ REST, JSON or SOAP.
|
|
166
177
|
:gateway_id => "XXXXXX",
|
167
178
|
:password => "YYYYYY"
|
168
179
|
})
|
169
|
-
rf_resp = transporter.
|
180
|
+
rf_resp = transporter.submit(rf_req)
|
170
181
|
raise "Refund failed: #{rf_resp.exact_resp_code}, #{rf_resp.exact_message}" unless rf_resp.approved?
|
171
182
|
end
|
172
183
|
</pre>
|
@@ -178,12 +189,6 @@ spec
|
|
178
189
|
Run all test in spec/ folder (default)
|
179
190
|
</pre>
|
180
191
|
<p>
|
181
|
-
rcov
|
182
|
-
</p>
|
183
|
-
<pre>
|
184
|
-
Run all test and generate coverage report in coverage/
|
185
|
-
</pre>
|
186
|
-
<p>
|
187
192
|
rdoc
|
188
193
|
</p>
|
189
194
|
<pre>
|
@@ -0,0 +1,107 @@
|
|
1
|
+
<?xml version="1.0" encoding="iso-8859-1"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
5
|
+
|
6
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
7
|
+
<head>
|
8
|
+
<title>File: VERSION</title>
|
9
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
10
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
11
|
+
<link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
|
12
|
+
<script type="text/javascript">
|
13
|
+
// <![CDATA[
|
14
|
+
|
15
|
+
function popupCode( url ) {
|
16
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
17
|
+
}
|
18
|
+
|
19
|
+
function toggleCode( id ) {
|
20
|
+
if ( document.getElementById )
|
21
|
+
elem = document.getElementById( id );
|
22
|
+
else if ( document.all )
|
23
|
+
elem = eval( "document.all." + id );
|
24
|
+
else
|
25
|
+
return false;
|
26
|
+
|
27
|
+
elemStyle = elem.style;
|
28
|
+
|
29
|
+
if ( elemStyle.display != "block" ) {
|
30
|
+
elemStyle.display = "block"
|
31
|
+
} else {
|
32
|
+
elemStyle.display = "none"
|
33
|
+
}
|
34
|
+
|
35
|
+
return true;
|
36
|
+
}
|
37
|
+
|
38
|
+
// Make codeblocks hidden by default
|
39
|
+
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
40
|
+
|
41
|
+
// ]]>
|
42
|
+
</script>
|
43
|
+
|
44
|
+
</head>
|
45
|
+
<body>
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
<div id="fileHeader">
|
50
|
+
<h1>VERSION</h1>
|
51
|
+
<table class="header-table">
|
52
|
+
<tr class="top-aligned-row">
|
53
|
+
<td><strong>Path:</strong></td>
|
54
|
+
<td>VERSION
|
55
|
+
</td>
|
56
|
+
</tr>
|
57
|
+
<tr class="top-aligned-row">
|
58
|
+
<td><strong>Last Update:</strong></td>
|
59
|
+
<td>Fri May 30 11:17:26 +1000 2008</td>
|
60
|
+
</tr>
|
61
|
+
</table>
|
62
|
+
</div>
|
63
|
+
<!-- banner header -->
|
64
|
+
|
65
|
+
<div id="bodyContent">
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
<div id="contextContent">
|
70
|
+
|
71
|
+
<div id="description">
|
72
|
+
<p>
|
73
|
+
0.5.1
|
74
|
+
</p>
|
75
|
+
|
76
|
+
</div>
|
77
|
+
|
78
|
+
|
79
|
+
</div>
|
80
|
+
|
81
|
+
|
82
|
+
</div>
|
83
|
+
|
84
|
+
|
85
|
+
<!-- if includes -->
|
86
|
+
|
87
|
+
<div id="section">
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
<!-- if method_list -->
|
97
|
+
|
98
|
+
|
99
|
+
</div>
|
100
|
+
|
101
|
+
|
102
|
+
<div id="validator-badges">
|
103
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
104
|
+
</div>
|
105
|
+
|
106
|
+
</body>
|
107
|
+
</html>
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>
|
59
|
+
<td>Fri May 30 14:41:31 +1000 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -74,6 +74,7 @@
|
|
74
74
|
|
75
75
|
<div class="name-list">
|
76
76
|
builder
|
77
|
+
activesupport
|
77
78
|
</div>
|
78
79
|
</div>
|
79
80
|
|
@@ -56,7 +56,7 @@
|
|
56
56
|
</tr>
|
57
57
|
<tr class="top-aligned-row">
|
58
58
|
<td><strong>Last Update:</strong></td>
|
59
|
-
<td>Fri May 30
|
59
|
+
<td>Fri May 30 14:41:35 +1000 2008</td>
|
60
60
|
</tr>
|
61
61
|
</table>
|
62
62
|
</div>
|
@@ -74,7 +74,6 @@
|
|
74
74
|
|
75
75
|
<div class="name-list">
|
76
76
|
rubygems
|
77
|
-
activesupport
|
78
77
|
ews/transaction/mapping
|
79
78
|
ews/transaction/request
|
80
79
|
ews/transaction/response
|
data/doc/fr_file_index.html
CHANGED
@@ -20,7 +20,10 @@
|
|
20
20
|
<div id="index">
|
21
21
|
<h1 class="section-bar">Files</h1>
|
22
22
|
<div id="index-entries">
|
23
|
+
<a href="files/CHANGELOG.html">CHANGELOG</a><br />
|
24
|
+
<a href="files/LICENCE.html">LICENCE</a><br />
|
23
25
|
<a href="files/README.html">README</a><br />
|
26
|
+
<a href="files/VERSION.html">VERSION</a><br />
|
24
27
|
<a href="files/lib/ews/transaction/mapping_rb.html">lib/ews/transaction/mapping.rb</a><br />
|
25
28
|
<a href="files/lib/ews/transaction/request_rb.html">lib/ews/transaction/request.rb</a><br />
|
26
29
|
<a href="files/lib/ews/transaction/response_rb.html">lib/ews/transaction/response.rb</a><br />
|
data/doc/fr_method_index.html
CHANGED
@@ -24,7 +24,7 @@
|
|
24
24
|
<a href="classes/EWS/Transaction/Request.html#M000006">is_find_transaction? (EWS::Transaction::Request)</a><br />
|
25
25
|
<a href="classes/EWS/Transaction/Transporter.html#M000001">new (EWS::Transaction::Transporter)</a><br />
|
26
26
|
<a href="classes/EWS/Transaction/Request.html#M000004">new (EWS::Transaction::Request)</a><br />
|
27
|
-
<a href="classes/EWS/Transaction/Transporter.html#M000002">
|
27
|
+
<a href="classes/EWS/Transaction/Transporter.html#M000002">submit (EWS::Transaction::Transporter)</a><br />
|
28
28
|
<a href="classes/EWS/Transaction/Request.html#M000005">transaction_type= (EWS::Transaction::Request)</a><br />
|
29
29
|
<a href="classes/EWS/Transaction/Request.html#M000007">valid? (EWS::Transaction::Request)</a><br />
|
30
30
|
</div>
|
@@ -62,7 +62,7 @@ module EWS # :nodoc:
|
|
62
62
|
# assume we're given a symbol, so look up the code
|
63
63
|
value = @@transaction_codes[type_sym]
|
64
64
|
# if nothing found, then maybe we were given an actual code?
|
65
|
-
value = type_sym if value.nil? and @@transaction_codes.values.include?
|
65
|
+
value = type_sym if value.nil? and @@transaction_codes.values.include?(type_sym)
|
66
66
|
|
67
67
|
@transaction_type = value
|
68
68
|
end
|
@@ -96,7 +96,7 @@ module EWS # :nodoc:
|
|
96
96
|
def valid_amount?(amount)
|
97
97
|
return true if amount.blank?
|
98
98
|
|
99
|
-
(amount.class == Float) or (amount.class == Fixnum) or !amount.match
|
99
|
+
(amount.class == Float) or (amount.class == Fixnum) or !amount.match(/[^0-9.]/)
|
100
100
|
end
|
101
101
|
|
102
102
|
def valid_card_number?
|
@@ -117,7 +117,7 @@ module EWS # :nodoc:
|
|
117
117
|
return true if self.cc_expiry.blank?
|
118
118
|
|
119
119
|
# check format
|
120
|
-
return false unless self.cc_expiry.match
|
120
|
+
return false unless self.cc_expiry.match(/^\d{4}$/)
|
121
121
|
|
122
122
|
# check date is not in past
|
123
123
|
year, month = 2000 + self.cc_expiry[0..1].to_i, self.cc_expiry[2..3].to_i
|