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.
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
@@ -1,4 +1,4 @@
1
- # $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
1
+ $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
2
 
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
@@ -1,4 +1,4 @@
1
- # $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
1
+ $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
2
 
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
@@ -9,5 +9,5 @@ PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
9
9
  # see: http://help.paytrace.com/api-email-receipt for details
10
10
 
11
11
  PayTrace::Debug.trace {
12
- PayTrace::Transaction.attach_signature({transaction_id: 1143, image_file: File.expand_path('smiley_face.png', File.dirname(__FILE__)), image_type: "PNG"})
12
+ PayTrace::Transaction.attach_signature_file({transaction_id: 1143, image_file: File.expand_path('smiley_face.png', File.dirname(__FILE__)), image_type: "PNG"})
13
13
  }
@@ -1,4 +1,4 @@
1
- # $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
1
+ $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
2
 
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
@@ -14,8 +14,7 @@ PayTrace::Debug.trace do
14
14
  shipping_postal_code: 94947,
15
15
  shipping_weight: 5.1,
16
16
  shippers: "UPS,USPS,FEDEX",
17
- shipping_state: "CA",
18
- shipping_country: "US"
17
+ shipping_state: "CA"
19
18
  }
20
19
  PayTrace::Transaction.calculate_shipping(params)
21
20
  end
@@ -1,3 +1,5 @@
1
+ $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
+
1
3
  require "paytrace"
2
4
  require "paytrace/debug"
3
5
 
@@ -17,11 +17,10 @@ PayTrace::Debug.trace do
17
17
  check_type: "Sale",
18
18
  amount: 15.99,
19
19
  # replace this with a valid customer ID
20
- customer_id: 'MoMouse',
21
- test_flag: 'Y'
20
+ customer_id: 'MoMouse'
22
21
  }
23
22
 
24
- PayTrace::CheckTransaction::process_sale(params)
23
+ PayTrace::CheckTransaction::customer_id_sale(params)
25
24
  end
26
25
 
27
26
  # process manage check -- this is invalid data, you can replace with a valid check number
@@ -1,4 +1,4 @@
1
- # $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
1
+ $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
2
 
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
@@ -6,32 +6,25 @@ require "paytrace/debug"
6
6
  # change this as needed to reflect the username, password, and test host you're testing against
7
7
  PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
8
8
 
9
- # this should be a valid credit card number (it can be a "sandbox" number, however)
10
- cc = PayTrace::CreditCard.new({
11
- card_number: "4111111111111111",
12
- expiration_month: 12,
13
- expiration_year: 2014
14
- })
15
- ba = PayTrace::Address.new({
16
- name: "John Doe",
17
- street: "1234 Main Street",
18
- street2: "Apartment 1B",
19
- city: "Shoreline",
20
- state: "WA",
21
- country: "US",
22
- postal_code: "98133",
23
- address_type: :billing
24
- })
25
9
  params = {
26
10
  customer_id: "john_doe",
27
- credit_card: cc,
28
- billing_address: ba,
11
+ card_number: "4111111111111111",
12
+ expiration_month: 12,
13
+ expiration_year: 2014,
14
+ billing_name: "John Doe",
15
+ billing_address: "1234 Main Street",
16
+ billing_address2: "Apartment 1B",
17
+ billing_city: "Shoreline",
18
+ billing_state: "WA",
19
+ billing_country: "US",
20
+ billing_postal_code: "98133",
29
21
  email: "support@paytrace.com",
30
- phone: "206-555-1212",
31
- fax: "206-555-1313",
32
- password: "foxtrot123",
22
+ customer_phone: "206-555-1212",
23
+ customer_fax: "206-555-1313",
24
+ customer_password: "foxtrot123",
33
25
  account_number: 123456789,
34
26
  routing_number: 325081403,
35
27
  discretionary_data: { hair_color: "blue" }
36
28
  }
37
- PayTrace::Debug.trace { c = PayTrace::Customer.from_cc_info(params) }
29
+
30
+ PayTrace::Debug.trace { PayTrace::Customer.from_cc_info(params) }
@@ -1,4 +1,4 @@
1
- # $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
1
+ $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
2
 
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
@@ -7,11 +7,9 @@ require "paytrace/debug"
7
7
  PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
8
8
 
9
9
  PayTrace::Debug.trace do
10
- e = PayTrace::EmailReceiptRequest.new({email: "support@paytrace.com", check_id: "62" })
11
- r = e.send_request
10
+ PayTrace::EmailReceiptRequest.create({email: "support@paytrace.com", check_id: "62" })
12
11
  end
13
12
 
14
13
  PayTrace::Debug.trace do
15
- e = PayTrace::EmailReceiptRequest.new({email: "support@paytrace.com", transaction_id: "1143"})
16
- r = e.send_request
14
+ PayTrace::EmailReceiptRequest.create({email: "support@paytrace.com", transaction_id: "1143"})
17
15
  end
@@ -2,6 +2,7 @@ $:<< "./lib" # uncomment this to run against a Git clone instead of an installed
2
2
 
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
5
+ require 'io/console'
5
6
 
6
7
  # change this as needed to reflect the username, password, and test host you're testing against
7
8
  PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
@@ -11,7 +12,7 @@ PayTrace::Debug.trace do
11
12
  params = {
12
13
  batch_number: 413
13
14
  }
14
- result = PayTrace::BatchOperations.exportSingle(params)
15
+ result = PayTrace::BatchOperations.export_single(params)
15
16
  end
16
17
 
17
18
  # export batches by date range
@@ -20,7 +21,7 @@ PayTrace::Debug.trace do
20
21
  start_date: "01/01/2014",
21
22
  end_date: "05/01/2014"
22
23
  }
23
- result = PayTrace::BatchOperations.exportMultiple(params)
24
+ result = PayTrace::BatchOperations.export_multiple(params)
24
25
  end
25
26
 
26
27
  # export batch transaction details
@@ -28,5 +29,7 @@ PayTrace::Debug.trace do
28
29
  params = {
29
30
  batch_number: 413
30
31
  }
31
- result = PayTrace::BatchOperations.exportDetails(params)
32
+ puts "About to export transaction details for batch number #{params[:batch_number]}..."
33
+ STDIN.getc
34
+ result = PayTrace::BatchOperations.export_details(params)
32
35
  end
@@ -1,4 +1,4 @@
1
- # $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
1
+ $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
2
 
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
@@ -1,4 +1,4 @@
1
- # $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
1
+ $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
2
 
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
@@ -14,4 +14,4 @@ params = {
14
14
  # transaction_id: 1143
15
15
  }
16
16
 
17
- PayTrace::Debug.trace { puts PayTrace::Transaction.export(params) }
17
+ PayTrace::Debug.trace { puts PayTrace::Transaction.export_by_date_range(params) }
@@ -13,7 +13,7 @@ PayTrace::Debug.trace do
13
13
  invoice: "12346",
14
14
  customer_reference_id: "1234578",
15
15
  tax_amount: 31.76,
16
- ntax: 0.00,
16
+ national_tax: 0.00,
17
17
  merchant_tax_id: "13692468",
18
18
  customer_tax_id: "12369240",
19
19
  ccode: "1234abcd",
@@ -1,4 +1,4 @@
1
- # $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
1
+ $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
2
 
3
3
  require "paytrace"
4
4
  require "paytrace/debug"
@@ -6,41 +6,31 @@ require "paytrace/debug"
6
6
  # change this as needed to reflect the username, password, and test host you're testing against
7
7
  PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
8
8
 
9
- # this should be a valid credit card number (it can be a "sandbox" number, however)
10
- cc = PayTrace::CreditCard.new({
11
- card_number: "4111111111111111",
12
- expiration_month: 12,
13
- expiration_year: 2014
14
- })
15
- ba = PayTrace::Address.new({
16
- name: "John Doe",
17
- street: "1234 Main Street",
18
- street2: "Apartment 1B",
19
- city: "Shoreline",
20
- state: "WA",
21
- country: "US",
22
- postal_code: "98133",
23
- address_type: :billing
24
- })
25
-
26
9
  params = {
27
10
  customer_id: "john_doe",
28
- credit_card: cc,
29
- billing_address: ba,
11
+ card_number: "4111111111111111",
12
+ expiration_month: 12,
13
+ expiration_year: 2014,
14
+ billing_name: "John Doe",
15
+ billing_address: "1234 Main Street",
16
+ billing_address2: "Apartment 1B",
17
+ billing_city: "Shoreline",
18
+ billing_state: "WA",
19
+ billing_country: "US",
20
+ billing_postal_code: "98133",
30
21
  email: "support@paytrace.com",
31
- phone: "206-555-1212",
32
- fax: "206-555-1313",
33
- password: "foxtrot123",
22
+ customer_phone: "206-555-1212",
23
+ customer_fax: "206-555-1313",
24
+ customer_password: "foxtrot123",
34
25
  account_number: 123456789,
35
26
  routing_number: 325081403,
36
- discretionary_data: {test: "test data"}
27
+ discretionary_data: {hair_color: "red"}
37
28
  }
38
29
 
39
30
  begin
40
31
  PayTrace::Debug.log "Attempting to remove existing customer 'john_doe'..."
41
- c = PayTrace::Customer.new("john_doe")
42
32
  # delete customer "john_doe" if he already exists
43
- PayTrace::Debug.trace { c.delete() }
33
+ PayTrace::Debug.trace { PayTrace::Customer.delete("john_doe") }
44
34
  rescue PayTrace::Exceptions::ErrorResponse
45
35
  PayTrace::Debug.log "No such cusomter... continuing..."
46
36
  end
@@ -50,8 +40,7 @@ begin
50
40
  PayTrace::Debug.trace do
51
41
  ################
52
42
  # create "john_doe" profile from credit card information and a billing address. Also include extra information such as email, phone, and fax
53
- c = PayTrace::Customer.from_cc_info(params)
54
- PayTrace::Debug.log "Customer ID: #{c.id}"
43
+ PayTrace::Customer.from_cc_info(params)
55
44
  end
56
45
  rescue
57
46
  if PayTrace::API::Gateway.last_response_object.errors.has_key?("ERROR-171")
@@ -78,13 +67,15 @@ params = {
78
67
  PayTrace::Debug.trace do
79
68
  ################
80
69
  # create a recurring payment for "john_doe" of $9.99 every month starting on 4/22/2016, running indefinitely. Send a receipt.
81
- recur_id = PayTrace::RecurringTransaction.create(params)
70
+ result = PayTrace::RecurringTransaction.create(params)
71
+ recur_id = result.values['RECURID']
82
72
  PayTrace::Debug.log "Recurrence ID: #{recur_id}"
83
73
  end
84
74
 
85
75
  PayTrace::Debug.log "Modify recurrence for john_doe..."
86
76
  PayTrace::Debug.trace do
87
- recur_id = PayTrace::RecurringTransaction.create(params)
77
+ result = PayTrace::RecurringTransaction.create(params)
78
+ recur_id = result.values['RECURID']
88
79
  PayTrace::Debug.log "Recurrence ID: #{recur_id}"
89
80
  update_params = {
90
81
  recur_id: recur_id,
@@ -95,7 +86,8 @@ end
95
86
 
96
87
  PayTrace::Debug.log "Delete a recurrence for john_doe..."
97
88
  PayTrace::Debug.trace do
98
- recur_id = PayTrace::RecurringTransaction.create(params)
89
+ result = PayTrace::RecurringTransaction.create(params)
90
+ recur_id = result.values['RECURID']
99
91
  PayTrace::Debug.log "Recurrence ID: #{recur_id}"
100
92
  PayTrace::RecurringTransaction.delete({recur_id: recur_id})
101
93
  end
@@ -121,4 +113,4 @@ PayTrace::Debug.trace { PayTrace::RecurringTransaction.delete({customer_id: "joh
121
113
  PayTrace::Debug.log "Deleting customer 'john_doe'..."
122
114
  ################
123
115
  # delete "john doe"
124
- PayTrace::Debug.trace { c.delete() }
116
+ PayTrace::Debug.trace { PayTrace::Customer.delete("john_doe") }
@@ -9,11 +9,11 @@ PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
9
9
  # settle a transaction via a recurrence ID
10
10
  PayTrace::Debug.trace do
11
11
  params = { recur_id: "1143" } # you must replace this with a valid recurrence ID!
12
- PayTrace::Transaction.settle_transaction(params)
12
+ PayTrace::Transaction.settle_transactions(params)
13
13
  end
14
14
 
15
15
  # settle a transaction via a customer ID
16
16
  PayTrace::Debug.trace do
17
17
  params = { customer_id: "1143" } # you must replace this with a valid customer ID!
18
- PayTrace::Transaction.settle_transaction(params)
18
+ PayTrace::Transaction.settle_transactions(params)
19
19
  end
data/test/test_helper.rb CHANGED
@@ -1,5 +1,16 @@
1
+ require 'simplecov'
2
+
3
+ SimpleCov.start do
4
+ add_filter "lib/paytrace/debug.rb"
5
+ end
6
+
1
7
  require 'minitest/autorun'
2
8
  require 'minitest/pride'
9
+ require 'mocha/mini_test'
3
10
  require 'paytrace'
11
+ require "paytrace/debug"
12
+
13
+ def assert_last_request_equals(expected)
14
+ assert_empty(PayTrace::Debug.diff_requests("UN~#{PayTrace.configuration.user_name}|PSWD~#{PayTrace.configuration.password}|TERMS~Y|" <<expected, PayTrace::API::Gateway.last_request))
15
+ end
4
16
 
5
- require 'mocha/mini_test'
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.23
4
+ version: 1.0.0
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-08 00:00:00.000000000 Z
11
+ date: 2014-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: 0.7.1
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: 0.7.1
111
125
  description: Integration with PayTrace Payment Gateway
112
126
  email:
113
127
  - trevor@paytrace.com
@@ -133,7 +147,6 @@ files:
133
147
  - lib/paytrace/batch_operations.rb
134
148
  - lib/paytrace/check_transaction.rb
135
149
  - lib/paytrace/configuration.rb
136
- - lib/paytrace/credit_card.rb
137
150
  - lib/paytrace/customer.rb
138
151
  - lib/paytrace/debug.rb
139
152
  - lib/paytrace/email_receipt_request.rb
@@ -142,15 +155,15 @@ files:
142
155
  - lib/paytrace/transaction.rb
143
156
  - lib/paytrace/version.rb
144
157
  - paytrace.gemspec
158
+ - run_all_integrations.sh
145
159
  - test/paytrace/address_spec.rb
146
160
  - test/paytrace/api/fields_spec.rb
147
161
  - test/paytrace/api/gateway_spec.rb
148
162
  - test/paytrace/api/request_spec.rb
149
163
  - test/paytrace/api/response_spec.rb
150
164
  - test/paytrace/batch_operations_spec.rb
151
- - test/paytrace/check_transactions_spec.rb
165
+ - test/paytrace/check_transaction_spec.rb
152
166
  - test/paytrace/configuration_spec.rb
153
- - test/paytrace/credit_card_spec.rb
154
167
  - test/paytrace/customer_spec.rb
155
168
  - test/paytrace/email_receipt_request_spec.rb
156
169
  - test/paytrace/exceptions_spec.rb
@@ -204,9 +217,8 @@ test_files:
204
217
  - test/paytrace/api/request_spec.rb
205
218
  - test/paytrace/api/response_spec.rb
206
219
  - test/paytrace/batch_operations_spec.rb
207
- - test/paytrace/check_transactions_spec.rb
220
+ - test/paytrace/check_transaction_spec.rb
208
221
  - test/paytrace/configuration_spec.rb
209
- - test/paytrace/credit_card_spec.rb
210
222
  - test/paytrace/customer_spec.rb
211
223
  - test/paytrace/email_receipt_request_spec.rb
212
224
  - test/paytrace/exceptions_spec.rb
@@ -1,32 +0,0 @@
1
- module PayTrace
2
- # Contains credit card information, including possible swipe data.
3
- class CreditCard
4
- attr_accessor :card_number, :expiration_month, :expiration_year, :swipe, :csc
5
-
6
- # Initialize instance; possible options are:
7
- # * *:card_number* -- the credit card number
8
- # * *:expiration_month* -- the expiration month of the card
9
- # * *:expiration_year* -- the expiration year of the card
10
- # * *:csc* -- the CSC code
11
- # * *:swipe* -- swipe data, if present
12
- # All parameters are passed in a hash, with symbols for key names.
13
- def initialize(options={})
14
- @card_number = options[:card_number]
15
- @expiration_month = options[:expiration_month]
16
- @expiration_year = options[:expiration_year]
17
- @swipe = options[:swipe]
18
- @csc = options[:csc]
19
- end
20
-
21
- # :nodoc:
22
- # Internal helper method; not meant to be called directly.
23
- def set_request_data(request = nil)
24
- request ||= PayTrace::API::Request.new
25
- request.set_param(:card_number, card_number) if card_number
26
- request.set_param(:expiration_month, expiration_month) if expiration_month
27
- request.set_param(:expiration_year, expiration_year) if expiration_year
28
- request.set_param(:swipe, swipe) if swipe
29
- request.set_param(:csc, csc) if csc
30
- end
31
- end
32
- end
@@ -1,26 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '../../test_helper.rb')
2
-
3
- describe PayTrace::CreditCard do
4
- it "can be initialized with nothing" do
5
- cc = PayTrace::CreditCard.new
6
- cc.card_number.must_be_nil
7
- end
8
- it "can be initialized from a card number and expiration date" do
9
- cc = PayTrace::CreditCard.new(:card_number => "5454545454545454", :expiration_month => 10, :expiration_year => 24)
10
- cc.card_number.must_equal "5454545454545454"
11
- cc.expiration_month.must_equal 10
12
- cc.expiration_year.must_equal 24
13
- end
14
-
15
- it "can be initialized from a hash" do
16
- cc = {credit_card: {
17
- card_number: "1234123412341234",
18
- expiration_month: 10,
19
- expiration_year: 24
20
- }}
21
-
22
- cc = PayTrace::CreditCard.new(cc[:credit_card])
23
- cc.card_number.must_equal "1234123412341234"
24
-
25
- end
26
- end