paytrace 0.1.18 → 0.1.19

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: 9b8c933ace0d385e68fb1fa6763ef764d969160c
4
- data.tar.gz: 2c0f4df1ebd158e3d95e0dcfb4b178583a426f05
3
+ metadata.gz: 320dcdc4504f93ee689d060590f765241e9b2e2b
4
+ data.tar.gz: 8babaffbd61ff385240e26268c4ac9b16002195f
5
5
  SHA512:
6
- metadata.gz: 4757b23b7fa51b37b985c3aee2a8cf33602bf1a52eb600ece91849be7f8751a1510ea1b0717176cf6e868851c1bd74e85b3578a89e017a4c4b319a2fbeff19ec
7
- data.tar.gz: 2765509db5fa83ead7620de56e9160825d74452c9e396955412517af4cb155f385f2495ae3e982a375b84a7ec2bc8de8e6fea25c276a4a0eb2ed972f35dc5c75
6
+ metadata.gz: dade330968ea5744206631a953abde4f18aab0a2757f0d0678409931497646dfd522cdd68e51f1e7c01406f3fe6cf9d4ee692b69e17f8890456b37a732a95371
7
+ data.tar.gz: d2ff117c82ecb19ceda25508cd96a460926c31bdbe0c25ff5e94ae297b4d718cea61722badefdbb3c187ab912219a0046c79a7617938e666ad81d753f51c7e60
@@ -106,7 +106,9 @@ module PayTrace
106
106
  source_zip: "SOURCEZIP",
107
107
  source_state: "SOURCESTATE",
108
108
  shipping_weight: "WEIGHT",
109
- shippers: "SHIPPERS"
109
+ shippers: "SHIPPERS",
110
+ # test flag
111
+ test_flag: "TEST"
110
112
  }
111
113
  end
112
114
  end
@@ -1,16 +1,66 @@
1
1
  module PayTrace
2
2
  class CheckTransaction
3
3
  PROCESS_SALE_METHOD = "ProcessCheck"
4
+ MANAGE_CHECK_METHOD = "ManageCheck"
4
5
 
5
6
  def self.process_sale(params = {})
6
7
  request = PayTrace::API::Request.new
7
8
  request.set_param(:method, PROCESS_SALE_METHOD)
9
+ self.add_common_parameters(params, request)
10
+
11
+ gateway = PayTrace::API::Gateway.new
12
+ response = gateway.send_request(request)
13
+ unless response.has_errors?
14
+ response.values
15
+ end
16
+ end
17
+
18
+ def self.process_hold(params = {})
19
+ request = PayTrace::API::Request.new
20
+ request.set_param(:method, PROCESS_SALE_METHOD)
21
+ params.delete(:check_type) # make sure we don't duplicate this
22
+ self.add_common_parameters(params, request)
23
+ request.set_param(:check_type, "Hold")
24
+
25
+ gateway = PayTrace::API::Gateway.new
26
+ response = gateway.send_request(request)
27
+ unless response.has_errors?
28
+ response.values
29
+ end
30
+ end
31
+
32
+ def self.process_refund(params = {})
33
+ request = PayTrace::API::Request.new
34
+ request.set_param(:method, PROCESS_SALE_METHOD)
35
+ params.delete(:check_type) # make sure we don't duplicate this
36
+ self.add_common_parameters(params, request)
37
+ request.set_param(:check_id, params[:check_id])
38
+ request.set_param(:check_type, "Refund")
39
+
40
+ gateway = PayTrace::API::Gateway.new
41
+ response = gateway.send_request(request)
42
+ unless response.has_errors?
43
+ response.values
44
+ end
45
+ end
46
+
47
+ def self.manage_check(params = {})
48
+ request = PayTrace::API::Request.new
49
+ request.set_param(:method, MANAGE_CHECK_METHOD)
50
+ request.set_params([:check_type, :check_id], params)
51
+
52
+ gateway = PayTrace::API::Gateway.new
53
+ response = gateway.send_request(request)
54
+ unless response.has_errors?
55
+ response.values
56
+ end
57
+ end
58
+
59
+ def self.add_common_parameters(params = {}, request)
8
60
  request.set_params([
9
61
  :check_type,
10
62
  :amount, :customer_id, :account_number, :routing_number,
11
- :billing_name, :billing_address, :billing_address2, :billing_city, :billing_state, :billing_postal_code, :billing_country,
12
- :shipping_name, :shipping_address, :shipping_address2, :shipping_city, :shipping_region, :shipping_state, :shipping_postal_code, :shipping_country,
13
- :email, :invoice, :description, :tax_amount, :customer_reference_id
63
+ :email, :invoice, :description, :tax_amount, :customer_reference_id, :test_flag
14
64
  ], params)
15
65
 
16
66
  if params[:discretionary_data]
@@ -18,11 +68,13 @@ module PayTrace
18
68
  request.set_discretionary(k, params[:discretionary_data][k])
19
69
  end
20
70
  end
21
-
22
- gateway = PayTrace::API::Gateway.new
23
- response = gateway.send_request(request)
24
- unless response.has_errors?
25
- response.values
71
+
72
+ if params.has_key?(:billing_address)
73
+ params[:billing_address].set_request(request)
74
+ end
75
+
76
+ if params.has_key?(:shipping_address)
77
+ params[:shipping_address].set_request(request)
26
78
  end
27
79
  end
28
80
  end
@@ -1,3 +1,3 @@
1
1
  module PayTrace
2
- VERSION = "0.1.18"
2
+ VERSION = "0.1.19"
3
3
  end
@@ -10,34 +10,153 @@ describe PayTrace::CheckTransaction do
10
10
  PayTrace::API::Gateway.reset_trace()
11
11
  end
12
12
 
13
- # UN, PSWD, TERMS, METHOD, CHECKTYPE, AMOUNT, DDA, TR
14
- it "should process a check payment via routing number/account number" do
15
- PayTrace::API::Gateway.next_response = "RESULT~Ok"
16
- params = {
17
- check_type: 'foo',
18
- amount: 17.29,
19
- account_number: 1234567,
20
- routing_number: 1234568
21
- }
22
- result = PayTrace::CheckTransaction.process_sale(params)
23
- PayTrace::API::Gateway.last_request.must_equal base_url(PayTrace::CheckTransaction::PROCESS_SALE_METHOD) +
24
- "CHECKTYPE~foo|AMOUNT~17.29|DDA~1234567|TR~1234568|"
25
- end
13
+ describe "sale transactions" do
14
+
15
+ # UN, PSWD, TERMS, METHOD, CHECKTYPE, AMOUNT, DDA, TR
16
+ it "should process a check payment via routing number/account number" do
17
+ PayTrace::API::Gateway.next_response = "RESULT~Ok"
18
+ params = {
19
+ check_type: 'foo',
20
+ amount: 17.29,
21
+ account_number: 1234567,
22
+ routing_number: 1234568
23
+ }
24
+ result = PayTrace::CheckTransaction.process_sale(params)
25
+ PayTrace::API::Gateway.last_request.must_equal base_url(PayTrace::CheckTransaction::PROCESS_SALE_METHOD) +
26
+ "CHECKTYPE~foo|AMOUNT~17.29|DDA~1234567|TR~1234568|"
27
+ end
28
+
29
+ # UN, PSWD, TERMS, METHOD, CHECKTYPE, AMOUNT, CUSTID
30
+ it "should process a check payment via customer id" do
31
+ PayTrace::API::Gateway.next_response = "RESULT~Ok"
32
+ params = {
33
+ check_type: 'bar',
34
+ amount: 17.28,
35
+ customer_id: 'MMouse'
36
+ }
37
+ result = PayTrace::CheckTransaction.process_sale(params)
38
+ PayTrace::API::Gateway.last_request.must_equal base_url(PayTrace::CheckTransaction::PROCESS_SALE_METHOD) +
39
+ "CHECKTYPE~bar|AMOUNT~17.28|CUSTID~MMouse|"
40
+ end
41
+
42
+
43
+ it "accepts billing and shipping information" do
44
+ PayTrace::API::Gateway.next_response = "RESULT~Ok"
45
+
46
+ ba = PayTrace::Address.new({
47
+ name: "John Doe",
48
+ street: "1234 Main Street",
49
+ street2: "Apartment 1B",
50
+ city: "Shoreline",
51
+ state: "WA",
52
+ country: "US",
53
+ postal_code: "98133",
54
+ address_type: :billing
55
+ })
56
+
57
+ sa = PayTrace::Address.new({
58
+ name: "Jane Doe",
59
+ street: "1235 Moon Street",
60
+ street2: "Apartment 2C",
61
+ city: "Shortline",
62
+ state: "WA",
63
+ country: "US",
64
+ postal_code: "98134",
65
+ address_type: :shipping
66
+ })
67
+
68
+ params = {
69
+ check_type: 'baz',
70
+ amount: 17.29,
71
+ customer_id: 'DDuck',
72
+ billing_address: ba,
73
+ shipping_address: sa
74
+ }
75
+
76
+ result = PayTrace::CheckTransaction.process_sale(params)
77
+ PayTrace::API::Gateway.last_request.must_equal base_url(PayTrace::CheckTransaction::PROCESS_SALE_METHOD) +
78
+ "CHECKTYPE~baz|AMOUNT~17.29|CUSTID~DDuck|BNAME~John Doe|BADDRESS~1234 Main Street|BADDRESS2~Apartment 1B|BCITY~Shoreline|BSTATE~WA|BZIP~98133|BCOUNTRY~US|SNAME~Jane Doe|SADDRESS~1235 Moon Street|SADDRESS2~Apartment 2C|SCITY~Shortline|SSTATE~WA|SZIP~98134|SCOUNTRY~US|"
79
+ end
80
+
81
+
82
+ it "accepts email, invoice, description, tax amount, and customer reference id" do
83
+ PayTrace::API::Gateway.next_response = "RESULT~Ok"
26
84
 
27
- # UN, PSWD, TERMS, METHOD, CHECKTYPE, AMOUNT, CUSTID
28
- it "should process a check payment via customer id" do
29
- PayTrace::API::Gateway.next_response = "RESULT~Ok"
30
- params = {
31
- check_type: 'bar',
32
- amount: 17.28,
33
- customer_id: 'MMouse'
34
- }
35
- result = PayTrace::CheckTransaction.process_sale(params)
36
- PayTrace::API::Gateway.last_request.must_equal base_url(PayTrace::CheckTransaction::PROCESS_SALE_METHOD) +
37
- "CHECKTYPE~bar|AMOUNT~17.28|CUSTID~MMouse|"
85
+ params = {
86
+ email: 'foo@bar.com',
87
+ description: 'You bought something with a check, yo!',
88
+ invoice: '12345',
89
+ amount: 17.27,
90
+ customer_id: 'YosemiteSam',
91
+ tax_amount: 2.11,
92
+ customer_reference_id: '1234AB'
93
+ }
94
+ result = PayTrace::CheckTransaction.process_sale(params)
95
+
96
+ PayTrace::API::Gateway.last_request.must_equal base_url(PayTrace::CheckTransaction::PROCESS_SALE_METHOD) +
97
+ "AMOUNT~17.27|CUSTID~YosemiteSam|EMAIL~foo@bar.com|INVOICE~12345|DESCRIPTION~You bought something with a check, yo!|TAX~2.11|CUSTREF~1234AB|"
98
+ end
99
+
100
+ it "accepts discretionary data" do
101
+ PayTrace::API::Gateway.next_response = "RESULT~Ok"
102
+
103
+ params = {
104
+ check_type: 'foo',
105
+ amount: 17.29,
106
+ account_number: 1234567,
107
+ routing_number: 1234568,
108
+ discretionary_data: {hair_color: :red}
109
+ }
110
+ result = PayTrace::CheckTransaction.process_sale(params)
111
+
112
+ PayTrace::API::Gateway.last_request.must_equal base_url(PayTrace::CheckTransaction::PROCESS_SALE_METHOD) +
113
+ "CHECKTYPE~foo|AMOUNT~17.29|DDA~1234567|TR~1234568|hair_color~red|"
114
+ end
38
115
  end
39
116
 
40
- it "accepts billing and shipping information"
41
- it "accepts email, invoice, description, tax amount, and customer reference id"
42
- it "accepts discretionary data"
117
+ # hold transactions are just sale transactions with a CheckType of "Hold" -- don't need to re-test
118
+ describe "hold transactions" do
119
+ it "accepts a routing number/account number hold request" do
120
+ PayTrace::API::Gateway.next_response = "RESULT~Ok"
121
+ params = {
122
+ check_type: 'foo',
123
+ amount: 17.29,
124
+ account_number: 1234567,
125
+ routing_number: 1234568,
126
+ discretionary_data: {hair_color: :red}
127
+ }
128
+ result = PayTrace::CheckTransaction.process_hold(params)
129
+
130
+ PayTrace::API::Gateway.last_request.must_equal base_url(PayTrace::CheckTransaction::PROCESS_SALE_METHOD) +
131
+ "AMOUNT~17.29|DDA~1234567|TR~1234568|CHECKTYPE~Hold|hair_color~red|"
132
+ end
133
+
134
+ describe "refund transactions" do
135
+ it "accepts a check ID" do
136
+ PayTrace::API::Gateway.next_response = "RESULT~Ok"
137
+ params = {
138
+ check_type: 'foo',
139
+ check_id: 12345678
140
+ }
141
+ result = PayTrace::CheckTransaction.process_refund(params)
142
+
143
+ PayTrace::API::Gateway.last_request.must_equal base_url(PayTrace::CheckTransaction::PROCESS_SALE_METHOD) +
144
+ "CHECKID~12345678|CHECKTYPE~Refund|"
145
+ end
146
+ end
147
+
148
+ describe "manage a check" do
149
+ it "accepts check id" do
150
+ PayTrace::API::Gateway.next_response = "RESULT~Ok"
151
+ params = {
152
+ check_type: 'Hold',
153
+ check_id: 12345678
154
+ }
155
+ result = PayTrace::CheckTransaction.manage_check(params)
156
+
157
+ PayTrace::API::Gateway.last_request.must_equal base_url(PayTrace::CheckTransaction::MANAGE_CHECK_METHOD) +
158
+ "CHECKTYPE~Hold|CHECKID~12345678|"
159
+ end
160
+ end
161
+ end
43
162
  end
@@ -9,8 +9,8 @@ PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
9
9
  PayTrace::Debug.trace do
10
10
  params = {
11
11
  # this must be a valid transaction ID for the credentials supplied
12
- transaction_id: 1131,
13
- amount: 4.01
12
+ transaction_id: 938,
13
+ amount: 1.01
14
14
  }
15
15
  PayTrace::Transaction::adjust_amount(params)
16
16
  end
@@ -0,0 +1,21 @@
1
+ $:<< "./lib" # uncomment this to run against a Git clone instead of an installed gem
2
+
3
+ require "paytrace"
4
+ require "paytrace/debug"
5
+
6
+ # change this as needed to reflect the username, password, and test host you're testing against
7
+ PayTrace::Debug.configure_test("demo123", "demo123", "stage.paytrace.com")
8
+
9
+ # http://help.paytrace.com/api-processing-a-check-sale
10
+
11
+ PayTrace::Debug.trace do
12
+ params = {
13
+ check_type: "Sale",
14
+ amount: 15.99,
15
+ # replace this with a valid customer ID
16
+ customer_id: 'MoMouse',
17
+ test_flag: 'Y'
18
+ }
19
+
20
+ PayTrace::CheckTransaction::process_sale(params)
21
+ end
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.18
4
+ version: 0.1.19
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-01 00:00:00.000000000 Z
11
+ date: 2014-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -145,6 +145,7 @@ files:
145
145
  - test/scripts/run_attach_signature.rb
146
146
  - test/scripts/run_calculate_shipping_costs.rb
147
147
  - test/scripts/run_change_password.rb
148
+ - test/scripts/run_check_transactions.rb
148
149
  - test/scripts/run_create_customer.rb
149
150
  - test/scripts/run_email_request.rb
150
151
  - test/scripts/run_export_customers.rb
@@ -198,6 +199,7 @@ test_files:
198
199
  - test/scripts/run_attach_signature.rb
199
200
  - test/scripts/run_calculate_shipping_costs.rb
200
201
  - test/scripts/run_change_password.rb
202
+ - test/scripts/run_check_transactions.rb
201
203
  - test/scripts/run_create_customer.rb
202
204
  - test/scripts/run_email_request.rb
203
205
  - test/scripts/run_export_customers.rb