paytrace 0.1.20 → 0.1.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c5e82942b71219987900a9ece01e48f70b44833
4
- data.tar.gz: 8bb191238ff8bbf79bcc5afcf2011d1e0578d353
3
+ metadata.gz: 151f729f1e86c8a9dd7f218afe022017af0c9c5f
4
+ data.tar.gz: 8e5bae858b0e4825466d61fd8084f56d94b43dd5
5
5
  SHA512:
6
- metadata.gz: f374f6d857de369ec8554404108057191b71e4a9d04f4b9c23f247eafdd25124fdfa9f5e659acf91f11b18463352df8e7b6340db2fbc35ee718e4662fa593a18
7
- data.tar.gz: 2b9ec845d6a698605509144cf7aae2fa3b25ba62a802ad95d6036943de2b5009412af076e3efe21bf8b5f636edb097f96507efa36c9569adbbff622f40aab073
6
+ metadata.gz: 7c704b30039685e4f063bb4906ce383d3a14805ef5aafc0fd533b94b63b5771d3e42eff7e9b4bcf1d928e558512a91334eef0c98d0e00558217fda368859e25e
7
+ data.tar.gz: d3b6bbdd08257974328db8713cdfc62d94880bd4c3cb0f193af3ea10f9f514f052e33de7424c22cb1f080ef9afae69ddb669e45dd34e885868c24fb2ff8897d2
@@ -4,6 +4,7 @@ module PayTrace
4
4
  class Response
5
5
  attr_reader :values, :errors
6
6
 
7
+ # Called by the PayTrace::API::Gateway object to initialize a response
7
8
  def initialize(response_string, multi_value_fields = [])
8
9
  @field_delim = "|"
9
10
  @value_delim = "~"
@@ -13,14 +14,17 @@ module PayTrace
13
14
  parse_response(response_string, multi_value_fields)
14
15
  end
15
16
 
17
+ # Returns the response code(s) received
16
18
  def response_code
17
19
  get_response
18
20
  end
19
21
 
22
+ # Returns true if the response contained any error codes
20
23
  def has_errors?
21
- @errors.length > 0
24
+ @errors.length > 0
22
25
  end
23
26
 
27
+ # Called by the initialize method
24
28
  def parse_response(response_string, multi_value_fields = [])
25
29
 
26
30
  if (response_string.include? "ERROR")
@@ -39,6 +43,7 @@ module PayTrace
39
43
  end
40
44
  end
41
45
 
46
+ # Called by the framework in the event of an error response
42
47
  def parse_errors(response_string)
43
48
  pairs = response_string.split(@field_delim)
44
49
  pairs.each do |p|
@@ -48,11 +53,13 @@ module PayTrace
48
53
  end
49
54
  end
50
55
 
56
+ # Internal use only
51
57
  def generate_error_key(key,value)
52
58
  #get the error number from the value
53
59
  return key +'-'+ value[/([1-9]*)/,1]
54
60
  end
55
61
 
62
+ # Returns any status code(s) or error code(s) received
56
63
  def get_response()
57
64
  if has_errors?
58
65
  return get_error_response()
@@ -60,6 +67,7 @@ module PayTrace
60
67
  @values["RESPONSE"]
61
68
  end
62
69
 
70
+ # Returns any error code(s) received
63
71
  def get_error_response()
64
72
  error_message = ""
65
73
  @errors.each do |k,v|
@@ -173,6 +173,7 @@ module PayTrace
173
173
  t
174
174
  end
175
175
 
176
+ # Not meant to be called directly; use static helper methods instead
176
177
  def initialize(params = {})
177
178
  @amount = params[:amount]
178
179
  @credit_card = params[:credit_card]
@@ -182,6 +183,7 @@ module PayTrace
182
183
  include_optional(params[:optional]) if params[:optional]
183
184
  end
184
185
 
186
+ # Internal helper method
185
187
  def set_request(request)
186
188
  add_credit_card(request, credit_card) if credit_card
187
189
  if customer.is_a?(PayTrace::Customer)
@@ -198,7 +200,17 @@ module PayTrace
198
200
  end
199
201
  # :doc:
200
202
 
201
-
203
+ # See http://help.paytrace.com/api-export-transaction-information
204
+ # Exports transaction information.
205
+ # Parameters hash:
206
+ # * *:transaction_id* -- a specific transaction ID to export, _or_
207
+ # * *:start_date* -- a start date for a range of transactions to export
208
+ # * *:end_date* -- an end date for a range of transactions to export
209
+ # * *:transaction_type* -- the type of transaction to export (optional)
210
+ # * *:customer_id* -- a specific customer ID to export transactions for (optional)
211
+ # * *:transaction_user* -- the user who created the transaction (optional)
212
+ # * *: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
+ # * *:search_text* -- text that will be searched to narrow down transaction and check results for ExportTranx and ExportCheck requests (optional)
202
214
  def self.export(params = {})
203
215
  request = PayTrace::API::Request.new
204
216
  request.set_param(:method, EXPORT_TRANSACTIONS_METHOD)
@@ -220,6 +232,14 @@ module PayTrace
220
232
  end
221
233
  end
222
234
 
235
+ # See http://help.paytrace.com/api-signature-capture-image
236
+ # Attach Signature Request -- allows attaching a signature image to a transactions
237
+ # Parameters hash includes:
238
+ # * *: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
+ # * *: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.
223
243
  def self.attach_signature(params = {})
224
244
  request = PayTrace::API::Request.new
225
245
  request.set_param(:method, ATTACH_SIGNATURE_METHOD)
@@ -236,10 +256,27 @@ module PayTrace
236
256
  gateway.send_request(request)
237
257
  end
238
258
 
259
+ # See http://help.paytrace.com/api-calculate-shipping-rates
260
+ # Calculates the estimaged shipping cost to send a package of a given weight from a source zip to a destination.
261
+ # Returns an array of potential shippers, such as USPS, Fedex, etc., and the estimated cost to ship the package
262
+ # Params hash includes:
263
+ # * *:source_zip* -- the zip code the package will be shipped from
264
+ # * *:source_state* -- the state the package will be shipped from
265
+ # * *:shipping_postal_code* -- the postal (zip) code the package will be shipped to
266
+ # * *:shipping_state* -- the state the package will be shipped to
267
+ # * *:shipping_weight* -- the weight of the package
268
+ # * *: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
239
269
  def self.calculate_shipping(params = {})
240
270
  request = PayTrace::API::Request.new
241
271
  request.set_param(:method, CALCULATE_SHIPPING_COST)
242
- request.set_params(params.keys, params)
272
+ request.set_params([
273
+ :source_zip,
274
+ :source_state,
275
+ :shipping_postal_code,
276
+ :shipping_state,
277
+ :shipping_weight,
278
+ :shippers
279
+ ], params)
243
280
 
244
281
  gateway = PayTrace::API::Gateway.new
245
282
  response = gateway.send_request(request, [CALCULATE_SHIPPING_COST_RESPONSE])
@@ -248,6 +285,51 @@ module PayTrace
248
285
  end
249
286
  end
250
287
 
288
+ # See http://help.paytrace.com/api-adding-level-3-data-to-a-visa-sale
289
+ #
290
+ # Level 3 data is additional information that may be applied to enrich a transaction’s reporting value to both the merchant and the customers. Generally, merchant service providers offer reduced or qualified pricing for transactions that are processed with Level 3 data.
291
+ #
292
+ # Level 3 data may be added to any Visa or MasterCard sale that is approved and pending settlement. Some level 3 data, specifically enhanced data such as Invoice and Customer Reference ID, may overlap with data provided with the base transaction. Enhanced data, when applied, will always overwrite such data that may already be stored with the transaction.
293
+ #
294
+ # Level 3 data consists of enhanced data and 1 or more line item records. This information is intended to describe the details of the transaction and the products or services rendered. However, defaults may be applied in the event that some data is missing or unknown. So, all required fields must be present, even if their values are empty. Empty values will be overwritten with PayTrace defaults.
295
+ #
296
+ # Please note that Visa and MasterCard each have their own requirements for level 3 data, so your application should be able to determine if the transaction being updated in a Visa or a MasterCard before formatting and sending the request. All Visa account numbers begin with “4” and contain 16 digits. All MasterCard account numbers begin with “5” and also contain 16 digits.
297
+ #
298
+ # Required parameters (in arguments hash):
299
+ #
300
+ # * *:transaction_id* -- the transaction ID to which to add this data (required)
301
+ #
302
+ # Optional parameters (in arguments hash):
303
+ #
304
+ # * *:invoice* -- invoice is the identifier for this transaction in your accounting or inventory management system
305
+ # * *:customer_reference_id* -- customer reference ID is only used for transactions that are identified as corporate or purchasing credit cards. The customer reference ID is an identifier that your customer may ask you to provide in order to reference the transaction to their credit card statement
306
+ # * *:tax_amount* -- portion of the original transaction amount that is tax. Must be a number that reports the tax amount of the transaction. Use -1 if the transaction is tax exempt
307
+ # * *:national_tax* -- portion of the original transaction amount that is national tax. Generally only applicable to orders shipped to countries with a national or value added tax
308
+ # * *:merchant_tax_id* -- merchant’s tax identifier used for tax reporting purposes
309
+ # * *:customer_tax_id* -- customer’s tax identifier used for tax reporting purposes
310
+ # * *:ccode* -- commodity code that generally applies to each product included in the order. Commodity codes are generally assigned by your merchant service provider
311
+ # * *:discount* -- discount value should represent the amount discounted from the original transaction amount
312
+ # * *:freight* -- freight value should represent the portion of the transaction amount that was generated from shipping costs
313
+ # * *:duty* -- duty should represent any costs associated with shipping through a country’s customs
314
+ # * *:source_zip* -- zip code that the package will be sent from
315
+ # * *:shipping_postal_code* -- zip code where the product is delivered
316
+ # * *:shipping_country* -- country where the product is delivered
317
+ # * *:add_tax* -- any tax generated from freight or other services associated with the transaction
318
+ # * *:add_tax_rate* -- rate at which additional tax was assessed
319
+ # * *:line_items* -- see below
320
+ #
321
+ # The params may include a :line_items key, which should be an array of zero or more line item detail items. Each detail item is itself a parameter hash, containing any or none of the following:
322
+ #
323
+ # * *:ccode_li* -- the complete commodity code unique to the product referenced in this specific line item record. Commodity codes are generally assigned by your merchant service provider
324
+ # * *:product_id* -- your unique identifier for the product
325
+ # * *:description* -- optional text describing the transaction, products, customers, or other attributes of the transaction
326
+ # * *:quantity* -- item count of the product in this order
327
+ # * *:measure* -- unit of measure applied to the product and its quantity. For example, LBS/LITERS, OUNCES, etc.
328
+ # * *:unit_cost* -- product amount per quantity
329
+ # * *:add_tax_li* -- additional tax amount applied to the transaction applicable to this line item record
330
+ # * *:add_tax_rate_li* -- rate at which additional tax was calculated in reference to this specific line item record
331
+ # * *:discount_li* -- discount amount applied to the transaction amount in reference to this line item record
332
+ # * *:amount_li* -- total amount included in the transaction amount generated from this line item record
251
333
  def self.add_level_three_visa(params = {})
252
334
  line_items = params.delete(:line_items) || []
253
335
  request = PayTrace::API::Request.new
@@ -281,6 +363,53 @@ module PayTrace
281
363
  end
282
364
  end
283
365
 
366
+ # See http://help.paytrace.com/api-adding-level-3-data-to-a-mastercard-sale
367
+ #
368
+ # Level 3 data is additional information that may be applied to enrich a transaction’s reporting value to both the merchant and the customers. Generally, merchant service providers offer reduced or qualified pricing for transactions that are processed with Level 3 data.
369
+ #
370
+ # Level 3 data may be added to any Visa or MasterCard sale that is approved and pending settlement. Some level 3 data, specifically enhanced data such as Invoice and Customer Reference ID, may overlap with data provided with the base transaction. Enhanced data, when applied, will always overwrite such data that may already be stored with the transaction.
371
+ #
372
+ # Level 3 data consists of enhanced data and 1 or more line item records. This information is intended to describe the details of the transaction and the products or services rendered. However, defaults may be applied in the event that some data is missing or unknown. So, all required fields must be present, even if their values are empty. Empty values will be overwritten with PayTrace defaults.
373
+ #
374
+ # Please note that Visa and MasterCard each have their own requirements for level 3 data, so your application should be able to determine if the transaction being updated in a Visa or a MasterCard before formatting and sending the request. All Visa account numbers begin with “4” and contain 16 digits. All MasterCard account numbers begin with “5” and also contain 16 digits.
375
+ #
376
+ # Required parameters (in arguments hash):
377
+ #
378
+ # * *:transaction_id* -- the transaction ID to which to add this data (required)
379
+ #
380
+ # Optional parameters (in arguments hash):
381
+ #
382
+ # * *:invoice* -- invoice is the identifier for this transaction in your accounting or inventory management system
383
+ # * *:customer_reference_id* -- customer reference ID is only used for transactions that are identified as corporate or purchasing credit cards. The customer reference ID is an identifier that your customer may ask you to provide in order to reference the transaction to their credit card statement
384
+ # * *:tax_amount* -- portion of the original transaction amount that is tax. Must be a number that reports the tax amount of the transaction. Use -1 if the transaction is tax exempt
385
+ # * *:national_tax* -- portion of the original transaction amount that is national tax. Generally only applicable to orders shipped to countries with a national or value added tax
386
+ # * *:ccode* -- commodity code that generally applies to each product included in the order. Commodity codes are generally assigned by your merchant service provider
387
+ # * *:freight* -- freight value should represent the portion of the transaction amount that was generated from shipping costs
388
+ # * *:duty* -- duty should represent any costs associated with shipping through a country’s customs
389
+ # * *:source_zip* -- zip code that the package will be sent from
390
+ # * *:shipping_postal_code* -- zip code where the product is delivered
391
+ # * *:shipping_country* -- country where the product is delivered
392
+ # * *:add_tax* -- any tax generated from freight or other services associated with the transaction
393
+ # * *:additional_tax_included* -- a flag used to indicate where additional tax was included in this transaction. Set to Y if additional tax was included and N if no additional tax was applied
394
+ # * *:line_items* -- see below
395
+ #
396
+ # The params may include a :line_items key, which should be an array of zero or more line item detail items. Each detail item is itself a parameter hash, containing any or none of the following:
397
+ #
398
+ # * *:product_id* -- your unique identifier for the product
399
+ # * *:description* -- optional text describing the transaction, products, customers, or other attributes of the transaction
400
+ # * *:quantity* -- item count of the product in this order
401
+ # * *:measure* -- unit of measure applied to the product and its quantity. For example, LBS/LITERS, OUNCES, etc.
402
+ # * *:merchant_tax_id* -- merchant’s tax identifier used for tax reporting purposes
403
+ # * *:unit_cost* -- product amount per quantity
404
+ # * *:additional_tax_included_li* -- descriptor used to describe additional tax that is applied to the transaction amount in reference to this specific line item
405
+ # * *:add_tax_li* -- additional tax amount applied to the transaction applicable to this line item record
406
+ # * *:add_tax_rate_li* -- rate at which additional tax was calculated in reference to this specific line item record
407
+ # * *:amount_li* -- total amount included in the transaction amount generated from this line item record
408
+ # * *:discount_included* -- flag used to indicate whether discount was applied to the transaction amount in reference to this specific line item record
409
+ # * *:line_item_is_gross* -- flag used to indicate whether the line item amount is net or gross to specify whether the line item amount includes tax. Possible values are Y (includes tax) and N (does not include tax)
410
+ # * *:is_debit_or_credit* -- flag used to determine whether the line item amount was a debit or a credit to the customer. Generally always a debit or a factor that increased the transaction amount. Possible values are D (net is a debit) and C (net is a credit)
411
+ # * *:discount_li* -- discount amount applied to the transaction amount in reference to this line item record
412
+ # * *:discount_rate* -- rate at which discount was applied to the transaction in reference to this specific line item
284
413
  def self.add_level_three_mc(params = {})
285
414
  line_items = params.delete(:line_items) || []
286
415
  request = PayTrace::API::Request.new
@@ -310,14 +439,33 @@ module PayTrace
310
439
  end
311
440
  end
312
441
 
442
+ # See http://help.paytrace.com/api-settling-transactions
443
+ #
444
+ # 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
+ #
446
+ # No parameters are required.
313
447
  def self.settle_transaction(params = {})
314
448
  request = PayTrace::API::Request.new
315
449
  request.set_param(:method, SETTLE_TRANSACTION_METHOD)
316
- request.set_params([:recur_id, :customer_id], params)
317
450
  gateway = PayTrace::API::Gateway.new
318
451
  gateway.send_request(request)
319
452
  end
320
453
 
454
+ # See http://help.paytrace.com/api-adjusting-transaction-amounts
455
+ #
456
+ # Transactions processed through merchant accounts that are set up on the TSYS/Vital network or other terminal-based networks may adjust transaction amounts to any amount that is less than or equal to the original transaction amount and greater than zero. A transaction cannot be adjusted to more than 30% above its authorized amount. Amounts may be adjusted for the following transaction conditions:
457
+ #
458
+ # * Approved Sale that is not yet settled
459
+ # * Forced Sale that is not yet settled
460
+ # * Authorization that is approved and not yet settled
461
+ # * Refund that is not yet settled
462
+ #
463
+ # Please note that amounts for cash advance transaction may also not be adjusted.
464
+ #
465
+ # The parameters hash includes the following required parameters:
466
+ #
467
+ # *: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
+ # *:amount* -- dollar amount of the transaction. Must be a positive number up to two decimal places
321
469
  def self.adjust_amount(params = {})
322
470
  request = PayTrace::API::Request.new
323
471
  request.set_param(:method, ADJUST_AMOUNT_METHOD)
@@ -327,6 +475,7 @@ module PayTrace
327
475
  gateway.send_request(request)
328
476
  end
329
477
 
478
+ # :nodoc:
330
479
  def add_transaction_info(request)
331
480
  request.set_param(:transaction_type, type)
332
481
  request.set_param(:method, TRANSACTION_METHOD)
@@ -1,4 +1,4 @@
1
1
  module PayTrace
2
2
  # Version number
3
- VERSION = "0.1.20"
3
+ VERSION = "0.1.21"
4
4
  end
@@ -58,26 +58,6 @@ describe PayTrace::Transaction do
58
58
  PayTrace::API::Gateway.last_request.must_equal base_url + "METHOD~AdjustAmount|TRANXID~1234|AMOUNT~9.87|"
59
59
  end
60
60
 
61
- it "can settle a transaction by recurrence ID" do
62
- PayTrace::API::Gateway.next_response = "SHIPPINGRECORD~SHIPPINGCOMPANY=USPS+SHIPPINGMETHOD=STANDARD POST+SHIPPINGRATE=12.72|"
63
- params = {
64
- # UN, PSWD, TERMS, METHOD, RECURID
65
- recur_id: 12345
66
- }
67
- result = PayTrace::Transaction.settle_transaction(params)
68
- PayTrace::API::Gateway.last_request.must_equal base_url + "METHOD~SettleTranx|RECURID~12345|"
69
- end
70
-
71
- it "can settle a transaction by customer ID" do
72
- PayTrace::API::Gateway.next_response = "SHIPPINGRECORD~SHIPPINGCOMPANY=USPS+SHIPPINGMETHOD=STANDARD POST+SHIPPINGRATE=12.72|"
73
- params = {
74
- # UN, PSWD, TERMS, METHOD, RECURID
75
- customer_id: 12346
76
- }
77
- result = PayTrace::Transaction.settle_transaction(params)
78
- PayTrace::API::Gateway.last_request.must_equal base_url + "METHOD~SettleTranx|CUSTID~12346|"
79
- end
80
-
81
61
  describe "create sales transactions" do
82
62
  it "can create a Payment Authorization" do
83
63
  t = PayTrace::Transaction.authorization(
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.1.20
4
+ version: 0.1.21
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-05-06 00:00:00.000000000 Z
11
+ date: 2014-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday