espago 0.0.9 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/Gemfile.lock +14 -1
- data/Guardfile +1 -0
- data/README.md +118 -6
- data/espago.gemspec +6 -1
- data/lib/espago.rb +4 -3
- data/lib/espago/api_connection.rb +16 -7
- data/lib/espago/api_connection/{post_clients.rb → api.rb} +1 -5
- data/lib/espago/api_connection/api_delete.rb +9 -0
- data/lib/espago/api_connection/api_get.rb +13 -0
- data/lib/espago/api_connection/api_post.rb +9 -0
- data/lib/espago/api_connection/api_put.rb +9 -0
- data/lib/espago/api_connection/charges_complete_post.rb +9 -0
- data/lib/espago/api_connection/charges_delete.rb +9 -0
- data/lib/espago/api_connection/charges_get.rb +9 -0
- data/lib/espago/api_connection/charges_post.rb +9 -0
- data/lib/espago/api_connection/{post_charges_refund.rb → charges_refund_post.rb} +1 -5
- data/lib/espago/api_connection/clients_authorize_post.rb +9 -0
- data/lib/espago/api_connection/clients_delete.rb +9 -0
- data/lib/espago/api_connection/clients_get.rb +9 -0
- data/lib/espago/api_connection/clients_invoices_get.rb +9 -0
- data/lib/espago/api_connection/clients_post.rb +9 -0
- data/lib/espago/api_connection/clients_put.rb +9 -0
- data/lib/espago/api_connection/clients_subscriptions_get.rb +9 -0
- data/lib/espago/api_connection/complete_post.rb +14 -0
- data/lib/espago/api_connection/invoice_items_delete.rb +9 -0
- data/lib/espago/api_connection/invoice_items_get.rb +9 -0
- data/lib/espago/api_connection/invoice_items_post.rb +9 -0
- data/lib/espago/api_connection/invoices_get.rb +9 -0
- data/lib/espago/api_connection/line_items_get.rb +9 -0
- data/lib/espago/api_connection/plans_delete.rb +9 -0
- data/lib/espago/api_connection/plans_get.rb +9 -0
- data/lib/espago/api_connection/plans_post.rb +9 -0
- data/lib/espago/api_connection/plans_put.rb +9 -0
- data/lib/espago/api_connection/subscriptions_delete.rb +9 -0
- data/lib/espago/api_connection/subscriptions_get.rb +9 -0
- data/lib/espago/api_connection/subscriptions_post.rb +9 -0
- data/lib/espago/api_connection/tokens_get.rb +9 -0
- data/lib/espago/api_connection/{post_tokens.rb → tokens_post.rb} +2 -2
- data/lib/espago/back_request.rb +33 -0
- data/lib/espago/client.rb +12 -3
- data/lib/espago/router.rb +1 -1
- data/lib/espago/version.rb +1 -1
- data/spec/espago/api_connection_spec.rb +4 -3
- data/spec/espago/back_request_spec.rb +33 -0
- data/spec/espago/client_spec.rb +3 -2
- data/spec/espago/router_spec.rb +2 -2
- data/spec/features/apis_spec.rb +21 -0
- data/spec/features/charges_spec.rb +79 -0
- data/spec/features/clients_spec.rb +100 -0
- data/spec/features/error_spec.rb +28 -0
- data/spec/features/invoice_items_spec.rb +37 -0
- data/spec/features/invoices_spec.rb +24 -0
- data/spec/features/line_items_spec.rb +17 -0
- data/spec/features/plans_spec.rb +61 -0
- data/spec/features/subscriptions_spec.rb +43 -0
- data/spec/features/tokens_spec.rb +40 -0
- data/spec/fixtures/cassettes/api_2.yml +68 -0
- data/spec/fixtures/cassettes/api_3.yml +68 -0
- data/spec/fixtures/cassettes/charges_complete.yml +48 -0
- data/spec/fixtures/cassettes/charges_complete_deprecation.yml +48 -0
- data/spec/fixtures/cassettes/charges_destroy.yml +46 -0
- data/spec/fixtures/cassettes/charges_get.yml +67 -0
- data/spec/fixtures/cassettes/charges_get_pay_mTOngouLTJWZ0w.yml +46 -0
- data/spec/fixtures/cassettes/charges_post.yml +48 -0
- data/spec/fixtures/cassettes/charges_refund.yml +48 -0
- data/spec/fixtures/cassettes/clients_authorize.yml +48 -0
- data/spec/fixtures/cassettes/clients_delete.yml +42 -0
- data/spec/fixtures/cassettes/clients_get.yml +46 -0
- data/spec/fixtures/cassettes/clients_get_cli_w0Se2smYwyQ0Uw.yml +46 -0
- data/spec/fixtures/cassettes/clients_invoices.yml +46 -0
- data/spec/fixtures/cassettes/clients_post.yml +48 -0
- data/spec/fixtures/cassettes/clients_put.yml +48 -0
- data/spec/fixtures/cassettes/clients_subscriptions.yml +46 -0
- data/spec/fixtures/cassettes/error_400.yml +46 -0
- data/spec/fixtures/cassettes/error_401.yml +46 -0
- data/spec/fixtures/cassettes/error_500.yml +46 -0
- data/spec/fixtures/cassettes/invoice_items_delete_ii_WDzszvhTshe78Xd.yml +42 -0
- data/spec/fixtures/cassettes/invoice_items_get_ii_5LS-YR7S1QaJBl3.yml +47 -0
- data/spec/fixtures/cassettes/invoice_items_post_ii_5LS-YR7S1QaJBl3.yml +49 -0
- data/spec/fixtures/cassettes/invoices_get.yml +46 -0
- data/spec/fixtures/cassettes/invoices_get_in_tUCMhwlg2nkvAaL.yml +46 -0
- data/spec/fixtures/cassettes/line_items_get.yml +47 -0
- data/spec/fixtures/cassettes/plans_delete.yml +42 -0
- data/spec/fixtures/cassettes/plans_get.yml +46 -0
- data/spec/fixtures/cassettes/plans_get_pl_12345.yml +46 -0
- data/spec/fixtures/cassettes/plans_post.yml +48 -0
- data/spec/fixtures/cassettes/plans_put.yml +44 -0
- data/spec/fixtures/cassettes/subscriptions_delete_sub_8yYuCBKdywr7e2.yml +42 -0
- data/spec/fixtures/cassettes/subscriptions_get.yml +46 -0
- data/spec/fixtures/cassettes/subscriptions_get_sub_8yYuCBKdywr7e2.yml +46 -0
- data/spec/fixtures/cassettes/subscriptions_post.yml +48 -0
- data/spec/fixtures/cassettes/tokens_get.yml +46 -0
- data/spec/fixtures/cassettes/tokens_post.yml +54 -0
- data/spec/spec_helper.rb +30 -0
- metadata +197 -37
- data/lib/espago/api_connection/delete_charges.rb +0 -13
- data/lib/espago/api_connection/delete_clients.rb +0 -13
- data/lib/espago/api_connection/get_charges.rb +0 -17
- data/lib/espago/api_connection/get_clients.rb +0 -17
- data/lib/espago/api_connection/get_tokens.rb +0 -13
- data/lib/espago/api_connection/post_charges.rb +0 -13
- data/lib/espago/api_connection/post_clients_authorize.rb +0 -13
- data/lib/espago/api_connection/post_complete.rb +0 -13
- data/lib/espago/api_connection/put_clients.rb +0 -13
@@ -0,0 +1,79 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
describe 'Espago.charges' do
|
6
|
+
|
7
|
+
it "should get list of charges" do
|
8
|
+
VCR.use_cassette('charges get') do
|
9
|
+
response = Espago.charges :get
|
10
|
+
response.count.should eq(589)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should get info abount charges" do
|
15
|
+
VCR.use_cassette('charges get pay_mTOngouLTJWZ0w') do
|
16
|
+
response = Espago.charges :get,{charge_id:'pay_mTOngouLTJWZ0w'}
|
17
|
+
response.status.should eq(200)
|
18
|
+
response.channel.should eq('elavon')
|
19
|
+
response.state.should eq('executed')
|
20
|
+
response.currency.should eq('PLN')
|
21
|
+
response.description.should eq('Test12345')
|
22
|
+
response.client.should eq('cli_YM5tKz6-IfhN7T')
|
23
|
+
response.created_at.should eq Time.at(1416917311)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should get params from new charge" do
|
28
|
+
VCR.use_cassette('charges post') do
|
29
|
+
response = Espago.charges :post, { amount:'49.99',
|
30
|
+
currency:'PLN',
|
31
|
+
description:'Test12345',
|
32
|
+
card: {
|
33
|
+
first_name: 'Jan',
|
34
|
+
last_name: 'Kowalski',
|
35
|
+
number: '4242424242424242',
|
36
|
+
verification_value: '123',
|
37
|
+
year:'2015',
|
38
|
+
month:'2'
|
39
|
+
},
|
40
|
+
}
|
41
|
+
response.status.should eq(201)
|
42
|
+
response.channel.should eq('elavon')
|
43
|
+
response.state.should eq('executed')
|
44
|
+
response.currency.should eq('PLN')
|
45
|
+
response.description.should eq('Test12345')
|
46
|
+
response.client.should eq('cli_YM5tKz6-IfhN7T')
|
47
|
+
response.created_at.should eq Time.at(1416917311)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should get 204 status after destroy charge" do
|
52
|
+
VCR.use_cassette('charges destroy') do
|
53
|
+
response = Espago.charges :delete,{charge_id:'pay_kQmS_3RTfm4eix'}
|
54
|
+
response.state.should eq('reversed')
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should get refunded status after refund charge" do
|
59
|
+
VCR.use_cassette('charges refund') do
|
60
|
+
response = Espago.charges_refund :post,{charge_id:'pay_lQGyIon5qG59O5'}
|
61
|
+
response.state.should eq('refunded')
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should get params from complete charge" do
|
66
|
+
VCR.use_cassette('charges complete') do
|
67
|
+
response = Espago.charges_complete :post,{charge_id:'pay_kQmS_3RTfm4eix'}
|
68
|
+
response.state.should eq('executed')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should get params from complete charge (deprecated)" do
|
73
|
+
VCR.use_cassette('charges complete deprecation') do
|
74
|
+
response = Espago.complete :post,{charge_id:'pay_Wmu3hmXJIG4jsg'}
|
75
|
+
response.state.should eq('executed')
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe 'Espago.clients' do
|
4
|
+
|
5
|
+
it "should get list of clients" do
|
6
|
+
VCR.use_cassette('clients get') do
|
7
|
+
response = Espago.clients :get
|
8
|
+
response.count.should eq(597)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should get info abount clients" do
|
13
|
+
VCR.use_cassette('clients get cli_w0Se2smYwyQ0Uw') do
|
14
|
+
response = Espago.clients :get,{client_id:'cli_w0Se2smYwyQ0Uw'}
|
15
|
+
response.email.should eq(nil)
|
16
|
+
response.card['company'].should eq('VI')
|
17
|
+
response.description.should eq(nil)
|
18
|
+
response.created_at.should eq Time.at(1417004837)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should get params from new client" do
|
23
|
+
VCR.use_cassette('clients post') do
|
24
|
+
response = Espago.clients :post, { card: {
|
25
|
+
first_name: 'Jan',
|
26
|
+
last_name: 'Kowalski',
|
27
|
+
number: '424242424242',
|
28
|
+
verification_value: '123',
|
29
|
+
year:'2015',
|
30
|
+
month:'2'
|
31
|
+
},
|
32
|
+
}
|
33
|
+
response.status.should eq(201)
|
34
|
+
response.card['company'].should eq('VI')
|
35
|
+
response.card['last4'].should eq('4242')
|
36
|
+
response.card['authorized'].should eq(nil)
|
37
|
+
response.deleted.should eq(false)
|
38
|
+
response.created_at.should eq Time.at(1417007099)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should get status after authorize client card" do
|
43
|
+
VCR.use_cassette('clients authorize') do
|
44
|
+
response = Espago.clients_authorize :post,{client_id:'cli_w0Se2smYwyQ0Uw'}
|
45
|
+
response.status.should eq(201)
|
46
|
+
response.card['company'].should eq('VI')
|
47
|
+
response.card['last4'].should eq('1112')
|
48
|
+
response.card['authorized'].should eq(true)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
it "should get params from updated client" do
|
54
|
+
VCR.use_cassette('clients put') do
|
55
|
+
response = Espago.clients :put, { client_id:'cli_w0Se2smYwyQ0Uw',
|
56
|
+
card: {
|
57
|
+
first_name: 'Jan',
|
58
|
+
last_name: 'Kowalski',
|
59
|
+
number: '4242424242424242',
|
60
|
+
verification_value: '123',
|
61
|
+
year:'2015',
|
62
|
+
month:'2'
|
63
|
+
},
|
64
|
+
}
|
65
|
+
response.status.should eq(200)
|
66
|
+
response.card['company'].should eq('VI')
|
67
|
+
response.card['last4'].should eq('4242')
|
68
|
+
response.card['authorized'].should eq(nil)
|
69
|
+
response.deleted.should eq(false)
|
70
|
+
response.created_at.should eq Time.at(1417004837)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should get client invoices" do
|
75
|
+
VCR.use_cassette('clients invoices') do
|
76
|
+
response = Espago.clients_invoices :get, { client_id:'cli_w0Se2smYwyQ0Uw'}
|
77
|
+
response.status.should eq(200)
|
78
|
+
response.count.should eq(0)
|
79
|
+
response.invoices.should eq([])
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
it "should get client subscriptions" do
|
85
|
+
VCR.use_cassette('clients subscriptions') do
|
86
|
+
response = Espago.clients_subscriptions :get, { client_id:'cli_w0Se2smYwyQ0Uw'}
|
87
|
+
response.status.should eq(200)
|
88
|
+
response.count.should eq(0)
|
89
|
+
response.subscriptions.should eq([])
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should get status 204 after delete client" do
|
94
|
+
VCR.use_cassette('clients delete') do
|
95
|
+
response = Espago.clients :delete, { client_id:'cli_5rDoJyvKDM4RbM'}
|
96
|
+
response.status.should eq(204)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe 'Fake errors!' do
|
4
|
+
|
5
|
+
it "should get 500 error" do
|
6
|
+
VCR.use_cassette('error 500') do
|
7
|
+
expect {response = Espago.plans :get }.to raise_error(Espago::ApiError)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should get 400 error" do
|
12
|
+
VCR.use_cassette('error 400') do
|
13
|
+
expect {response = Espago.plans :get }.to raise_error(Espago::InvalidRequestError)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should get 401 error" do
|
18
|
+
VCR.use_cassette('error 401') do
|
19
|
+
expect {response = Espago.plans :get }.to raise_error(Espago::AuthenticationError)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "method missing" do
|
24
|
+
VCR.use_cassette('method missing') do
|
25
|
+
expect {Espago.method_missing :get}.to raise_error(NoMethodError)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe 'Espago.invoice_items' do
|
4
|
+
|
5
|
+
it "should get info abount invoice_items" do
|
6
|
+
VCR.use_cassette('invoice_items get ii_5LS-YR7S1QaJBl3') do
|
7
|
+
response = Espago.invoice_items :get,{invoice_item_id:'ii_5LS-YR7S1QaJBl3'}
|
8
|
+
response.client.should eq('cli_90Pi6Jf0ndl_PP')
|
9
|
+
response.amount.should eq('123.45')
|
10
|
+
response.created_at.should eq Time.at(1417030496)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should get info abount invoice_items" do
|
15
|
+
VCR.use_cassette('invoice_items post ii_5LS-YR7S1QaJBl3') do
|
16
|
+
response = Espago.invoice_items :post,{ amount:49.99,
|
17
|
+
currency:'pln',
|
18
|
+
date:'1417126942',
|
19
|
+
description: 'Test invoice items',
|
20
|
+
client: 'cli_90Pi6Jf0ndl_PP'
|
21
|
+
}
|
22
|
+
response.status.should eq(201)
|
23
|
+
response.client.should eq('cli_90Pi6Jf0ndl_PP')
|
24
|
+
response.amount.should eq('49.99')
|
25
|
+
response.currency.should eq('pln')
|
26
|
+
response.created_at.should eq Time.at(1417102491)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should get info abount deleted invoice_items" do
|
31
|
+
VCR.use_cassette('invoice_items delete ii_WDzszvhTshe78Xd') do
|
32
|
+
response = Espago.invoice_items :delete,{invoice_item_id:'ii_WDzszvhTshe78Xd'}
|
33
|
+
response.status.should eq(204)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe 'Espago.invoices' do
|
4
|
+
|
5
|
+
it "should get list of invoices" do
|
6
|
+
VCR.use_cassette('invoices get') do
|
7
|
+
response = Espago.invoices :get
|
8
|
+
response.count.should eq(1)
|
9
|
+
response.invoices.size.should eq(1)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should get info abount invoices" do
|
14
|
+
VCR.use_cassette('invoices get in_tUCMhwlg2nkvAaL') do
|
15
|
+
response = Espago.invoices :get,{invoice_id:'in_tUCMhwlg2nkvAaL'}
|
16
|
+
response.paid.should eq(true)
|
17
|
+
response.client.should eq('cli_90Pi6Jf0ndl_PP')
|
18
|
+
response.amount.should eq('123.45')
|
19
|
+
response.created_at.should eq Time.at(1417030497)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe 'Espago.line_items' do
|
4
|
+
|
5
|
+
it "should get info abount line_items" do
|
6
|
+
VCR.use_cassette('line_items get') do
|
7
|
+
response = Espago.line_items :get,{invoice_id:'in_tUCMhwlg2nkvAaL'}
|
8
|
+
response.count.should eq(1)
|
9
|
+
response.invoice_items[0]['client'].should eq('cli_90Pi6Jf0ndl_PP')
|
10
|
+
response.invoice_items[0]['amount'].should eq('123.45')
|
11
|
+
response.invoice_items[0]['description'].should eq('Golden plan')
|
12
|
+
response.invoice_items[0]['created_at'].should eq(1417030496)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe 'Espago.plans' do
|
4
|
+
|
5
|
+
it "should get list of plans" do
|
6
|
+
VCR.use_cassette('plans get') do
|
7
|
+
response = Espago.plans :get
|
8
|
+
response.count.should eq(1)
|
9
|
+
response.plans.size.should eq(1)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should get info abount plans" do
|
14
|
+
VCR.use_cassette('plans get pl_12345') do
|
15
|
+
response = Espago.plans :get,{plan_id:'pl_12345'}
|
16
|
+
response.description.should eq('Golden plan')
|
17
|
+
response.period.should eq(5)
|
18
|
+
response.period_unit.should eq('days')
|
19
|
+
response.amount.should eq(123.45)
|
20
|
+
response.created_at.should eq Time.at(1413807490)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should get params from new plan" do
|
25
|
+
VCR.use_cassette('plans post') do
|
26
|
+
response = Espago.plans :post, { period_unit: 'day',
|
27
|
+
period: 14,
|
28
|
+
amount: 49.99,
|
29
|
+
currency: 'pln',
|
30
|
+
description: 'Test Plan'
|
31
|
+
}
|
32
|
+
response.status.should eq(201)
|
33
|
+
response.description.should eq('Test Plan')
|
34
|
+
response.period.should eq(14)
|
35
|
+
response.period_unit.should eq('day')
|
36
|
+
response.amount.should eq('49.99')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
it "should get params from updated plan" do
|
42
|
+
VCR.use_cassette('plans put') do
|
43
|
+
response = Espago.plans :put, { plan_id: 'pl_XczKHr_42CRiKXZ',
|
44
|
+
period_unit: 'month',
|
45
|
+
period: 1,
|
46
|
+
amount: 149.99,
|
47
|
+
currency: 'pln',
|
48
|
+
description: 'Test Plan'
|
49
|
+
}
|
50
|
+
response.status.should eq(204)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should get 204 after deleted plan" do
|
55
|
+
VCR.use_cassette('plans delete') do
|
56
|
+
response = Espago.plans :delete, { plan_id: 'pl_XczKHr_42CRiKXZ'}
|
57
|
+
response.status.should eq(204)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe 'Espago.subscriptions' do
|
4
|
+
|
5
|
+
it "should get list of subscriptions" do
|
6
|
+
VCR.use_cassette('subscriptions get') do
|
7
|
+
response = Espago.subscriptions :get
|
8
|
+
response.count.should eq(1)
|
9
|
+
response.subscriptions.size.should eq(1)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should get info abount subscriptions" do
|
14
|
+
VCR.use_cassette('subscriptions get sub_8yYuCBKdywr7e2') do
|
15
|
+
response = Espago.subscriptions :get,{subscription_id:'sub_8yYuCBKdywr7e2'}
|
16
|
+
response.status.should eq(200)
|
17
|
+
response.state.should eq('active')
|
18
|
+
response.client.should eq('cli_90Pi6Jf0ndl_PP')
|
19
|
+
response.plan.should eq('pl_12345')
|
20
|
+
response.last_invoice.should be_kind_of(Hash)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should get params from new plan" do
|
25
|
+
VCR.use_cassette('subscriptions post') do
|
26
|
+
response = Espago.subscriptions :post,{ plan:'pl_12345',client:'cli_90Pi6Jf0ndl_PP'}
|
27
|
+
response.status.should eq(201)
|
28
|
+
response.state.should eq('active')
|
29
|
+
response.client.should eq('cli_90Pi6Jf0ndl_PP')
|
30
|
+
response.plan.should eq('pl_12345')
|
31
|
+
response.last_invoice.should be_kind_of(Hash)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should get info after deleted subscription" do
|
36
|
+
VCR.use_cassette('subscriptions delete sub_8yYuCBKdywr7e2') do
|
37
|
+
response = Espago.subscriptions :delete,{subscription_id:'sub_8yYuCBKdywr7e2'}
|
38
|
+
response.status.should eq(204)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe 'Espago.tokens' do
|
4
|
+
|
5
|
+
it "should get params from new token" do
|
6
|
+
VCR.use_cassette('tokens post') do
|
7
|
+
response = Espago.tokens :post, {
|
8
|
+
card: {
|
9
|
+
first_name: 'Jan',
|
10
|
+
last_name: 'Kowalski',
|
11
|
+
number: '4242424242424242',
|
12
|
+
verification_value: '123',
|
13
|
+
year:'2015',
|
14
|
+
month:'2'
|
15
|
+
},
|
16
|
+
}
|
17
|
+
response.status.should eq(201)
|
18
|
+
response.id.should_not eq(nil)
|
19
|
+
response.used.should eq(false)
|
20
|
+
response.created_at.should eq Time.at(1417029320)
|
21
|
+
response.card['company'].should eq('VI')
|
22
|
+
response.card['last4'].should eq('4242')
|
23
|
+
response.card['authorized'].should eq(nil)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should get token params" do
|
28
|
+
VCR.use_cassette('tokens get') do
|
29
|
+
response = Espago.tokens :get, {token_id: 'cc_166YDMhrVcemFb3'}
|
30
|
+
response.status.should eq(200)
|
31
|
+
response.id.should eq('cc_166YDMhrVcemFb3')
|
32
|
+
response.used.should eq(false)
|
33
|
+
response.created_at.should eq Time.at(1417029320)
|
34
|
+
response.card['company'].should eq('VI')
|
35
|
+
response.card['last4'].should eq('4242')
|
36
|
+
response.card['authorized'].should eq(nil)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://app_id_test:app_password_test@sandbox.espago.com/api/charges
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- application/vnd.espago.v2+json
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
User-Agent:
|
15
|
+
- Ruby
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Content-Type:
|
22
|
+
- application/json; charset=utf-8
|
23
|
+
X-Meta-Request-Version:
|
24
|
+
- 0.2.2
|
25
|
+
X-Ua-Compatible:
|
26
|
+
- IE=Edge
|
27
|
+
Etag:
|
28
|
+
- '"36ab75a48cfe4bce4bd0ff6d680a374e"'
|
29
|
+
Cache-Control:
|
30
|
+
- max-age=0, private, must-revalidate
|
31
|
+
Set-Cookie:
|
32
|
+
- _session_id=e7fc731f6d8d81b24924c4b812b9da80; path=/; HttpOnly
|
33
|
+
X-Request-Id:
|
34
|
+
- 5fadd0cef6940344df06709e4ba0be7a
|
35
|
+
X-Runtime:
|
36
|
+
- '1.233832'
|
37
|
+
Connection:
|
38
|
+
- close
|
39
|
+
Server:
|
40
|
+
- thin 1.5.0 codename Knife
|
41
|
+
body:
|
42
|
+
encoding: UTF-8
|
43
|
+
string: '{"count":596,"charges":[{"id":"pay_uxILF7D-heZaT2","description":"Golden
|
44
|
+
plan 2014-11-26","channel":"elavon","amount":"123.45","currency":"pln","state":"executed","client":"cli_90Pi6Jf0ndl_PP","created_at":1417030497,"card":{"company":"VI","last4":"4242","year":2019,"month":3,"first_name":"Jan","last_name":"Kowalski","authorized":null,"created_at":1416842254},"issuer_response_code":"00","reversable":true,"invoice":"in_tUCMhwlg2nkvAaL","subscription":"sub_8yYuCBKdywr7e2","transaction_id":"tn_mQKcgfsNw"},{"id":"pay_Wmu3hmXJIG4jsg","description":"Opis
|
45
|
+
transakcji","channel":"elavon","amount":"49.99","currency":"pln","state":"executed","client":"cli_PQI_mlA6DXe1nP","created_at":1417009684,"issuer_response_code":"00","reversable":true,"transaction_id":"tn_0pydA_RVa"},{"id":"pay_JEWqRdltANdqzH","description":"Opis
|
46
|
+
transakcji","channel":"elavon","amount":"49.99","currency":"pln","state":"preauthorized","client":"cli_0Z-QNfJjl0R7J3","created_at":1417008454,"issuer_response_code":"00","completed":false,"reversable":true,"transaction_id":"tn_2WMKrXcW-"},{"id":"pay_kQmS_3RTfm4eix","description":"Opis
|
47
|
+
transakcji","channel":"elavon","amount":"49.99","currency":"pln","state":"reversed","client":"cli_5rDoJyvKDM4RbM","created_at":1417005334,"issuer_response_code":"00","transaction_id":"tn_tAxxrivny"},{"id":"pay_b1Y2ZuJNXXRDM5","description":"Opis
|
48
|
+
transakcji","channel":"elavon","amount":"49.99","currency":"pln","state":"reversed","client":"cli_VTsnOHjUohL02K","created_at":1416920783,"issuer_response_code":"00","transaction_id":"tn_mhAlwzK0x"},{"id":"pay_ftMx2WoXveVOdF","description":"Opis
|
49
|
+
transakcji","channel":"elavon","amount":"49.99","currency":"pln","state":"reversed","client":"cli_84RAbl__uG21sV","created_at":1416920765,"issuer_response_code":"00","transaction_id":"tn_feetNVaqb"},{"id":"pay_mTOngouLTJWZ0w","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"executed","client":"cli_YM5tKz6-IfhN7T","created_at":1416917311,"issuer_response_code":"00","transaction_id":"tn_5puLXUWDf"},{"id":"pay_yBeZDDdvI9-xPs","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"rejected","client":"cli_As1e5K4jpHy5Aw","created_at":1416917203,"reject_reason":"card
|
50
|
+
expired","issuer_response_code":"54","transaction_id":"tn_sC6zyk_5F"},{"id":"pay_Mc4aIdi0mMTwqw","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"rejected","client":"cli_DYuoBap-1hJzBU","created_at":1416916959,"reject_reason":"card
|
51
|
+
expired","issuer_response_code":"54","transaction_id":"tn_a0UiElEVZ"},{"id":"pay_dNeWnyjbgh8mry","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"rejected","client":"cli_DAGc95pNHoYTup","created_at":1416916878,"reject_reason":"card
|
52
|
+
expired","issuer_response_code":"54","transaction_id":"tn_egEqc9QKG"},{"id":"pay_HxEZHsvAe_DKEf","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"rejected","client":"cli_7FXtokGKn71rBJ","created_at":1416916867,"reject_reason":"card
|
53
|
+
expired","issuer_response_code":"54","transaction_id":"tn_MfEarJeKF"},{"id":"pay_kabeiSF6rqkXhf","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"rejected","client":"cli_PRg_F5LPOzlaw0","created_at":1416916839,"reject_reason":"card
|
54
|
+
expired","issuer_response_code":"54","transaction_id":"tn_nDxoks8Nw"},{"id":"pay_AqipUAnHNnxk6e","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"rejected","client":"cli_Gq_WKAtb1sk-_H","created_at":1416916725,"reject_reason":"card
|
55
|
+
expired","issuer_response_code":"54","transaction_id":"tn_3Q5dbU_B_"},{"id":"pay_M_3aKKX3hEwdJR","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"rejected","client":"cli_ZAe6FMTGpAx2D1","created_at":1416916429,"reject_reason":"card
|
56
|
+
expired","issuer_response_code":"54","transaction_id":"tn_PyZneugYr"},{"id":"pay_sM6u2z1uvYuLtp","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"rejected","client":"cli_qRRYr2riz-IEqd","created_at":1416915972,"reject_reason":"card
|
57
|
+
expired","issuer_response_code":"54","transaction_id":"tn_RVWC2QZAL"},{"id":"pay_9dhQSFZ5ZoCTot","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"rejected","client":"cli_fxWPgeAkWOo1ZU","created_at":1416915851,"reject_reason":"card
|
58
|
+
expired","issuer_response_code":"54","transaction_id":"tn_uNcAmJQIP"},{"id":"pay_VhLoTUAI4SdKAQ","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"rejected","client":"cli_qaiHjuRdLKrDfy","created_at":1416915841,"reject_reason":"card
|
59
|
+
expired","issuer_response_code":"54","transaction_id":"tn_d7oo1A-83"},{"id":"pay_WtOOd39mtQ5U9A","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"rejected","client":"cli_9qUJ-X9sF-x8H4","created_at":1416915721,"reject_reason":"card
|
60
|
+
expired","issuer_response_code":"54","transaction_id":"tn_m-wM2cSAu"},{"id":"pay_NBdRkyjAUHCS4b","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"rejected","client":"cli_GO5IjkVbJJM8EP","created_at":1416915649,"reject_reason":"card
|
61
|
+
expired","issuer_response_code":"54","transaction_id":"tn_vHPyGDu76"},{"id":"pay_OA5PkgCKJXAfS4","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"rejected","client":"cli_Ays1Jh3WdgvwdF","created_at":1416915327,"reject_reason":"card
|
62
|
+
expired","issuer_response_code":"54","transaction_id":"tn_0E7kcajyW"},{"id":"pay_UJWQP-sGbC_7Wo","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"rejected","client":"cli_FqguquyelXPRme","created_at":1416915312,"reject_reason":"card
|
63
|
+
expired","issuer_response_code":"54","transaction_id":"tn_mFqUywuHv"},{"id":"pay_xfhHX_6-YRcCnp","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"rejected","client":"cli_n5hLfjUbGg9_kd","created_at":1416915291,"reject_reason":"card
|
64
|
+
expired","issuer_response_code":"54","transaction_id":"tn_FDIGDOPtr"},{"id":"pay_8UPROeEjy1mfiZ","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"new","client":"cli_3HMQxyuFUlqrof","created_at":1416915219,"issuer_response_code":"","transaction_id":"tn_zJrhC6LIg"},{"id":"pay_0dAV3hHjTOynda","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"new","client":"cli_dJ4AONo8kaB9dW","created_at":1416915092,"issuer_response_code":"","transaction_id":"tn_5Ye7_y71v"},{"id":"pay_q4YyzX_LopLa3V","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"new","client":"cli_BYyLfXi2Y1yD13","created_at":1416915011,"issuer_response_code":"","transaction_id":"tn_Zrkeox6AF"},{"id":"pay_YAM-5tPuCW7zc5","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"new","client":"cli_WbJy48Hih3qzLl","created_at":1416914988,"issuer_response_code":"","transaction_id":"tn_Zq0C-zIXS"},{"id":"pay_yAUVDCvLcKTdlt","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"new","client":"cli_RQ2JS7ZkuHmjTA","created_at":1416914971,"issuer_response_code":"","transaction_id":"tn__pAcdnNKx"},{"id":"pay_9Sol_CfGKSwfzu","description":"Test12345","channel":"elavon","amount":"49.99","currency":"PLN","state":"new","client":"cli_S7FbD61XKua7hH","created_at":1416914232,"issuer_response_code":"","transaction_id":"tn_HN3yjWFhA"},{"id":"pay_F6X-6bq8NrP8TV","description":"payment_id:17","channel":"elavon","amount":"369.00","currency":"PLN","state":"executed","client":"cli_1_9zd3sba03Os5","created_at":1416827486,"issuer_response_code":"00","transaction_id":"tn_QelKAfJje"},{"id":"pay_SejDXvQj3EDuOM","description":"Opis
|
65
|
+
transakcji","channel":"elavon","amount":"49.99","currency":"pln","state":"failed","client":"cli_bjyYV5SMWyqaHk","created_at":1416408068,"issuer_response_code":null,"transaction_id":"tn_n2vdQTxX6"}]}'
|
66
|
+
http_version:
|
67
|
+
recorded_at: Wed, 26 Nov 2014 21:46:10 GMT
|
68
|
+
recorded_with: VCR 2.9.3
|