pay_simple 0.0.1
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 +7 -0
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +35 -0
- data/LICENSE.txt +22 -0
- data/README.md +100 -0
- data/Rakefile +1 -0
- data/lib/ps.rb +32 -0
- data/lib/ps/api.rb +80 -0
- data/lib/ps/api/json.rb +78 -0
- data/lib/ps/base.rb +22 -0
- data/lib/ps/enumerations.rb +191 -0
- data/lib/ps/exceptions.rb +5 -0
- data/lib/ps/object.rb +48 -0
- data/lib/ps/objects/ach_account.rb +34 -0
- data/lib/ps/objects/credit_card_account.rb +38 -0
- data/lib/ps/objects/customer.rb +79 -0
- data/lib/ps/objects/customer_account.rb +25 -0
- data/lib/ps/objects/payment.rb +73 -0
- data/lib/ps/objects/payment_status_filter.rb +6 -0
- data/lib/ps/objects/recurring_payment.rb +60 -0
- data/lib/ps/objects/recurring_payment_filter.rb +26 -0
- data/lib/ps/objects/user.rb +10 -0
- data/lib/ps/response.rb +83 -0
- data/lib/ps/util.rb +28 -0
- data/lib/ps/util/hash.rb +17 -0
- data/lib/ps/util/state.rb +15 -0
- data/lib/ps/util/states.yml +263 -0
- data/lib/ps/util/string.rb +15 -0
- data/paysimple.gemspec +19 -0
- data/spec/config.yml.example +13 -0
- data/spec/factories/ach_account.rb +11 -0
- data/spec/factories/credit_card_accounts.rb +11 -0
- data/spec/factories/customer_accounts.rb +7 -0
- data/spec/factories/customers.rb +18 -0
- data/spec/factories/payment.rb +12 -0
- data/spec/factories/recurring_payment.rb +25 -0
- data/spec/ps/api/json_spec.rb +12 -0
- data/spec/ps/api_spec.rb +53 -0
- data/spec/ps/base_spec.rb +40 -0
- data/spec/ps/format_spec.rb +16 -0
- data/spec/ps/object_spec.rb +35 -0
- data/spec/ps/objects/ach_account_spec.rb +57 -0
- data/spec/ps/objects/credit_card_account_spec.rb +69 -0
- data/spec/ps/objects/customer_account_spec.rb +43 -0
- data/spec/ps/objects/customer_spec.rb +153 -0
- data/spec/ps/objects/payment_spec.rb +98 -0
- data/spec/ps/objects/recurring_payment_spec.rb +145 -0
- data/spec/ps/objects/user_spec.rb +14 -0
- data/spec/ps/response_spec.rb +39 -0
- data/spec/ps/util/hash_spec.rb +33 -0
- data/spec/ps/util/states_spec.rb +25 -0
- data/spec/ps/util/string_spec.rb +21 -0
- data/spec/ps/util_spec.rb +30 -0
- data/spec/spec_functions.rb +155 -0
- data/spec/spec_helper.rb +22 -0
- metadata +156 -0
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "An instance of", PS::Payment do
|
4
|
+
before { connect() }
|
5
|
+
let(:customer_id) { PS::Customer.create(FactoryGirl.attributes_for(:customer)).ps_reference_id }
|
6
|
+
let(:customer_account_id) do
|
7
|
+
PS::CreditCardAccount.create(
|
8
|
+
FactoryGirl.attributes_for(:credit_card_account, :customer_id => customer_id )
|
9
|
+
).ps_reference_id
|
10
|
+
end
|
11
|
+
let(:amount) { 5 }
|
12
|
+
|
13
|
+
describe "#list" do
|
14
|
+
let(:payment_id) do
|
15
|
+
PS::Payment.make(customer_id, amount, customer_account_id)
|
16
|
+
end
|
17
|
+
subject { PS::Payment.list(customer_id) }
|
18
|
+
|
19
|
+
it "should list the payments for a customer given a their id" do
|
20
|
+
subject
|
21
|
+
end
|
22
|
+
|
23
|
+
#need pages to iterate through...
|
24
|
+
it "should find a customer given criteria to search with"
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "manage payment" do
|
28
|
+
context "with instance" do
|
29
|
+
subject do
|
30
|
+
PS::Payment.make(customer_id, amount, customer_account_id)
|
31
|
+
end
|
32
|
+
|
33
|
+
context "#cancel_payment" do
|
34
|
+
it "should cancel the given payment." do
|
35
|
+
payment = subject
|
36
|
+
payment.cancel
|
37
|
+
payment.status.should == PaymentStatus::VOIDED
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "#reverse_payment" do
|
42
|
+
it "should reverse the given payment" do
|
43
|
+
#cannot test
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "with id" do
|
49
|
+
let(:payment_id) do
|
50
|
+
PS::Payment.make(customer_id, amount, customer_account_id).ps_reference_id
|
51
|
+
end
|
52
|
+
subject { PS::Payment }
|
53
|
+
|
54
|
+
context ".cancel_by_id" do
|
55
|
+
it "should cancel a payment given a payment id." do
|
56
|
+
subject.cancel_by_id(payment_id).should == true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context ".reverse_by_id" do
|
61
|
+
it "should reverse a payment given a payment id." do
|
62
|
+
#cant be tested
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe ".make" do
|
69
|
+
subject do
|
70
|
+
PS::Payment.make(customer_id, amount, customer_account_id)
|
71
|
+
end
|
72
|
+
context "given a customer_id and amount" do
|
73
|
+
it "should make a payment." do
|
74
|
+
payment = subject
|
75
|
+
payment.ps_reference_id.should_not be_nil
|
76
|
+
payment.status.should == PaymentStatus::AUTHORIZED
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "&update_by_find" do
|
82
|
+
before do
|
83
|
+
8.times do
|
84
|
+
PS::Payment.make(customer_id, amount, customer_account_id)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
subject do
|
88
|
+
PS::Payment.make(customer_id, amount, customer_account_id)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should iterate through the payments and update the correct attrs" do
|
92
|
+
payment = subject
|
93
|
+
payment.status.should == PaymentStatus::AUTHORIZED
|
94
|
+
payment.cancel
|
95
|
+
payment.status.should == PaymentStatus::VOIDED
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,145 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "An instance of", PS::RecurringPayment do
|
4
|
+
before { connect() }
|
5
|
+
let(:customer_id) do
|
6
|
+
FactoryGirl.create(:customer).ps_reference_id
|
7
|
+
end
|
8
|
+
let(:customer_account_id) do
|
9
|
+
PS::CreditCardAccount.create(
|
10
|
+
FactoryGirl.attributes_for(:credit_card_account, :customer_id => customer_id )
|
11
|
+
).ps_reference_id
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#create" do
|
15
|
+
subject do
|
16
|
+
PS::RecurringPayment.create(
|
17
|
+
FactoryGirl.attributes_for(:recurring_payment,
|
18
|
+
{
|
19
|
+
:customer_id => customer_id,
|
20
|
+
:customer_account_id => customer_account_id
|
21
|
+
}
|
22
|
+
)
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should create a new recurring payment" do
|
27
|
+
new_payment = subject
|
28
|
+
new_payment.class.should == PS::RecurringPayment
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "bad save" do
|
33
|
+
subject do
|
34
|
+
PS::RecurringPayment.new(
|
35
|
+
FactoryGirl.attributes_for(:recurring_payment, {:start_date => "ratesdlcd" })
|
36
|
+
).save()
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should catch the exception and return false" do
|
40
|
+
subject.should == false
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "#destroy" do
|
45
|
+
let(:schedule) {
|
46
|
+
PS::RecurringPayment.create(
|
47
|
+
FactoryGirl.attributes_for(:recurring_payment,
|
48
|
+
{
|
49
|
+
:customer_id => customer_id,
|
50
|
+
:customer_account_id => customer_account_id,
|
51
|
+
:start_date => Time.now+(36400*3)
|
52
|
+
}
|
53
|
+
)
|
54
|
+
)
|
55
|
+
}
|
56
|
+
|
57
|
+
subject { schedule.destroy }
|
58
|
+
|
59
|
+
it "should delete a schedule" do
|
60
|
+
subject
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "given a recurring payment" do
|
65
|
+
subject do
|
66
|
+
PS::RecurringPayment.create(
|
67
|
+
FactoryGirl.attributes_for(:recurring_payment,
|
68
|
+
{
|
69
|
+
:customer_id => customer_id,
|
70
|
+
:customer_account_id => customer_account_id
|
71
|
+
}
|
72
|
+
)
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
describe "#update" do
|
77
|
+
it "should be able to set an instance variable to something else and update" do
|
78
|
+
subject.has_end_date = true
|
79
|
+
subject.end_date = Time.now+(86400*365)
|
80
|
+
subject.update
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
describe "#suspend" do
|
85
|
+
it "should suspend the schedule" do
|
86
|
+
subject.suspend
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#resume" do
|
91
|
+
it "should resume the schedule" do
|
92
|
+
subject.resume
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe ".list" do
|
98
|
+
let(:start_date) { Time.now - (36400*5) }
|
99
|
+
let(:end_date) { Time.now + (36400*5) }
|
100
|
+
let(:customer_id) { FactoryGirl.create(:customer).ps_reference_id }
|
101
|
+
let(:account_id) { FactoryGirl.create(:credit_card_account, { :customer_id => customer_id }).ps_reference_id }
|
102
|
+
|
103
|
+
|
104
|
+
subject { PS::RecurringPayment.list(start_date, end_date, customer_id) }
|
105
|
+
|
106
|
+
before do
|
107
|
+
2.times do
|
108
|
+
PS::RecurringPayment.create(
|
109
|
+
FactoryGirl.attributes_for(:recurring_payment,
|
110
|
+
{
|
111
|
+
:customer_id => customer_id,
|
112
|
+
:customer_account_id => account_id
|
113
|
+
}
|
114
|
+
)
|
115
|
+
)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should return all schedules between the start_date and end_date for a given customer_id" do
|
120
|
+
schedules = subject
|
121
|
+
schedules.length.should == 2
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe ".find" do
|
126
|
+
let(:customer_id) { FactoryGirl.create(:customer).ps_reference_id }
|
127
|
+
let(:account_id) { FactoryGirl.create(:credit_card_account, { :customer_id => customer_id }).ps_reference_id }
|
128
|
+
let(:schedule_id) do
|
129
|
+
PS::RecurringPayment.create(
|
130
|
+
FactoryGirl.attributes_for(:recurring_payment,
|
131
|
+
{
|
132
|
+
:customer_id => customer_id,
|
133
|
+
:customer_account_id => account_id
|
134
|
+
}
|
135
|
+
)
|
136
|
+
).ps_reference_id
|
137
|
+
end
|
138
|
+
|
139
|
+
subject { PS::RecurringPayment.find(schedule_id) }
|
140
|
+
|
141
|
+
it "should return the schedule base off of the schedule id" do
|
142
|
+
subject.ps_reference_id.should == schedule_id
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "An instance of", PS::User do
|
4
|
+
before { connect() }
|
5
|
+
|
6
|
+
describe "#get" do
|
7
|
+
subject { PS::User.get() }
|
8
|
+
#NOTE: I am unsure that this even works in paysimple...
|
9
|
+
it "should get the account user" do
|
10
|
+
subject
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "An instance of", PS::Response do
|
4
|
+
before { connect() }
|
5
|
+
context "where more than one ps_object is returned" do
|
6
|
+
context "of the same subtype" do
|
7
|
+
subject { PS::Response.new(test_ps_response_with_multiple_ps_objects()) }
|
8
|
+
|
9
|
+
it "should check for success" do
|
10
|
+
PS::Response.any_instance.should_receive(:successful_request?)
|
11
|
+
subject
|
12
|
+
end
|
13
|
+
|
14
|
+
it "raw should return an array" do
|
15
|
+
subject.ps_object.class.should == Array
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
context "of different subtypes" do
|
21
|
+
subject { PS::Response.new(test_add_customer_and_make_cc_payment()) }
|
22
|
+
|
23
|
+
it "should check for success, and prepare PsObject results" do
|
24
|
+
PS::Response.any_instance.should_receive(:successful_request?) { true }
|
25
|
+
subject.ps_object
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "where one ps_object is returned" do
|
31
|
+
subject { PS::Response.new(test_ps_response_with_single_ps_object()) }
|
32
|
+
|
33
|
+
it "then ps_object should only contain one object" do
|
34
|
+
response = subject
|
35
|
+
response.ps_object.class.should == Hash
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Hash do
|
4
|
+
describe "#camel_case_keys" do
|
5
|
+
let(:hash) do
|
6
|
+
{ :snake_case => "rawr",
|
7
|
+
:foo => "bar"
|
8
|
+
}
|
9
|
+
end
|
10
|
+
subject { hash.camel_case_keys }
|
11
|
+
|
12
|
+
it "should convert the keys to camel case" do
|
13
|
+
keys = subject.keys
|
14
|
+
keys[0].should == "SnakeCase"
|
15
|
+
keys[1].should == "Foo"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "#snake_case_keys" do
|
20
|
+
let(:hash) do
|
21
|
+
{ :CamelCase => "rawr",
|
22
|
+
:Foo => "bar"
|
23
|
+
}
|
24
|
+
end
|
25
|
+
subject { hash.snake_case_keys }
|
26
|
+
|
27
|
+
it "should convert the keys to snake case" do
|
28
|
+
keys = subject.keys
|
29
|
+
keys[0].should == "camel_case"
|
30
|
+
keys[1].should == "foo"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class DummyClass
|
4
|
+
extend PS::State
|
5
|
+
end
|
6
|
+
|
7
|
+
describe PS::State do
|
8
|
+
let(:states) { }
|
9
|
+
subject { PS::State }
|
10
|
+
|
11
|
+
|
12
|
+
YAML.load_file("lib/ps/util/states.yml").each do |k, state|
|
13
|
+
context "being #{state["name"]}" do
|
14
|
+
let(:abbrev) { PS::States.const_get(state["abbreviation"].upcase) }
|
15
|
+
|
16
|
+
it "should have the state name as a method" do
|
17
|
+
subject.send((state["name"].downcase.gsub(/ /, '_')).to_sym).should == abbrev
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have the state abbr as a method" do
|
21
|
+
(subject.send(state["abbreviation"].downcase.to_sym)).should == abbrev
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe String do
|
4
|
+
describe "#to_snake_case" do
|
5
|
+
let(:string) { "CamelCase" }
|
6
|
+
subject { string.to_snake_case }
|
7
|
+
|
8
|
+
it "should convert the string to snake_case" do
|
9
|
+
subject.should == "camel_case"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "#to_camel_case" do
|
14
|
+
let(:string) { "snake_case" }
|
15
|
+
subject { string.to_camel_case }
|
16
|
+
|
17
|
+
it "should convert the sring to CamelCase" do
|
18
|
+
subject.should == "SnakeCase"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PS::Util do
|
4
|
+
context "Given multiple ps objects" do
|
5
|
+
let(:ps_objects) do
|
6
|
+
[
|
7
|
+
{ "__type" => "PsCustomer:http://api.paysimple.com" },
|
8
|
+
{ "__type" => "PsCreditCardAccount:http://api.paysimple.com" },
|
9
|
+
{ "__type" => "PsPayment:http://api.paysimple.com" }
|
10
|
+
]
|
11
|
+
end
|
12
|
+
subject { PS::Util.instantiate_ps_objects(ps_objects) }
|
13
|
+
|
14
|
+
it "should instantiate the appropriate ps objects" do
|
15
|
+
objects = subject
|
16
|
+
objects[0].class.should == PS::Customer
|
17
|
+
objects[1].class.should == PS::CreditCardAccount
|
18
|
+
objects[2].class.should == PS::Payment
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "given ane ps object" do
|
23
|
+
let(:ps_object) { { "__type" => "PsCustomer:http://api.paysimple.com" } }
|
24
|
+
subject { PS::Util.instantiate_ps_objects(ps_object) }
|
25
|
+
|
26
|
+
it "should instantiate the ps object" do
|
27
|
+
subject.class.should == PS::Customer
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
#the yaml file for config should be in the following format:
|
2
|
+
#:development:
|
3
|
+
# :apikey: ""
|
4
|
+
# :userkey: ""
|
5
|
+
# :env: "development"
|
6
|
+
# :format: "json"
|
7
|
+
# :company_name: ""
|
8
|
+
#:production:
|
9
|
+
# :apikey: ""
|
10
|
+
# :userkey: ""
|
11
|
+
# :env: "production"
|
12
|
+
# :format: "json"
|
13
|
+
# :company_name: ""
|
14
|
+
def formatted_connection_config(format, env=:development)
|
15
|
+
config = YAML.load_file(File.dirname(__FILE__)+"/config.yml")[env]
|
16
|
+
config[:format] = format
|
17
|
+
config
|
18
|
+
end
|
19
|
+
|
20
|
+
def formatless_connection_config(env=:development)
|
21
|
+
YAML.load_file(File.dirname(__FILE__)+"/config.yml")[env]
|
22
|
+
end
|
23
|
+
|
24
|
+
def connect
|
25
|
+
config = formatted_connection_config("Json")
|
26
|
+
PS::Base.establish_connection({
|
27
|
+
:apikey => config[:apikey],
|
28
|
+
:userkey => config[:userkey],
|
29
|
+
:company_name => config[:company_name],
|
30
|
+
:env => config[:env],
|
31
|
+
:format => config[:format]
|
32
|
+
})
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_customer_camel
|
36
|
+
{
|
37
|
+
"FirstName" => "test",
|
38
|
+
"MiddleName" => "e",
|
39
|
+
"LastName" => "name",
|
40
|
+
"Email" => "example@test.com",
|
41
|
+
"Phone" => "0000000000",
|
42
|
+
"BillingAddress1" => "1600 Pennsylvania Ave NW",
|
43
|
+
"BillingCity" => "Washington",
|
44
|
+
"BillingState" => 8,
|
45
|
+
"BillingPostalCode" => 20500,
|
46
|
+
"BillingCountryCode" => "USA",
|
47
|
+
"ShippingSameAsBilling" => 1,
|
48
|
+
"CompanyName" => "USA"
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_customer
|
53
|
+
{
|
54
|
+
:first_name => "test",
|
55
|
+
:middle_name => "e",
|
56
|
+
:last_name => "name",
|
57
|
+
:email => "example@test.com",
|
58
|
+
:phone => "0000000000",
|
59
|
+
:billing_address1 => "1600 Pennsylvania Ave NW",
|
60
|
+
:billing_city => "Washington",
|
61
|
+
:billing_state => 8,
|
62
|
+
:billing_postal_code => 20500,
|
63
|
+
:billing_country_code => "USA",
|
64
|
+
:shipping_same_as_billing => 1,
|
65
|
+
:company_name => "USA"
|
66
|
+
}
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_customer_account
|
70
|
+
{
|
71
|
+
:customer_id => PS::Customer.create(test_customer()).ps_reference_id
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_recurring_payment
|
76
|
+
{
|
77
|
+
:customer_id => PS::Customer.create(test_customer()).ps_reference_id,
|
78
|
+
:customer_account_id => PS::CustomerAccount.new(test_customer_account()).ps_reference_id,
|
79
|
+
:recurring_schedule_type => RecurringScheduleType::PAYMENT_PLAN,
|
80
|
+
:start_date => Time.now,
|
81
|
+
:has_end_date => false,
|
82
|
+
:end_date => "",
|
83
|
+
:billing_frequency_type => BillingFrequencyType::WEEKLY,
|
84
|
+
:billing_frequency_param => "",
|
85
|
+
:payment_amount => 100,
|
86
|
+
:first_payment_done => true,
|
87
|
+
:first_payment_amount => 100,
|
88
|
+
:first_payment_date => Time.now-(86400*3),
|
89
|
+
:total_due_amount => 1000,
|
90
|
+
:total_number_of_payments => 10,
|
91
|
+
:balance_remaining => 900,
|
92
|
+
:number_of_payments_remaining => 9,
|
93
|
+
:invoice_no => "",
|
94
|
+
:order_id => "",
|
95
|
+
:description => "",
|
96
|
+
:schedule_stats => PS::ScheduleStatus::ACTIVE,
|
97
|
+
:number_of_payments_made => 1,
|
98
|
+
:total_amount_paid => 100,
|
99
|
+
:date_of_last_payment_made => Time.now-(86400*3),
|
100
|
+
:pause_until_date => ""
|
101
|
+
}
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_response
|
105
|
+
{
|
106
|
+
"PsObject" => [
|
107
|
+
{
|
108
|
+
"TestAttr" => "value",
|
109
|
+
"AnotherTestAttr" => 1
|
110
|
+
},
|
111
|
+
{
|
112
|
+
"TestAttr" => "value",
|
113
|
+
"AnotherTestAttr" => 1
|
114
|
+
}
|
115
|
+
]
|
116
|
+
}
|
117
|
+
end
|
118
|
+
|
119
|
+
def test_response_snake
|
120
|
+
{
|
121
|
+
"PsObject" => [
|
122
|
+
{
|
123
|
+
"test_attr" => "value",
|
124
|
+
"another_test_attr" => 1
|
125
|
+
},
|
126
|
+
{
|
127
|
+
"test_attr" => "value",
|
128
|
+
"another_test_attr" => 1
|
129
|
+
}
|
130
|
+
]
|
131
|
+
}
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_credit_card_account
|
135
|
+
{
|
136
|
+
"api_consumer_data"=>"",
|
137
|
+
"ps_reference_id"=>0,
|
138
|
+
"customer_id"=>0,
|
139
|
+
"account_number"=>"4111111111111111",
|
140
|
+
"c_c_expiry"=>"12/2015",
|
141
|
+
"c_c_type"=>1
|
142
|
+
}
|
143
|
+
end
|
144
|
+
|
145
|
+
def test_add_customer_and_make_cc_payment
|
146
|
+
JSON.load('{"__type":"PsResponse:http:\/\/api.paysimple.com","CurrentPage":0,"ErrorMessage":null,"ErrorType":0,"IsSuccess":true,"ItemsPerPage":0,"PsObject":[{"__type":"PsCustomer:http:\/\/api.paysimple.com","ApiConsumerData":"","PsReferenceId":99301,"AltEmail":"testemail@paysimpledev.com","AltPhone":"","BillingAddress1":"TestBillingAddress1","BillingAddress2":"","BillingCity":"Denver","BillingCountryCode":null,"BillingPostalCode":"80202","BillingState":6,"CompanyName":"TestCompany","CreatedOn":"\/Date(1293737680899-0700)\/","Email":"testemail@paysimpledev.com","Fax":"","FirstName":"TestFirstName","LastModified":"\/Date(1293737680899-0700)\/","LastName":"TestLastName","MiddleName":"","Notes":"","Phone":"5551234567","ShippingAddress1":null,"ShippingAddress2":null,"ShippingCity":null,"ShippingCountryCode":null,"ShippingPostalCode":null,"ShippingSameAsBilling":false,"ShippingState":0,"WebSite":""},{"__type":"PsCreditCardAccount:http:\/\/api.paysimple.com","ApiConsumerData":null,"PsReferenceId":57799,"CustomerId":99301,"AccountNumber":"","CCExpiry":"12\/2011","CCType":1},{"__type":"PsPayment:http:\/\/api.paysimple.com","ApiConsumerData":null,"PsReferenceId":79188,"ActualSettledDate":"\/Date(1294038000000-0700)\/","Amount":1,"CanVoidUntil":"\/Date(1293767100000-0700)\/","CustomData":null,"CustomerAccountId":57799,"CustomerId":99301,"Description":null,"EstimateSettledDate":"\/Date(1294038000000-0700)\/","InvoiceId":0,"InvoiceNumber":null,"IsDebit":false,"OrderId":null,"PaymentDate":"\/Date(1293692400000-0700)\/","PaymentSubType":"Moto","PaymentType":1,"ProviderAuthCode":null,"PurchaseOrderNumber":null,"RecurringScheduleId":0,"RefPaymentId":0,"Status":12,"TraceNumber":"TAS121"}],"SubType":"PsCustomer,PsCustomerAccount,PsPayment","TotalItems":3}')
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_ps_response_with_single_ps_object
|
150
|
+
JSON.load('{"__type":"PsResponse:http:\/\/api.paysimple.com","CurrentPage":0,"ErrorMessage":null,"ErrorType":0,"IsSuccess":true,"ItemsPerPage":0,"PsObject":[{"__type":"PsCustomer:http:\/\/api.paysimple.com","ApiConsumerData":"","PsReferenceId":99304,"AltEmail":"testemail@paysimpledev.com","AltPhone":"","BillingAddress1":"TestBillingAddress1","BillingAddress2":"","BillingCity":"Denver","BillingCountryCode":null,"BillingPostalCode":"80202","BillingState":6,"CompanyName":"TestCompany","CreatedOn":"\/Date(1293737698321-0700)\/","Email":"testemail@paysimpledev.com","Fax":"","FirstName":"TestFirstName","LastModified":"\/Date(1293737698321-0700)\/","LastName":"TestLastName","MiddleName":"","Notes":"","Phone":"5551234567","ShippingAddress1":"TestBillingAddress1","ShippingAddress2":"","ShippingCity":"Denver","ShippingCountryCode":null,"ShippingPostalCode":"80202","ShippingSameAsBilling":false,"ShippingState":6,"WebSite":""}],"SubType":"PsCustomer","TotalItems":1}')
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_ps_response_with_multiple_ps_objects
|
154
|
+
JSON.load('{"__type":"PsResponse:http:\/\/api.paysimple.com","CurrentPage":0,"ErrorMessage":null,"ErrorType":0,"IsSuccess":true,"ItemsPerPage":0,"PsObject":[{"__type":"PsCustomer:http:\/\/api.paysimple.com","ApiConsumerData":"","PsReferenceId":99304,"AltEmail":"testemail@paysimpledev.com","AltPhone":"","BillingAddress1":"TestBillingAddress1","BillingAddress2":"","BillingCity":"Denver","BillingCountryCode":null,"BillingPostalCode":"80202","BillingState":6,"CompanyName":"TestCompany","CreatedOn":"\/Date(1293737698321-0700)\/","Email":"testemail@paysimpledev.com","Fax":"","FirstName":"TestFirstName","LastModified":"\/Date(1293737698321-0700)\/","LastName":"TestLastName","MiddleName":"","Notes":"","Phone":"5551234567","ShippingAddress1":"TestBillingAddress1","ShippingAddress2":"","ShippingCity":"Denver","ShippingCountryCode":null,"ShippingPostalCode":"80202","ShippingSameAsBilling":false,"ShippingState":6,"WebSite":""}, {"__type":"PsCustomer:http:\/\/api.paysimple.com","ApiConsumerData":"","PsReferenceId":99304,"AltEmail":"testemail@paysimpledev.com","AltPhone":"","BillingAddress1":"TestBillingAddress1","BillingAddress2":"","BillingCity":"Denver","BillingCountryCode":null,"BillingPostalCode":"80202","BillingState":6,"CompanyName":"TestCompany","CreatedOn":"\/Date(1293737698321-0700)\/","Email":"testemail@paysimpledev.com","Fax":"","FirstName":"TestFirstName","LastModified":"\/Date(1293737698321-0700)\/","LastName":"TestLastName","MiddleName":"","Notes":"","Phone":"5551234567","ShippingAddress1":"TestBillingAddress1","ShippingAddress2":"","ShippingCity":"Denver","ShippingCountryCode":null,"ShippingPostalCode":"80202","ShippingSameAsBilling":false,"ShippingState":6,"WebSite":""}],"SubType":"PsCustomer","TotalItems":1}')
|
155
|
+
end
|