paytrace 0.1.23 → 1.0.0
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.
- checksums.yaml +4 -4
- data/lib/paytrace/address.rb +2 -0
- data/lib/paytrace/api/gateway.rb +19 -4
- data/lib/paytrace/api/request.rb +72 -28
- data/lib/paytrace/api/response.rb +19 -11
- data/lib/paytrace/batch_operations.rb +8 -30
- data/lib/paytrace/check_transaction.rb +119 -84
- data/lib/paytrace/configuration.rb +2 -0
- data/lib/paytrace/customer.rb +95 -97
- data/lib/paytrace/debug.rb +36 -0
- data/lib/paytrace/email_receipt_request.rb +4 -28
- data/lib/paytrace/recurring_transaction.rb +20 -67
- data/lib/paytrace/transaction.rb +680 -267
- data/lib/paytrace/version.rb +1 -1
- data/lib/paytrace.rb +0 -4
- data/paytrace.gemspec +1 -0
- data/run_all_integrations.sh +15 -0
- data/test/paytrace/api/gateway_spec.rb +8 -0
- data/test/paytrace/api/request_spec.rb +84 -28
- data/test/paytrace/api/response_spec.rb +2 -2
- data/test/paytrace/batch_operations_spec.rb +5 -5
- data/test/paytrace/{check_transactions_spec.rb → check_transaction_spec.rb} +40 -19
- data/test/paytrace/customer_spec.rb +86 -110
- data/test/paytrace/email_receipt_request_spec.rb +9 -8
- data/test/paytrace/level3_data_spec.rb +28 -2
- data/test/paytrace/recurring_transaction_spec.rb +8 -16
- data/test/paytrace/transaction_spec.rb +300 -330
- data/test/scripts/run_adjust_amount.rb +1 -1
- data/test/scripts/run_attach_signature.rb +2 -2
- data/test/scripts/run_calculate_shipping_costs.rb +2 -3
- data/test/scripts/run_change_password.rb +2 -0
- data/test/scripts/run_check_transactions.rb +2 -3
- data/test/scripts/run_create_customer.rb +16 -23
- data/test/scripts/run_email_request.rb +3 -5
- data/test/scripts/run_export_batches.rb +6 -3
- data/test/scripts/run_export_customers.rb +1 -1
- data/test/scripts/run_export_transactions.rb +2 -2
- data/test/scripts/run_level3_data.rb +1 -1
- data/test/scripts/run_recur_payments_integration.rb +24 -32
- data/test/scripts/run_settle_transaction.rb +2 -2
- data/test/test_helper.rb +12 -1
- metadata +19 -7
- data/lib/paytrace/credit_card.rb +0 -32
- data/test/paytrace/credit_card_spec.rb +0 -26
@@ -1,51 +1,83 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '../../test_helper.rb')
|
2
2
|
|
3
3
|
describe PayTrace::Transaction do
|
4
|
-
def base_url
|
5
|
-
"UN~#{PayTrace.configuration.user_name}|PSWD~#{PayTrace.configuration.password}|TERMS~Y|"
|
6
|
-
end
|
7
|
-
|
8
4
|
before do
|
9
5
|
PayTrace::API::Gateway.debug = true
|
10
6
|
PayTrace::API::Gateway.reset_trace()
|
11
7
|
PayTrace::API::Gateway.next_response = "RESPONSE~ok|"
|
12
8
|
end
|
13
9
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
10
|
+
describe "export transactions" do
|
11
|
+
it "exports transaction(s)" do
|
12
|
+
PayTrace::API::Gateway.next_response = "TRANSACTIONRECORD~TRANXID=1143"
|
13
|
+
records = PayTrace::Transaction.export_by_id({transaction_id: 1143})
|
14
|
+
records.must_be_instance_of Array
|
15
|
+
records.count.must_equal 1
|
16
|
+
records[0].must_be_instance_of Hash
|
17
|
+
records[0]["TRANXID"].must_equal "1143"
|
18
|
+
|
19
|
+
assert_last_request_equals "METHOD~ExportTranx|TRANXID~1143|"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "it can export transactions by date range" do
|
23
|
+
PayTrace::API::Gateway.next_response = "TRANSACTIONRECORD~TRANXID=1144|TRANSACTIONRECORD~TRANXID=1145|"
|
24
|
+
|
25
|
+
params = {
|
26
|
+
start_date: '01/02/2013',
|
27
|
+
end_date: '01/03/2014',
|
28
|
+
transaction_type: 'SETTLED',
|
29
|
+
customer_id: 1234,
|
30
|
+
transaction_user: 'DDuck',
|
31
|
+
return_bin: 'Y',
|
32
|
+
search_text: 'search text'
|
33
|
+
}
|
34
|
+
|
35
|
+
records = PayTrace::Transaction.export_by_date_range(params)
|
36
|
+
records.must_be_instance_of Array
|
37
|
+
records.count.must_equal 2
|
38
|
+
records[0].must_be_instance_of Hash
|
39
|
+
records[0]["TRANXID"].must_equal "1144"
|
40
|
+
|
41
|
+
assert_last_request_equals "METHOD~ExportTranx|SDATE~01/02/2013|EDATE~01/03/2014|TRANXTYPE~SETTLED|CUSTID~1234|USER~DDuck|RETURNBIN~Y|SEARCHTEXT~search text|"
|
42
|
+
end
|
21
43
|
end
|
22
44
|
|
23
|
-
|
45
|
+
describe "settle transactions" do
|
46
|
+
it "can settle transactions" do
|
47
|
+
PayTrace::Transaction.settle_transactions()
|
48
|
+
|
49
|
+
assert_last_request_equals "METHOD~SettleTranx|"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it "successfully attaches image files to transactions as signatures" do
|
24
54
|
PayTrace::API::Gateway.next_response = "RESPONSE~172. The signature image was successfully attached to Transaction ID 13192003.|"
|
25
|
-
result = PayTrace::Transaction.
|
55
|
+
result = PayTrace::Transaction.attach_signature_file({transaction_id: 13192003, image_file: __FILE__, image_type: "png"})
|
26
56
|
result.has_errors?.must_equal false
|
27
57
|
end
|
28
58
|
|
29
|
-
it "successfully attaches image
|
59
|
+
it "successfully attaches image data to transactions as signatures" do
|
30
60
|
PayTrace::API::Gateway.next_response = "RESPONSE~172. The signature image was successfully attached to Transaction ID 13192003.|"
|
31
|
-
result = PayTrace::Transaction.
|
61
|
+
result = PayTrace::Transaction.attach_signature_data({transaction_id: 13192003, image_data: "fakebase64data", image_type: "png"})
|
32
62
|
result.has_errors?.must_equal false
|
63
|
+
|
64
|
+
assert_last_request_equals "METHOD~AttachSignature|TRANXID~13192003|IMAGEDATA~fakebase64data|IMAGETYPE~png"
|
33
65
|
end
|
34
66
|
|
35
67
|
it "calculates shipping costs" do
|
36
68
|
PayTrace::API::Gateway.next_response = "SHIPPINGRECORD~SHIPPINGCOMPANY=USPS+SHIPPINGMETHOD=STANDARD POST+SHIPPINGRATE=12.72|"
|
37
69
|
params = {
|
38
|
-
#UN, PSWD, TERMS, METHOD, SOURCEZIP, SOURCESTATE, SZIP, WEIGHT, SHIPPERS, SSTATE
|
39
70
|
source_zip: 98133,
|
40
71
|
source_state: "WA",
|
41
72
|
shipping_postal_code: 94947,
|
42
73
|
shipping_weight: 5.1,
|
43
74
|
shippers: "UPS,USPS,FEDEX",
|
44
|
-
shipping_state: "CA"
|
45
|
-
shipping_country: "US"
|
75
|
+
shipping_state: "CA"
|
46
76
|
}
|
47
77
|
result = PayTrace::Transaction.calculate_shipping(params)
|
48
78
|
result[0]['SHIPPINGCOMPANY'].must_equal "USPS"
|
79
|
+
|
80
|
+
assert_last_request_equals "METHOD~CalculateShipping|SOURCEZIP~98133|SOURCESTATE~WA|SZIP~94947|WEIGHT~5.1|SHIPPERS~UPS,USPS,FEDEX|SSTATE~CA|"
|
49
81
|
end
|
50
82
|
|
51
83
|
it "can adjust a transaction" do
|
@@ -55,370 +87,308 @@ describe PayTrace::Transaction do
|
|
55
87
|
amount: 9.87
|
56
88
|
}
|
57
89
|
result = PayTrace::Transaction.adjust_amount(params)
|
58
|
-
|
90
|
+
assert_last_request_equals "METHOD~AdjustAmount|TRANXID~1234|AMOUNT~9.87|"
|
59
91
|
end
|
60
92
|
|
61
93
|
describe "create sales transactions" do
|
62
|
-
it "can create a
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
94
|
+
it "can create a payment authorization for a keyed credit card" do
|
95
|
+
PayTrace::Transaction.keyed_authorization({
|
96
|
+
amount:"1242.32",
|
97
|
+
card_number:"1234123412341234",
|
98
|
+
expiration_month:10,
|
99
|
+
expiration_year:24
|
100
|
+
})
|
101
|
+
|
102
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Authorization|AMOUNT~1242.32|CC~1234123412341234|EXPMNTH~10|EXPYR~24|"
|
103
|
+
end
|
72
104
|
|
105
|
+
it "can create a payment authorization based upon a customer ID" do
|
106
|
+
PayTrace::Transaction.customer_id_authorization({
|
107
|
+
amount:"1242.32",
|
108
|
+
customer_id: 1234
|
109
|
+
})
|
73
110
|
|
74
|
-
|
75
|
-
|
76
|
-
|
111
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Authorization|AMOUNT~1242.32|CUSTID~1234|"
|
112
|
+
end
|
113
|
+
|
114
|
+
it "can charge sales to a swiped credit card" do
|
115
|
+
PayTrace::Transaction.swiped_sale({
|
116
|
+
amount: "1242.32",
|
117
|
+
swipe: "this is fake swipe data"
|
118
|
+
})
|
77
119
|
|
78
|
-
|
79
|
-
t.credit_card.card_number.must_equal "1234123412341234"
|
80
|
-
t.credit_card.expiration_month.must_equal 10
|
81
|
-
t.credit_card.expiration_year.must_equal 24
|
120
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|AMOUNT~1242.32|TRANXTYPE~SALE|SWIPE~this is fake swipe data|"
|
82
121
|
end
|
83
122
|
|
84
|
-
it "can charge sales to a credit card" do
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
#Transaction is properly configured
|
95
|
-
t.amount.must_equal "1242.32"
|
96
|
-
t.type.must_equal PayTrace::TransactionTypes::SALE
|
97
|
-
|
98
|
-
#Sets up a card
|
99
|
-
t.credit_card.card_number.must_equal "1234123412341234"
|
100
|
-
t.credit_card.expiration_month.must_equal 10
|
101
|
-
t.credit_card.expiration_year.must_equal 24
|
123
|
+
it "can charge sales to a keyed credit card" do
|
124
|
+
PayTrace::Transaction.keyed_sale({
|
125
|
+
amount: "1242.32",
|
126
|
+
card_number: "1234123412341234",
|
127
|
+
expiration_month: 10,
|
128
|
+
expiration_year: 24
|
129
|
+
})
|
130
|
+
|
131
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|AMOUNT~1242.32|TRANXTYPE~SALE|CC~1234123412341234|EXPMNTH~10|EXPYR~24|"
|
102
132
|
end
|
103
133
|
|
104
134
|
it "can run a transaction for a customer" do
|
105
|
-
|
135
|
+
PayTrace::Transaction.customer_id_sale(
|
106
136
|
{amount: "1.00",
|
107
|
-
|
137
|
+
customer_id: 123456}
|
108
138
|
)
|
109
139
|
|
110
|
-
|
111
|
-
t.type.must_equal PayTrace::TransactionTypes::SALE
|
112
|
-
t.customer.must_equal 123456
|
113
|
-
t.credit_card.must_be_nil
|
140
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|AMOUNT~1.00|TRANXTYPE~SALE|CUSTID~123456|"
|
114
141
|
end
|
142
|
+
end
|
115
143
|
|
116
|
-
|
117
|
-
|
144
|
+
describe "cash advance" do
|
145
|
+
it "can perform a cash advance for swiped credit card data" do
|
118
146
|
args = {
|
119
147
|
amount:"1.00",
|
120
148
|
cc_last_4:"1234",
|
121
149
|
id_number:"12345",
|
122
150
|
id_expiration:"12/29/2020",
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
credit_card: {
|
132
|
-
swipe:'%B5454545454545454^J/SCOTT^2612101001020001000000701000000?;5454545454545454=26121010010270100001?'
|
151
|
+
billing_name: "John Doe",
|
152
|
+
billing_address: "1234 happy lane",
|
153
|
+
billing_address2: "apt #1",
|
154
|
+
billing_city: "Seattle",
|
155
|
+
billing_state: "WA",
|
156
|
+
billing_postal_code:"98107",
|
157
|
+
billing_country:"US",
|
158
|
+
swipe:'%B5454545454545454^J/SCOTT^2612101001020001000000701000000?;5454545454545454=26121010010270100001?'
|
133
159
|
}
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
t.amount.must_equal "1.00"
|
138
|
-
t.type.must_equal PayTrace::TransactionTypes::SALE
|
139
|
-
t.credit_card.swipe.must_equal '%B5454545454545454^J/SCOTT^2612101001020001000000701000000?;5454545454545454=26121010010270100001?'
|
140
|
-
t.optional_fields[:cc_last_4].must_equal "1234"
|
141
|
-
t.optional_fields[:id_expiration].must_equal "12/29/2020"
|
142
|
-
t.optional_fields[:id_number].must_equal "12345"
|
143
|
-
|
144
|
-
t.billing_address.street.must_equal "1234 happy lane"
|
145
|
-
t.response.must_equal @response
|
146
|
-
|
160
|
+
|
161
|
+
PayTrace::Transaction.swiped_cash_advance(args)
|
162
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~SALE|AMOUNT~1.00|LAST4~1234|PHOTOID~12345|IDEXP~12/29/2020|CASHADVANCE~Y|BNAME~John Doe|BADDRESS~1234 happy lane|BADDRESS2~apt #1|BCITY~Seattle|BSTATE~WA|BZIP~98107|BCOUNTRY~US|SWIPE~%B5454545454545454^J/SCOTT^2612101001020001000000701000000?;5454545454545454=26121010010270100001?"
|
147
163
|
end
|
148
164
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
s.street2.must_equal "suit 234"
|
170
|
-
s.city.must_equal "Seattle"
|
171
|
-
s.state.must_equal "WA"
|
172
|
-
s.country.must_equal "USA"
|
173
|
-
s.postal_code.must_equal "98107"
|
174
|
-
|
175
|
-
end
|
176
|
-
it "can take a billing address" do
|
177
|
-
t = PayTrace::Transaction.new({
|
178
|
-
optional: {
|
179
|
-
billing_address: {
|
180
|
-
street: "1234 happy lane",
|
181
|
-
street2: "suit 234",
|
182
|
-
city:"Seattle",
|
183
|
-
state:"WA",
|
184
|
-
country:"USA",
|
185
|
-
postal_code:"98107"
|
186
|
-
}
|
187
|
-
}
|
188
|
-
})
|
189
|
-
b = t.billing_address
|
190
|
-
b.street.must_equal "1234 happy lane"
|
191
|
-
b.street2.must_equal "suit 234"
|
192
|
-
b.city.must_equal "Seattle"
|
193
|
-
b.state.must_equal "WA"
|
194
|
-
b.country.must_equal "USA"
|
195
|
-
b.postal_code.must_equal "98107"
|
165
|
+
it "can perform a cash advance for keyed-in credit card data" do
|
166
|
+
args = {
|
167
|
+
amount:"1.00",
|
168
|
+
cc_last_4:"1234",
|
169
|
+
id_number:"12345",
|
170
|
+
id_expiration:"12/29/2020",
|
171
|
+
billing_name: "John Doe",
|
172
|
+
billing_address: "1234 happy lane",
|
173
|
+
billing_address2: "apt #1",
|
174
|
+
billing_city: "Seattle",
|
175
|
+
billing_state: "WA",
|
176
|
+
billing_postal_code:"98107",
|
177
|
+
billing_country:"US",
|
178
|
+
card_number: 1234123412341234,
|
179
|
+
expiration_month: 10,
|
180
|
+
expiration_year: 24
|
181
|
+
}
|
182
|
+
|
183
|
+
PayTrace::Transaction.keyed_cash_advance(args)
|
184
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~SALE|AMOUNT~1.00|LAST4~1234|PHOTOID~12345|IDEXP~12/29/2020|CASHADVANCE~Y|BNAME~John Doe|BADDRESS~1234 happy lane|BADDRESS2~apt #1|BCITY~Seattle|BSTATE~WA|BZIP~98107|BCOUNTRY~US|CC~1234123412341234|EXPMNTH~10|EXPYR~24|"
|
196
185
|
end
|
197
186
|
end
|
198
187
|
|
199
|
-
|
200
|
-
|
201
|
-
|
188
|
+
describe "store and forward transactions" do
|
189
|
+
it "can perform a store and forward transaction for swiped credit card data" do
|
190
|
+
params = {amount: 19.97, swipe: 'this is fake swipe data'}
|
191
|
+
PayTrace::Transaction.swiped_store_forward(params)
|
202
192
|
|
203
|
-
|
204
|
-
|
205
|
-
PayTrace::API::Gateway.any_instance.expects(:send_request).returns(@response)
|
206
|
-
|
207
|
-
t = PayTrace::Transaction.void("111")
|
208
|
-
t.optional_fields[:transaction_id].must_equal "111"
|
209
|
-
t.type.must_equal PayTrace::TransactionTypes::Void
|
210
|
-
end
|
193
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Str/FWD|AMOUNT~19.97|SWIPE~this is fake swipe data|"
|
194
|
+
end
|
211
195
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
t.optional_fields[:approval_code].must_equal "111"
|
216
|
-
t.type.must_equal PayTrace::TransactionTypes::ForcedSale
|
217
|
-
end
|
196
|
+
it "can perform a store and forward transaction for keyed-in credit card data" do
|
197
|
+
params = {amount: 19.96, card_number: 1234123412341234, expiration_month: 10, expiration_year: 24}
|
198
|
+
PayTrace::Transaction.keyed_store_forward(params)
|
218
199
|
|
200
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Str/FWD|AMOUNT~19.96|CC~1234123412341234|EXPMNTH~10|EXPYR~24|"
|
201
|
+
end
|
219
202
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
card_number: "1234123412341234",
|
224
|
-
expiration_year: 24,
|
225
|
-
expiration_month: 10 }),
|
226
|
-
type: PayTrace::TransactionTypes::SALE})
|
227
|
-
r = PayTrace::API::Request.new
|
228
|
-
t.set_request(r)
|
229
|
-
|
230
|
-
r.params[:card_number].must_equal ["1234123412341234"]
|
231
|
-
r.params[:expiration_month].must_equal [10]
|
232
|
-
r.params[:expiration_year].must_equal [24]
|
233
|
-
r.params[:transaction_type].must_equal ["SALE"]
|
234
|
-
r.params[:method].must_equal ["PROCESSTRANX"]
|
235
|
-
r.params[:amount].must_equal ["23.12"]
|
236
|
-
|
237
|
-
url = r.to_parms_string
|
238
|
-
url.must_equal "UN~#{PayTrace.configuration.user_name}|PSWD~#{PayTrace.configuration.password}|TERMS~Y|CC~1234123412341234|EXPMNTH~10|EXPYR~24|TRANXTYPE~SALE|METHOD~PROCESSTRANX|AMOUNT~23.12|"
|
239
|
-
end
|
203
|
+
it "can perform a store and forward transaction referencing a customer id" do
|
204
|
+
params = {amount: 19.96, customer_id: 1234}
|
205
|
+
PayTrace::Transaction.customer_id_store_forward(params)
|
240
206
|
|
241
|
-
|
242
|
-
|
243
|
-
customer: 1234,
|
244
|
-
type: PayTrace::TransactionTypes::SALE
|
245
|
-
}
|
246
|
-
)
|
247
|
-
r = PayTrace::API::Request.new
|
248
|
-
t.set_request(r)
|
249
|
-
|
250
|
-
r.params[:customer_id].must_equal [1234]
|
251
|
-
r.params[:amount].must_equal ["12.34"]
|
252
|
-
|
253
|
-
url = r.to_parms_string
|
254
|
-
|
255
|
-
#Make sure it puts in values we expect
|
256
|
-
url.must_match /\|CUSTID~1234\|/
|
257
|
-
url.must_match /\|AMOUNT~12.34\|/
|
258
|
-
url.must_match /\|METHOD~PROCESSTRANX\|/
|
259
|
-
url.must_match /\|TRANXTYPE~SALE\|/
|
260
|
-
end
|
207
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Str/FWD|AMOUNT~19.96|CUSTID~1234|"
|
208
|
+
end
|
261
209
|
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
210
|
+
it "accepts extra parameters" do
|
211
|
+
params = {
|
212
|
+
amount: 19.96,
|
213
|
+
customer_id: 1234,
|
214
|
+
billing_name: "John Doe",
|
215
|
+
billing_address: "1234 Fake St.",
|
216
|
+
billing_address2: "Suite 123",
|
217
|
+
billing_city: "Seattle",
|
218
|
+
billing_state: "WA",
|
219
|
+
billing_postal_code: "98133",
|
220
|
+
billing_country: "US",
|
221
|
+
shipping_name: "Jim Doe",
|
222
|
+
shipping_address: "1235 Fake Ave.",
|
223
|
+
shipping_address2: "Suite 345",
|
224
|
+
shipping_city: "Shoreline",
|
225
|
+
shipping_state: "WA",
|
226
|
+
shipping_postal_code: "98134",
|
227
|
+
shipping_region: "King County",
|
228
|
+
shipping_country: "US",
|
229
|
+
email: "support@paytrace.com",
|
230
|
+
csc: 993,
|
231
|
+
invoice: "fake_invoice",
|
232
|
+
description: "fake_description",
|
233
|
+
tax_amount: 19.98,
|
234
|
+
customer_reference_id: "cust_ref_id",
|
235
|
+
discretionary_data: {hair_color: "red"},
|
236
|
+
return_clr: "Y",
|
237
|
+
custom_dba: "Arcadian Productions",
|
238
|
+
enable_partial_authentication: "Y"
|
239
|
+
}
|
240
|
+
PayTrace::Transaction.customer_id_store_forward(params)
|
292
241
|
|
242
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Str/FWD|AMOUNT~19.96|CUSTID~1234|BNAME~John Doe|BADDRESS~1234 Fake St.|BADDRESS2~Suite 123|BCITY~Seattle|BSTATE~WA|BZIP~98133|BCOUNTRY~US|SNAME~Jim Doe|SADDRESS~1235 Fake Ave.|SADDRESS2~Suite 345|SCITY~Shoreline|SSTATE~WA|SZIP~98134|SCOUNTY~King County|SCOUNTRY~US|EMAIL~support@paytrace.com|CSC~993|INVOICE~fake_invoice|DESCRIPTION~fake_description|TAX~19.98|CUSTREF~cust_ref_id|RETURNCLR~Y|CUSTOMDBA~Arcadian Productions|ENABLEPARTIALAUTH~Y|hair_color~red"
|
243
|
+
end
|
293
244
|
end
|
294
245
|
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
return_clr: "Y",
|
302
|
-
enable_partial_authentication:"Y",
|
303
|
-
custom_dba:"NewName"
|
304
|
-
},
|
305
|
-
discretionary_data: {hair_color: "red"}
|
306
|
-
})
|
246
|
+
describe "refund transactions" do
|
247
|
+
it "can create a refund transaction for a swiped credit card" do
|
248
|
+
params = {
|
249
|
+
amount: 19.99,
|
250
|
+
swipe: 'this is fake swipe data'
|
251
|
+
}
|
307
252
|
|
308
|
-
|
309
|
-
|
253
|
+
PayTrace::Transaction.swiped_refund(params)
|
254
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Refund|AMOUNT~19.99|SWIPE~this is fake swipe data|"
|
255
|
+
end
|
310
256
|
|
311
|
-
|
257
|
+
it "can create a refund transaction for a keyed-in credit card" do
|
258
|
+
params = {
|
259
|
+
amount: 19.99,
|
260
|
+
card_number: 5444444444444444,
|
261
|
+
expiration_month: 10,
|
262
|
+
expiration_year: 24
|
263
|
+
}
|
312
264
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
url.must_match /\|RETURNCLR~Y\|/
|
317
|
-
url.must_match /\|ENABLEPARTIALAUTH~Y\|/
|
318
|
-
url.must_match /\|hair_color~red\|/
|
319
|
-
url.must_match /\|CUSTOMDBA~NewName\|/
|
320
|
-
end
|
265
|
+
PayTrace::Transaction.keyed_refund(params)
|
266
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Refund|AMOUNT~19.99|CC~5444444444444444|EXPMNTH~10|EXPYR~24|"
|
267
|
+
end
|
321
268
|
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
amount: '1.00',
|
328
|
-
credit_card:cc
|
329
|
-
})
|
269
|
+
it "can create a refund transaction for a particular customer ID" do
|
270
|
+
params = {
|
271
|
+
amount: 19.99,
|
272
|
+
customer_id: 1234
|
273
|
+
}
|
330
274
|
|
331
|
-
|
332
|
-
|
275
|
+
PayTrace::Transaction.customer_id_refund(params)
|
276
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Refund|AMOUNT~19.99|CUSTID~1234|"
|
277
|
+
end
|
333
278
|
|
334
|
-
|
279
|
+
it "can create a refund transaction for a particular transaction ID" do
|
280
|
+
params = {
|
281
|
+
amount: 19.99,
|
282
|
+
transaction_id: 1234
|
283
|
+
}
|
335
284
|
|
336
|
-
|
337
|
-
|
285
|
+
PayTrace::Transaction.transaction_id_refund(params)
|
286
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Refund|AMOUNT~19.99|TRANXID~1234|"
|
287
|
+
end
|
338
288
|
|
289
|
+
it "accepts optional data" do
|
290
|
+
params = {
|
291
|
+
amount: 19.99,
|
292
|
+
transaction_id: 1234,
|
293
|
+
billing_name: "John Doe",
|
294
|
+
billing_address: "1234 Fake St.",
|
295
|
+
billing_address2: "Suite 123",
|
296
|
+
billing_city: "Seattle",
|
297
|
+
billing_state: "WA",
|
298
|
+
billing_postal_code: "98133",
|
299
|
+
billing_country: "US",
|
300
|
+
shipping_name: "Jim Doe",
|
301
|
+
shipping_address: "1235 Fake Ave.",
|
302
|
+
shipping_address2: "Suite 345",
|
303
|
+
shipping_city: "Shoreline",
|
304
|
+
shipping_state: "WA",
|
305
|
+
shipping_postal_code: "98134",
|
306
|
+
shipping_region: "King County",
|
307
|
+
shipping_country: "US",
|
308
|
+
email: "support@paytrace.com",
|
309
|
+
csc: 993,
|
310
|
+
invoice: "fake_invoice",
|
311
|
+
description: "fake_description",
|
312
|
+
tax_amount: 19.98,
|
313
|
+
customer_reference_id: "cust_ref_id",
|
314
|
+
discretionary_data: {hair_color: "red"}
|
315
|
+
}
|
339
316
|
|
317
|
+
PayTrace::Transaction.transaction_id_refund(params)
|
318
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Refund|AMOUNT~19.99|TRANXID~1234|BNAME~John Doe|BADDRESS~1234 Fake St.|BADDRESS2~Suite 123|BCITY~Seattle|BSTATE~WA|BZIP~98133|BCOUNTRY~US|SNAME~Jim Doe|SADDRESS~1235 Fake Ave.|SADDRESS2~Suite 345|SCITY~Shoreline|SSTATE~WA|SZIP~98134|SCOUNTY~King County|SCOUNTRY~US|EMAIL~support@paytrace.com|CSC~993|INVOICE~fake_invoice|DESCRIPTION~fake_description|TAX~19.98|CUSTREF~cust_ref_id|hair_color~red"
|
319
|
+
end
|
340
320
|
end
|
341
321
|
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
amount:
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
322
|
+
describe "adding address info" do
|
323
|
+
it "can take a shipping address" do
|
324
|
+
PayTrace::Transaction.customer_id_sale({
|
325
|
+
amount: 19.99,
|
326
|
+
customer_id: 'MMouse',
|
327
|
+
shipping_name: "Joe Blow",
|
328
|
+
shipping_address: "1234 happy lane",
|
329
|
+
shipping_address2: "suit 234",
|
330
|
+
shipping_city:"Seattle",
|
331
|
+
shipping_state:"WA",
|
332
|
+
shipping_country:"USA",
|
333
|
+
shipping_postal_code:"98107"
|
334
|
+
})
|
335
|
+
|
336
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~SALE|AMOUNT~19.99|CUSTID~MMouse|SNAME~Joe Blow|SADDRESS~1234 happy lane|SADDRESS2~suit 234|SCITY~Seattle|SSTATE~WA|SCOUNTRY~USA|SZIP~98107|"
|
337
|
+
end
|
353
338
|
|
354
|
-
|
355
|
-
|
339
|
+
it "can take a billing address" do
|
340
|
+
PayTrace::Transaction.customer_id_sale({
|
341
|
+
amount: 19.99,
|
342
|
+
customer_id: 'MMouse',
|
343
|
+
billing_name: "Joe Blow",
|
344
|
+
billing_address: "1234 happy lane",
|
345
|
+
billing_address2: "suit 234",
|
346
|
+
billing_city:"Seattle",
|
347
|
+
billing_state:"WA",
|
348
|
+
billing_country:"USA",
|
349
|
+
billing_postal_code:"98107"
|
350
|
+
})
|
351
|
+
|
352
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~SALE|AMOUNT~19.99|CUSTID~MMouse|BNAME~Joe Blow|BADDRESS~1234 happy lane|BADDRESS2~suit 234|BCITY~Seattle|BSTATE~WA|BCOUNTRY~USA|BZIP~98107|"
|
353
|
+
end
|
356
354
|
end
|
357
355
|
|
358
|
-
it "can create
|
359
|
-
|
360
|
-
|
361
|
-
card_number: "1234123412341234",
|
362
|
-
expiration_year: 24,
|
363
|
-
expiration_month: 10 }),
|
364
|
-
type: PayTrace::TransactionTypes::ForcedSale,
|
365
|
-
optional:{approval_code:'1234'}
|
366
|
-
})
|
367
|
-
|
368
|
-
r = PayTrace::API::Request.new
|
369
|
-
t.set_request(r)
|
370
|
-
|
371
|
-
url = r.to_parms_string
|
372
|
-
|
373
|
-
url.must_match /\|APPROVAL~1234\|/
|
374
|
-
url.must_match /\|TRANXTYPE~Force\|/
|
375
|
-
|
356
|
+
it "can create and send a void transaction" do
|
357
|
+
PayTrace::Transaction.void({transaction_id: "111"})
|
358
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Void|TRANXID~111|"
|
376
359
|
end
|
377
360
|
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
})
|
406
|
-
|
407
|
-
r = PayTrace::API::Request.new
|
408
|
-
t.set_request(r)
|
409
|
-
|
410
|
-
url = r.to_parms_string
|
411
|
-
|
412
|
-
url.must_match /\|AMOUNT~1.00\|/
|
413
|
-
url.must_match /\|SWIPE~%B4055010000000005/
|
414
|
-
url.must_match /\|CASHADVANCE~Y\|/
|
415
|
-
url.must_match /\|PHOTOID~1234\|/
|
416
|
-
url.must_match /\|LAST4~1234\|/
|
417
|
-
url.must_match /\|BADDRESS~1234 happy lane\|/
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
361
|
+
describe "forced sales" do
|
362
|
+
it "can create a forced sale for a swiped credit card" do
|
363
|
+
PayTrace::Transaction.swiped_forced_sale(amount: 19.99, swipe: "this is some fake swipe data", approval_code: 111)
|
364
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Force|AMOUNT~19.99|SWIPE~this is some fake swipe data|APPROVAL~111|"
|
365
|
+
end
|
366
|
+
|
367
|
+
it "can create a forced sale for a keyed-in credit card" do
|
368
|
+
params = {
|
369
|
+
amount: 19.98,
|
370
|
+
card_number: 1234123412341234,
|
371
|
+
expiration_month: 10,
|
372
|
+
expiration_year: 24,
|
373
|
+
approval_code: 123
|
374
|
+
}
|
375
|
+
PayTrace::Transaction.keyed_forced_sale(params)
|
376
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Force|AMOUNT~19.98|CC~1234123412341234|EXPMNTH~10|EXPYR~24|APPROVAL~123|"
|
377
|
+
end
|
378
|
+
|
379
|
+
it "can create a forced sale for a given customer ID" do
|
380
|
+
PayTrace::Transaction.customer_id_forced_sale(amount: 19.99, customer_id: "MMouse", approval_code: 111)
|
381
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Force|AMOUNT~19.99|CUSTID~MMouse|APPROVAL~111|"
|
382
|
+
end
|
383
|
+
|
384
|
+
it "can create a forced sale for a given transaction ID" do
|
385
|
+
PayTrace::Transaction.transaction_id_forced_sale(transaction_id: 1234, approval_code: 111)
|
386
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Force|TRANXID~1234|APPROVAL~111|"
|
387
|
+
end
|
422
388
|
end
|
423
389
|
|
390
|
+
it "can perform a capture transaction" do
|
391
|
+
PayTrace::Transaction.capture(transaction_id: 1234)
|
392
|
+
assert_last_request_equals "METHOD~PROCESSTRANX|TRANXTYPE~Capture|TRANXID~1234|"
|
393
|
+
end
|
424
394
|
end
|