paytrace 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2441f7bcebff6b1c3a6fcca8143734334b17a6fd
4
- data.tar.gz: 1d28434069fb9e1d22509a89767058ab8177b864
3
+ metadata.gz: 01f77e0d7062c1ba84c52b6e7e5df520c2427193
4
+ data.tar.gz: efc8200cbb14404542ae71630d8ab88fd41033b2
5
5
  SHA512:
6
- metadata.gz: 810bc896355a1b2037c479cf105d0e5117400558cd7b5fa96fd2f1c5dab77c13059a60311929a32987f7ff43596d42ba322149b92b5a41748d27101fd6c5888b
7
- data.tar.gz: dd72443f179654f8682d36dfb4ce8e4b44203c91f1deefba3a1e6d5e3ab2ce67744335f01f79d6e602062e2f882291267d5e3cd64cf39f79600d5deaf92b6de4
6
+ metadata.gz: 8359ca5ec958109d517ee5a8d44408da79a3dcd7d9ed3492a71d51b5f93ccab85274ca7701d558cd2a6729679d80c3f66bd617de710ceb436851905d78d20a86
7
+ data.tar.gz: e458c8d04bf2503f6831d1294f8f4bf255c387bc7160d074e01a7014068b1f7edb6d2fe1072222133eed1669a017402b31808dbaf638af255e34e0efebf9945b
@@ -0,0 +1,46 @@
1
+ require 'paytrace'
2
+
3
+ module PayTrace
4
+ module Debug
5
+ #
6
+ # Helper that loops through the response values and dumps them out
7
+ #
8
+ def self.dump_transaction
9
+ puts "[REQUEST] #{PayTrace::API::Gateway.last_request}"
10
+ response = PayTrace::API::Gateway.last_response_object
11
+ if(response.has_errors?)
12
+ response.errors.each do |key, value|
13
+ puts "[RESPONSE] ERROR: #{key.ljust(20)}#{value}"
14
+ end
15
+ else
16
+ response.values.each do |key, value|
17
+ puts "[RESPONSE] #{key.ljust(20)}#{value}"
18
+ end
19
+ end
20
+ end
21
+
22
+ def self.log(msg)
23
+ puts ">>>>>> #{msg}"
24
+ end
25
+
26
+ def self.trace(&block)
27
+ PayTrace::API::Gateway.debug = true
28
+
29
+ begin
30
+ yield
31
+ rescue Exception => e
32
+ raise
33
+ else
34
+ dump_transaction
35
+ end
36
+ end
37
+
38
+ def self.configure_test
39
+ PayTrace.configure do |config|
40
+ config.user_name = "demo123"
41
+ config.password = "demo123"
42
+ config.domain = "stage.paytrace.com"
43
+ end
44
+ end
45
+ end
46
+ end
@@ -13,11 +13,8 @@ module PayTrace
13
13
  def set_request(request = nil)
14
14
  request ||= PayTrace::API::Request.new
15
15
  request.set_param(:method, TRANSACTION_METHOD)
16
- if @check_id
17
- request.set_param(:check_id, @check_id)
18
- else
19
- request.set_param(:transaction_id, @transaction_id)
20
- end
16
+ request.set_param(:check_id, @check_id)
17
+ request.set_param(:transaction_id, @transaction_id)
21
18
  request.set_param(:email, @email)
22
19
 
23
20
  request
@@ -1,3 +1,3 @@
1
1
  module PayTrace
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
3
3
  end
@@ -1,50 +1,12 @@
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
+ require "paytrace/debug"
4
5
 
5
- # see: http://help.paytrace.com/api-email-receipt for details
6
-
7
- #
8
- # Helper that loops through the response values and dumps them out
9
- #
10
- def dump_transaction
11
- puts "[REQUEST] #{PayTrace::API::Gateway.last_request}"
12
- response = PayTrace::API::Gateway.last_response_object
13
- if(response.has_errors?)
14
- response.errors.each do |key, value|
15
- puts "[RESPONSE] ERROR: #{key.ljust(20)}#{value}"
16
- end
17
- else
18
- response.values.each do |key, value|
19
- puts "[RESPONSE] #{key.ljust(20)}#{value}"
20
- end
21
- end
22
- end
23
-
24
- def log(msg)
25
- puts ">>>>>> #{msg}"
26
- end
27
-
28
- def trace(&block)
29
- PayTrace::API::Gateway.debug = true
6
+ PayTrace::Debug.configure_test
30
7
 
31
- begin
32
- yield
33
- rescue Exception => e
34
- raise
35
- else
36
- dump_transaction
37
- end
38
- end
39
-
40
- PayTrace.configure do |config|
41
- config.user_name = "demo123"
42
- config.password = "demo123"
43
- config.domain = "stage.paytrace.com"
44
- end
45
-
46
- PayTrace::API::Gateway.debug = true
8
+ # see: http://help.paytrace.com/api-email-receipt for details
47
9
 
48
- trace {
10
+ PayTrace::Debug.trace {
49
11
  PayTrace::Transaction.attach_signature({image_file: File.expand_path('smiley_face.png', File.dirname(__FILE__)), image_type: "PNG"})
50
12
  }
@@ -1,51 +1,11 @@
1
1
  $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
2
 
3
3
  require "paytrace"
4
+ require "paytrace/debug"
4
5
 
5
- # see: http://help.paytrace.com/api-email-receipt for details
6
+ PayTrace::Debug.configure_test
6
7
 
7
- #
8
- # Helper that loops through the response values and dumps them out
9
- #
10
- def dump_transaction
11
- puts "[REQUEST] #{PayTrace::API::Gateway.last_request}"
12
- response = PayTrace::API::Gateway.last_response_object
13
- if(response.has_errors?)
14
- response.errors.each do |key, value|
15
- puts "[RESPONSE] ERROR: #{key.ljust(20)}#{value}"
16
- end
17
- else
18
- response.values.each do |key, value|
19
- puts "[RESPONSE] #{key.ljust(20)}#{value}"
20
- end
21
- end
22
- end
23
-
24
- def log(msg)
25
- puts ">>>>>> #{msg}"
26
- end
27
-
28
- def trace(&block)
29
- PayTrace::API::Gateway.debug = true
30
-
31
- begin
32
- yield
33
- rescue Exception => e
34
- raise
35
- else
36
- dump_transaction
37
- end
38
- end
39
-
40
- PayTrace.configure do |config|
41
- config.user_name = "demo123"
42
- config.password = "demo123"
43
- config.domain = "stage.paytrace.com"
44
- end
45
-
46
- PayTrace::API::Gateway.debug = true
47
-
48
- trace do
8
+ PayTrace::Debug.trace do
49
9
  params = {
50
10
  #UN, PSWD, TERMS, METHOD, SOURCEZIP, SOURCESTATE, SZIP, WEIGHT, SHIPPERS, SSTATE
51
11
  source_zip: 98133,
@@ -1,27 +1,9 @@
1
- require 'paytrace'
1
+ # $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
2
 
3
- # see: http://help.paytrace.com/api-email-receipt for details
3
+ require "paytrace"
4
+ require "paytrace/debug"
4
5
 
5
- #
6
- # Helper that loops through the response values and dumps them out
7
- #
8
- def dump_response_values(response)
9
- if(response.has_errors?)
10
- response.errors.each do |key, value|
11
- puts "#{key.ljust(20)}#{value}"
12
- end
13
- else
14
- response.values.each do |key, value|
15
- puts "#{key.ljust(20)}#{value}"
16
- end
17
- end
18
- end
19
-
20
- PayTrace.configure do |config|
21
- config.user_name = "demo123"
22
- config.password = "demo123"
23
- config.domain = "stage.paytrace.com"
24
- end
6
+ PayTrace::Debug.configure_test
25
7
 
26
8
  # this should be a valid credit card number (it can be a "sandbox" number, however)
27
9
  cc = PayTrace::CreditCard.new({
@@ -39,17 +21,16 @@ ba = PayTrace::Address.new({
39
21
  postal_code: "98133",
40
22
  address_type: :billing
41
23
  })
42
- extra = {
24
+ params = {
25
+ customer_id: "john_doe",
26
+ credit_card: cc,
27
+ billing_address: ba,
43
28
  email: "support@paytrace.com",
44
29
  phone: "206-555-1212",
45
30
  fax: "206-555-1313",
46
31
  password: "foxtrot123",
47
32
  account_number: 123456789,
48
- routing_number: 12345678,
49
- discretionary_data: "Discretionary data."
33
+ routing_number: 325081403,
34
+ discretionary_data: { hair_color: "blue" }
50
35
  }
51
-
52
- PayTrace::API::Gateway.set_debug(true)
53
- c = PayTrace::Customer.from_cc_info("john_doe", cc, ba, nil, extra)
54
-
55
- dump_response_values(PayTrace::API::Gateway.last_response)
36
+ PayTrace::Debug.trace { c = PayTrace::Customer.from_cc_info(params) }
@@ -1,36 +1,16 @@
1
- require 'paytrace'
1
+ # $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
2
 
3
- # see: http://help.paytrace.com/api-email-receipt for details
3
+ require "paytrace"
4
+ require "paytrace/debug"
4
5
 
5
- #
6
- # Helper that loops through the response values and dumps them out
7
- #
8
- def dump_response_values(response)
9
- if(response.has_errors?)
10
- response.errors.each do |key, value|
11
- puts "#{key.ljust(20)}#{value}"
12
- end
13
- else
14
- response.values.each do |key, value|
15
- puts "#{key.ljust(20)}#{value}"
16
- end
17
- end
18
- end
6
+ PayTrace::Debug.configure_test
19
7
 
20
- PayTrace.configure do |config|
21
- config.user_name = "demo123"
22
- config.password = "demo123"
23
- config.domain = "stage.paytrace.com"
8
+ PayTrace::Debug.trace do
9
+ e = PayTrace::EmailReceiptRequest.new({email: "support@paytrace.com", check_id: "CHECK2345" })
10
+ r = e.send_request
24
11
  end
25
12
 
26
- e = PayTrace::EmailReceiptRequest.new({email: "support@paytrace.com", check_id: "CHECK2345"})
27
- r = e.send_request
28
-
29
- # this is for the check auth version
30
- dump_response_values(r)
31
-
32
- e = PayTrace::EmailReceiptRequest.new({email: "support@paytrace.com", transaction_id: "TRANS1234"})
33
- r = e.send_request
34
-
35
- # this is for the transaction version
36
- dump_response_values(r)
13
+ PayTrace::Debug.trace do
14
+ e = PayTrace::EmailReceiptRequest.new({email: "support@paytrace.com", transaction_id: "1143"})
15
+ r = e.send_request
16
+ end
@@ -1,52 +1,12 @@
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
+ require "paytrace/debug"
4
5
 
5
- # see: http://help.paytrace.com/api-exporting-customer-profiles for details
6
-
7
- #
8
- # Helper that loops through the response values and dumps them out
9
- #
10
- def dump_transaction
11
- puts "[REQUEST] #{PayTrace::API::Gateway.last_request}"
12
- response = PayTrace::API::Gateway.last_response_object
13
- if(response.has_errors?)
14
- response.errors.each do |key, value|
15
- puts "[RESPONSE] ERROR: #{key.ljust(20)}#{value}"
16
- end
17
- else
18
- response.values.each do |key, value|
19
- puts "[RESPONSE] #{key.ljust(20)}#{value}"
20
- end
21
- end
22
- end
23
-
24
- def log(msg)
25
- puts ">>>>>> #{msg}"
26
- end
27
-
28
- def trace(&block)
29
- PayTrace::API::Gateway.debug = true
30
-
31
- begin
32
- yield
33
- rescue Exception => e
34
- raise
35
- else
36
- dump_transaction
37
- end
38
- end
39
-
40
- PayTrace.configure do |config|
41
- config.user_name = "demo123"
42
- config.password = "demo123"
43
- config.domain = "stage.paytrace.com"
44
- end
45
-
46
- PayTrace::API::Gateway.debug = true
6
+ PayTrace::Debug.configure_test
47
7
 
48
8
  # this should dump out a wall of text...
49
- trace { puts PayTrace::Customer.export() }
9
+ PayTrace::Debug.trace { puts PayTrace::Customer.export() }
50
10
 
51
11
  # this should dump inactive api-exporting-customer-profiles
52
- trace { puts PayTrace::Customer.export_inactive({days_inactive: 30}) }
12
+ PayTrace::Debug.trace { puts PayTrace::Customer.export_inactive({days_inactive: 30}) }
@@ -1,47 +1,9 @@
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
+ require "paytrace/debug"
4
5
 
5
- # see: http://help.paytrace.com/api-email-receipt for details
6
-
7
- #
8
- # Helper that loops through the response values and dumps them out
9
- #
10
- def dump_transaction
11
- puts "[REQUEST] #{PayTrace::API::Gateway.last_request}"
12
- response = PayTrace::API::Gateway.last_response_object
13
- if(response.has_errors?)
14
- response.errors.each do |key, value|
15
- puts "[RESPONSE] ERROR: #{key.ljust(20)}#{value}"
16
- end
17
- else
18
- response.values.each do |key, value|
19
- puts "[RESPONSE] #{key.ljust(20)}#{value}"
20
- end
21
- end
22
- end
23
-
24
- def log(msg)
25
- puts ">>>>>> #{msg}"
26
- end
27
-
28
- def trace(&block)
29
- PayTrace::API::Gateway.debug = true
30
-
31
- begin
32
- yield
33
- rescue Exception => e
34
- raise
35
- else
36
- dump_transaction
37
- end
38
- end
39
-
40
- PayTrace.configure do |config|
41
- config.user_name = "demo123"
42
- config.password = "demo123"
43
- config.domain = "stage.paytrace.com"
44
- end
6
+ PayTrace::Debug.configure_test
45
7
 
46
8
  PayTrace::API::Gateway.debug = true
47
9
 
@@ -51,4 +13,4 @@ params = {
51
13
  transaction_id: 1143
52
14
  }
53
15
 
54
- trace { puts PayTrace::Transaction.export(params) }
16
+ PayTrace::Debug.trace { puts PayTrace::Transaction.export(params) }
@@ -1,41 +1,9 @@
1
- require "paytrace"
2
-
3
- # see: http://help.paytrace.com/api-email-receipt for details
1
+ # $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
4
2
 
5
- #
6
- # Helper that loops through the response values and dumps them out
7
- #
8
- def dump_transaction
9
- puts "[REQUEST] #{PayTrace::API::Gateway.last_request}"
10
- response = PayTrace::API::Gateway.last_response_object
11
- if(response.has_errors?)
12
- response.errors.each do |key, value|
13
- puts "[RESPONSE] ERROR: #{key.ljust(20)}#{value}"
14
- end
15
- else
16
- response.values.each do |key, value|
17
- puts "[RESPONSE] #{key.ljust(20)}#{value}"
18
- end
19
- end
20
- end
21
-
22
- def log(msg)
23
- puts ">>>>>> #{msg}"
24
- end
25
-
26
- def trace(&block)
27
- begin
28
- yield
29
- ensure
30
- dump_transaction
31
- end
32
- end
3
+ require "paytrace"
4
+ require "paytrace/debug"
33
5
 
34
- PayTrace.configure do |config|
35
- config.user_name = "demo123"
36
- config.password = "demo123"
37
- config.domain = "stage.paytrace.com"
38
- end
6
+ PayTrace::Debug.configure_test
39
7
 
40
8
  # this should be a valid credit card number (it can be a "sandbox" number, however)
41
9
  cc = PayTrace::CreditCard.new({
@@ -67,35 +35,33 @@ params = {
67
35
  discretionary_data: {test: "test data"}
68
36
  }
69
37
 
70
- PayTrace::API::Gateway.debug = true
71
-
72
38
  begin
73
- log "Attempting to remove existing customer 'john_doe'..."
39
+ PayTrace::Debug.log "Attempting to remove existing customer 'john_doe'..."
74
40
  c = PayTrace::Customer.new("john_doe")
75
41
  # delete customer "john_doe" if he already exists
76
- trace { c.delete() }
42
+ PayTrace::Debug.trace { c.delete() }
77
43
  rescue PayTrace::Exceptions::ErrorResponse
78
- log "No such cusomter... continuing..."
44
+ PayTrace::Debug.log "No such cusomter... continuing..."
79
45
  end
80
46
 
81
- log "Creating customer john_doe..."
47
+ PayTrace::Debug.log "Creating customer john_doe..."
82
48
  begin
83
- trace do
49
+ PayTrace::Debug.trace do
84
50
  ################
85
51
  # create "john_doe" profile from credit card information and a billing address. Also include extra information such as email, phone, and fax
86
52
  c = PayTrace::Customer.from_cc_info(params)
87
- log "Customer ID: #{c.id}"
53
+ PayTrace::Debug.log "Customer ID: #{c.id}"
88
54
  end
89
55
  rescue
90
56
  if PayTrace::API::Gateway.last_response_object.errors.has_key?("ERROR-171")
91
- log "Customer already exists..."
57
+ PayTrace::Debug.log "Customer already exists..."
92
58
  else
93
- log "Failure; raw request: #{PayTrace::API::Gateway.last_request}"
59
+ PayTrace::Debug.log "Failure; raw request: #{PayTrace::API::Gateway.last_request}"
94
60
  raise
95
61
  end
96
62
  end
97
63
 
98
- log "Creating recurrence for john_doe..."
64
+ PayTrace::Debug.log "Creating recurrence for john_doe..."
99
65
  params = {
100
66
  customer_id: "john_doe",
101
67
  recur_frequency: "3",
@@ -108,31 +74,31 @@ params = {
108
74
  recur_type: "A"
109
75
  }
110
76
 
111
- trace do
77
+ PayTrace::Debug.trace do
112
78
  ################
113
79
  # create a recurring payment for "john_doe" of $9.99 every month starting on 4/22/2016, running indefinitely. Send a receipt.
114
80
  recur_id = PayTrace::RecurringTransaction.create(params)
115
- log "Recurrence ID: #{recur_id}"
81
+ PayTrace::Debug.log "Recurrence ID: #{recur_id}"
116
82
  end
117
83
 
118
84
  begin
119
- log "Exporting recurring transaction..."
120
- trace do
85
+ PayTrace::Debug.log "Exporting recurring transaction..."
86
+ PayTrace::Debug.trace do
121
87
  ################
122
88
  # export any scheduled recurring transactions for "john_doe" to a RecurringTransaction object...
123
89
  exported = PayTrace::RecurringTransaction.export_scheduled({customer_id: "john_doe"})
124
- log "Exported transaction:\n#{exported.inspect}"
90
+ PayTrace::Debug.log "Exported transaction:\n#{exported.inspect}"
125
91
  end
126
92
  rescue
127
- log "Export failed..."
93
+ PayTrace::Debug.log "Export failed..."
128
94
  end
129
95
 
130
- log "Deleting recurrences for 'john_doe'..."
96
+ PayTrace::Debug.log "Deleting recurrences for 'john_doe'..."
131
97
  ################
132
98
  # delete any scheduled recurring transactions for "john_doe"
133
- trace { PayTrace::RecurringTransaction.delete({customer_id: "john_doe"}) }
99
+ PayTrace::Debug.trace { PayTrace::RecurringTransaction.delete({customer_id: "john_doe"}) }
134
100
 
135
- log "Deleting customer 'john_doe'..."
101
+ PayTrace::Debug.log "Deleting customer 'john_doe'..."
136
102
  ################
137
103
  # delete "john doe"
138
- trace { c.delete() }
104
+ PayTrace::Debug.trace { c.delete() }
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.11
4
+ version: 0.1.12
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-04-09 00:00:00.000000000 Z
11
+ date: 2014-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -119,6 +119,7 @@ files:
119
119
  - lib/paytrace/configuration.rb
120
120
  - lib/paytrace/credit_card.rb
121
121
  - lib/paytrace/customer.rb
122
+ - lib/paytrace/debug.rb
122
123
  - lib/paytrace/email_receipt_request.rb
123
124
  - lib/paytrace/exceptions.rb
124
125
  - lib/paytrace/recurring_transaction.rb