webpay 2.4.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -2
- data/Rakefile +0 -6
- data/lib/webpay/account.rb +19 -24
- data/lib/webpay/api_resource.rb +5 -0
- data/lib/webpay/charge.rb +48 -27
- data/lib/webpay/customer.rb +56 -91
- data/lib/webpay/data_types.rb +2069 -0
- data/lib/webpay/error.rb +68 -0
- data/lib/webpay/event.rb +19 -16
- data/lib/webpay/recursion.rb +47 -46
- data/lib/webpay/shop.rb +37 -68
- data/lib/webpay/token.rb +19 -10
- data/lib/webpay.rb +114 -77
- data/webpay.gemspec +6 -13
- metadata +16 -179
- data/.rspec +0 -2
- data/.travis.yml +0 -12
- data/LICENSE.txt +0 -22
- data/README.md +0 -52
- data/gemfiles/no_doc_gems +0 -14
- data/lib/data/ca-certificates.crt +0 -3829
- data/lib/webpay/card.rb +0 -13
- data/lib/webpay/client.rb +0 -81
- data/lib/webpay/deleted_entity.rb +0 -8
- data/lib/webpay/entity.rb +0 -71
- data/lib/webpay/entity_list.rb +0 -25
- data/lib/webpay/fee.rb +0 -13
- data/lib/webpay/operations.rb +0 -49
- data/lib/webpay/response_converter.rb +0 -57
- data/lib/webpay/version.rb +0 -5
- data/lib/webpay/webpay_error.rb +0 -126
- data/spec/resources/account/delete.txt +0 -15
- data/spec/resources/account/retrieve.txt +0 -23
- data/spec/resources/charges/all.txt +0 -139
- data/spec/resources/charges/capture.txt +0 -49
- data/spec/resources/charges/create_with_card.txt +0 -49
- data/spec/resources/charges/create_with_customer.txt +0 -49
- data/spec/resources/charges/refund.txt +0 -57
- data/spec/resources/charges/retrieve.txt +0 -49
- data/spec/resources/charges/retrieve_not_captured.txt +0 -42
- data/spec/resources/customers/all.txt +0 -76
- data/spec/resources/customers/create.txt +0 -31
- data/spec/resources/customers/delete.txt +0 -16
- data/spec/resources/customers/retrieve.txt +0 -63
- data/spec/resources/customers/retrieve_deleted.txt +0 -16
- data/spec/resources/customers/update.txt +0 -31
- data/spec/resources/errors/bad_request.txt +0 -18
- data/spec/resources/errors/broken_json.txt +0 -16
- data/spec/resources/errors/card_error.txt +0 -19
- data/spec/resources/errors/not_found.txt +0 -18
- data/spec/resources/errors/not_found_ja.txt +0 -20
- data/spec/resources/errors/unauthorized.txt +0 -16
- data/spec/resources/errors/unknown_api_error.txt +0 -17
- data/spec/resources/events/all_with_type.txt +0 -164
- data/spec/resources/events/retrieve.txt +0 -41
- data/spec/resources/recursions/all.txt +0 -61
- data/spec/resources/recursions/create.txt +0 -26
- data/spec/resources/recursions/delete.txt +0 -16
- data/spec/resources/recursions/resume.txt +0 -26
- data/spec/resources/recursions/retrieve.txt +0 -26
- data/spec/resources/recursions/retrieve_deleted.txt +0 -16
- data/spec/resources/recursions/retrieve_suspended.txt +0 -26
- data/spec/resources/shops/all.txt +0 -122
- data/spec/resources/shops/create.txt +0 -54
- data/spec/resources/shops/retrieve.txt +0 -54
- data/spec/resources/shops/update.txt +0 -55
- data/spec/resources/tokens/create.txt +0 -30
- data/spec/resources/tokens/retrieve.txt +0 -30
- data/spec/spec_helper.rb +0 -37
- data/spec/webpay/account_spec.rb +0 -24
- data/spec/webpay/charge_spec.rb +0 -143
- data/spec/webpay/customer_spec.rb +0 -109
- data/spec/webpay/event_spec.rb +0 -30
- data/spec/webpay/recursion_spec.rb +0 -93
- data/spec/webpay/shop_spec.rb +0 -121
- data/spec/webpay/token_spec.rb +0 -33
- data/spec/webpay/webpay_error_spec.rb +0 -64
- data/spec/webpay_spec.rb +0 -40
data/spec/webpay/token_spec.rb
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
describe WebPay::Token do
|
3
|
-
describe '.create' do
|
4
|
-
let(:params) {{:number=>'4242-4242-4242-4242',
|
5
|
-
:exp_month=>'12',
|
6
|
-
:exp_year=>'2015',
|
7
|
-
:cvc=>'123',
|
8
|
-
:name=>'YUUKO SHIONJI'}}
|
9
|
-
before do
|
10
|
-
stub_post_request('/tokens', 'tokens/create', params)
|
11
|
-
end
|
12
|
-
subject(:token) { WebPay::Token.create(params)}
|
13
|
-
|
14
|
-
its(:id) { should eq 'tok_3dw2T20rzekM1Kf' }
|
15
|
-
its(:used) { should eq false }
|
16
|
-
it 'card.name' do
|
17
|
-
expect(token.card.name).to eq 'YUUKO SHIONJI'
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '.retrieve' do
|
22
|
-
let(:id) { 'tok_3dw2T20rzekM1Kf' }
|
23
|
-
before do
|
24
|
-
stub_get_request("/tokens/#{id}", 'tokens/retrieve')
|
25
|
-
end
|
26
|
-
|
27
|
-
subject(:token) { described_class.retrieve(id) }
|
28
|
-
its(:id) { should eq id }
|
29
|
-
it 'card.fingerprint' do
|
30
|
-
expect(token.card.fingerprint).to eq '215b5b2fe460809b8bb90bae6eeac0e0e0987bd7'
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
describe WebPay::WebPayError do
|
3
|
-
def error_response_from_file(name)
|
4
|
-
content = response_file('errors/' + name).read
|
5
|
-
status = content.split(" ", 3)[1].to_i
|
6
|
-
body = content.split("\n\n", 2).last
|
7
|
-
|
8
|
-
described_class.from_response(status, body)
|
9
|
-
end
|
10
|
-
|
11
|
-
describe 'Bad Request' do
|
12
|
-
subject(:error) { error_response_from_file('bad_request') }
|
13
|
-
it { should be_instance_of WebPay::InvalidRequestError }
|
14
|
-
its(:status) { should eq 400 }
|
15
|
-
its(:type) { should eq 'invalid_request_error' }
|
16
|
-
its(:param) { should eq 'currency' }
|
17
|
-
its(:message) { should eq 'Missing required param: currency' }
|
18
|
-
end
|
19
|
-
|
20
|
-
describe 'Unauthorized' do
|
21
|
-
subject(:error) { error_response_from_file('unauthorized') }
|
22
|
-
it { should be_instance_of WebPay::AuthenticationError }
|
23
|
-
its(:status) { should eq 401 }
|
24
|
-
its(:message) { should eq 'Invalid API key provided. Check your API key is correct.' }
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'Card Error' do
|
28
|
-
subject(:error) { error_response_from_file('card_error') }
|
29
|
-
it { should be_instance_of WebPay::CardError }
|
30
|
-
its(:status) { should eq 402 }
|
31
|
-
its(:type) { should eq 'card_error' }
|
32
|
-
its(:param) { should eq 'number' }
|
33
|
-
let(:code) { should eq 'incorrect_number' }
|
34
|
-
its(:message) { should eq 'Your card number is incorrect' }
|
35
|
-
end
|
36
|
-
|
37
|
-
describe 'Not Found' do
|
38
|
-
subject(:error) { error_response_from_file('not_found') }
|
39
|
-
it { should be_instance_of WebPay::InvalidRequestError }
|
40
|
-
its(:status) { should eq 404 }
|
41
|
-
its(:type) { should eq 'invalid_request_error' }
|
42
|
-
its(:param) { should eq 'id' }
|
43
|
-
end
|
44
|
-
|
45
|
-
describe 'API Error' do
|
46
|
-
subject(:error) { error_response_from_file('unknown_api_error') }
|
47
|
-
it { should be_instance_of WebPay::APIError }
|
48
|
-
its(:status) { should eq 500 }
|
49
|
-
its(:type) { should eq 'api_error' }
|
50
|
-
its(:message) { should eq 'Unknown error occurred' }
|
51
|
-
end
|
52
|
-
|
53
|
-
describe 'The response JSON is broken' do
|
54
|
-
subject(:error) { error_response_from_file('broken_json') }
|
55
|
-
it { should be_instance_of WebPay::APIConnectionError }
|
56
|
-
its(:message) { should include 'Response JSON is broken' }
|
57
|
-
end
|
58
|
-
|
59
|
-
describe 'The response JSON has no "error" field' do
|
60
|
-
subject(:error) { described_class.from_response(404, '{}') }
|
61
|
-
it { should be_instance_of WebPay::APIConnectionError }
|
62
|
-
its(:message) { should include 'Invalid response {}' }
|
63
|
-
end
|
64
|
-
end
|
data/spec/webpay_spec.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
describe WebPay do
|
6
|
-
it 'should set proxy on Faraday client from api_proxy option' do
|
7
|
-
proxy_uri = 'http://test.example.com:8080'
|
8
|
-
WebPay.api_proxy = proxy_uri
|
9
|
-
expect(WebPay.client.instance_variable_get(:@conn).proxy[:uri])
|
10
|
-
.to eq(URI.parse(proxy_uri))
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'Not Found with Accept-Language: ja' do
|
14
|
-
let(:id) { 'cus_eS6dGfa8BeUlbS' }
|
15
|
-
before do
|
16
|
-
stub_request(:get, 'http://api.example.com/v1/customers/' + id).
|
17
|
-
with(headers: { 'Authorization' => 'Bearer fake_apikey', 'Accept-Language' => 'ja' }).
|
18
|
-
to_return(response_file('errors/not_found_ja'))
|
19
|
-
end
|
20
|
-
subject(:error) {
|
21
|
-
WebPay.api_base = 'http://api.example.com/v1'
|
22
|
-
WebPay.language = :ja
|
23
|
-
begin
|
24
|
-
WebPay::Customer.retrieve(id)
|
25
|
-
rescue => e
|
26
|
-
e
|
27
|
-
end
|
28
|
-
}
|
29
|
-
it { should be_instance_of WebPay::InvalidRequestError }
|
30
|
-
its(:status) { should eq 404 }
|
31
|
-
its(:type) { should eq 'invalid_request_error' }
|
32
|
-
its(:param) { should eq 'id' }
|
33
|
-
its(:message) { should eq '該当する顧客がありません: cus_eS6dGfa8BeUlbS' }
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'should handle invalid URL as ApiConnectionError' do
|
37
|
-
expect { WebPay::Charge.retrieve('ch_aaaaxxxx 2014-04-04') }.
|
38
|
-
to raise_error(WebPay::APIConnectionError, 'Connection with WebPay API server failed. bad URI(is not URI?): /v1/charges/ch_aaaaxxxx 2014-04-04')
|
39
|
-
end
|
40
|
-
end
|