slidepay 0.0.12 → 0.0.13
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 +4 -4
- data/README.md +71 -0
- data/TODO.md +8 -6
- data/lib/slidepay.rb +5 -0
- data/lib/slidepay/ach/balance.rb +31 -0
- data/lib/slidepay/ach/resource.rb +17 -0
- data/lib/slidepay/ach/retrieval.rb +111 -0
- data/lib/slidepay/ach/settlement.rb +68 -0
- data/lib/slidepay/resources/api_resource.rb +18 -16
- data/lib/slidepay/resources/payment.rb +17 -0
- data/lib/slidepay/version.rb +1 -1
- data/scenarios/ach/balance.rb +18 -0
- data/scenarios/ach/fetch_retrieval.rb +19 -0
- data/scenarios/ach/retrieval_create_with_bank_account_info.rb +39 -0
- data/scenarios/ach/retrieval_create_with_id_fields.rb +25 -0
- data/scenarios/ach/retrieval_fetch_with_settlement_token_class_method.rb +17 -0
- data/scenarios/ach/retrieval_settlement_token_fetch.rb +19 -0
- data/scenarios/ach/settlement.rb +28 -0
- data/scenarios/create_simple_payment.rb +33 -0
- data/spec/ach/balance_spec.rb +38 -0
- data/spec/ach/resource_spec.rb +17 -0
- data/spec/ach/retrieval_spec.rb +170 -0
- data/spec/ach/settlement_spec.rb +121 -0
- data/spec/payment_spec.rb +26 -1
- data/spec/spec_helper.rb +524 -1
- metadata +22 -2
@@ -0,0 +1,19 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
2
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'spec'))
|
3
|
+
|
4
|
+
require 'multi_json'
|
5
|
+
require 'slidepay'
|
6
|
+
require 'spec_helper'
|
7
|
+
|
8
|
+
include SlidePay
|
9
|
+
|
10
|
+
SlidePay.configure(development: true)
|
11
|
+
SlidePay.api_key = ENV["admin_api_key"]
|
12
|
+
|
13
|
+
RestClient.proxy = "http://127.0.0.1:8888"
|
14
|
+
|
15
|
+
r = ACH::Retrieval.new
|
16
|
+
r['retrieval_id'] = ENV["retrieval_id"]
|
17
|
+
r.retrieve()
|
18
|
+
|
19
|
+
puts "retrieval: #{r}"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
2
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'spec'))
|
3
|
+
|
4
|
+
require 'multi_json'
|
5
|
+
require 'slidepay'
|
6
|
+
require 'spec_helper'
|
7
|
+
|
8
|
+
include SlidePay
|
9
|
+
|
10
|
+
SlidePay.configure(development: true)
|
11
|
+
SlidePay.api_key = ENV["ach_api_key"]
|
12
|
+
|
13
|
+
RestClient.proxy = "http://127.0.0.1:8888"
|
14
|
+
|
15
|
+
bank_account_info = {
|
16
|
+
location_id: ENV["location_id"],
|
17
|
+
company_id: ENV["company_id"],
|
18
|
+
bank_account_id: 0,
|
19
|
+
user_master_id: ENV["user_master_id"],
|
20
|
+
bank_account_first_name: "Father",
|
21
|
+
bank_account_last_name: "Yummy Bears",
|
22
|
+
name: "ACCOUNT 211",
|
23
|
+
bank_account_type: "Personal Checking",
|
24
|
+
bank_account_routing_number: ENV["retrieval_routing_number"],
|
25
|
+
bank_account_account_number: ENV["retrieval_account_number"],
|
26
|
+
bank_account_address_1: "123 blah st",
|
27
|
+
bank_account_city: "SAN JOSE",
|
28
|
+
bank_account_state: "CA",
|
29
|
+
bank_account_postal_code: "11111",
|
30
|
+
bank_account_country: "USA",
|
31
|
+
bank_account_phone_country_code: "1",
|
32
|
+
bank_account_phone: "1231231234",
|
33
|
+
retrieval_amount: 0.01
|
34
|
+
}
|
35
|
+
|
36
|
+
r = ACH::Retrieval.create_with_bank_account(bank_account_info)
|
37
|
+
|
38
|
+
puts "retrieval: #{r}"
|
39
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
2
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'spec'))
|
3
|
+
|
4
|
+
require 'multi_json'
|
5
|
+
require 'slidepay'
|
6
|
+
require 'spec_helper'
|
7
|
+
|
8
|
+
include SlidePay
|
9
|
+
|
10
|
+
SlidePay.configure(development: true)
|
11
|
+
SlidePay.api_key = ENV["ach_api_key"]
|
12
|
+
|
13
|
+
RestClient.proxy = "http://127.0.0.1:8888"
|
14
|
+
|
15
|
+
bank_account_id_refs = {
|
16
|
+
location_id: ENV["location_id"],
|
17
|
+
company_id: ENV["company_id"],
|
18
|
+
bank_account_id: ENV["retrieval_bank_account"],
|
19
|
+
user_master_id: ENV["user_master_id"],
|
20
|
+
retrieval_amount: 0.01
|
21
|
+
}
|
22
|
+
|
23
|
+
r = ACH::Retrieval.create_with_bank_account(bank_account_id_refs)
|
24
|
+
|
25
|
+
puts "retrieval: #{r}"
|
@@ -0,0 +1,17 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
2
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'spec'))
|
3
|
+
|
4
|
+
require 'multi_json'
|
5
|
+
require 'slidepay'
|
6
|
+
require 'spec_helper'
|
7
|
+
|
8
|
+
include SlidePay
|
9
|
+
|
10
|
+
SlidePay.configure(development: true)
|
11
|
+
SlidePay.api_key = ENV["admin_api_key"]
|
12
|
+
|
13
|
+
RestClient.proxy = "http://127.0.0.1:8888"
|
14
|
+
|
15
|
+
r = ACH::Retrieval.retrieve_by_settlement_token(ENV["settlement_transaction_token"])
|
16
|
+
|
17
|
+
puts "retrieval: #{r}"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
2
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'spec'))
|
3
|
+
|
4
|
+
require 'multi_json'
|
5
|
+
require 'slidepay'
|
6
|
+
require 'spec_helper'
|
7
|
+
|
8
|
+
include SlidePay
|
9
|
+
|
10
|
+
SlidePay.configure(development: true)
|
11
|
+
SlidePay.api_key = ENV["admin_api_key"]
|
12
|
+
|
13
|
+
RestClient.proxy = "http://127.0.0.1:8888"
|
14
|
+
|
15
|
+
r = ACH::Retrieval.new
|
16
|
+
r['settlement_transaction_token'] = ENV["settlement_transaction_token"]
|
17
|
+
r.retrieve()
|
18
|
+
|
19
|
+
puts "retrieval: #{r}"
|
@@ -0,0 +1,28 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
2
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'spec'))
|
3
|
+
|
4
|
+
require 'multi_json'
|
5
|
+
require 'slidepay'
|
6
|
+
require 'spec_helper'
|
7
|
+
|
8
|
+
include SlidePay
|
9
|
+
|
10
|
+
SlidePay.configure(development: true)
|
11
|
+
SlidePay.api_key = ENV["ach_api_key"]
|
12
|
+
|
13
|
+
RestClient.proxy = "http://127.0.0.1:8888"
|
14
|
+
|
15
|
+
settlement_descriptor = {
|
16
|
+
location_id: ENV["location_id"],
|
17
|
+
company_id: ENV["company_id"],
|
18
|
+
settlement_list:[
|
19
|
+
{ bank_account_id: ENV["settlement_bank_account"] , amount:0.25 }
|
20
|
+
],
|
21
|
+
notes:'Test Settlement'
|
22
|
+
}
|
23
|
+
|
24
|
+
settlement_descriptor_list = []
|
25
|
+
|
26
|
+
settlment_result = SlidePay::ACH::Settlement.process(settlement_descriptor)
|
27
|
+
|
28
|
+
puts "Settlement processed for location_id #{ENV["location_id"]} for $0.00. Result: #{settlment_result}"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
2
|
+
$:.unshift(File.join(File.dirname(__FILE__), 'spec'))
|
3
|
+
|
4
|
+
require 'multi_json'
|
5
|
+
require 'slidepay'
|
6
|
+
require 'spec_helper'
|
7
|
+
|
8
|
+
include SlidePay
|
9
|
+
|
10
|
+
SlidePay.configure(development: true)
|
11
|
+
SlidePay.api_key = ENV["api_key"]
|
12
|
+
|
13
|
+
RestClient.proxy = "http://127.0.0.1:8888"
|
14
|
+
|
15
|
+
|
16
|
+
cc = {
|
17
|
+
cc_number: "",
|
18
|
+
cc_expiry_month: "01",
|
19
|
+
cc_expiry_year: "2017",
|
20
|
+
cc_billing_zip: "95112",
|
21
|
+
method: "CreditCard",
|
22
|
+
amount: 2.01
|
23
|
+
}
|
24
|
+
payment = SlidePay::Payment.new(cc)
|
25
|
+
|
26
|
+
r = payment.process()
|
27
|
+
|
28
|
+
if r
|
29
|
+
puts "Payment created with id: #{p.id}"
|
30
|
+
else
|
31
|
+
puts "Payment failed. "
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "slidepay"
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe SlidePay::ACH::Balance do
|
5
|
+
describe "retrieve" do
|
6
|
+
it "append location_id to the url" do
|
7
|
+
SlidePay.should_receive(:post).with(hash_including(path: "settlement/balance/4")).and_return(a_response_object)
|
8
|
+
SlidePay::ACH::Balance.retrieve(4)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should pass auth information to SlidePay.post" do
|
12
|
+
auth_hash = { token: "TOKEN", api_key: "API_KEY", endpoint: "ENDPOINT" }
|
13
|
+
SlidePay.should_receive(:post).with(hash_including(path: "settlement/balance/1", token: "TOKEN")).and_return(a_response_object)
|
14
|
+
SlidePay::ACH::Balance.retrieve(1, auth_hash)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should raise an error if balance could not be retrieved" do
|
18
|
+
SlidePay.should_receive(:post).and_return(a_response_object(failed_balance_response))
|
19
|
+
expect {
|
20
|
+
SlidePay::ACH::Balance.retrieve(1)
|
21
|
+
}.to raise_error
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should raise an error if no location_id is provided" do
|
25
|
+
expect {
|
26
|
+
SlidePay::ACH::Balance.retrieve()
|
27
|
+
}.to raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return the balance value if call is successful" do
|
31
|
+
SlidePay.should_receive(:post).and_return(a_response_object(successful_balance_response))
|
32
|
+
balance = SlidePay::ACH::Balance.retrieve(1)
|
33
|
+
|
34
|
+
expect(balance).to eq(15.00)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "slidepay"
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe SlidePay::ACH::Resource do
|
5
|
+
# No need to test anything until we remove methods from the ApiResource class
|
6
|
+
describe "removed methods" do
|
7
|
+
it "should raise an error if save is called" do
|
8
|
+
r = SlidePay::ACH::Resource.new()
|
9
|
+
expect { r.save() }.to raise_error
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should raise an error if destroy is called" do
|
13
|
+
r = SlidePay::ACH::Resource.new()
|
14
|
+
expect { r.destroy() }.to raise_error
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
require "slidepay"
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe SlidePay::ACH::Retrieval do
|
5
|
+
# Test retrieval initialization
|
6
|
+
describe "instantiation" do
|
7
|
+
it "should populate the object instance with the hash passed in" do
|
8
|
+
r = SlidePay::ACH::Retrieval.new(unledgered_retrieval_object)
|
9
|
+
expect(r.is_new?).to be_false
|
10
|
+
expect(r.id()).to eq(3)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "class methods" do
|
15
|
+
describe "create_with_bank_account" do
|
16
|
+
# it "should call"
|
17
|
+
# 1. [Create] Retrieval with bank_account_id, user_master_id, company_id, location_id
|
18
|
+
it "should accept the _id parameters as a hash" do
|
19
|
+
params = {
|
20
|
+
location_id: 622,
|
21
|
+
company_id: 18,
|
22
|
+
bank_account_id: 167,
|
23
|
+
retrieval_amount: 1.01,
|
24
|
+
user_master_id: 661
|
25
|
+
}
|
26
|
+
|
27
|
+
SlidePay.should_receive(:post).with(hash_including(data: params.to_json)).and_return(a_response_object)
|
28
|
+
|
29
|
+
SlidePay::ACH::Retrieval.create_with_bank_account(params)
|
30
|
+
end
|
31
|
+
|
32
|
+
# 2. [Create] Retrieval with bank_account object
|
33
|
+
it "should accept a bank account object as a parameter" do
|
34
|
+
bank_account = {
|
35
|
+
bank_account_id: 211,
|
36
|
+
company_id: 213,
|
37
|
+
location_id: 285,
|
38
|
+
user_master_id: 297,
|
39
|
+
account_first_name: "Father",
|
40
|
+
account_last_name: "Yummy Bears",
|
41
|
+
name: "ACCOUNT 211",
|
42
|
+
routing_number: "211123456",
|
43
|
+
account_number: "211211211",
|
44
|
+
created: "2013-09-06T04:05:49",
|
45
|
+
last_update: "2013-09-06T04:05:49"
|
46
|
+
}
|
47
|
+
|
48
|
+
SlidePay.should_receive(:post).with(hash_including(data: bank_account.to_json)).and_return(a_response_object)
|
49
|
+
|
50
|
+
SlidePay::ACH::Retrieval.create_with_bank_account(bank_account)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "retrieve_by_settlement_token" do
|
55
|
+
it "should accept a string for the settlement_transaction_token" do
|
56
|
+
settlement_transaction_token = "SETTLEMENT_TRANSACTION_TOKEN"
|
57
|
+
base_path = "retrieval"
|
58
|
+
SlidePay.should_receive(:get).with(hash_including(path: "#{base_path}?settlement_transaction_token=#{settlement_transaction_token}")).and_return(a_response_object)
|
59
|
+
SlidePay::ACH::Retrieval.retrieve_by_settlement_token(settlement_transaction_token)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should raise an error if the transaction_token is not a String" do
|
63
|
+
expect {
|
64
|
+
SlidePay::ACH::Retrieval.retrieve_by_settlement_token(1)
|
65
|
+
}.to raise_error
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "instance methods" do
|
71
|
+
describe "url" do
|
72
|
+
it "should append the retrieval_id to url_root if present" do
|
73
|
+
r = SlidePay::ACH::Retrieval.new("retrieval_id" => 3)
|
74
|
+
expect(r.url()).to eq("retrieval/3")
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should append the settlement_transaction_token to url_root if it is present, but retrieval_id is not" do
|
78
|
+
r = SlidePay::ACH::Retrieval.new("settlement_transaction_token" => "SETTLEMENT_TRANSACTION_TOKEN")
|
79
|
+
expect(r.url()).to eq("retrieval?settlement_transaction_token=SETTLEMENT_TRANSACTION_TOKEN")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe "is_new?" do
|
84
|
+
it "should return false if settlement_transaction_token is not nil" do
|
85
|
+
r = SlidePay::ACH::Retrieval.new("settlement_transaction_token" => "SETTLEMENT_TRANSACTION_TOKEN")
|
86
|
+
expect(r.is_new?).to be_false
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should return false if retrieval_id is not nil" do
|
90
|
+
r = SlidePay::ACH::Retrieval.new("retrieval_id" => 3)
|
91
|
+
expect(r.is_new?).to be_false
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should return true if neither retrieval_id or settlement_transaction_token are set" do
|
95
|
+
r = SlidePay::ACH::Retrieval.new
|
96
|
+
expect(r.is_new?).to be_true
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe "create_with_bank_account" do
|
101
|
+
it "should call the class-level create_with_bank_account method" do
|
102
|
+
bank_account_hash = {}
|
103
|
+
SlidePay::ACH::Retrieval.should_receive(:create_with_bank_account).and_return({})
|
104
|
+
|
105
|
+
r = SlidePay::ACH::Retrieval.new()
|
106
|
+
r.create_with_bank_account(bank_account_hash)
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should pass auth options into the class-level method" do
|
110
|
+
auth_hash = { token: "TOKEN", api_key: "API_KEY", endpoint: "ENDPOINT" }
|
111
|
+
SlidePay::ACH::Retrieval.should_receive(:create_with_bank_account).with({}, auth_hash).and_return({})
|
112
|
+
|
113
|
+
r = SlidePay::ACH::Retrieval.new(auth_hash)
|
114
|
+
r.create_with_bank_account({})
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "retrieve_by_settlement_token" do
|
119
|
+
it "should call the class-level retrieve_by_settlement_token method" do
|
120
|
+
transaction_token = "SETTLEMENT_TRANSACTION_TOKEN"
|
121
|
+
SlidePay::ACH::Retrieval.should_receive(:retrieve_by_settlement_token) do |arg1, arg2|
|
122
|
+
expect(arg1).to eq(transaction_token)
|
123
|
+
{}
|
124
|
+
end
|
125
|
+
|
126
|
+
r = SlidePay::ACH::Retrieval.new()
|
127
|
+
r.retrieve_by_settlement_token(transaction_token)
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should pass auth options into the class-level method" do
|
131
|
+
auth_hash = { :token => "TOKEN", :api_key => "API_KEY", :endpoint => "ENDPOINT" }
|
132
|
+
transaction_token = "SETTLEMENT_TRANSACTION_TOKEN"
|
133
|
+
|
134
|
+
SlidePay::ACH::Retrieval.should_receive(:retrieve_by_settlement_token).with(transaction_token, auth_hash).and_return({})
|
135
|
+
|
136
|
+
r = SlidePay::ACH::Retrieval.new(auth_hash)
|
137
|
+
r.retrieve_by_settlement_token(transaction_token)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# Test retrieve
|
142
|
+
describe "retrieve" do
|
143
|
+
before(:all) do
|
144
|
+
SlidePay.stub(:get) { a_response_object(successful_retrieval_retrieve_response) }
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should populate a retrieval object on success" do
|
148
|
+
r = SlidePay::ACH::Retrieval.new()
|
149
|
+
r["retrieval_id"] = 4
|
150
|
+
r.retrieve()
|
151
|
+
|
152
|
+
expect(r.is_new?).to be_false
|
153
|
+
expect(r["settlement_transaction_token"]).to eq("B41BB60D-942C-46DB-99F8-D3308F3ECA3D")
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe "ledgered?" do
|
158
|
+
it "should return false if the retrieval has not been ledgered" do
|
159
|
+
r = SlidePay::ACH::Retrieval.new(unledgered_retrieval_object)
|
160
|
+
expect(r.is_ledgered?).to be_false
|
161
|
+
end
|
162
|
+
|
163
|
+
it "should return true if the retrieval has been ledgered" do
|
164
|
+
r = SlidePay::ACH::Retrieval.new(ledgered_retrieval_object)
|
165
|
+
expect(r.is_ledgered?).to be_true
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require "slidepay"
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
# Settlement descriptors
|
5
|
+
valid_descriptor = { bank_account_id: 1, amount: 1.01 }
|
6
|
+
valid_descriptor_list = [{ bank_account_id: 1, amount: 1.01 }, { bank_account_id: 2, amount: 2.02 }]
|
7
|
+
valid_descriptor_list_string_keys = [{ "bank_account_id" => 1, "amount" => 1.01 }, { "bank_account_id" => 2, "amount" => 2.02 }]
|
8
|
+
invalid_descriptor_list = [{ bank_account_id: 1, amount: 1.01 }, { amount: 2.02 }]
|
9
|
+
invalid_descriptor_no_bank_account_id = { amount: 1.23 }
|
10
|
+
invalid_descriptor_no_amount = { bank_account_id: 1 }
|
11
|
+
|
12
|
+
# Settlement order objects
|
13
|
+
def settlement_order(settlement_list)
|
14
|
+
{
|
15
|
+
company_id: 18,
|
16
|
+
location_id: 622,
|
17
|
+
settlement_list: settlement_list,
|
18
|
+
notes: "Test Settlement"
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def settlement_order_string_keys
|
23
|
+
{
|
24
|
+
"company_id" => 18,
|
25
|
+
"location_id" => 622,
|
26
|
+
"settlement_list" => [{ "bank_account_id" => 1, "amount" => 1.01 }, { "bank_account_id" => 2, "amount" => 2.02 }],
|
27
|
+
"notes" => "Test Settlement"
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def settlement_order_symbol_keys
|
32
|
+
{
|
33
|
+
company_id: 18,
|
34
|
+
location_id: 622,
|
35
|
+
settlement_list: [{ bank_account_id: 1, amount: 1.01 }, { bank_account_id: 2, amount: 2.02 }],
|
36
|
+
notes: "Test Settlement"
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
def settlement_order_no_company_id(settlement_list)
|
41
|
+
{
|
42
|
+
location_id: 622,
|
43
|
+
settlement_list: settlement_list,
|
44
|
+
notes: "Test Settlement"
|
45
|
+
}
|
46
|
+
end
|
47
|
+
|
48
|
+
def settlement_order_no_location_id(settlement_list)
|
49
|
+
{
|
50
|
+
company_id: 18,
|
51
|
+
settlement_list: settlement_list,
|
52
|
+
notes: "Test Settlement"
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def settlement_order_no_settlement_list
|
57
|
+
{
|
58
|
+
company_id: 18,
|
59
|
+
location_id: 622,
|
60
|
+
notes: "Test Settlement"
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
describe SlidePay::ACH::Settlement do
|
65
|
+
describe "process" do
|
66
|
+
it "should accept a hash " do
|
67
|
+
SlidePay.should_receive(:post).and_return(a_response_object)
|
68
|
+
|
69
|
+
SlidePay::ACH::Settlement.process(settlement_order(valid_descriptor_list))
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should call the SlidePay.post method" do
|
73
|
+
SlidePay.should_receive(:post).and_return(a_response_object)
|
74
|
+
SlidePay::ACH::Settlement.process(settlement_order(valid_descriptor_list))
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "failure cases" do
|
78
|
+
it "should raise an error if the settlment_order is not a hash" do
|
79
|
+
expect { SlidePay::ACH::Settlement.process("I AM A STRING") }.to raise_error
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should raise an error if company_id is not supplied" do
|
83
|
+
expect { SlidePay::ACH::Settlement.process(settlement_order_no_company_id(valid_descriptor_list)) }.to raise_error
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should raise an error if location_id is not supplied" do
|
87
|
+
expect { SlidePay::ACH::Settlement.process(settlement_order_no_location_id(valid_descriptor_list)) }.to raise_error
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should raise an error if settlement_list is not supplied" do
|
91
|
+
expect { SlidePay::ACH::Settlement.process(settlement_order_no_settlement_list) }.to raise_error
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should raise an error if a descriptor is supplied without a bank_account_id" do
|
95
|
+
expect { SlidePay::ACH::Settlement.process(settlement_order([invalid_descriptor_no_bank_account_id])) }.to raise_error
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should raise an error if a descriptor is supplied without an amount" do
|
99
|
+
expect { SlidePay::ACH::Settlement.process(settlement_order([invalid_descriptor_no_amount])) }.to raise_error
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should raise an error if one descriptor in a list is invalid" do
|
103
|
+
expect { SlidePay::ACH::Settlement.process(settlement_order(invalid_descriptor_list)) }.to raise_error
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "acceptable parameters" do
|
108
|
+
it "should accept symbol keys in the settlement_order hash" do
|
109
|
+
SlidePay.should_receive(:post).and_return(a_response_object)
|
110
|
+
SlidePay::ACH::Settlement.process(settlement_order_symbol_keys)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should accept string keys in the settlement_order hash" do
|
114
|
+
SlidePay.should_receive(:post).and_return(a_response_object)
|
115
|
+
SlidePay::ACH::Settlement.process(settlement_order_string_keys)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|