espago 0.1.8 → 0.1.10
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 +5 -5
- data/.travis.yml +15 -8
- data/Gemfile +2 -0
- data/Gemfile.lock +254 -130
- data/README.md +13 -15
- data/app/views/espago_secure_web_page/_form.html.haml +3 -2
- data/espago.gemspec +13 -12
- data/lib/espago/api_connection/charges_complete_post.rb +1 -1
- data/lib/espago/api_connection/refunds_post.rb +9 -0
- data/lib/espago/api_connection/secure_web_page_register_post.rb +9 -0
- data/lib/espago/api_connection/tokens_post.rb +1 -1
- data/lib/espago/api_connection/visacheckout_post.rb +9 -0
- data/lib/espago/api_connection.rb +4 -2
- data/lib/espago/client.rb +5 -6
- data/lib/espago/secure_web_page.rb +13 -10
- data/lib/espago/version.rb +1 -1
- data/spec/espago/api_connection_spec.rb +1 -1
- data/spec/espago/back_request_spec.rb +11 -11
- data/spec/espago/client_spec.rb +8 -8
- data/spec/espago/error_spec.rb +4 -3
- data/spec/espago/response_spec.rb +10 -10
- data/spec/espago/router_spec.rb +5 -6
- data/spec/features/apis_spec.rb +2 -2
- data/spec/features/charges_spec.rb +19 -19
- data/spec/features/charges_spec_with_params_spec.rb +22 -22
- data/spec/features/clients_spec.rb +28 -28
- data/spec/features/dcc_decision_spec.rb +7 -7
- data/spec/features/invoice_items_spec.rb +9 -9
- data/spec/features/invoices_spec.rb +6 -6
- data/spec/features/line_items_spec.rb +5 -5
- data/spec/features/plans_spec.rb +14 -14
- data/spec/features/secure_web_page_register_spec.rb +23 -0
- data/spec/features/subscriptions_spec.rb +13 -13
- data/spec/features/tokens_spec.rb +15 -16
- data/spec/fixtures/cassettes/api_2.yml +1 -1
- data/spec/fixtures/cassettes/api_3.yml +1 -1
- data/spec/fixtures/cassettes/charges_complete.yml +1 -1
- data/spec/fixtures/cassettes/charges_complete_deprecation.yml +1 -1
- data/spec/fixtures/cassettes/charges_destroy.yml +1 -1
- data/spec/fixtures/cassettes/charges_get.yml +1 -1
- data/spec/fixtures/cassettes/charges_get_pay_mTOngouLTJWZ0w.yml +3 -1
- data/spec/fixtures/cassettes/charges_post.yml +3 -1
- data/spec/fixtures/cassettes/charges_refund.yml +3 -1
- data/spec/fixtures/cassettes/clients_authorize.yml +3 -1
- data/spec/fixtures/cassettes/clients_delete.yml +3 -1
- data/spec/fixtures/cassettes/clients_get.yml +3 -1
- data/spec/fixtures/cassettes/clients_get_cli_w0Se2smYwyQ0Uw.yml +3 -1
- data/spec/fixtures/cassettes/clients_invoices.yml +3 -1
- data/spec/fixtures/cassettes/clients_post.yml +3 -1
- data/spec/fixtures/cassettes/clients_put.yml +3 -1
- data/spec/fixtures/cassettes/clients_subscriptions.yml +3 -1
- data/spec/fixtures/cassettes/dcc_decision_post.yml +3 -1
- data/spec/fixtures/cassettes/error_400.yml +3 -1
- data/spec/fixtures/cassettes/error_401.yml +3 -1
- data/spec/fixtures/cassettes/error_500.yml +3 -1
- data/spec/fixtures/cassettes/invoice_items_delete_ii_WDzszvhTshe78Xd.yml +3 -1
- data/spec/fixtures/cassettes/invoice_items_get_ii_5LS-YR7S1QaJBl3.yml +3 -1
- data/spec/fixtures/cassettes/invoice_items_post_ii_5LS-YR7S1QaJBl3.yml +3 -1
- data/spec/fixtures/cassettes/invoices_get.yml +3 -1
- data/spec/fixtures/cassettes/invoices_get_in_tUCMhwlg2nkvAaL.yml +3 -1
- data/spec/fixtures/cassettes/line_items_get.yml +1 -1
- data/spec/fixtures/cassettes/plans_delete.yml +1 -1
- data/spec/fixtures/cassettes/plans_get.yml +1 -1
- data/spec/fixtures/cassettes/plans_get_pl_12345.yml +1 -1
- data/spec/fixtures/cassettes/plans_post.yml +3 -1
- data/spec/fixtures/cassettes/plans_put.yml +3 -1
- data/spec/fixtures/cassettes/secure_web_page_register_post.yml +56 -0
- data/spec/fixtures/cassettes/subscriptions_delete_sub_8yYuCBKdywr7e2.yml +3 -1
- data/spec/fixtures/cassettes/subscriptions_get.yml +1 -1
- data/spec/fixtures/cassettes/subscriptions_get_sub_8yYuCBKdywr7e2.yml +1 -1
- data/spec/fixtures/cassettes/subscriptions_post.yml +3 -1
- data/spec/fixtures/cassettes/tokens_get.yml +3 -1
- data/spec/fixtures/cassettes/tokens_post.yml +3 -1
- data/spec/spec_helper.rb +4 -7
- metadata +58 -23
@@ -22,8 +22,6 @@ end
|
|
22
22
|
|
23
23
|
module Espago
|
24
24
|
class ApiConnection
|
25
|
-
extend Forwardable
|
26
|
-
def_delegator :@connection, :basic_auth, :authenticate
|
27
25
|
|
28
26
|
def initialize(enviroment,headers)
|
29
27
|
@connection = Faraday.new(enviroment)
|
@@ -38,6 +36,10 @@ module Espago
|
|
38
36
|
handle_response response
|
39
37
|
end
|
40
38
|
|
39
|
+
def authenticate(username, password)
|
40
|
+
@connection.request(:authorization, :basic, username, password)
|
41
|
+
end
|
42
|
+
|
41
43
|
private
|
42
44
|
|
43
45
|
def handle_response(response)
|
data/lib/espago/client.rb
CHANGED
@@ -12,13 +12,13 @@ module Espago
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def send_request(path, method, params = {})
|
15
|
-
|
15
|
+
|
16
16
|
app_id = params[:app_id].present? ? params.delete(:app_id) : @app_id
|
17
|
-
app_password = params[:app_password].present? ? params.delete(:app_password) : @app_password
|
18
|
-
production_param = !params[:production].nil? ? params.delete(:production) : production
|
19
|
-
|
17
|
+
app_password = params[:app_password].present? ? params.delete(:app_password) : @app_password
|
18
|
+
production_param = !params[:production].nil? ? params.delete(:production) : production
|
19
|
+
|
20
20
|
raise NotAuthenticated unless valid?(app_id, app_password)
|
21
|
-
|
21
|
+
|
22
22
|
connection = @connection.new(enviroment(production_param),api_version_header)
|
23
23
|
connection.authenticate(app_id, app_password)
|
24
24
|
connection.create(path, method, params)
|
@@ -30,7 +30,6 @@ module Espago
|
|
30
30
|
|
31
31
|
private
|
32
32
|
def enviroment(production_param)
|
33
|
-
# "http://127.0.0.1:3007/api"
|
34
33
|
production_param ? "https://secure.espago.com/api" : "https://sandbox.espago.com/api"
|
35
34
|
end
|
36
35
|
|
@@ -1,28 +1,31 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'forwardable'
|
2
4
|
module Espago
|
3
5
|
class SecureWebPage
|
4
6
|
attr_accessor :production
|
5
7
|
|
6
|
-
def self.calculate_checksum(app_id, kind, session_id,amount,currency,ts,checksum_key)
|
7
|
-
Digest::MD5.hexdigest(
|
8
|
+
def self.calculate_checksum(app_id, kind, session_id, amount, currency, ts, service_client_id, checksum_key)
|
9
|
+
return Digest::MD5.hexdigest(
|
8
10
|
[app_id.to_s, kind, session_id.to_s, amount.to_s, currency.to_s, ts.to_s, checksum_key.to_s].join('|')
|
11
|
+
) if service_client_id.blank?
|
12
|
+
Digest::MD5.hexdigest(
|
13
|
+
[app_id.to_s, kind, session_id.to_s, amount.to_s, currency.to_s, ts.to_s, service_client_id.to_s, checksum_key.to_s].join('|')
|
9
14
|
)
|
10
15
|
end
|
11
16
|
|
12
|
-
def self.form_post(
|
13
|
-
Espago.production ?
|
17
|
+
def self.form_post(_api_v = nil)
|
18
|
+
Espago.production ? 'https://secure.espago.com/secure_web_page' : 'https://sandbox.espago.com/secure_web_page'
|
14
19
|
end
|
15
20
|
|
16
21
|
def self.prepare_form(data)
|
17
|
-
data[:kind] ||=
|
18
|
-
data[:ts] ||=
|
22
|
+
data[:kind] ||= 'sale'
|
23
|
+
data[:ts] ||= Time.now.to_i
|
19
24
|
data[:app_id] ||= Espago.app_id
|
20
25
|
data[:api_version] ||= Espago.api_version
|
21
26
|
data[:amount] = format('%.2f', data[:amount])
|
22
|
-
data[:checksum] = calculate_checksum(data[:app_id],data[:kind],data[:session_id],data[:amount],data[:currency],data[:ts],data[:checksum_key]|| Espago.checksum_key)
|
27
|
+
data[:checksum] = calculate_checksum(data[:app_id], data[:kind], data[:session_id], data[:amount], data[:currency], data[:ts], data[:service_client_id], data[:checksum_key] || Espago.checksum_key)
|
23
28
|
data
|
24
29
|
end
|
25
|
-
|
26
|
-
|
27
30
|
end
|
28
31
|
end
|
data/lib/espago/version.rb
CHANGED
@@ -27,7 +27,7 @@ describe Espago::ApiConnection do
|
|
27
27
|
|
28
28
|
context "#create" do
|
29
29
|
it "returns response" do
|
30
|
-
subject.create(:path, :stubbed).
|
30
|
+
expect(subject.create(:path, :stubbed)).to be_a_kind_of Espago::Response
|
31
31
|
end
|
32
32
|
it "raises auth error" do
|
33
33
|
expect { subject.create(:path, :unauthorized) }.to raise_error Espago::AuthenticationError
|
@@ -19,15 +19,15 @@ describe Espago::BackRequest do
|
|
19
19
|
"created_at"=>1417030497
|
20
20
|
}
|
21
21
|
}
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
22
|
+
it {
|
23
|
+
expect(subject.id).to eq("in_tUCMhwlg2nkvAaL")
|
24
|
+
expect(subject.subscription).to eq("sub_8yYuCBKdywr7e2")
|
25
|
+
expect(subject.amount).to eq("123.45")
|
26
|
+
expect(subject.currency).to eq("pln")
|
27
|
+
expect(subject.paid).to eq("true")
|
28
|
+
expect(subject.client).to eq("cli_90Pi6Jf0ndl_PP")
|
29
|
+
expect(subject.created_at).to eq(Time.at(1417030497))
|
30
|
+
expect(subject.card).to eq({})
|
31
|
+
expect(subject.imaginated_attribute).to be_nil
|
32
|
+
}
|
33
33
|
end
|
data/spec/espago/client_spec.rb
CHANGED
@@ -15,10 +15,10 @@ describe Espago::Client do
|
|
15
15
|
let(:stubbed_api_connection) { StubbedApiConnection }
|
16
16
|
let(:response) { FakeResponse.new(200, {id: 1, status: "2012"}.to_json) }
|
17
17
|
|
18
|
-
it { subject.
|
19
|
-
it { subject.
|
20
|
-
it { subject.
|
21
|
-
it { subject.
|
18
|
+
it { expect(subject).to respond_to :app_id }
|
19
|
+
it { expect(subject).to respond_to :app_password }
|
20
|
+
it { expect(subject).to respond_to :public_key }
|
21
|
+
it { expect(subject).to respond_to :api_version }
|
22
22
|
|
23
23
|
context "#send_request" do
|
24
24
|
let(:method) { :get }
|
@@ -26,7 +26,7 @@ describe Espago::Client do
|
|
26
26
|
let(:params) { { name: "Jan Kowalski"} }
|
27
27
|
|
28
28
|
it "should create an api request" do
|
29
|
-
subject.send_request(path, method, params).
|
29
|
+
expect(subject.send_request(path, method, params)).to eq('returned api data')
|
30
30
|
end
|
31
31
|
|
32
32
|
context "with no credentials" do
|
@@ -45,7 +45,7 @@ describe Espago::Client do
|
|
45
45
|
let(:params) { { name: "Jan Kowalski", app_id: 'app_id_test', app_password: 'secret'} }
|
46
46
|
|
47
47
|
it "should create an api request" do
|
48
|
-
subject.send_request(path, method, params).
|
48
|
+
expect(subject.send_request(path, method, params)).to eq('returned api data')
|
49
49
|
end
|
50
50
|
|
51
51
|
end
|
@@ -54,12 +54,12 @@ describe Espago::Client do
|
|
54
54
|
subject { Espago::Client.new }
|
55
55
|
|
56
56
|
it "should delegate work to parser" do
|
57
|
-
Espago::Response.
|
57
|
+
expect(Espago::Response).to receive(:new).with(response)
|
58
58
|
subject.parse_response(response)
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should parse response into object" do
|
62
|
-
subject.parse_response(response).class.
|
62
|
+
expect(subject.parse_response(response).class).to eq(Espago::Response)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
data/spec/espago/error_spec.rb
CHANGED
@@ -10,7 +10,8 @@ describe Espago::Error do
|
|
10
10
|
let(:response) {
|
11
11
|
FakeResponse.new(422, response_body)
|
12
12
|
}
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
it {
|
14
|
+
expect(subject.body).to eq('body')
|
15
|
+
expect(subject.status).to eq(422)
|
16
|
+
}
|
16
17
|
end
|
@@ -25,14 +25,14 @@ describe Espago::Response do
|
|
25
25
|
}
|
26
26
|
}.to_json)
|
27
27
|
}
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
28
|
+
it {
|
29
|
+
expect(subject.id).to eq("pay_hViT20SOWaUL_w")
|
30
|
+
expect(subject.description).to eq("Zakupy z example.com")
|
31
|
+
expect(subject.amount).to eq("49.99")
|
32
|
+
expect(subject.currency).to eq("pln")
|
33
|
+
expect(subject.state).to eq("executed")
|
34
|
+
expect(subject.client).to eq("cli_wm7dGQltAqIfH8")
|
35
|
+
expect(subject.created_at).to eq(Time.parse("2013-06-28 10:31:14 +0200"))
|
36
|
+
expect(subject.imaginated_attribute).to be_nil
|
37
|
+
}
|
38
38
|
end
|
data/spec/espago/router_spec.rb
CHANGED
@@ -6,12 +6,12 @@ class Espago::ApiConnection::StubbedRequestGet; end
|
|
6
6
|
describe Espago::Router do
|
7
7
|
subject { Espago::Router.new(:stubbed_request, :get) }
|
8
8
|
|
9
|
-
it { subject.
|
10
|
-
it { subject.
|
9
|
+
it { expect(subject).to respond_to :path}
|
10
|
+
it { expect(subject).to respond_to :method}
|
11
11
|
|
12
12
|
context "#route" do
|
13
13
|
it "should get a class name depending on path and method" do
|
14
|
-
subject.route.
|
14
|
+
expect(subject.route).to eq( Espago::ApiConnection::StubbedRequestGet )
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should raise error if class not found" do
|
@@ -22,14 +22,13 @@ describe Espago::Router do
|
|
22
22
|
|
23
23
|
context "#path_exists?" do
|
24
24
|
it "should return if path exists" do
|
25
|
-
subject.path_exists
|
25
|
+
expect(subject.path_exists?).to be_truthy
|
26
26
|
end
|
27
27
|
|
28
28
|
context "with invalid path name" do
|
29
29
|
subject { Espago::Router.new(:not, :existing) }
|
30
|
-
|
31
30
|
it "should return false" do
|
32
|
-
subject.path_exists
|
31
|
+
expect(subject.path_exists?).not_to be_truthy
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
data/spec/features/apis_spec.rb
CHANGED
@@ -6,7 +6,7 @@ describe 'Two api headers test' do
|
|
6
6
|
Espago.api_version = '2'
|
7
7
|
VCR.use_cassette('api 2') do
|
8
8
|
response = Espago.charges :get
|
9
|
-
response.count.
|
9
|
+
expect(response.count).to eq(596)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -14,7 +14,7 @@ describe 'Two api headers test' do
|
|
14
14
|
Espago.api_version = '3'
|
15
15
|
VCR.use_cassette('api 3') do
|
16
16
|
response = Espago.charges :get
|
17
|
-
response.count.
|
17
|
+
expect(response.count).to eq(596)
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -7,20 +7,20 @@ describe 'Espago.charges' do
|
|
7
7
|
it "should get list of charges" do
|
8
8
|
VCR.use_cassette('charges get') do
|
9
9
|
response = Espago.charges :get
|
10
|
-
response.count.
|
10
|
+
expect(response.count).to eq(589)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should get info abount charges" do
|
15
15
|
VCR.use_cassette('charges get pay_mTOngouLTJWZ0w') do
|
16
16
|
response = Espago.charges :get,{charge_id:'pay_mTOngouLTJWZ0w'}
|
17
|
-
response.status.
|
18
|
-
response.channel.
|
19
|
-
response.state.
|
20
|
-
response.currency.
|
21
|
-
response.description.
|
22
|
-
response.client.
|
23
|
-
response.created_at.
|
17
|
+
expect(response.status).to eq(200)
|
18
|
+
expect(response.channel).to eq('elavon')
|
19
|
+
expect(response.state).to eq('executed')
|
20
|
+
expect(response.currency).to eq('PLN')
|
21
|
+
expect(response.description).to eq('Test12345')
|
22
|
+
expect(response.client).to eq('cli_YM5tKz6-IfhN7T')
|
23
|
+
expect(response.created_at).to eq Time.at(1416917311)
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -38,41 +38,41 @@ describe 'Espago.charges' do
|
|
38
38
|
month:'2'
|
39
39
|
},
|
40
40
|
}
|
41
|
-
response.status.
|
42
|
-
response.channel.
|
43
|
-
response.state.
|
44
|
-
response.currency.
|
45
|
-
response.description.
|
46
|
-
response.client.
|
47
|
-
response.created_at.
|
41
|
+
expect(response.status).to eq(201)
|
42
|
+
expect(response.channel).to eq('elavon')
|
43
|
+
expect(response.state).to eq('executed')
|
44
|
+
expect(response.currency).to eq('PLN')
|
45
|
+
expect(response.description).to eq('Test12345')
|
46
|
+
expect(response.client).to eq('cli_YM5tKz6-IfhN7T')
|
47
|
+
expect(response.created_at).to eq Time.at(1416917311)
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
51
|
it "should get 204 status after destroy charge" do
|
52
52
|
VCR.use_cassette('charges destroy') do
|
53
53
|
response = Espago.charges :delete,{charge_id:'pay_kQmS_3RTfm4eix'}
|
54
|
-
response.state.
|
54
|
+
expect(response.state).to eq('reversed')
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should get refunded status after refund charge" do
|
59
59
|
VCR.use_cassette('charges refund') do
|
60
60
|
response = Espago.charges_refund :post,{charge_id:'pay_lQGyIon5qG59O5'}
|
61
|
-
response.state.
|
61
|
+
expect(response.state).to eq('refunded')
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should get params from complete charge" do
|
66
66
|
VCR.use_cassette('charges complete') do
|
67
67
|
response = Espago.charges_complete :post,{charge_id:'pay_kQmS_3RTfm4eix'}
|
68
|
-
response.state.
|
68
|
+
expect(response.state).to eq('executed')
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
72
|
it "should get params from complete charge (deprecated)" do
|
73
73
|
VCR.use_cassette('charges complete deprecation') do
|
74
74
|
response = Espago.complete :post,{charge_id:'pay_Wmu3hmXJIG4jsg'}
|
75
|
-
response.state.
|
75
|
+
expect(response.state).to eq('executed')
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
@@ -2,37 +2,37 @@
|
|
2
2
|
require "spec_helper"
|
3
3
|
|
4
4
|
describe 'Espago.charges_with_params' do
|
5
|
-
|
5
|
+
|
6
6
|
before :each do
|
7
7
|
Espago.app_id = ''
|
8
8
|
Espago.app_password = ''
|
9
9
|
Espago.public_key = ''
|
10
10
|
Espago.production = true
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should get list of charges" do
|
14
14
|
VCR.use_cassette('charges get') do
|
15
15
|
response = Espago.charges :get,{app_id: 'app_id_test', app_password: 'app_password_test', production: false}
|
16
|
-
response.count.
|
16
|
+
expect(response.count).to eq(589)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should get info abount charges" do
|
21
21
|
VCR.use_cassette('charges get pay_mTOngouLTJWZ0w') do
|
22
22
|
response = Espago.charges :get,{charge_id:'pay_mTOngouLTJWZ0w', app_id: 'app_id_test', app_password: 'app_password_test', production: false}
|
23
|
-
response.status.
|
24
|
-
response.channel.
|
25
|
-
response.state.
|
26
|
-
response.currency.
|
27
|
-
response.description.
|
28
|
-
response.client.
|
29
|
-
response.created_at.
|
23
|
+
expect(response.status).to eq(200)
|
24
|
+
expect(response.channel).to eq('elavon')
|
25
|
+
expect(response.state).to eq('executed')
|
26
|
+
expect(response.currency).to eq('PLN')
|
27
|
+
expect(response.description).to eq('Test12345')
|
28
|
+
expect(response.client).to eq('cli_YM5tKz6-IfhN7T')
|
29
|
+
expect(response.created_at).to eq Time.at(1416917311)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should get params from new charge" do
|
34
34
|
VCR.use_cassette('charges post') do
|
35
|
-
response = Espago.charges :post, {
|
35
|
+
response = Espago.charges :post, {
|
36
36
|
app_id: 'app_id_test',
|
37
37
|
app_password: 'app_password_test',
|
38
38
|
production: false,
|
@@ -48,41 +48,41 @@ describe 'Espago.charges_with_params' do
|
|
48
48
|
month:'2'
|
49
49
|
},
|
50
50
|
}
|
51
|
-
response.status.
|
52
|
-
response.channel.
|
53
|
-
response.state.
|
54
|
-
response.currency.
|
55
|
-
response.description.
|
56
|
-
response.client.
|
57
|
-
response.created_at.
|
51
|
+
expect(response.status).to eq(201)
|
52
|
+
expect(response.channel).to eq('elavon')
|
53
|
+
expect(response.state).to eq('executed')
|
54
|
+
expect(response.currency).to eq('PLN')
|
55
|
+
expect(response.description).to eq('Test12345')
|
56
|
+
expect(response.client).to eq('cli_YM5tKz6-IfhN7T')
|
57
|
+
expect(response.created_at).to eq Time.at(1416917311)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should get 204 status after destroy charge" do
|
62
62
|
VCR.use_cassette('charges destroy') do
|
63
63
|
response = Espago.charges :delete,{charge_id:'pay_kQmS_3RTfm4eix', app_id: 'app_id_test', app_password: 'app_password_test', production: false}
|
64
|
-
response.state.
|
64
|
+
expect(response.state).to eq('reversed')
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
it "should get refunded status after refund charge" do
|
69
69
|
VCR.use_cassette('charges refund') do
|
70
70
|
response = Espago.charges_refund :post,{charge_id:'pay_lQGyIon5qG59O5', app_id: 'app_id_test', app_password: 'app_password_test', production: false}
|
71
|
-
response.state.
|
71
|
+
expect(response.state).to eq('refunded')
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should get params from complete charge" do
|
76
76
|
VCR.use_cassette('charges complete') do
|
77
77
|
response = Espago.charges_complete :post,{charge_id:'pay_kQmS_3RTfm4eix', app_id: 'app_id_test', app_password: 'app_password_test', production: false}
|
78
|
-
response.state.
|
78
|
+
expect(response.state).to eq('executed')
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should get params from complete charge (deprecated)" do
|
83
83
|
VCR.use_cassette('charges complete deprecation') do
|
84
84
|
response = Espago.complete :post,{charge_id:'pay_Wmu3hmXJIG4jsg', app_id: 'app_id_test', app_password: 'app_password_test', production: false}
|
85
|
-
response.state.
|
85
|
+
expect(response.state).to eq('executed')
|
86
86
|
end
|
87
87
|
end
|
88
88
|
|
@@ -5,17 +5,17 @@ describe 'Espago.clients' do
|
|
5
5
|
it "should get list of clients" do
|
6
6
|
VCR.use_cassette('clients get') do
|
7
7
|
response = Espago.clients :get
|
8
|
-
response.count.
|
8
|
+
expect(response.count).to eq(597)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should get info abount clients" do
|
13
13
|
VCR.use_cassette('clients get cli_w0Se2smYwyQ0Uw') do
|
14
14
|
response = Espago.clients :get,{client_id:'cli_w0Se2smYwyQ0Uw'}
|
15
|
-
response.email.
|
16
|
-
response.card['company'].
|
17
|
-
response.description.
|
18
|
-
response.created_at.
|
15
|
+
expect(response.email).to eq(nil)
|
16
|
+
expect(response.card['company']).to eq('VI')
|
17
|
+
expect(response.description).to eq(nil)
|
18
|
+
expect(response.created_at).to eq Time.at(1417004837)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -30,22 +30,22 @@ describe 'Espago.clients' do
|
|
30
30
|
month:'2'
|
31
31
|
},
|
32
32
|
}
|
33
|
-
response.status.
|
34
|
-
response.card['company'].
|
35
|
-
response.card['last4'].
|
36
|
-
response.card['authorized'].
|
37
|
-
response.deleted.
|
38
|
-
response.created_at.
|
33
|
+
expect(response.status).to eq(201)
|
34
|
+
expect(response.card['company']).to eq('VI')
|
35
|
+
expect(response.card['last4']).to eq('4242')
|
36
|
+
expect(response.card['authorized']).to eq(nil)
|
37
|
+
expect(response.deleted).to eq(false)
|
38
|
+
expect(response.created_at).to eq Time.at(1417007099)
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
it "should get status after authorize client card" do
|
43
43
|
VCR.use_cassette('clients authorize') do
|
44
44
|
response = Espago.clients_authorize :post,{client_id:'cli_w0Se2smYwyQ0Uw'}
|
45
|
-
response.status.
|
46
|
-
response.card['company'].
|
47
|
-
response.card['last4'].
|
48
|
-
response.card['authorized'].
|
45
|
+
expect(response.status).to eq(201)
|
46
|
+
expect(response.card['company']).to eq('VI')
|
47
|
+
expect(response.card['last4']).to eq('1112')
|
48
|
+
expect(response.card['authorized']).to eq(true)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -62,21 +62,21 @@ describe 'Espago.clients' do
|
|
62
62
|
month:'2'
|
63
63
|
},
|
64
64
|
}
|
65
|
-
response.status.
|
66
|
-
response.card['company'].
|
67
|
-
response.card['last4'].
|
68
|
-
response.card['authorized'].
|
69
|
-
response.deleted.
|
70
|
-
response.created_at.
|
65
|
+
expect(response.status).to eq(200)
|
66
|
+
expect(response.card['company']).to eq('VI')
|
67
|
+
expect(response.card['last4']).to eq('4242')
|
68
|
+
expect(response.card['authorized']).to eq(nil)
|
69
|
+
expect(response.deleted).to eq(false)
|
70
|
+
expect(response.created_at).to eq Time.at(1417004837)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should get client invoices" do
|
75
75
|
VCR.use_cassette('clients invoices') do
|
76
76
|
response = Espago.clients_invoices :get, { client_id:'cli_w0Se2smYwyQ0Uw'}
|
77
|
-
response.status.
|
78
|
-
response.count.
|
79
|
-
response.invoices.
|
77
|
+
expect(response.status).to eq(200)
|
78
|
+
expect(response.count).to eq(0)
|
79
|
+
expect(response.invoices).to eq([])
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
@@ -84,16 +84,16 @@ describe 'Espago.clients' do
|
|
84
84
|
it "should get client subscriptions" do
|
85
85
|
VCR.use_cassette('clients subscriptions') do
|
86
86
|
response = Espago.clients_subscriptions :get, { client_id:'cli_w0Se2smYwyQ0Uw'}
|
87
|
-
response.status.
|
88
|
-
response.count.
|
89
|
-
response.subscriptions.
|
87
|
+
expect(response.status).to eq(200)
|
88
|
+
expect(response.count).to eq(0)
|
89
|
+
expect(response.subscriptions).to eq([])
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should get status 204 after delete client" do
|
94
94
|
VCR.use_cassette('clients delete') do
|
95
95
|
response = Espago.clients :delete, { client_id:'cli_5rDoJyvKDM4RbM'}
|
96
|
-
response.status.
|
96
|
+
expect(response.status).to eq(204)
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
@@ -6,13 +6,13 @@ describe 'Espago.dcc_decision' do
|
|
6
6
|
it "should get params from new charge" do
|
7
7
|
VCR.use_cassette('dcc_decision post') do
|
8
8
|
response = Espago.dcc_decision :post, {charge_id:'pay_mTOngouLTJWZ0w', decision:'Y'}
|
9
|
-
response.status.
|
10
|
-
response.channel.
|
11
|
-
response.state.
|
12
|
-
response.currency.
|
13
|
-
response.description.
|
14
|
-
response.client.
|
15
|
-
response.created_at.
|
9
|
+
expect(response.status).to eq(201)
|
10
|
+
expect(response.channel).to eq('elavon')
|
11
|
+
expect(response.state).to eq('executed')
|
12
|
+
expect(response.currency).to eq('PLN')
|
13
|
+
expect(response.description).to eq('Test12345')
|
14
|
+
expect(response.client).to eq('cli_YM5tKz6-IfhN7T')
|
15
|
+
expect(response.created_at).to eq Time.at(1416917311)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -5,9 +5,9 @@ describe 'Espago.invoice_items' do
|
|
5
5
|
it "should get info abount invoice_items" do
|
6
6
|
VCR.use_cassette('invoice_items get ii_5LS-YR7S1QaJBl3') do
|
7
7
|
response = Espago.invoice_items :get,{invoice_item_id:'ii_5LS-YR7S1QaJBl3'}
|
8
|
-
response.client.
|
9
|
-
response.amount.
|
10
|
-
response.created_at.
|
8
|
+
expect(response.client).to eq('cli_90Pi6Jf0ndl_PP')
|
9
|
+
expect(response.amount).to eq('123.45')
|
10
|
+
expect(response.created_at).to eq Time.at(1417030496)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
@@ -19,18 +19,18 @@ describe 'Espago.invoice_items' do
|
|
19
19
|
description: 'Test invoice items',
|
20
20
|
client: 'cli_90Pi6Jf0ndl_PP'
|
21
21
|
}
|
22
|
-
response.status.
|
23
|
-
response.client.
|
24
|
-
response.amount.
|
25
|
-
response.currency.
|
26
|
-
response.created_at.
|
22
|
+
expect(response.status).to eq(201)
|
23
|
+
expect(response.client).to eq('cli_90Pi6Jf0ndl_PP')
|
24
|
+
expect(response.amount).to eq('49.99')
|
25
|
+
expect(response.currency).to eq('pln')
|
26
|
+
expect(response.created_at).to eq Time.at(1417102491)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
it "should get info abount deleted invoice_items" do
|
31
31
|
VCR.use_cassette('invoice_items delete ii_WDzszvhTshe78Xd') do
|
32
32
|
response = Espago.invoice_items :delete,{invoice_item_id:'ii_WDzszvhTshe78Xd'}
|
33
|
-
response.status.
|
33
|
+
expect(response.status).to eq(204)
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|