paytrace 0.1.23 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/lib/paytrace/address.rb +2 -0
  3. data/lib/paytrace/api/gateway.rb +19 -4
  4. data/lib/paytrace/api/request.rb +72 -28
  5. data/lib/paytrace/api/response.rb +19 -11
  6. data/lib/paytrace/batch_operations.rb +8 -30
  7. data/lib/paytrace/check_transaction.rb +119 -84
  8. data/lib/paytrace/configuration.rb +2 -0
  9. data/lib/paytrace/customer.rb +95 -97
  10. data/lib/paytrace/debug.rb +36 -0
  11. data/lib/paytrace/email_receipt_request.rb +4 -28
  12. data/lib/paytrace/recurring_transaction.rb +20 -67
  13. data/lib/paytrace/transaction.rb +680 -267
  14. data/lib/paytrace/version.rb +1 -1
  15. data/lib/paytrace.rb +0 -4
  16. data/paytrace.gemspec +1 -0
  17. data/run_all_integrations.sh +15 -0
  18. data/test/paytrace/api/gateway_spec.rb +8 -0
  19. data/test/paytrace/api/request_spec.rb +84 -28
  20. data/test/paytrace/api/response_spec.rb +2 -2
  21. data/test/paytrace/batch_operations_spec.rb +5 -5
  22. data/test/paytrace/{check_transactions_spec.rb → check_transaction_spec.rb} +40 -19
  23. data/test/paytrace/customer_spec.rb +86 -110
  24. data/test/paytrace/email_receipt_request_spec.rb +9 -8
  25. data/test/paytrace/level3_data_spec.rb +28 -2
  26. data/test/paytrace/recurring_transaction_spec.rb +8 -16
  27. data/test/paytrace/transaction_spec.rb +300 -330
  28. data/test/scripts/run_adjust_amount.rb +1 -1
  29. data/test/scripts/run_attach_signature.rb +2 -2
  30. data/test/scripts/run_calculate_shipping_costs.rb +2 -3
  31. data/test/scripts/run_change_password.rb +2 -0
  32. data/test/scripts/run_check_transactions.rb +2 -3
  33. data/test/scripts/run_create_customer.rb +16 -23
  34. data/test/scripts/run_email_request.rb +3 -5
  35. data/test/scripts/run_export_batches.rb +6 -3
  36. data/test/scripts/run_export_customers.rb +1 -1
  37. data/test/scripts/run_export_transactions.rb +2 -2
  38. data/test/scripts/run_level3_data.rb +1 -1
  39. data/test/scripts/run_recur_payments_integration.rb +24 -32
  40. data/test/scripts/run_settle_transaction.rb +2 -2
  41. data/test/test_helper.rb +12 -1
  42. metadata +19 -7
  43. data/lib/paytrace/credit_card.rb +0 -32
  44. data/test/paytrace/credit_card_spec.rb +0 -26
@@ -7,9 +7,6 @@ module PayTrace
7
7
  # Manages transaction-related functionality
8
8
  class Transaction
9
9
  # :nodoc:
10
- attr_reader :amount, :credit_card, :type, :customer, :billing_address, :shipping_address,:optional_fields
11
- attr_accessor :response, :discretionary_data
12
-
13
10
  TRANSACTION_METHOD = "PROCESSTRANX"
14
11
  EXPORT_TRANSACTIONS_METHOD = "ExportTranx"
15
12
  EXPORT_TRANSACTIONS_RESPONSE = "TRANSACTIONRECORD"
@@ -21,188 +18,643 @@ module PayTrace
21
18
  SETTLE_TRANSACTION_METHOD = "SettleTranx"
22
19
  ADJUST_AMOUNT_METHOD = "AdjustAmount"
23
20
 
21
+ SWIPED_SALE_REQUEST_REQUIRED = [
22
+ :transaction_type,
23
+ :amount,
24
+ :swipe
25
+ ]
26
+
27
+ SWIPED_SALE_REQUEST_OPTIONAL = []
28
+
29
+ KEYED_SALE_REQUEST_REQUIRED = [
30
+ :transaction_type,
31
+ :amount,
32
+ :card_number,
33
+ :expiration_month,
34
+ :expiration_year
35
+ ]
36
+
37
+ KEYED_SALE_REQUEST_OPTIONAL = []
38
+
39
+ CUSTID_SALE_REQUEST_REQUIRED = [
40
+ :transaction_type,
41
+ :amount,
42
+ :customer_id
43
+ ]
44
+
45
+ BILLING_AND_SHIPPING_ADDRESS_FIELDS = [
46
+ :billing_name,
47
+ :billing_address,
48
+ :billing_address2,
49
+ :billing_city,
50
+ :billing_state,
51
+ :billing_postal_code,
52
+ :billing_country,
53
+ :shipping_name,
54
+ :shipping_address,
55
+ :shipping_address2,
56
+ :shipping_city,
57
+ :shipping_state,
58
+ :shipping_postal_code,
59
+ :shipping_region,
60
+ :shipping_country
61
+ ]
62
+
63
+ ADDRESSES_AND_EXTRA = BILLING_AND_SHIPPING_ADDRESS_FIELDS + [
64
+ :email,
65
+ :csc,
66
+ :invoice,
67
+ :description,
68
+ :tax_amount,
69
+ :customer_reference_id,
70
+ :discretionary_data
71
+ ]
72
+
73
+ ALL_OPTIONAL_FIELDS = ADDRESSES_AND_EXTRA + [
74
+ :return_clr,
75
+ :custom_dba,
76
+ :enable_partial_authentication
77
+ ]
78
+
79
+ CUSTID_SALE_REQUEST_OPTIONAL = ALL_OPTIONAL_FIELDS
80
+
81
+ REFERENCED_SALE_REQUEST_REQUIRED = [
82
+ :transaction_type,
83
+ :amount
84
+ ]
85
+
86
+ REFERENCED_SALE_REQUEST_OPTIONAL = [
87
+ ]
88
+
89
+ REFUND_OPTIONAL = ADDRESSES_AND_EXTRA + [:amount]
90
+
91
+ STORE_AND_FORWARD_OPTIONAL = ALL_OPTIONAL_FIELDS + [:store_forward_date]
92
+
93
+ CASH_ADVANCE_OPTIONAL = [
94
+ :billing_country,
95
+ :shipping_name,
96
+ :shipping_address,
97
+ :shipping_address2,
98
+ :shipping_city,
99
+ :shipping_region,
100
+ :shipping_state,
101
+ :shipping_postal_code,
102
+ :email,
103
+ :csc,
104
+ :invoice,
105
+ :description,
106
+ :tax_amount,
107
+ :customer_reference_id
108
+ ]
24
109
  # :doc:
25
110
 
26
111
  # See http://help.paytrace.com/api-sale
27
- # Creates a sale transaction. Params (in hash format):
112
+ #
113
+ # Creates a sale transaction using a keyed in credit card.
114
+ #
115
+ # Required parameters:
116
+ #
117
+ # * *:amount* -- the amount of the transaction
118
+ # * *:card_number* -- the credit card number used
119
+ # * *:expiration_month* -- the expiration month of the credit card
120
+ # * *:expiration_year* -- the expiration year of the credit card
121
+ def self.keyed_sale(params)
122
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
123
+ params.merge({transaction_type: TransactionTypes::SALE}),
124
+ KEYED_SALE_REQUEST_REQUIRED,
125
+ KEYED_SALE_REQUEST_OPTIONAL)
126
+ end
127
+
128
+ # See http://help.paytrace.com/api-sale
129
+ #
130
+ # Creates a sale transaction using a swiped in credit card.
131
+ #
132
+ # Required parameters:
133
+ #
28
134
  # * *:amount* -- the amount of the transaction
29
- # Depending upon the type of sale, the following additional parameters may be present:
30
- # * *:credit_card* -- a PayTrace::CreditCard object (key entered sale)
31
- # * *:customer* -- a PayTrace::Customer object (for additional customer data; customer ID token or referenced transaction sale). _Note:_ for discretionary data, the best way to include it is by adding it to the PayTrace::Customer object.
32
- # * *:optional* -- optional fields hash, kept inside the parameters
33
- # _Note:_ the following parameters are kept in the optional fields hash
34
135
  # * *:swipe* -- credit card swipe data (card swiped sales)
35
- # * *:customer_id* -- a PayTrace customer ID (customer ID token sale)
36
- # * *:transaction_id* -- a transaction ID (referenced transaction sale)
136
+ def self.swiped_sale(params)
137
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
138
+ params.merge({transaction_type: TransactionTypes::SALE}),
139
+ SWIPED_SALE_REQUEST_REQUIRED,
140
+ SWIPED_SALE_REQUEST_OPTIONAL)
141
+ end
142
+
143
+ # See http://help.paytrace.com/api-sale
144
+ #
145
+ # Creates a sale transaction using a swiped in credit card.
146
+ #
147
+ # Required parameters:
148
+ #
149
+ # * *:amount* -- the amount of the transaction
150
+ # * *:customer_id* -- the customer ID to reference for this sale
151
+ #
152
+ # Optional parameters:
153
+ #
154
+ # * *:billing_name* -- the billing name for this transaction
155
+ # * *:billing_address* -- the billing street address for this transaction
156
+ # * *:billing_address2* -- the billing street address second line (e.g., apartment, suite) for this transaction
157
+ # * *:billing_city* -- the billing city for this transaction
158
+ # * *:billing_state* -- the billing state for this transaction
159
+ # * *:billing_postal_code* -- the billing zip code for this transaction
160
+ # * *:billing_country* -- the billing country for this transaction
161
+ # * *:shipping_name* -- the shipping name for this transaction
162
+ # * *:shipping_address* -- the shipping street address for this transaction
163
+ # * *:shipping_address2* -- the shipping street address second line (e.g., apartment, suite) for this transaction
164
+ # * *:shipping_city* -- the shipping city for this transaction
165
+ # * *:shipping_state* -- the shipping state for this transaction
166
+ # * *:shipping_postal_code* -- the shipping zip code for this transaction
167
+ # * *:shipping_region* -- the shipping region (e.g. county) for this transaction
168
+ # * *:shipping_country* -- the shipping country for this transaction
169
+ # * *:email* -- the customer email for this transaction
37
170
  # * *:csc* -- credit card security code (customer ID token or referenced transaction sale)
38
171
  # * *:invoice* -- an internal invoice number (customer ID token or referenced transaction sale)
39
172
  # * *:description* -- a description of the sale (customer ID token or referenced transaction sale)
40
173
  # * *:tax_amount* -- the amount of tax on the sale (customer ID token or referenced transaction sale)
41
174
  # * *:customer_reference_id* -- a customer reference ID (customer ID token or referenced transaction sale)
175
+ # * *:discretionary_data* -- a hash of optional discretionary data to attach to this transaction
42
176
  # * *:return_clr* -- if set to "Y", card level results will be returned w/ the response. Card level results include whether or not the card is a consumer, purchasing, check, rewards, etc. account. Card level results are only returned with requests to process sales or authorizations through accounts on the TSYS/Vital, Heartland, Global, Paymentech, and Trident networks.(customer ID token sale)
43
177
  # * *:custom_dba* -- optional value that is sent to the cardholder’s issuer and overrides the business name stored in PayTrace. Custom DBA values are only used with requests to process sales or authorizations through accounts on the TSYS/Vital, Heartland, and Trident networks (customer ID token sale)
44
178
  # * *:enable_partial_authentication* -- flag that must be set to ‘Y’ in order to support partial authorization and balance amounts in transaction responses (customer ID token sale)
45
- def self.sale(args)
46
- create_transaction(args,TransactionTypes::SALE)
179
+ def self.customer_id_sale(params)
180
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
181
+ params.merge({transaction_type: TransactionTypes::SALE}),
182
+ CUSTID_SALE_REQUEST_REQUIRED,
183
+ CUSTID_SALE_REQUEST_OPTIONAL)
47
184
  end
48
185
 
49
186
  # See http://help.paytrace.com/api-authorizations
50
- # Performs an authorization transaction. Params (in hash format):
187
+ #
188
+ # Performs an authorization using a keyed in credit card.
189
+ #
190
+ # Required parameters:
191
+ #
192
+ # * *:amount* -- the amount of the transaction
193
+ # * *:card_number* -- the credit card number used
194
+ # * *:expiration_month* -- the expiration month of the credit card
195
+ # * *:expiration_year* -- the expiration year of the credit card
196
+ def self.keyed_authorization(params)
197
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
198
+ params.merge({transaction_type: TransactionTypes::Authorization}),
199
+ [:transaction_type, :amount, :card_number, :expiration_month, :expiration_year])
200
+ end
201
+
202
+ # See http://help.paytrace.com/api-authorizations
203
+ #
204
+ # Performs an authorization using a stored customer id.
205
+ #
206
+ # Required parameters:
207
+ #
208
+ # * *:amount* -- the amount of the transaction
209
+ # * *:customer_id* -- the customer ID to reference for this authorization
210
+ def self.customer_id_authorization(params)
211
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
212
+ params.merge({transaction_type: TransactionTypes::Authorization}), [:transaction_type, :amount, :customer_id])
213
+ end
214
+
215
+ # See http://help.paytrace.com/api-refunds
216
+ #
217
+ # Performs a refund using swiped credit card data.
218
+ #
219
+ # Required parameters:
220
+ #
221
+ # * *:amount* -- the amount of the transaction
222
+ # * *:swipe* -- credit card swipe data (card swiped sales)
223
+ #
224
+ # Optional parameters:
225
+ #
226
+ # * *:billing_name* -- the billing name for this transaction
227
+ # * *:billing_address* -- the billing street address for this transaction
228
+ # * *:billing_address2* -- the billing street address second line (e.g., apartment, suite) for this transaction
229
+ # * *:billing_city* -- the billing city for this transaction
230
+ # * *:billing_state* -- the billing state for this transaction
231
+ # * *:billing_postal_code* -- the billing zip code for this transaction
232
+ # * *:billing_country* -- the billing country for this transaction
233
+ # * *:shipping_name* -- the shipping name for this transaction
234
+ # * *:shipping_address* -- the shipping street address for this transaction
235
+ # * *:shipping_address2* -- the shipping street address second line (e.g., apartment, suite) for this transaction
236
+ # * *:shipping_city* -- the shipping city for this transaction
237
+ # * *:shipping_state* -- the shipping state for this transaction
238
+ # * *:shipping_postal_code* -- the shipping zip code for this transaction
239
+ # * *:shipping_region* -- the shipping region (e.g. county) for this transaction
240
+ # * *:shipping_country* -- the shipping country for this transaction
241
+ # * *:email* -- the customer email for this transaction
242
+ # * *:csc* -- credit card security code (customer ID token or referenced transaction sale)
243
+ # * *:invoice* -- an internal invoice number (customer ID token or referenced transaction sale)
244
+ # * *:description* -- a description of the sale (customer ID token or referenced transaction sale)
245
+ # * *:tax_amount* -- the amount of tax on the sale (customer ID token or referenced transaction sale)
246
+ # * *:customer_reference_id* -- a customer reference ID (customer ID token or referenced transaction sale)
247
+ # * *:discretionary_data* -- a hash of optional discretionary data to attach to this transaction
248
+ # * *:return_clr* -- if set to "Y", card level results will be returned w/ the response. Card level results include whether or not the card is a consumer, purchasing, check, rewards, etc. account. Card level results are only returned with requests to process sales or authorizations through accounts on the TSYS/Vital, Heartland, Global, Paymentech, and Trident networks.(customer ID token sale)
249
+ # * *:custom_dba* -- optional value that is sent to the cardholder’s issuer and overrides the business name stored in PayTrace. Custom DBA values are only used with requests to process sales or authorizations through accounts on the TSYS/Vital, Heartland, and Trident networks (customer ID token sale)
250
+ # * *:enable_partial_authentication* -- flag that must be set to ‘Y’ in order to support partial authorization and balance amounts in transaction responses (customer ID token sale)
251
+ def self.swiped_refund(params)
252
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
253
+ params.merge({transaction_type: TransactionTypes::Refund}), [:transaction_type, :amount, :swipe], REFUND_OPTIONAL)
254
+ end
255
+
256
+ # See http://help.paytrace.com/api-refunds
257
+ #
258
+ # Performs a refund using keyed-in credit card data.
259
+ #
260
+ # Required parameters:
261
+ #
262
+ # * *:amount* -- the amount of the transaction
263
+ # * *:card_number* -- the credit card number used
264
+ # * *:expiration_month* -- the expiration month of the credit card
265
+ # * *:expiration_year* -- the expiration year of the credit card
266
+ #
267
+ # _Note:_ optional parameters are identical to those for swiped_refund
268
+ def self.keyed_refund(params)
269
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
270
+ params.merge({transaction_type: TransactionTypes::Refund}), [
271
+ :transaction_type,
272
+ :amount,
273
+ :card_number,
274
+ :expiration_month,
275
+ :expiration_year], REFUND_OPTIONAL)
276
+ end
277
+
278
+
279
+ # See http://help.paytrace.com/api-refunds
280
+ #
281
+ # Performs a refund using a customer ID as a reference.
282
+ #
283
+ # Required parameters:
284
+ #
51
285
  # * *:amount* -- the amount of the transaction
52
- # Depending upon the type of authorization, the following additional parameters may be present:
53
- # * *:credit_card* -- a PayTrace::CreditCard object (standard authorization)
54
- # * *:customer* -- a PayTrace::Customer object (for additional customer data; customer ID token or referenced transaction sale). _Note:_ for discretionary data, the best way to include it is by adding it to the PayTrace::Customer object.
55
- # * *:optional* -- optional fields hash, kept inside the parameters
56
- # _Note:_ the following parameters are kept in the optional fields hash
57
- # * *:customer_id* -- a PayTrace customer ID (customer ID token auth)
58
- # * *:transaction_id* -- a transaction ID (referenced transaction sale)
59
- # * *:csc* -- credit card security code (customer ID token or referenced transaction auth)
60
- # * *:invoice* -- an internal invoice number (customer ID token or referenced transaction auth)
61
- # * *:description* -- a description of the auth (customer ID token or referenced transaction auth)
62
- # * *:tax_amount* -- the amount of tax on the auth (customer ID token or referenced transaction auth)
63
- # * *:customer_reference_id* -- a customer reference ID (customer ID token or referenced transaction auth)
64
- # * *:return_clr* -- if set to "Y", card level results will be returned w/ the response. Card level results include whether or not the card is a consumer, purchasing, check, rewards, etc. account. Card level results are only returned with requests to process auths or authorizations through accounts on the TSYS/Vital, Heartland, Global, Paymentech, and Trident networks.(customer ID token auth)
65
- # * *:custom_dba* -- optional value that is sent to the cardholder’s issuer and overrides the business name stored in PayTrace. Custom DBA values are only used with requests to process auths or authorizations through accounts on the TSYS/Vital, Heartland, and Trident networks (customer ID token auth)
66
- # * *:enable_partial_authentication* -- flag that must be set to ‘Y’ in order to support partial authorization and balance amounts in transaction responses (customer ID token auth)
67
- def self.authorization(args)
68
- create_transaction(args,TransactionTypes::Authorization)
286
+ # * *:customer_id -- the customer ID for the refund
287
+ #
288
+ # _Note:_ optional parameters are identical to those for swiped_refund
289
+ def self.customer_id_refund(params)
290
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
291
+ params.merge({transaction_type: TransactionTypes::Refund}), [:transaction_type, :amount, :customer_id], REFUND_OPTIONAL)
69
292
  end
70
293
 
294
+
71
295
  # See http://help.paytrace.com/api-refunds
72
- # Note that the parameters and transaction types are the same as for self.sale
73
- def self.refund(args)
74
- create_transaction(args,TransactionTypes::Refund)
296
+ #
297
+ # Performs a refund using a transaction ID as a reference.
298
+ #
299
+ # Required parameters:
300
+ #
301
+ # * *:amount* -- the amount of the transaction
302
+ # * *:transaction_id -- the customer ID for the refund
303
+ #
304
+ # _Note:_ optional parameters are identical to those for swiped_refund
305
+ def self.transaction_id_refund(params)
306
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
307
+ params.merge({transaction_type: TransactionTypes::Refund}), [:transaction_type, :transaction_id], REFUND_OPTIONAL)
75
308
  end
76
309
 
77
310
  # See http://help.paytrace.com/api-void
78
- # Performs a void request. Parameters are:
79
- # * *transaction_id* -- (_Note:_ this is _not_ in a hash!) the transaction ID to void
80
- def self.void(transaction_id)
81
- params = {transaction_id: transaction_id}
82
- t = Transaction.new({type: TransactionTypes::Void,
83
- optional:params})
84
- t.response = t.send_request
85
- t
311
+ #
312
+ # Performs a void request.
313
+ #
314
+ # Required parameters:
315
+ #
316
+ # * *:transaction_id* -- the transaction ID to void
317
+ def self.void(params)
318
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
319
+ params.merge({transaction_type: TransactionTypes::Void}), [:transaction_type, :transaction_id])
320
+ end
321
+
322
+ # See http://help.paytrace.com/api-forced-sale
323
+ #
324
+ # Performs a forced approval sale using swiped credit card data.
325
+ #
326
+ # Required parameters:
327
+ #
328
+ # * *:amount* -- the amount of the forced sale
329
+ # * *:swipe* -- credit card swipe data (card swiped sales)
330
+ # * *:approval_code* -- the approval code obtained external to the PayTrace system
331
+ def self.swiped_forced_sale(params)
332
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
333
+ params.merge({transaction_type: TransactionTypes::ForcedSale}), [:transaction_type, :amount, :swipe, :approval_code],
334
+ ADDRESSES_AND_EXTRA)
335
+ end
336
+
337
+ # See http://help.paytrace.com/api-forced-sale
338
+ #
339
+ # Performs a forced approval sale using keyed-in credit card data.
340
+ #
341
+ # Required parameters:
342
+ #
343
+ # * *:amount* -- the amount of the forced sale
344
+ # * *:card_number* -- the credit card number used
345
+ # * *:expiration_month* -- the expiration month of the credit card
346
+ # * *:expiration_year* -- the expiration year of the credit card
347
+ # * *:approval_code* -- the approval code obtained external to the PayTrace system
348
+ def self.keyed_forced_sale(params)
349
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
350
+ params.merge({transaction_type: TransactionTypes::ForcedSale}), [:transaction_type, :amount, :card_number, :expiration_month, :expiration_year, :approval_code],
351
+ ADDRESSES_AND_EXTRA)
352
+ end
353
+
354
+ # See http://help.paytrace.com/api-forced-sale
355
+ #
356
+ # Performs a forced approval sale using a customer ID as a reference.
357
+ #
358
+ # Required parameters:
359
+ #
360
+ # * *:amount* -- the amount of the forced sale
361
+ # * *:customer_id -- the customer ID for the forced sale
362
+ # * *:approval_code* -- the approval code obtained external to the PayTrace system
363
+ def self.customer_id_forced_sale(params)
364
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
365
+ params.merge({transaction_type: TransactionTypes::ForcedSale}), [:transaction_type, :amount, :customer_id, :approval_code],
366
+ ADDRESSES_AND_EXTRA)
86
367
  end
87
368
 
88
369
  # See http://help.paytrace.com/api-forced-sale
89
- # Performs a forced approval sale. Params are:
90
- # *approval_code* -- (_Note:_ this is _not_ in a hash!) the approval code obtained external to the PayTrace system
91
- # *args* -- the argument hash, see the arguments for self.sale
92
- def self.forced_sale(approval_code,args)
93
- args[:approval_code] = approval_code
94
- create_transaction(args,TransactionTypes::ForcedSale)
370
+ #
371
+ # Performs a forced approval sale using a transaction ID as a reference.
372
+ #
373
+ # Required parameters:
374
+ #
375
+ # * *:amount* -- the amount of the forced sale
376
+ # * *:transaction_id -- the transaction ID for the forced sale
377
+ # * *:approval_code* -- the approval code obtained external to the PayTrace system
378
+ def self.transaction_id_forced_sale(params)
379
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
380
+ params.merge({transaction_type: TransactionTypes::ForcedSale}), [:transaction_type, :transaction_id, :approval_code],
381
+ ADDRESSES_AND_EXTRA)
95
382
  end
96
383
 
97
384
  # See http://help.paytrace.com/api-capture
98
- # Capturing a transaction updates an approved authorization to a pending settlement status that will initiate a transfer of funds. Processing a capture through the PayTrace API may only be accomplished by providing the transaction ID of the unsettled transaction that should be settled. Params are:
385
+ #
386
+ # Capturing a transaction updates an approved authorization to a pending settlement status that will initiate a transfer of funds. Processing a capture through the PayTrace API may only be accomplished by providing the transaction ID of the unsettled transaction that should be settled.
387
+ #
388
+ # Required parameters:
389
+ #
99
390
  # * *transaction_id* -- the transaction ID to be captured
100
- def self.capture(transaction_id)
101
- t = Transaction.new({transaction_id: transaction_id, type: TransactionTypes::Capture,
102
- optional:params})
103
- t.response = t.send_request
104
- t
391
+ def self.capture(params)
392
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
393
+ params.merge({transaction_type: TransactionTypes::Capture}), [:transaction_type, :transaction_id])
105
394
  end
106
395
 
107
396
  # See http://help.paytrace.com/api-cash-advance
108
- # Processing a Cash Advance transaction is similar to processing a Sale, however Cash Advances are special transactions that result in cash disbursements to the card holder. Consequently, additional information is required to process Cash Advances. Cash Advances should always be swiped unless your card reader is not able to reader the card’s magnetic stripe. Additionally, your PayTrace account must be specially configured to process this type of transaction. Params are:
397
+ #
398
+ # Processing a Cash Advance transaction is similar to processing a Sale, however Cash Advances are special transactions that result in cash disbursements to the card holder. Consequently, additional information is required to process Cash Advances. Cash Advances should always be swiped unless your card reader is not able to reader the card’s magnetic stripe. Additionally, your PayTrace account must be specially configured to process this type of transaction.
399
+ #
109
400
  # * *:amount* -- the amount of the cash advance
110
- # Depending upon the type of cash advance, the following additional parameters may be present:
111
- # * *:credit_card* -- a PayTrace::CreditCard object (key entered cash advances)
112
- # * *:optional* -- optional fields hash, kept inside the parameters
113
- # _Note:_ the following parameters are kept in the optional fields hash
114
- # * *:swipe* -- swipe data provided with the cash advance (swiped cash advances)
115
- # * *:cash_advance* -- (swiped cash advances) When set to "Y", this attribute causes a Sale transaction to be processed as a cash advance where cash is given to the customer as opposed to a product or service. Please note that Cash Advances may only be processed on accounts that are set up on the TSYS/Vital network and are configured to process Cash Advances. Also, only swiped/card present Sales may include the CashAdvance parameter
116
- # * *:id_number* -- the card holder’s drivers license number or other form of photo ID
117
- # * *:id_expiration* -- the expiration date of the card holder’s photo ID. MM/DD/YYYY
118
- # * *:cc_last_4* -- the last 4 digits of the card number as it appears on the face of the card
119
- # * *:billing_address* -- a billing address provided with the cash advance
120
- # * *:shipping_address* -- a shipping address provided with the cash advance (key entered cash advances)
121
- # * *:csc* -- credit card security code (key entered cash advances)
122
- # * *:invoice* -- an internal invoice number (key entered cash advances)
123
- # * *:description* -- a description of the auth (key entered cash advances)
124
- # * *:tax_amount* -- the amount of tax on the auth (key entered cash advances)
125
- # * *:customer_reference_id* -- a customer reference ID (key entered cash advances)
126
- def self.cash_advance(args)
127
- args[:cash_advance] = "Y"
128
-
129
- create_transaction(args,TransactionTypes::SALE)
401
+ # * *:swipe* -- swipe data provided with the cash advance
402
+ # * *:id_number* -- the identification number of the photo ID used
403
+ # * *:id_expiration* -- the expiration date of the photo ID
404
+ # * *:cc_last_4* -- the last four digits of the credit card presented
405
+ # * *:billing_name* -- the billing name for this transaction
406
+ # * *:billing_address* -- the billing street address for this transaction
407
+ # * *:billing_address2* -- the billing street address second line (e.g., apartment, suite) for this transaction
408
+ # * *:billing_city* -- the billing city for this transaction
409
+ # * *:billing_state* -- the billing state for this transaction
410
+ # * *:billing_postal_code* -- the billing zip code for this transaction
411
+ #
412
+ # Optional parameters:
413
+ #
414
+ # * *:billing_country* -- the billing country for this transaction
415
+ # * *:shipping_name* -- the shipping name for this transaction
416
+ # * *:shipping_address* -- the shipping street address for this transaction
417
+ # * *:shipping_address2* -- the shipping street address second line (e.g., apartment, suite) for this transaction
418
+ # * *:shipping_city* -- the shipping city for this transaction
419
+ # * *:shipping_state* -- the shipping state for this transaction
420
+ # * *:shipping_postal_code* -- the shipping zip code for this transaction
421
+ # * *:shipping_region* -- the shipping region (e.g. county) for this transaction
422
+ # * *:email* -- the customer email for this transaction
423
+ # * *:csc* -- credit card security code (customer ID token or referenced transaction sale)
424
+ # * *:invoice* -- an internal invoice number (customer ID token or referenced transaction sale)
425
+ # * *:description* -- a description of the sale (customer ID token or referenced transaction sale)
426
+ # * *:tax_amount* -- the amount of tax on the sale (customer ID token or referenced transaction sale)
427
+ # * *:customer_reference_id* -- a customer reference ID (customer ID token or referenced transaction sale)
428
+ def self.swiped_cash_advance(params)
429
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
430
+ params.merge({transaction_type: TransactionTypes::SALE, cash_advance: 'Y'}), [
431
+ :transaction_type,
432
+ :amount,
433
+ :swipe,
434
+ :cash_advance,
435
+ :id_number,
436
+ :id_expiration,
437
+ :cc_last_4,
438
+ :billing_name,
439
+ :billing_address,
440
+ :billing_address2,
441
+ :billing_city,
442
+ :billing_state,
443
+ :billing_postal_code], CASH_ADVANCE_OPTIONAL)
130
444
  end
131
445
 
446
+ # See http://help.paytrace.com/api-cash-advance
447
+ #
448
+ # Processing a Cash Advance transaction is similar to processing a Sale, however Cash Advances are special transactions that result in cash disbursements to the card holder. Consequently, additional information is required to process Cash Advances. Cash Advances should always be swiped unless your card reader is not able to reader the card’s magnetic stripe. Additionally, your PayTrace account must be specially configured to process this type of transaction.
449
+ #
450
+ # * *:amount* -- the amount of the cash advance
451
+ # * *:card_number* -- the credit card number used
452
+ # * *:expiration_month* -- the expiration month of the credit card
453
+ # * *:expiration_year* -- the expiration year of the credit card
454
+ # * *:id_number* -- the identification number of the photo ID used
455
+ # * *:id_expiration* -- the expiration date of the photo ID
456
+ # * *:cc_last_4* -- the last four digits of the credit card presented
457
+ # * *:billing_name* -- the billing name for this transaction
458
+ # * *:billing_address* -- the billing street address for this transaction
459
+ # * *:billing_address2* -- the billing street address second line (e.g., apartment, suite) for this transaction
460
+ # * *:billing_city* -- the billing city for this transaction
461
+ # * *:billing_state* -- the billing state for this transaction
462
+ # * *:billing_postal_code* -- the billing zip code for this transaction
463
+ #
464
+ # Optional parameters:
465
+ #
466
+ # * *:billing_country* -- the billing country for this transaction
467
+ # * *:shipping_name* -- the shipping name for this transaction
468
+ # * *:shipping_address* -- the shipping street address for this transaction
469
+ # * *:shipping_address2* -- the shipping street address second line (e.g., apartment, suite) for this transaction
470
+ # * *:shipping_city* -- the shipping city for this transaction
471
+ # * *:shipping_state* -- the shipping state for this transaction
472
+ # * *:shipping_postal_code* -- the shipping zip code for this transaction
473
+ # * *:shipping_region* -- the shipping region (e.g. county) for this transaction
474
+ # * *:email* -- the customer email for this transaction
475
+ # * *:csc* -- credit card security code (customer ID token or referenced transaction sale)
476
+ # * *:invoice* -- an internal invoice number (customer ID token or referenced transaction sale)
477
+ # * *:description* -- a description of the sale (customer ID token or referenced transaction sale)
478
+ # * *:tax_amount* -- the amount of tax on the sale (customer ID token or referenced transaction sale)
479
+ # * *:customer_reference_id* -- a customer reference ID (customer ID token or referenced transaction sale)
480
+ def self.keyed_cash_advance(params)
481
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
482
+ params.merge({transaction_type: TransactionTypes::SALE, cash_advance: 'Y'}), [
483
+ :transaction_type,
484
+ :amount,
485
+ :card_number,
486
+ :expiration_month,
487
+ :expiration_year,
488
+ :cash_advance,
489
+ :id_number,
490
+ :id_expiration,
491
+ :cc_last_4,
492
+ :billing_name,
493
+ :billing_address,
494
+ :billing_address2,
495
+ :billing_city,
496
+ :billing_state,
497
+ :billing_postal_code], CASH_ADVANCE_OPTIONAL)
498
+ end
499
+
132
500
  # See http://help.paytrace.com/api-store-and-forward
501
+ #
133
502
  # Processing a store & forward through the PayTrace API will request that the transaction is stored for future authorization for specified amount. Please note that the authorization of the store & forward may be scheduled by provided a StrFwdDate value or manually via the Virtual Terminal. *Note that swiped account numbers and CSC values are not stored. Only the card number and expiration dates are stored from the swipe.*
134
- # All versions of store and forward may include the following parameters:
135
- # * *:amount* -- the amount of the store and forward
136
- # * *:optional* -- optional fields hash, kept inside the parameters
137
- # The swiped card version takes the following parameters:
138
- # * *:swipe* -- swipe data provided with the store and forward (in optional parameters hash)
139
- # The key entered version takes the following parameters:
140
- # * *:credit_card* -- additional credit card data
141
- # The customer ID (token) version takes the following parameters:
142
- # * *:customer_id* -- the customer ID (in optional parameters hash)
143
- # * *:customer* -- a PayTrace::Customer object for additional customer details
144
- # * *:csc* -- credit card security code (in optional parameters hash)
145
- # * *:invoice* -- an internal invoice number (in optional parameters hash)
146
- # * *:description* -- a description of the auth (in optional parameters hash)
147
- # * *:tax_amount* -- the amount of tax on the auth (in optional parameters hash)
148
- # * *:customer_reference_id* -- a customer reference ID (in optional parameters hash)
149
- # * *:return_clr* -- if set to "Y", card level results will be returned w/ the response. Card level results include whether or not the card is a consumer, purchasing, check, rewards, etc. account. Card level results are only returned with requests to process auths or authorizations through accounts on the TSYS/Vital, Heartland, Global, Paymentech, and Trident networks.(in optional parameters hash)
150
- # * *:custom_dba* -- optional value that is sent to the cardholder’s issuer and overrides the business name stored in PayTrace. Custom DBA values are only used with requests to process auths or authorizations through accounts on the TSYS/Vital, Heartland, and Trident networks (in optional parameters hash)
151
- # * *:enable_partial_authentication* -- flag that must be set to ‘Y’ in order to support partial authorization and balance amounts in transaction responses (in optional parameters hash)
152
- # * *:store_forward_date* -- optional future date when the transaction should be authorized and settled. Only applicable if the TranxType is STR/FWD (in optional parameters hash)
153
- def self.store_forward(amount,credit_card,args={})
154
- args[:amount] = amount
155
- args[:credit_card] = credit_card
156
- create_transaction(args,TransactionTypes::StoreForward)
503
+ #
504
+ # Required parameters:
505
+ #
506
+ # * *:amount* -- the amount of the sale
507
+ # * *:swipe* -- the swiped credit card information
508
+ #
509
+ # Optional parameters:
510
+ #
511
+ # * *:billing_name* -- the billing name for this transaction
512
+ # * *:billing_address* -- the billing street address for this transaction
513
+ # * *:billing_address2* -- the billing street address second line (e.g., apartment, suite) for this transaction
514
+ # * *:billing_city* -- the billing city for this transaction
515
+ # * *:billing_state* -- the billing state for this transaction
516
+ # * *:billing_postal_code* -- the billing zip code for this transaction
517
+ # * *:billing_country* -- the billing country for this transaction
518
+ # * *:shipping_name* -- the shipping name for this transaction
519
+ # * *:shipping_address* -- the shipping street address for this transaction
520
+ # * *:shipping_address2* -- the shipping street address second line (e.g., apartment, suite) for this transaction
521
+ # * *:shipping_city* -- the shipping city for this transaction
522
+ # * *:shipping_state* -- the shipping state for this transaction
523
+ # * *:shipping_postal_code* -- the shipping zip code for this transaction
524
+ # * *:shipping_region* -- the shipping region (e.g. county) for this transaction
525
+ # * *:shipping_country* -- the shipping country for this transaction
526
+ # * *:email* -- the customer email for this transaction
527
+ # * *:csc* -- credit card security code (customer ID token or referenced transaction sale)
528
+ # * *:invoice* -- an internal invoice number (customer ID token or referenced transaction sale)
529
+ # * *:description* -- a description of the sale (customer ID token or referenced transaction sale)
530
+ # * *:tax_amount* -- the amount of tax on the sale (customer ID token or referenced transaction sale)
531
+ # * *:customer_reference_id* -- a customer reference ID (customer ID token or referenced transaction sale)
532
+ # * *:discretionary_data* -- a hash of optional discretionary data to attach to this transaction
533
+ # * *:return_clr* -- if set to "Y", card level results will be returned w/ the response. Card level results include whether or not the card is a consumer, purchasing, check, rewards, etc. account. Card level results are only returned with requests to process sales or authorizations through accounts on the TSYS/Vital, Heartland, Global, Paymentech, and Trident networks.(customer ID token sale)
534
+ # * *:custom_dba* -- optional value that is sent to the cardholder’s issuer and overrides the business name stored in PayTrace. Custom DBA values are only used with requests to process sales or authorizations through accounts on the TSYS/Vital, Heartland, and Trident networks (customer ID token sale)
535
+ # * *:enable_partial_authentication* -- flag that must be set to ‘Y’ in order to support partial authorization and balance amounts in transaction responses (customer ID token sale)
536
+ # * *:store_forward_date* -- optional future date when the transaction should be authorized and settled. Only applicable if the TranxType is STR/FWD
537
+ def self.swiped_store_forward(params)
538
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
539
+ params.merge({transaction_type: TransactionTypes::StoreForward}), [:transaction_type, :amount, :swipe], STORE_AND_FORWARD_OPTIONAL)
157
540
  end
158
541
 
159
- # :nodoc:
160
- def self.create_transaction(args,type)
161
- amount = args.delete(:amount) if args[:amount]
162
- cc = CreditCard.new(args.delete(:credit_card)) if args[:credit_card]
163
- customer = args.delete(:customer) if args[:customer]
164
-
165
- t = Transaction.new({
166
- amount: amount,
167
- credit_card: cc,
168
- customer: customer,
169
- type: type,
170
- optional:args})
171
- t.send_request
172
-
173
- t
542
+ # See http://help.paytrace.com/api-store-and-forward
543
+ #
544
+ # Processing a store & forward through the PayTrace API will request that the transaction is stored for future authorization for specified amount. Please note that the authorization of the store & forward may be scheduled by provided a StrFwdDate value or manually via the Virtual Terminal. *Note that swiped account numbers and CSC values are not stored. Only the card number and expiration dates are stored from the swipe.*
545
+ #
546
+ # Required parameters:
547
+ #
548
+ # * *:amount* -- the amount of the sale
549
+ # * *:card_number* -- the credit card number
550
+ # * *:expiration_month* -- the expiration month of the credit card
551
+ # * *:expiration_year* -- the expiration year of the credit card
552
+ #
553
+ # Optional parameters:
554
+ #
555
+ # * *:billing_name* -- the billing name for this transaction
556
+ # * *:billing_address* -- the billing street address for this transaction
557
+ # * *:billing_address2* -- the billing street address second line (e.g., apartment, suite) for this transaction
558
+ # * *:billing_city* -- the billing city for this transaction
559
+ # * *:billing_state* -- the billing state for this transaction
560
+ # * *:billing_postal_code* -- the billing zip code for this transaction
561
+ # * *:billing_country* -- the billing country for this transaction
562
+ # * *:shipping_name* -- the shipping name for this transaction
563
+ # * *:shipping_address* -- the shipping street address for this transaction
564
+ # * *:shipping_address2* -- the shipping street address second line (e.g., apartment, suite) for this transaction
565
+ # * *:shipping_city* -- the shipping city for this transaction
566
+ # * *:shipping_state* -- the shipping state for this transaction
567
+ # * *:shipping_postal_code* -- the shipping zip code for this transaction
568
+ # * *:shipping_region* -- the shipping region (e.g. county) for this transaction
569
+ # * *:shipping_country* -- the shipping country for this transaction
570
+ # * *:email* -- the customer email for this transaction
571
+ # * *:csc* -- credit card security code (customer ID token or referenced transaction sale)
572
+ # * *:invoice* -- an internal invoice number (customer ID token or referenced transaction sale)
573
+ # * *:description* -- a description of the sale (customer ID token or referenced transaction sale)
574
+ # * *:tax_amount* -- the amount of tax on the sale (customer ID token or referenced transaction sale)
575
+ # * *:customer_reference_id* -- a customer reference ID (customer ID token or referenced transaction sale)
576
+ # * *:discretionary_data* -- a hash of optional discretionary data to attach to this transaction
577
+ # * *:return_clr* -- if set to "Y", card level results will be returned w/ the response. Card level results include whether or not the card is a consumer, purchasing, check, rewards, etc. account. Card level results are only returned with requests to process sales or authorizations through accounts on the TSYS/Vital, Heartland, Global, Paymentech, and Trident networks.(customer ID token sale)
578
+ # * *:custom_dba* -- optional value that is sent to the cardholder’s issuer and overrides the business name stored in PayTrace. Custom DBA values are only used with requests to process sales or authorizations through accounts on the TSYS/Vital, Heartland, and Trident networks (customer ID token sale)
579
+ # * *:enable_partial_authentication* -- flag that must be set to ‘Y’ in order to support partial authorization and balance amounts in transaction responses (customer ID token sale)
580
+ # * *:store_forward_date* -- optional future date when the transaction should be authorized and settled. Only applicable if the TranxType is STR/FWD
581
+ def self.keyed_store_forward(params)
582
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
583
+ params.merge({transaction_type: TransactionTypes::StoreForward}), [:transaction_type, :amount, :card_number, :expiration_month, :expiration_year], STORE_AND_FORWARD_OPTIONAL)
174
584
  end
175
585
 
176
- # Not meant to be called directly; use static helper methods instead
177
- def initialize(params = {})
178
- @amount = params[:amount]
179
- @credit_card = params[:credit_card]
180
- @type = params[:type]
181
- @customer = params[:customer]
182
- @discretionary_data = params[:discretionary_data] || {}
183
- include_optional(params[:optional]) if params[:optional]
586
+ # See http://help.paytrace.com/api-store-and-forward
587
+ #
588
+ # Processing a store & forward through the PayTrace API will request that the transaction is stored for future authorization for specified amount. Please note that the authorization of the store & forward may be scheduled by provided a StrFwdDate value or manually via the Virtual Terminal. *Note that swiped account numbers and CSC values are not stored. Only the card number and expiration dates are stored from the swipe.*
589
+ #
590
+ # Required parameters:
591
+ #
592
+ # * *:amount* -- the amount of the sale
593
+ # * *:customer_id* -- the customer ID for the sale
594
+ #
595
+ # Optional parameters:
596
+ #
597
+ # * *:billing_name* -- the billing name for this transaction
598
+ # * *:billing_address* -- the billing street address for this transaction
599
+ # * *:billing_address2* -- the billing street address second line (e.g., apartment, suite) for this transaction
600
+ # * *:billing_city* -- the billing city for this transaction
601
+ # * *:billing_state* -- the billing state for this transaction
602
+ # * *:billing_postal_code* -- the billing zip code for this transaction
603
+ # * *:billing_country* -- the billing country for this transaction
604
+ # * *:shipping_name* -- the shipping name for this transaction
605
+ # * *:shipping_address* -- the shipping street address for this transaction
606
+ # * *:shipping_address2* -- the shipping street address second line (e.g., apartment, suite) for this transaction
607
+ # * *:shipping_city* -- the shipping city for this transaction
608
+ # * *:shipping_state* -- the shipping state for this transaction
609
+ # * *:shipping_postal_code* -- the shipping zip code for this transaction
610
+ # * *:shipping_region* -- the shipping region (e.g. county) for this transaction
611
+ # * *:shipping_country* -- the shipping country for this transaction
612
+ # * *:email* -- the customer email for this transaction
613
+ # * *:csc* -- credit card security code (customer ID token or referenced transaction sale)
614
+ # * *:invoice* -- an internal invoice number (customer ID token or referenced transaction sale)
615
+ # * *:description* -- a description of the sale (customer ID token or referenced transaction sale)
616
+ # * *:tax_amount* -- the amount of tax on the sale (customer ID token or referenced transaction sale)
617
+ # * *:customer_reference_id* -- a customer reference ID (customer ID token or referenced transaction sale)
618
+ # * *:discretionary_data* -- a hash of optional discretionary data to attach to this transaction
619
+ # * *:return_clr* -- if set to "Y", card level results will be returned w/ the response. Card level results include whether or not the card is a consumer, purchasing, check, rewards, etc. account. Card level results are only returned with requests to process sales or authorizations through accounts on the TSYS/Vital, Heartland, Global, Paymentech, and Trident networks.(customer ID token sale)
620
+ # * *:custom_dba* -- optional value that is sent to the cardholder’s issuer and overrides the business name stored in PayTrace. Custom DBA values are only used with requests to process sales or authorizations through accounts on the TSYS/Vital, Heartland, and Trident networks (customer ID token sale)
621
+ # * *:enable_partial_authentication* -- flag that must be set to ‘Y’ in order to support partial authorization and balance amounts in transaction responses (customer ID token sale)
622
+ # * *:store_forward_date* -- optional future date when the transaction should be authorized and settled. Only applicable if the TranxType is STR/FWD
623
+ def self.customer_id_store_forward(params)
624
+ PayTrace::API::Gateway.send_request(TRANSACTION_METHOD,
625
+ params.merge({transaction_type: TransactionTypes::StoreForward}), [:transaction_type, :amount, :customer_id], STORE_AND_FORWARD_OPTIONAL)
184
626
  end
185
627
 
186
- # Internal helper method
187
- def set_request(request)
188
- add_credit_card(request, credit_card) if credit_card
189
- if customer.is_a?(PayTrace::Customer)
190
- customer.set_request_data(request)
191
- elsif customer.is_a?(Fixnum)
192
- request.set_param(:customer_id, customer)
193
- end
194
- add_transaction_info(request)
195
- add_addresses(request)
196
- add_optional_fields(request) if optional_fields
197
- if @discretionary_data.any?
198
- request.set_discretionary(@discretionary_data)
199
- end
628
+ # See http://help.paytrace.com/api-export-transaction-information
629
+ #
630
+ # Exports transaction information.
631
+ #
632
+ # Required parameters:
633
+ #
634
+ # * *:transaction_id* -- a specific transaction ID to export, _or_
635
+ # * *:start_date* -- a start date for a range of transactions to export
636
+ # * *:end_date* -- an end date for a range of transactions to export
637
+ # * *:transaction_type* -- the type of transaction to export (optional)
638
+ # * *:customer_id* -- a specific customer ID to export transactions for (optional)
639
+ # * *:transaction_user* -- the user who created the transaction (optional)
640
+ # * *:return_bin* -- if set to 'Y', card numbers from ExportTranx and ExportCustomers requests will include the first 6 and last 4 digits of the card number (optional)
641
+ # * *:search_text* -- text that will be searched to narrow down transaction and check results for ExportTranx and ExportCheck requests (optional)
642
+ def self.export_by_date_range(params = {})
643
+ response = PayTrace::API::Gateway.send_request(EXPORT_TRANSACTIONS_METHOD, params, [:start_date, :end_date], [
644
+ :transaction_type,
645
+ :customer_id,
646
+ :transaction_user,
647
+ :return_bin,
648
+ :search_text])
649
+ response.parse_records(EXPORT_TRANSACTIONS_RESPONSE)
200
650
  end
201
- # :doc:
202
651
 
203
652
  # See http://help.paytrace.com/api-export-transaction-information
653
+ #
204
654
  # Exports transaction information.
205
- # Parameters hash:
655
+ #
656
+ # Required parameters:
657
+ #
206
658
  # * *:transaction_id* -- a specific transaction ID to export, _or_
207
659
  # * *:start_date* -- a start date for a range of transactions to export
208
660
  # * *:end_date* -- an end date for a range of transactions to export
@@ -211,55 +663,55 @@ module PayTrace
211
663
  # * *:transaction_user* -- the user who created the transaction (optional)
212
664
  # * *:return_bin* -- if set to 'Y', card numbers from ExportTranx and ExportCustomers requests will include the first 6 and last 4 digits of the card number (optional)
213
665
  # * *:search_text* -- text that will be searched to narrow down transaction and check results for ExportTranx and ExportCheck requests (optional)
214
- def self.export(params = {})
215
- request = PayTrace::API::Request.new
216
- request.set_param(:method, EXPORT_TRANSACTIONS_METHOD)
217
- request.set_params([
218
- :transaction_id,
219
- :start_date,
220
- :end_date,
666
+ def self.export_by_id(params = {})
667
+ response = PayTrace::API::Gateway.send_request(EXPORT_TRANSACTIONS_METHOD, params, [:transaction_id], [
221
668
  :transaction_type,
222
669
  :customer_id,
223
670
  :transaction_user,
224
671
  :return_bin,
225
- :search_text], params)
226
-
227
- gateway = PayTrace::API::Gateway.new
228
- response = gateway.send_request(request, [EXPORT_TRANSACTIONS_RESPONSE])
229
-
230
- unless response.has_errors?
231
- response.values[EXPORT_TRANSACTIONS_RESPONSE]
232
- end
672
+ :search_text])
673
+ response.parse_records(EXPORT_TRANSACTIONS_RESPONSE)
233
674
  end
234
675
 
235
676
  # See http://help.paytrace.com/api-signature-capture-image
677
+ #
236
678
  # Attach Signature Request -- allows attaching a signature image to a transactions
237
- # Parameters hash includes:
679
+ #
680
+ # Required parameters:
681
+ #
238
682
  # * *:transaction_id* -- the transaction ID to attach a signature image
239
- # * *:image_data* -- the Base64 encoded image data
240
- # * *:image_type* -- the type of image attached (e.g. "PNG", "JPG", etc.)
241
683
  # * *:image_file* -- the filename of an image file to load and Base64 encode
242
- # _Note:_ only include the :image_data _or_ :image_file parameters. Also note that (due to technical limitations) if you supply the :image_file parameter, you must still supply the :image_type parameter.
243
- def self.attach_signature(params = {})
244
- request = PayTrace::API::Request.new
245
- request.set_param(:method, ATTACH_SIGNATURE_METHOD)
246
- request.set_params([:transaction_id,
247
- :image_data,
248
- :image_type], params)
249
- if params.has_key?(:image_file)
250
- File.open(params[:image_file], 'rb') do |file|
251
- request.set_param(:image_data, Base64.encode64(file.read))
252
- end
684
+ # * *:image_type* -- the type of image attached (e.g. "PNG", "JPG", etc.)
685
+ def self.attach_signature_file(params = {})
686
+ params = params.dup
687
+ File.open(params[:image_file], 'rb') do |file|
688
+ params[:image_data] = Base64.encode64(file.read)
689
+ params.delete(:image_file)
253
690
  end
254
691
 
255
- gateway = PayTrace::API::Gateway.new
256
- gateway.send_request(request)
692
+ PayTrace::API::Gateway.send_request(ATTACH_SIGNATURE_METHOD, params, [:transaction_id, :image_data, :image_type])
693
+ end
694
+
695
+ # See http://help.paytrace.com/api-signature-capture-image
696
+ #
697
+ # Attach Signature Request -- allows attaching a signature image to a transactions
698
+ #
699
+ # Required parameters:
700
+ #
701
+ # * *:transaction_id* -- the transaction ID to attach a signature image
702
+ # * *:image_data* -- the base-64 encoded image data of a signature
703
+ # * *:image_type* -- the type of image attached (e.g. "PNG", "JPG", etc.)
704
+ def self.attach_signature_data(params = {})
705
+ PayTrace::API::Gateway.send_request(ATTACH_SIGNATURE_METHOD, params, [:transaction_id, :image_data, :image_type])
257
706
  end
258
707
 
259
708
  # See http://help.paytrace.com/api-calculate-shipping-rates
709
+ #
260
710
  # Calculates the estimaged shipping cost to send a package of a given weight from a source zip to a destination.
261
711
  # Returns an array of potential shippers, such as USPS, Fedex, etc., and the estimated cost to ship the package
262
- # Params hash includes:
712
+ #
713
+ # Required parameters:
714
+ #
263
715
  # * *:source_zip* -- the zip code the package will be shipped from
264
716
  # * *:source_state* -- the state the package will be shipped from
265
717
  # * *:shipping_postal_code* -- the postal (zip) code the package will be shipped to
@@ -267,22 +719,15 @@ module PayTrace
267
719
  # * *:shipping_weight* -- the weight of the package
268
720
  # * *:shippers* -- string of shipping service providers you would like shipping quotes from. String may contain USPS, FEDEX, or UPS, separated by commas, in any order or combination
269
721
  def self.calculate_shipping(params = {})
270
- request = PayTrace::API::Request.new
271
- request.set_param(:method, CALCULATE_SHIPPING_COST)
272
- request.set_params([
722
+ response = PayTrace::API::Gateway.send_request(CALCULATE_SHIPPING_COST, params, [
273
723
  :source_zip,
274
724
  :source_state,
275
725
  :shipping_postal_code,
276
726
  :shipping_state,
277
727
  :shipping_weight,
278
728
  :shippers
279
- ], params)
280
-
281
- gateway = PayTrace::API::Gateway.new
282
- response = gateway.send_request(request, [CALCULATE_SHIPPING_COST_RESPONSE])
283
- unless response.has_errors?
284
- response.values[CALCULATE_SHIPPING_COST_RESPONSE]
285
- end
729
+ ])
730
+ response.parse_records(CALCULATE_SHIPPING_COST_RESPONSE)
286
731
  end
287
732
 
288
733
  # See http://help.paytrace.com/api-adding-level-3-data-to-a-visa-sale
@@ -331,11 +776,10 @@ module PayTrace
331
776
  # * *:discount_li* -- discount amount applied to the transaction amount in reference to this line item record
332
777
  # * *:amount_li* -- total amount included in the transaction amount generated from this line item record
333
778
  def self.add_level_three_visa(params = {})
779
+ params = params.dup # don't modify the original!
780
+
334
781
  line_items = params.delete(:line_items) || []
335
- request = PayTrace::API::Request.new
336
- request.set_param(:method, LEVEL_3_VISA_METHOD)
337
- request.set_params([
338
- :transaction_id,
782
+ PayTrace::API::Gateway.send_request(LEVEL_3_VISA_METHOD, params, [:transaction_id], [
339
783
  :invoice,
340
784
  :customer_reference_id,
341
785
  :tax_amount,
@@ -351,15 +795,26 @@ module PayTrace
351
795
  :shipping_country,
352
796
  :add_tax,
353
797
  :add_tax_rate
354
- ], params)
355
- line_items.each do |li|
356
- request.set_multivalue(:line_item, li)
357
- end
358
-
359
- gateway = PayTrace::API::Gateway.new
360
- response = gateway.send_request(request)
361
- unless response.has_errors?
362
- response.values
798
+ ]) do |request|
799
+
800
+ line_items.each do |li|
801
+ missing, extra = PayTrace::API::Request.process_param_list([
802
+ :ccode_li,
803
+ :product_id,
804
+ :description,
805
+ :quantity,
806
+ :measure,
807
+ :unit_cost,
808
+ :add_tax_li,
809
+ :add_tax_rate_li,
810
+ :discount_li,
811
+ :amount_li
812
+ ], li)
813
+ if extra.any?
814
+ raise PayTrace::Exceptions::ValidationError.new("The following line-item parameters are unknown: #{extra.to_s}")
815
+ end
816
+ request.set_multivalue(:line_item, li)
817
+ end
363
818
  end
364
819
  end
365
820
 
@@ -411,11 +866,10 @@ module PayTrace
411
866
  # * *:discount_li* -- discount amount applied to the transaction amount in reference to this line item record
412
867
  # * *:discount_rate* -- rate at which discount was applied to the transaction in reference to this specific line item
413
868
  def self.add_level_three_mc(params = {})
869
+ params = params.dup # don't modify the original!
870
+
414
871
  line_items = params.delete(:line_items) || []
415
- request = PayTrace::API::Request.new
416
- request.set_param(:method, LEVEL_3_MC_METHOD)
417
- request.set_params([
418
- :transaction_id,
872
+ response = PayTrace::API::Gateway.send_request(LEVEL_3_MC_METHOD, params, [:transaction_id], [
419
873
  :invoice,
420
874
  :customer_reference_id,
421
875
  :tax_amount,
@@ -427,15 +881,31 @@ module PayTrace
427
881
  :shipping_country,
428
882
  :add_tax,
429
883
  :additional_tax_included
430
- ], params)
431
- line_items.each do |li|
432
- request.set_multivalue(:line_item, li)
433
- end
434
-
435
- gateway = PayTrace::API::Gateway.new
436
- response = gateway.send_request(request)
437
- unless response.has_errors?
438
- response.values
884
+ ]) do |request|
885
+
886
+ line_items.each do |li|
887
+ missing, extra = PayTrace::API::Request.process_param_list([
888
+ :product_id,
889
+ :description,
890
+ :quantity,
891
+ :measure,
892
+ :merchant_tax_id,
893
+ :unit_cost,
894
+ :add_tax_li,
895
+ :add_tax_rate_li,
896
+ :additional_tax_included_li,
897
+ :amount_li,
898
+ :discount_included,
899
+ :discount_li,
900
+ :discount_rate,
901
+ :is_debit_or_credit,
902
+ :line_item_is_gross
903
+ ], li)
904
+ if extra.any?
905
+ raise PayTrace::Exceptions::ValidationError.new("The following line-item parameters are unknown: #{extra.to_s}")
906
+ end
907
+ request.set_multivalue(:line_item, li)
908
+ end
439
909
  end
440
910
  end
441
911
 
@@ -444,11 +914,8 @@ module PayTrace
444
914
  # Transactions processed through merchant accounts that are set up on the TSYS/Vital network or other terminal-based networks may initiate the settlement of batches through the PayTrace API.
445
915
  #
446
916
  # No parameters are required.
447
- def self.settle_transaction(params = {})
448
- request = PayTrace::API::Request.new
449
- request.set_param(:method, SETTLE_TRANSACTION_METHOD)
450
- gateway = PayTrace::API::Gateway.new
451
- gateway.send_request(request)
917
+ def self.settle_transactions(params = {})
918
+ PayTrace::API::Gateway.send_request(SETTLE_TRANSACTION_METHOD, [], {})
452
919
  end
453
920
 
454
921
  # See http://help.paytrace.com/api-adjusting-transaction-amounts
@@ -462,70 +929,16 @@ module PayTrace
462
929
  #
463
930
  # Please note that amounts for cash advance transaction may also not be adjusted.
464
931
  #
465
- # The parameters hash includes the following required parameters:
932
+ # Required parameters:
466
933
  #
467
934
  # *:transaction_id* -- a unique identifier for each transaction in the PayTrace system. This value is returned in the TRANSACTIONID parameter of an API response and will consequently be included in requests to email receipts, void transactions, add level 3 data, etc
468
935
  # *:amount* -- dollar amount of the transaction. Must be a positive number up to two decimal places
469
936
  def self.adjust_amount(params = {})
470
- request = PayTrace::API::Request.new
471
- request.set_param(:method, ADJUST_AMOUNT_METHOD)
472
- request.set_param(:transaction_id, params[:transaction_id])
473
- request.set_param(:amount, params[:amount])
474
- gateway = PayTrace::API::Gateway.new
475
- gateway.send_request(request)
476
- end
477
-
478
- # :nodoc:
479
- def add_transaction_info(request)
480
- request.set_param(:transaction_type, type)
481
- request.set_param(:method, TRANSACTION_METHOD)
482
- request.set_param(:amount, amount)
483
- end
484
-
485
- def add_credit_card(request, cc)
486
- cc.set_request_data(request)
487
- end
488
-
489
- def add_optional_fields(request)
490
- o = optional_fields
491
- o.each do |k,v|
492
- request.set_param(k, v)
493
- end
494
-
495
-
496
- end
497
-
498
- def add_addresses(request)
499
- shipping_address.set_request(request) if shipping_address
500
- billing_address.set_request(request) if billing_address
501
- end
502
-
503
- def include_optional(args)
504
- s = nil
505
- b = nil
506
-
507
- b = args.delete(:billing_address) if args[:billing_address]
508
- @billing_address = PayTrace::Address.new({address_type: :billing}.merge(b)) if b
509
- s = args.delete(:shipping_address) if args[:shipping_address]
510
- @shipping_address = PayTrace::Address.new({address_type: :shipping}.merge(s)) if s
511
- if args[:address_shipping_same_as_billing]
512
- @shipping_address = @billing_address
513
- end
514
-
515
- if args.any?
516
- @optional_fields = args
517
- end
518
- end
519
-
520
- def send_request
521
- request = PayTrace::API::Request.new
522
- self.set_request(request)
523
-
524
- gateway = PayTrace::API::Gateway.new
525
- gateway.send_request(request)
937
+ PayTrace::API::Gateway.send_request(ADJUST_AMOUNT_METHOD, params, [:transaction_id, :amount])
526
938
  end
527
939
  end
528
940
 
941
+ # enumeration of transaction subtypes
529
942
  module TransactionTypes
530
943
  SALE = "SALE"
531
944
  Authorization = "Authorization"