paytrace 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/api_names.txt +287 -0
- data/lib/paytrace/api/fields.rb +7 -0
- data/lib/paytrace/api/request.rb +7 -13
- data/lib/paytrace/api/response.rb +45 -3
- data/lib/paytrace/transaction.rb +75 -20
- data/lib/paytrace/version.rb +1 -1
- data/test/paytrace/api/request_spec.rb +65 -0
- data/test/paytrace/api/response_spec.rb +21 -0
- data/test/paytrace/transaction_spec.rb +83 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8e39285035b4738f309e0124bbb9984bc724ee9
|
4
|
+
data.tar.gz: 621bbb455c469a7e98abd9a1e7509364c23a7922
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e515351d099ee793196e7f83bbd431b8295c9d8eed6dfcd1cba57610420adecb85548281db275a48270fdd9b81b656450b4da657668a88894360b414c7bb84c
|
7
|
+
data.tar.gz: 4eeb9ecaad3cc8959d1588a91997bb1630469c47dc5c4d85439e0979b998c6c700d21af9135d0c0118754a2b05c2d879b26da8d6a437096f0fee0f4a11df7be0
|
data/api_names.txt
ADDED
@@ -0,0 +1,287 @@
|
|
1
|
+
|
2
|
+
ADDTAX
|
3
|
+
|
4
|
+
ADDTAXIND
|
5
|
+
|
6
|
+
ADDTAXINDLI
|
7
|
+
|
8
|
+
ADDTAXLI
|
9
|
+
|
10
|
+
ADDTAXRATE
|
11
|
+
|
12
|
+
ADDTAXRATELI
|
13
|
+
|
14
|
+
AMOUNT
|
15
|
+
|
16
|
+
AMOUNTLI
|
17
|
+
|
18
|
+
APPROVAL
|
19
|
+
|
20
|
+
APPROVEURL
|
21
|
+
|
22
|
+
BADDRESS
|
23
|
+
|
24
|
+
BADDRESS2
|
25
|
+
|
26
|
+
BATCHNUMBER
|
27
|
+
|
28
|
+
BCITY
|
29
|
+
|
30
|
+
BCOUNTRY
|
31
|
+
|
32
|
+
BNAME
|
33
|
+
|
34
|
+
BSTATE
|
35
|
+
|
36
|
+
CASHADVANCE
|
37
|
+
|
38
|
+
CC
|
39
|
+
|
40
|
+
CCODE
|
41
|
+
|
42
|
+
CCODELI
|
43
|
+
|
44
|
+
CHECKID
|
45
|
+
|
46
|
+
CHECKTYPE
|
47
|
+
|
48
|
+
CSC
|
49
|
+
|
50
|
+
CUSTID
|
51
|
+
|
52
|
+
CUSTOMDBA
|
53
|
+
|
54
|
+
CUSTOMERTAXID
|
55
|
+
|
56
|
+
CUSTPSWD
|
57
|
+
|
58
|
+
CUSTRECEIPT
|
59
|
+
|
60
|
+
CUSTREF
|
61
|
+
|
62
|
+
DCIND
|
63
|
+
|
64
|
+
DDA
|
65
|
+
|
66
|
+
DECLINEURL
|
67
|
+
|
68
|
+
DESCRIPTION
|
69
|
+
|
70
|
+
DISCOUNT
|
71
|
+
|
72
|
+
DISCOUNTIND
|
73
|
+
|
74
|
+
DISCOUNTLI
|
75
|
+
|
76
|
+
DISCOUNTRATE
|
77
|
+
|
78
|
+
DUTY
|
79
|
+
|
80
|
+
EDATE
|
81
|
+
|
82
|
+
EMAIL
|
83
|
+
|
84
|
+
ENABLEPARTIALAUTH
|
85
|
+
|
86
|
+
EXPMNTH
|
87
|
+
|
88
|
+
EXPYR
|
89
|
+
|
90
|
+
FAX
|
91
|
+
|
92
|
+
FORCEADDRESS
|
93
|
+
|
94
|
+
FORCECSC
|
95
|
+
|
96
|
+
FORCEEMAIL
|
97
|
+
|
98
|
+
FREIGHT
|
99
|
+
|
100
|
+
FREQUENCY
|
101
|
+
|
102
|
+
IDEXP
|
103
|
+
|
104
|
+
INVOICE
|
105
|
+
|
106
|
+
LAST4
|
107
|
+
|
108
|
+
MEASURE
|
109
|
+
|
110
|
+
MERCHANTTAXID
|
111
|
+
|
112
|
+
METHOD
|
113
|
+
|
114
|
+
NETGROSSIND
|
115
|
+
|
116
|
+
NEWCUSTID
|
117
|
+
|
118
|
+
NEWPSWD
|
119
|
+
|
120
|
+
NEWPSWD2
|
121
|
+
|
122
|
+
NEXT
|
123
|
+
|
124
|
+
NTAX
|
125
|
+
|
126
|
+
ORDERID
|
127
|
+
|
128
|
+
ORIGINALID
|
129
|
+
|
130
|
+
PHONE
|
131
|
+
|
132
|
+
PHOTOID
|
133
|
+
|
134
|
+
POSTURL
|
135
|
+
|
136
|
+
PRODUCTID
|
137
|
+
|
138
|
+
PSWD
|
139
|
+
|
140
|
+
QUANTITY
|
141
|
+
|
142
|
+
RECURID
|
143
|
+
|
144
|
+
RECURTYPE
|
145
|
+
|
146
|
+
RETURNBIN
|
147
|
+
|
148
|
+
RETURNCLR
|
149
|
+
|
150
|
+
RETURNID
|
151
|
+
|
152
|
+
SADDRESS
|
153
|
+
|
154
|
+
SADDRESS2
|
155
|
+
|
156
|
+
SCITY
|
157
|
+
|
158
|
+
SCOUNTRY
|
159
|
+
|
160
|
+
SCOUNTY
|
161
|
+
|
162
|
+
SDATE
|
163
|
+
|
164
|
+
SEARCHTEXT
|
165
|
+
|
166
|
+
SHIPPERS
|
167
|
+
|
168
|
+
SNAME
|
169
|
+
|
170
|
+
SOURCESTATE
|
171
|
+
|
172
|
+
SOURCEZIP
|
173
|
+
|
174
|
+
SSTATE
|
175
|
+
|
176
|
+
START
|
177
|
+
|
178
|
+
STRFWDDATE
|
179
|
+
|
180
|
+
SWIPE
|
181
|
+
|
182
|
+
SZIP
|
183
|
+
|
184
|
+
TAX
|
185
|
+
|
186
|
+
|
187
|
+
TERMS
|
188
|
+
|
189
|
+
TEST
|
190
|
+
|
191
|
+
TOTALCOUNT
|
192
|
+
|
193
|
+
TRANXID
|
194
|
+
|
195
|
+
TRANXTYPE
|
196
|
+
|
197
|
+
UN
|
198
|
+
|
199
|
+
UNITCOST
|
200
|
+
|
201
|
+
USER
|
202
|
+
|
203
|
+
WEIGHT
|
204
|
+
|
205
|
+
“……………………………”
|
206
|
+
Discretionary Data elements that are configured in PayTrace’s Virtual Terminal may be passed through the API. All Discretionary Data elements are optional in the API, our integrated solutions may make them required. Discretionary Data elements should be passed w/ the Title in the name portion of the pair and the value to the right of the tilde. For example, a Discretionary Data element titled “Hair Color” could be passed as “Hair Color~Red|” Please note that Discretionary Data titles and values should be URL encoded. Also, multiple select Discretionary Data values should be comma delimited
|
207
|
+
alpha-numeric
|
208
|
+
1-99
|
209
|
+
|
210
|
+
|
211
|
+
ACHCODE
|
212
|
+
|
213
|
+
ACHMSG
|
214
|
+
|
215
|
+
APPCODE
|
216
|
+
|
217
|
+
APPMSG
|
218
|
+
|
219
|
+
AUTHKEY
|
220
|
+
|
221
|
+
AVSRESPONSE
|
222
|
+
|
223
|
+
BALANCEAMOUNT
|
224
|
+
|
225
|
+
BATCHNUM
|
226
|
+
|
227
|
+
CHECKIDENTIFIER
|
228
|
+
|
229
|
+
CSCRESPONSE
|
230
|
+
|
231
|
+
CUSTOMERID
|
232
|
+
|
233
|
+
CUSTOMERRECORD
|
234
|
+
|
235
|
+
ERROR
|
236
|
+
|
237
|
+
IP
|
238
|
+
|
239
|
+
LASTCHECK
|
240
|
+
|
241
|
+
LASTTRANX
|
242
|
+
|
243
|
+
NETAMOUNT
|
244
|
+
|
245
|
+
PARTIALAMOUNT
|
246
|
+
|
247
|
+
REFUNDAMOUNT
|
248
|
+
|
249
|
+
REFUNDCOUNT
|
250
|
+
|
251
|
+
RESPONSE
|
252
|
+
|
253
|
+
SALESAMOUNT
|
254
|
+
|
255
|
+
SALESCOUNT
|
256
|
+
|
257
|
+
SETTLED
|
258
|
+
|
259
|
+
SHIPPINGCOMPANY
|
260
|
+
|
261
|
+
SHIPPINGMETHOD
|
262
|
+
|
263
|
+
SHIPPINGRATE
|
264
|
+
|
265
|
+
SHIPPINGRECORD
|
266
|
+
|
267
|
+
STATUS
|
268
|
+
|
269
|
+
TRANSACTIONID
|
270
|
+
|
271
|
+
TRANSACTIONRECORD
|
272
|
+
|
273
|
+
TRANXCOUNT
|
274
|
+
|
275
|
+
VISAREFUNDAMOUNT
|
276
|
+
|
277
|
+
VISAREFUNDCOUNT
|
278
|
+
|
279
|
+
VISASALESAMOUNT
|
280
|
+
|
281
|
+
VISASALESCOUNT
|
282
|
+
|
283
|
+
WHEN
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
|
data/lib/paytrace/api/fields.rb
CHANGED
@@ -43,6 +43,13 @@ module PayTrace
|
|
43
43
|
#customer
|
44
44
|
customer_id: "CUSTID",
|
45
45
|
customer_reference_id:"CUSTREF",
|
46
|
+
approval_code:"APPROVAL",
|
47
|
+
#cash advance
|
48
|
+
cash_advance:"CASHADVANCE",
|
49
|
+
id_number:"PHOTOID",
|
50
|
+
id_expiration:"IDEXP",
|
51
|
+
cc_last_4:"LAST4"
|
52
|
+
|
46
53
|
}
|
47
54
|
end
|
48
55
|
end
|
data/lib/paytrace/api/request.rb
CHANGED
@@ -31,7 +31,7 @@ module PayTrace
|
|
31
31
|
@params[:method] = TRANSACTION_METHOD
|
32
32
|
@params[:amount] = t.amount
|
33
33
|
load_address(t)
|
34
|
-
|
34
|
+
load_misc_fields(t) if t.optional_fields
|
35
35
|
end
|
36
36
|
|
37
37
|
def add_credit_card(cc)
|
@@ -42,18 +42,13 @@ module PayTrace
|
|
42
42
|
@params[:csc] = cc.csc if cc.csc
|
43
43
|
end
|
44
44
|
|
45
|
-
def
|
45
|
+
def load_misc_fields(t)
|
46
46
|
o = t.optional_fields
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
@params[:discretionary_data] = o[:discretionary_data] if o[:discretionary_data]
|
53
|
-
@params[:custom_dba] = o[:custom_dba] if o[:custom_dba]
|
54
|
-
@params[:invoice] = o[:invoice] if o[:invoice]
|
55
|
-
@params[:transaction_id] = o[:transaction_id] if o[:transaction_id]
|
56
|
-
@params[:customer_reference_id] = o[:customer_reference_id] if o[:customer_reference_id]
|
47
|
+
o.each do |k,v|
|
48
|
+
@params[k]= v
|
49
|
+
end
|
50
|
+
|
51
|
+
|
57
52
|
end
|
58
53
|
|
59
54
|
def load_address(t)
|
@@ -82,7 +77,6 @@ module PayTrace
|
|
82
77
|
@params[:"#{address_type}_state"] = address.state if address.state
|
83
78
|
@params[:"#{address_type}_postal_code"] = address.postal_code if address.postal_code
|
84
79
|
@params[:"#{address_type}_country"] = address.country if address.country
|
85
|
-
|
86
80
|
end
|
87
81
|
|
88
82
|
|
@@ -1,13 +1,30 @@
|
|
1
1
|
module PayTrace
|
2
2
|
module API
|
3
3
|
class Response
|
4
|
-
attr_reader :values
|
4
|
+
attr_reader :values, :errors
|
5
5
|
|
6
6
|
def initialize(response_string)
|
7
7
|
@field_delim = "|"
|
8
8
|
@value_delim = "~"
|
9
9
|
@values = {}
|
10
|
-
|
10
|
+
@errors = {}
|
11
|
+
parse_response(response_string)
|
12
|
+
end
|
13
|
+
|
14
|
+
def response_code
|
15
|
+
get_response
|
16
|
+
end
|
17
|
+
|
18
|
+
def has_errors?
|
19
|
+
@errors.length > 0
|
20
|
+
end
|
21
|
+
|
22
|
+
def parse_response(response_string)
|
23
|
+
|
24
|
+
if (response_string.include? "ERROR")
|
25
|
+
return parse_errors(response_string)
|
26
|
+
end
|
27
|
+
|
11
28
|
pairs = response_string.split(@field_delim)
|
12
29
|
pairs.each do |p|
|
13
30
|
k,v = p.split(@value_delim)
|
@@ -15,9 +32,34 @@ module PayTrace
|
|
15
32
|
end
|
16
33
|
end
|
17
34
|
|
18
|
-
def
|
35
|
+
def parse_errors(response_string)
|
36
|
+
pairs = response_string.split(@field_delim)
|
37
|
+
pairs.each do |p|
|
38
|
+
k,v = p.split(@value_delim)
|
39
|
+
k = generate_error_key(k,v)
|
40
|
+
@errors[k] = v
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def generate_error_key(key,value)
|
45
|
+
#get the error number from the value
|
46
|
+
return key +'-'+ value[/([1-9]*)/,1]
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_response()
|
50
|
+
if has_errors?
|
51
|
+
return get_error_response()
|
52
|
+
end
|
19
53
|
@values["RESPONSE"]
|
20
54
|
end
|
55
|
+
|
56
|
+
def get_error_response()
|
57
|
+
error_message = ""
|
58
|
+
@errors.each do |k,v|
|
59
|
+
error_message << v + ","
|
60
|
+
end
|
61
|
+
error_message
|
62
|
+
end
|
21
63
|
end
|
22
64
|
end
|
23
65
|
end
|
data/lib/paytrace/transaction.rb
CHANGED
@@ -3,21 +3,72 @@ require 'paytrace/api/gateway'
|
|
3
3
|
require 'paytrace/address'
|
4
4
|
module PayTrace
|
5
5
|
module TransactionOperations
|
6
|
-
def sale(
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def sale(args)
|
7
|
+
create_transaction(args,TransactionTypes::SALE)
|
8
|
+
end
|
9
|
+
|
10
|
+
def authorization(args)
|
11
|
+
create_transaction(args,TransactionTypes::Authorization)
|
12
|
+
end
|
13
|
+
|
14
|
+
def refund(args)
|
15
|
+
create_transaction(args,TransactionTypes::Refund)
|
16
|
+
end
|
17
|
+
|
18
|
+
def void(transaction_id)
|
19
|
+
params = {transaction_id: transaction_id}
|
20
|
+
t = Transaction.new(type: TransactionTypes::Void,
|
21
|
+
optional:params)
|
22
|
+
t.response = send_request(t)
|
23
|
+
t
|
24
|
+
end
|
25
|
+
|
26
|
+
def forced_sale(approval_code,args)
|
27
|
+
args[:approval_code] = approval_code
|
28
|
+
create_transaction(args,TransactionTypes::ForcedSale)
|
29
|
+
end
|
30
|
+
|
31
|
+
def capture(transaction_id)
|
32
|
+
params = {transaction_id: transaction_id}
|
33
|
+
t = Transaction.new(type: TransactionTypes::Capture,
|
34
|
+
optional:params)
|
35
|
+
t.response = send_request(t)
|
36
|
+
t
|
37
|
+
end
|
38
|
+
|
39
|
+
def cash_advance(args)
|
40
|
+
args[:cash_advance] = "Y"
|
41
|
+
|
42
|
+
create_transaction(args,TransactionTypes::SALE)
|
43
|
+
end
|
44
|
+
|
45
|
+
def store_forward(amount,credit_card,optional={})
|
46
|
+
optional[:amount] = amount
|
47
|
+
optional[:credit_card] = credit_card
|
48
|
+
create_transaction(optional,TransactionTypes::StoreForward)
|
49
|
+
end
|
10
50
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
51
|
+
private
|
52
|
+
def create_transaction(args,type)
|
53
|
+
amount = args.delete(:amount) if args[:amount]
|
54
|
+
cc = CreditCard.new(args.delete(:credit_card)) if args[:credit_card]
|
55
|
+
customer = Customer.new(customer_id: args.delete(:customer_id)) if args[:customer_id]
|
56
|
+
|
57
|
+
t = Transaction.new(amount: amount,
|
58
|
+
credit_card: cc,
|
59
|
+
customer: customer,
|
60
|
+
type: type,
|
61
|
+
optional:args)
|
62
|
+
|
63
|
+
t.response = send_request(t)
|
64
|
+
t
|
65
|
+
end
|
16
66
|
|
67
|
+
private
|
68
|
+
def send_request(t)
|
17
69
|
request = PayTrace::API::Request.new(transaction: t)
|
18
70
|
gateway = PayTrace::API::Gateway.new
|
19
|
-
|
20
|
-
t
|
71
|
+
gateway.send_request(request)
|
21
72
|
end
|
22
73
|
|
23
74
|
end
|
@@ -45,21 +96,19 @@ module PayTrace
|
|
45
96
|
end
|
46
97
|
|
47
98
|
private
|
48
|
-
def include_optional(
|
99
|
+
def include_optional(args)
|
100
|
+
s = nil
|
101
|
+
b = nil
|
49
102
|
|
50
|
-
b =
|
103
|
+
b = args.delete(:billing_address) if args[:billing_address]
|
51
104
|
@billing_address = PayTrace::Address.new(b) if b
|
52
|
-
s =
|
105
|
+
s = args.delete(:shipping_address) if args[:shipping_address]
|
53
106
|
@shipping_address = PayTrace::Address.new(s) if s
|
54
|
-
if
|
107
|
+
if args[:address_shipping_same_as_billing]
|
55
108
|
self.set_shipping_same_as_billing
|
56
109
|
end
|
57
110
|
|
58
|
-
|
59
|
-
optional[:billing_address] = nil
|
60
|
-
optional[:shipping_address] = nil
|
61
|
-
|
62
|
-
@optional_fields = optional
|
111
|
+
@optional_fields = args
|
63
112
|
|
64
113
|
end
|
65
114
|
|
@@ -68,6 +117,12 @@ module PayTrace
|
|
68
117
|
|
69
118
|
module TransactionTypes
|
70
119
|
SALE = "SALE"
|
120
|
+
Authorization = "Authorization"
|
121
|
+
Refund = "Refund"
|
122
|
+
Void = "Void"
|
123
|
+
ForcedSale = "Force"
|
124
|
+
Capture = "Capture"
|
125
|
+
StoreForward ="Str/FWD"
|
71
126
|
end
|
72
127
|
|
73
128
|
end
|
data/lib/paytrace/version.rb
CHANGED
@@ -77,6 +77,9 @@ describe PayTrace::API::Request do
|
|
77
77
|
}
|
78
78
|
}
|
79
79
|
)
|
80
|
+
|
81
|
+
t.shipping_address.must_be_nil
|
82
|
+
|
80
83
|
r = PayTrace::API::Request.new(transaction: t)
|
81
84
|
|
82
85
|
url = r.to_parms_string
|
@@ -149,4 +152,66 @@ describe PayTrace::API::Request do
|
|
149
152
|
url.must_match /\|AMOUNT~1.00\|/
|
150
153
|
url.must_match /\|TRANXID~1234|/
|
151
154
|
end
|
155
|
+
|
156
|
+
it "can create an approval code call" do
|
157
|
+
t = PayTrace::Transaction.new({amount: "23.12",
|
158
|
+
credit_card: PayTrace::CreditCard.new({
|
159
|
+
card_number: "1234123412341234",
|
160
|
+
expiration_year: 24,
|
161
|
+
expiration_month: 10 }),
|
162
|
+
type: PayTrace::TransactionTypes::ForcedSale,
|
163
|
+
optional:{approval_code:'1234'}
|
164
|
+
})
|
165
|
+
r = PayTrace::API::Request.new(transaction: t)
|
166
|
+
url = r.to_parms_string
|
167
|
+
|
168
|
+
url.must_match /\|APPROVAL~1234\|/
|
169
|
+
url.must_match /\|TRANXTYPE~Force\|/
|
170
|
+
|
171
|
+
end
|
172
|
+
|
173
|
+
it "can create a new cash_advance sale" do
|
174
|
+
cc = PayTrace::CreditCard.new( {
|
175
|
+
swipe: '%B4055010000000005^J/SCOTT^1212101001020001000000701000000?;4055010000000005=12121010010270100001?'
|
176
|
+
})
|
177
|
+
|
178
|
+
optional = {
|
179
|
+
billing_address:{
|
180
|
+
name:"John Doe",
|
181
|
+
street:"1234 happy lane",
|
182
|
+
street2:"apt#2",
|
183
|
+
city:"Seattle",
|
184
|
+
state:"WA",
|
185
|
+
country: "US",
|
186
|
+
postal_code:"98107"
|
187
|
+
},
|
188
|
+
id_number: "1234",
|
189
|
+
id_expiration:"12/20/2020",
|
190
|
+
cc_last_4: "1234",
|
191
|
+
cash_advance: "Y"
|
192
|
+
|
193
|
+
|
194
|
+
}
|
195
|
+
t = PayTrace::Transaction.new(
|
196
|
+
amount: '1.00',
|
197
|
+
credit_card:cc,
|
198
|
+
type: PayTrace::TransactionTypes::SALE,
|
199
|
+
optional:optional
|
200
|
+
)
|
201
|
+
|
202
|
+
r = PayTrace::API::Request.new(transaction: t)
|
203
|
+
url = r.to_parms_string
|
204
|
+
|
205
|
+
url.must_match /\|AMOUNT~1.00\|/
|
206
|
+
url.must_match /\|SWIPE~%B4055010000000005/
|
207
|
+
url.must_match /\|CASHADVANCE~Y\|/
|
208
|
+
url.must_match /\|PHOTOID~1234\|/
|
209
|
+
url.must_match /\|LAST4~1234\|/
|
210
|
+
url.must_match /\|BADDRESS~1234 happy lane\|/
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
end
|
216
|
+
|
152
217
|
end
|
@@ -7,4 +7,25 @@ describe PayTrace::API::Response do
|
|
7
7
|
response = PayTrace::API::Response.new(from_server)
|
8
8
|
response.response_code.must_equal "101. Your transaction was successfully approved."
|
9
9
|
end
|
10
|
+
|
11
|
+
it "parses multiple error responses" do
|
12
|
+
from_server ="ERROR~35. Please provide a valid Credit Card Number.|ERROR~43. Please provide a valid Expiration Month.|"
|
13
|
+
response = PayTrace::API::Response.new(from_server)
|
14
|
+
response.has_errors?.must_equal true
|
15
|
+
end
|
16
|
+
|
17
|
+
it "will can contain multiple error messages" do
|
18
|
+
from_server ="ERROR~35. Please provide a valid Credit Card Number.|ERROR~43. Please provide a valid Expiration Month.|"
|
19
|
+
response = PayTrace::API::Response.new(from_server)
|
20
|
+
response.errors.length.must_equal 2
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should create a response with all errors in it" do
|
24
|
+
from_server ="ERROR~35. Please provide a valid Credit Card Number.|ERROR~43. Please provide a valid Expiration Month.|"
|
25
|
+
response = PayTrace::API::Response.new(from_server)
|
26
|
+
actual ="35. Please provide a valid Credit Card Number.,43. Please provide a valid Expiration Month.,"
|
27
|
+
response.response_code.must_equal actual
|
28
|
+
end
|
29
|
+
|
30
|
+
|
10
31
|
end
|
@@ -6,6 +6,28 @@ describe PayTrace::Transaction do
|
|
6
6
|
@response = mock()
|
7
7
|
PayTrace::API::Gateway.any_instance.expects(:send_request).returns(@response)
|
8
8
|
end
|
9
|
+
it "can create a Payment Authorization" do
|
10
|
+
t = PayTrace::Transaction.authorization(
|
11
|
+
{ amount:"1242.32",
|
12
|
+
credit_card: {
|
13
|
+
card_number:"1234123412341234",
|
14
|
+
expiration_month:10,
|
15
|
+
expiration_year:24
|
16
|
+
}
|
17
|
+
}
|
18
|
+
)
|
19
|
+
|
20
|
+
|
21
|
+
#Transaction is properly configured
|
22
|
+
t.amount.must_equal "1242.32"
|
23
|
+
t.type.must_equal PayTrace::TransactionTypes::Authorization
|
24
|
+
|
25
|
+
#Sets up a card
|
26
|
+
t.credit_card.card_number.must_equal "1234123412341234"
|
27
|
+
t.credit_card.expiration_month.must_equal 10
|
28
|
+
t.credit_card.expiration_year.must_equal 24
|
29
|
+
end
|
30
|
+
|
9
31
|
it "can charge sales to a credit card" do
|
10
32
|
t = PayTrace::Transaction.sale(
|
11
33
|
{amount: "1242.32",
|
@@ -40,6 +62,41 @@ describe PayTrace::Transaction do
|
|
40
62
|
t.response.must_equal @response
|
41
63
|
|
42
64
|
end
|
65
|
+
|
66
|
+
it "can run a cash advance" do
|
67
|
+
|
68
|
+
args = {
|
69
|
+
amount:"1.00",
|
70
|
+
cc_last_4:"1234",
|
71
|
+
id_number:"12345",
|
72
|
+
id_expiration:"12/29/2020",
|
73
|
+
billing_address: {
|
74
|
+
street: "1234 happy lane",
|
75
|
+
street2: "apt #1",
|
76
|
+
city: "Seattle",
|
77
|
+
state: "WA",
|
78
|
+
postal_code:"98107",
|
79
|
+
country:"US"
|
80
|
+
},
|
81
|
+
credit_card: {
|
82
|
+
swipe:'%B5454545454545454^J/SCOTT^2612101001020001000000701000000?;5454545454545454=26121010010270100001?'
|
83
|
+
}
|
84
|
+
}
|
85
|
+
t = PayTrace::Transaction.cash_advance(args)
|
86
|
+
|
87
|
+
t.amount.must_equal "1.00"
|
88
|
+
t.type.must_equal PayTrace::TransactionTypes::SALE
|
89
|
+
t.credit_card.swipe.must_equal '%B5454545454545454^J/SCOTT^2612101001020001000000701000000?;5454545454545454=26121010010270100001?'
|
90
|
+
t.optional_fields[:cc_last_4].must_equal "1234"
|
91
|
+
t.optional_fields[:id_expiration].must_equal "12/29/2020"
|
92
|
+
t.optional_fields[:id_number].must_equal "12345"
|
93
|
+
|
94
|
+
t.billing_address.street.must_equal "1234 happy lane"
|
95
|
+
t.response.must_equal @response
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
|
43
100
|
end
|
44
101
|
describe "adding address info" do
|
45
102
|
it "can take a shipping address" do
|
@@ -106,7 +163,33 @@ describe PayTrace::Transaction do
|
|
106
163
|
t.shipping_address.must_equal t.billing_address
|
107
164
|
end
|
108
165
|
|
166
|
+
end
|
109
167
|
|
168
|
+
it "can be set to void a transaction" do
|
169
|
+
t = PayTrace::Transaction.new(optional:{transaction_id:"11"})
|
110
170
|
end
|
111
171
|
|
172
|
+
it "can create and send a void transaction" do
|
173
|
+
@response = mock()
|
174
|
+
PayTrace::API::Gateway.any_instance.expects(:send_request).returns(@response)
|
175
|
+
|
176
|
+
t = PayTrace::Transaction.void("111")
|
177
|
+
t.optional_fields[:transaction_id].must_equal "111"
|
178
|
+
t.type.must_equal PayTrace::TransactionTypes::Void
|
179
|
+
end
|
180
|
+
|
181
|
+
it "can create a forced sale" do
|
182
|
+
@response = mock()
|
183
|
+
PayTrace::API::Gateway.any_instance.expects(:send_request).returns(@response)
|
184
|
+
t = PayTrace::Transaction.forced_sale("111",{})
|
185
|
+
|
186
|
+
t.optional_fields[:approval_code].must_equal "111"
|
187
|
+
t.type.must_equal PayTrace::TransactionTypes::ForcedSale
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
|
192
|
+
end
|
193
|
+
|
194
|
+
|
112
195
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paytrace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Trevor Redfern
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- README.md
|
82
82
|
- Rakefile
|
83
83
|
- Vagrantfile
|
84
|
+
- api_names.txt
|
84
85
|
- lib/paytrace.rb
|
85
86
|
- lib/paytrace/address.rb
|
86
87
|
- lib/paytrace/api/fields.rb
|