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
@@ -1,55 +0,0 @@
|
|
1
|
-
HTTP/1.1 200 OK
|
2
|
-
Content-Type: application/json; charset=utf-8
|
3
|
-
X-Ua-Compatible: IE=Edge
|
4
|
-
Etag: "dddb6342b15c871b2283b7e468528dd9"
|
5
|
-
Cache-Control: max-age=0, private, must-revalidate
|
6
|
-
X-Request-Id: 5c8a469c04d4d4361e646584c52df499
|
7
|
-
X-Runtime: 0.395131
|
8
|
-
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-02-22)
|
9
|
-
Date: Sat, 05 Apr 2014 13:50:05 GMT
|
10
|
-
Content-Length: 1462
|
11
|
-
Connection: Keep-Alive
|
12
|
-
|
13
|
-
{
|
14
|
-
"id": "sh_4hBfnVcoNdRw0Jj",
|
15
|
-
"object": "shop",
|
16
|
-
"livemode": false,
|
17
|
-
"status": "created",
|
18
|
-
"description": "最新の店子",
|
19
|
-
"access_key": "shop_1Qy9XO2G56ru4DedFFgjr3vZ",
|
20
|
-
"created": 1396705255,
|
21
|
-
"details": {
|
22
|
-
"url": "https://new.example.com",
|
23
|
-
"name": "WebPay",
|
24
|
-
"name_alphabet": "WEBPAY",
|
25
|
-
"name_kana": "ウェブペイ",
|
26
|
-
"product": "クレジットカード決済API",
|
27
|
-
"pricing_url": "https://webpay.jp/pricing",
|
28
|
-
"commercial_law_url": "https://webpay.jp/company",
|
29
|
-
"price_min": "30",
|
30
|
-
"price_max": "50000",
|
31
|
-
"price_average": "4000",
|
32
|
-
"zipcode": "1410022",
|
33
|
-
"address": "東京都品川区東品川2丁目2-28 タチバナビル2F",
|
34
|
-
"address_kana": "トウキョウトシナガワクヒガシシナガワ2チョウメ2-28 タチバナビル2F",
|
35
|
-
"applicant_name": "曾川景介",
|
36
|
-
"applicant_name_kana": "ソガワケイスケ",
|
37
|
-
"applicant_email": "sowawa@webpay.jp",
|
38
|
-
"applicant_phone": "03-4589-4747",
|
39
|
-
"company_name": "ウェブペイ株式会社",
|
40
|
-
"company_name_kana": "ウェブペイカブシキガイシャ",
|
41
|
-
"company_phone": "03-4589-4747",
|
42
|
-
"company_found_date": "20130601",
|
43
|
-
"company_president_name": "久保渓",
|
44
|
-
"company_president_name_kana": "クボケイ",
|
45
|
-
"company_president_birth_date": "19850810"
|
46
|
-
},
|
47
|
-
"statement_descriptor": null,
|
48
|
-
"card_types_supported": [
|
49
|
-
"Visa",
|
50
|
-
"American Express",
|
51
|
-
"MasterCard",
|
52
|
-
"JCB",
|
53
|
-
"Diners Club"
|
54
|
-
]
|
55
|
-
}
|
@@ -1,30 +0,0 @@
|
|
1
|
-
HTTP/1.1 201 Created
|
2
|
-
Content-Type: application/json; charset=utf-8
|
3
|
-
X-Ua-Compatible: IE=Edge
|
4
|
-
Etag: "05ec1d26e74ca3aaa0f83f4a592ea069"
|
5
|
-
Cache-Control: max-age=0, private, must-revalidate
|
6
|
-
X-Request-Id: 73e33db3646601c24efd77b0b00ba28d
|
7
|
-
X-Runtime: 0.587596
|
8
|
-
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-02-22)
|
9
|
-
Date: Wed, 11 Sep 2013 12:03:55 GMT
|
10
|
-
Content-Length: 378
|
11
|
-
Connection: Keep-Alive
|
12
|
-
|
13
|
-
{
|
14
|
-
"id": "tok_3dw2T20rzekM1Kf",
|
15
|
-
"object": "token",
|
16
|
-
"livemode": false,
|
17
|
-
"created": 1378901035,
|
18
|
-
"used": false,
|
19
|
-
"card": {
|
20
|
-
"object": "card",
|
21
|
-
"exp_year": 2015,
|
22
|
-
"exp_month": 12,
|
23
|
-
"fingerprint": "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
|
24
|
-
"name": "YUUKO SHIONJI",
|
25
|
-
"country": "JP",
|
26
|
-
"type": "Visa",
|
27
|
-
"cvc_check": "pass",
|
28
|
-
"last4": "4242"
|
29
|
-
}
|
30
|
-
}
|
@@ -1,30 +0,0 @@
|
|
1
|
-
HTTP/1.1 200 OK
|
2
|
-
Content-Type: application/json; charset=utf-8
|
3
|
-
X-Ua-Compatible: IE=Edge
|
4
|
-
Etag: "05ec1d26e74ca3aaa0f83f4a592ea069"
|
5
|
-
Cache-Control: max-age=0, private, must-revalidate
|
6
|
-
X-Request-Id: 0ad1274f865ae7cce5d8187373fa0fa4
|
7
|
-
X-Runtime: 0.013401
|
8
|
-
Server: WEBrick/1.3.1 (Ruby/1.9.3/2013-02-22)
|
9
|
-
Date: Wed, 11 Sep 2013 12:07:10 GMT
|
10
|
-
Content-Length: 378
|
11
|
-
Connection: Keep-Alive
|
12
|
-
|
13
|
-
{
|
14
|
-
"id": "tok_3dw2T20rzekM1Kf",
|
15
|
-
"object": "token",
|
16
|
-
"livemode": false,
|
17
|
-
"created": 1378901035,
|
18
|
-
"used": false,
|
19
|
-
"card": {
|
20
|
-
"object": "card",
|
21
|
-
"exp_year": 2015,
|
22
|
-
"exp_month": 12,
|
23
|
-
"fingerprint": "215b5b2fe460809b8bb90bae6eeac0e0e0987bd7",
|
24
|
-
"name": "YUUKO SHIONJI",
|
25
|
-
"country": "JP",
|
26
|
-
"type": "Visa",
|
27
|
-
"cvc_check": "pass",
|
28
|
-
"last4": "4242"
|
29
|
-
}
|
30
|
-
}
|
data/spec/spec_helper.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'webmock/rspec'
|
2
|
-
require 'webpay'
|
3
|
-
|
4
|
-
RSpec.configure do |config|
|
5
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
6
|
-
config.run_all_when_everything_filtered = true
|
7
|
-
config.filter_run :focus
|
8
|
-
|
9
|
-
config.order = 'random'
|
10
|
-
|
11
|
-
config.before(:each) do
|
12
|
-
WebPay.api_key = 'fake_apikey'
|
13
|
-
WebPay.api_base = 'http://api.example.com'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def stub_get_request(path, file)
|
18
|
-
stub_request(:get, 'http://api.example.com/v1' + path).
|
19
|
-
with(headers: { 'Authorization' => 'Bearer fake_apikey' }).
|
20
|
-
to_return(response_file(file))
|
21
|
-
end
|
22
|
-
|
23
|
-
def stub_post_request(path, file, params = {})
|
24
|
-
stub_request(:post, 'http://api.example.com/v1' + path).
|
25
|
-
with(headers: { 'Authorization' => 'Bearer fake_apikey' }, body: params).
|
26
|
-
to_return(response_file(file))
|
27
|
-
end
|
28
|
-
|
29
|
-
def stub_delete_request(path, file)
|
30
|
-
stub_request(:delete, 'http://api.example.com/v1' + path).
|
31
|
-
with(headers: { 'Authorization' => 'Bearer fake_apikey' }).
|
32
|
-
to_return(response_file(file))
|
33
|
-
end
|
34
|
-
|
35
|
-
def response_file(file)
|
36
|
-
File.new(File.expand_path(File.join(__FILE__, '..', 'resources', file + '.txt')))
|
37
|
-
end
|
data/spec/webpay/account_spec.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
describe WebPay::Account do
|
3
|
-
describe '.retrieve' do
|
4
|
-
before do
|
5
|
-
stub_get_request('/account', 'account/retrieve')
|
6
|
-
end
|
7
|
-
|
8
|
-
subject(:account) { described_class.retrieve }
|
9
|
-
its(:object) { should eq 'account' }
|
10
|
-
its(:id) { should eq 'acct_2Cmdexb7J2r78rz' }
|
11
|
-
its(:email) { should eq 'test-me@example.com' }
|
12
|
-
its(:currencies_supported) { should eq ['jpy'] }
|
13
|
-
end
|
14
|
-
|
15
|
-
describe '.delete_data' do
|
16
|
-
before do
|
17
|
-
stub_delete_request('/account/data', 'account/delete')
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'should return true' do
|
21
|
-
expect(described_class.delete_data).to eq true
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
data/spec/webpay/charge_spec.rb
DELETED
@@ -1,143 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
describe WebPay::Charge do
|
3
|
-
describe '.create' do
|
4
|
-
subject(:charge) { WebPay::Charge.create(params)}
|
5
|
-
|
6
|
-
describe 'with card' do
|
7
|
-
let(:params) {{
|
8
|
-
:amount=>'1000',
|
9
|
-
:currency=>'jpy',
|
10
|
-
:card=>
|
11
|
-
{:number=>'4242-4242-4242-4242',
|
12
|
-
:exp_month=>'12',
|
13
|
-
:exp_year=>'2015',
|
14
|
-
:cvc=>'123',
|
15
|
-
:name=>'YUUKO SHIONJI'},
|
16
|
-
:description=>'Test Charge'
|
17
|
-
}}
|
18
|
-
before do
|
19
|
-
stub_post_request('/charges', 'charges/create_with_card', params)
|
20
|
-
end
|
21
|
-
|
22
|
-
its(:id) { should eq 'ch_5112dw9eYekJc2s' }
|
23
|
-
its(:description) { should eq "Test Charge" }
|
24
|
-
it 'card.name' do
|
25
|
-
expect(charge.card.name).to eq 'YUUKO SHIONJI'
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'fees' do
|
29
|
-
expect(charge.fees.length).to eq 1
|
30
|
-
fee = charge.fees[0]
|
31
|
-
expect(fee.transaction_type).to eq 'payment'
|
32
|
-
expect(fee.transaction_fee).to eq 0
|
33
|
-
expect(fee.rate).to eq 3.25
|
34
|
-
expect(fee.amount).to eq 33
|
35
|
-
expect(fee.created).to eq 1397444129
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe 'with customer' do
|
40
|
-
let(:params) {{
|
41
|
-
:amount=>'1000',
|
42
|
-
:currency=>'jpy',
|
43
|
-
:customer => 'cus_5119ShaAgbLyfwS',
|
44
|
-
:description=>'Test Charge'
|
45
|
-
}}
|
46
|
-
before do
|
47
|
-
stub_post_request('/charges', 'charges/create_with_customer', params)
|
48
|
-
end
|
49
|
-
|
50
|
-
its(:id) { should eq 'ch_5112KydVn9zId7h' }
|
51
|
-
it 'card.name' do
|
52
|
-
expect(charge.card.name).to eq 'KEI KUBO'
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe '.retrieve' do
|
58
|
-
let(:id) { 'ch_5112dw9eYekJc2s' }
|
59
|
-
before do
|
60
|
-
stub_get_request("/charges/#{id}", 'charges/retrieve')
|
61
|
-
end
|
62
|
-
|
63
|
-
subject(:charge) { described_class.retrieve(id) }
|
64
|
-
its(:id) { should eq id }
|
65
|
-
it 'card.fingerprint' do
|
66
|
-
expect(charge.card.fingerprint).to eq '215b5b2fe460809b8bb90bae6eeac0e0e0987bd7'
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe '.all' do
|
71
|
-
context 'with craeted[gt]' do
|
72
|
-
before do
|
73
|
-
stub_get_request("/charges?count=3&offset=0&created[gt]=1397401200", 'charges/all')
|
74
|
-
end
|
75
|
-
|
76
|
-
subject(:list) { described_class.all(count: 3, offset: 0, created: { gt: 1397401200 }) }
|
77
|
-
its(:url) { should eq '/v1/charges' }
|
78
|
-
its(:count) { should eq 4 }
|
79
|
-
it 'data.first.description' do
|
80
|
-
expect(list.data.first.description).to eq 'Test Charge'
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
context 'with customer' do
|
85
|
-
before do
|
86
|
-
stub_get_request("/charges?customer=cus_5119ShaAgbLyfwS", 'charges/all')
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'should respond the list' do
|
90
|
-
list = described_class.all(customer: 'cus_5119ShaAgbLyfwS')
|
91
|
-
expect(list.url).to eq '/v1/charges'
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
describe '#refund' do
|
97
|
-
let(:id) { 'ch_5112dw9eYekJc2s' }
|
98
|
-
|
99
|
-
before do
|
100
|
-
stub_get_request("/charges/#{id}", 'charges/retrieve')
|
101
|
-
stub_post_request("/charges/#{id}/refund", 'charges/refund', amount: '1000')
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'should refund the retrieved charge' do
|
105
|
-
charge = described_class.retrieve(id)
|
106
|
-
expect(charge.refunded).to eq false
|
107
|
-
charge.refund(amount: 1000)
|
108
|
-
expect(charge.refunded).to eq true
|
109
|
-
expect(charge.amount_refunded).to eq 1000
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'should add refund fees' do
|
113
|
-
charge = described_class.retrieve(id)
|
114
|
-
expect(charge.refunded).to eq false
|
115
|
-
charge.refund(amount: 1000)
|
116
|
-
|
117
|
-
expect(charge.fees.length).to eq 2
|
118
|
-
fee = charge.fees[1]
|
119
|
-
expect(fee.transaction_type).to eq 'refund'
|
120
|
-
expect(fee.transaction_fee).to eq 0
|
121
|
-
expect(fee.rate).to eq 3.25
|
122
|
-
expect(fee.amount).to eq -33
|
123
|
-
expect(fee.created).to eq 1397444526
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe '#capture' do
|
128
|
-
let(:id) { 'ch_5113hA4L51yj8TF' }
|
129
|
-
before do
|
130
|
-
stub_get_request("/charges/#{id}", 'charges/retrieve_not_captured')
|
131
|
-
stub_post_request("/charges/#{id}/capture", 'charges/capture', amount: '1000')
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'should capture the retrieved charge' do
|
135
|
-
charge = described_class.retrieve(id)
|
136
|
-
expect(charge.captured).to eq false
|
137
|
-
expect(charge.fees.length).to eq 0
|
138
|
-
charge.capture(amount: 1000)
|
139
|
-
expect(charge.captured).to eq true
|
140
|
-
expect(charge.fees.length).to eq 1
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
describe WebPay::Customer do
|
3
|
-
describe '.create' do
|
4
|
-
let(:params) {{
|
5
|
-
:description => 'Test Customer from Java',
|
6
|
-
:email => 'customer@example.com',
|
7
|
-
:card=>
|
8
|
-
{:number=>'4242-4242-4242-4242',
|
9
|
-
:exp_month=>'12',
|
10
|
-
:exp_year=>'2015',
|
11
|
-
:cvc=>'123',
|
12
|
-
:name=>'YUUKO SHIONJI'}
|
13
|
-
}}
|
14
|
-
before do
|
15
|
-
stub_post_request('/customers', 'customers/create', params)
|
16
|
-
end
|
17
|
-
subject(:customer) { WebPay::Customer.create(params)}
|
18
|
-
|
19
|
-
its(:id) { should eq 'cus_39o4Fv82E1et5Xb' }
|
20
|
-
its(:description) { should eq "Test Customer from Java" }
|
21
|
-
it 'active_card.name' do
|
22
|
-
expect(customer.active_card.name).to eq 'YUUKO SHIONJI'
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '.retrieve' do
|
27
|
-
let(:id) { 'cus_39o4Fv82E1et5Xb' }
|
28
|
-
before do
|
29
|
-
stub_get_request("/customers/#{id}", 'customers/retrieve')
|
30
|
-
end
|
31
|
-
|
32
|
-
subject(:customer) { described_class.retrieve(id) }
|
33
|
-
its(:id) { should eq id }
|
34
|
-
it 'active_card.fingerprint' do
|
35
|
-
expect(customer.active_card.fingerprint).to eq '215b5b2fe460809b8bb90bae6eeac0e0e0987bd7'
|
36
|
-
end
|
37
|
-
it 'recursions.first.id' do
|
38
|
-
expect(customer.recursions.first.id).to eq 'rec_7pF9dTfm11u5cXL'
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe '.retrieve deleted instance' do
|
43
|
-
let(:id) { 'cus_7GafGMbML8R28Io' }
|
44
|
-
before do
|
45
|
-
stub_get_request("/customers/#{id}", 'customers/retrieve_deleted')
|
46
|
-
end
|
47
|
-
|
48
|
-
subject(:customer) { described_class.retrieve(id) }
|
49
|
-
its(:id) { should eq id }
|
50
|
-
its(:deleted) { should eq true }
|
51
|
-
it { should be_deleted }
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '.all' do
|
55
|
-
before do
|
56
|
-
stub_get_request("/customers?count=3&offset=0&created[gt]=1378000000", 'customers/all')
|
57
|
-
end
|
58
|
-
|
59
|
-
subject(:list) { described_class.all(count: 3, offset: 0, created: { gt: 1378000000 }) }
|
60
|
-
its(:url) { should eq '/v1/customers' }
|
61
|
-
its(:count) { should eq 4 }
|
62
|
-
it 'data.first.description' do
|
63
|
-
expect(list.data.first.description).to eq 'Test Customer from Java'
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#save' do
|
68
|
-
let(:id) { 'cus_39o4Fv82E1et5Xb' }
|
69
|
-
let(:email) { 'newmail@example.com' }
|
70
|
-
let(:description) { 'New description' }
|
71
|
-
let(:card_info) { {:number=>'4242-4242-4242-4242',
|
72
|
-
:exp_month=>'12',
|
73
|
-
:exp_year=>'2016',
|
74
|
-
:cvc=>'123',
|
75
|
-
:name=>'YUUKO SHIONJI'} }
|
76
|
-
before do
|
77
|
-
stub_get_request("/customers/#{id}", 'customers/retrieve')
|
78
|
-
stub_post_request("/customers/#{id}", 'customers/update',
|
79
|
-
email: email,
|
80
|
-
description: description,
|
81
|
-
card: card_info)
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'should update information of the retrieved customer' do
|
85
|
-
customer = described_class.retrieve(id)
|
86
|
-
customer.email = email
|
87
|
-
customer.description = description
|
88
|
-
customer.card = card_info
|
89
|
-
customer.save
|
90
|
-
|
91
|
-
expect(customer.email).to eq email
|
92
|
-
expect(customer.description).to eq description
|
93
|
-
expect(customer.active_card.exp_year).to eq 2016
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
describe '#delete' do
|
98
|
-
let(:id) { 'cus_39o4Fv82E1et5Xb' }
|
99
|
-
before do
|
100
|
-
stub_get_request("/customers/#{id}", 'customers/retrieve')
|
101
|
-
stub_delete_request("/customers/#{id}", 'customers/delete')
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'should delete the retrieved customer' do
|
105
|
-
customer = described_class.retrieve(id)
|
106
|
-
expect(customer.delete).to eq true
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
data/spec/webpay/event_spec.rb
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
describe WebPay::Event do
|
3
|
-
describe '.retrieve' do
|
4
|
-
let(:id) { 'evt_39o9oUevb5NCeM1' }
|
5
|
-
before do
|
6
|
-
stub_get_request("/events/#{id}", 'events/retrieve')
|
7
|
-
end
|
8
|
-
|
9
|
-
subject(:event) { described_class.retrieve(id) }
|
10
|
-
its(:id) { should eq id }
|
11
|
-
its(:type) { should eq 'customer.created' }
|
12
|
-
it 'data.object' do
|
13
|
-
expect(event.data.object).to be_instance_of(WebPay::Customer)
|
14
|
-
expect(event.data.object.email).to eq 'customer@example.com'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '.all' do
|
19
|
-
before do
|
20
|
-
stub_get_request("/events?type=*.created", 'events/all_with_type')
|
21
|
-
end
|
22
|
-
|
23
|
-
subject(:list) { described_class.all(type: '*.created') }
|
24
|
-
its(:url) { should eq '/v1/events' }
|
25
|
-
its(:count) { should eq 5 }
|
26
|
-
it 'data.first.type' do
|
27
|
-
expect(list.data.first.type).to eq 'customer.created'
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'spec_helper'
|
3
|
-
describe WebPay::Recursion do
|
4
|
-
describe '.create' do
|
5
|
-
let(:params) {{
|
6
|
-
:amount => '400',
|
7
|
-
:currency => 'jpy',
|
8
|
-
:customer => 'cus_5lF6YD7mq3dWdzB',
|
9
|
-
:period => 'month',
|
10
|
-
:description => 'WebPayマガジン購読料',
|
11
|
-
}}
|
12
|
-
before do
|
13
|
-
stub_post_request('/recursions', 'recursions/create', params)
|
14
|
-
end
|
15
|
-
subject(:recursion) { WebPay::Recursion.create(params)}
|
16
|
-
|
17
|
-
its(:id) { should eq 'rec_5lFaeX56W7bkdKR' }
|
18
|
-
its(:object) { should eq 'recursion' }
|
19
|
-
its(:livemode) { should eq false }
|
20
|
-
its(:description) { should eq 'WebPayマガジン購読料' }
|
21
|
-
its(:attempted) { should eq nil }
|
22
|
-
its(:status) { should eq 'active' }
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '.retrieve' do
|
26
|
-
let(:id) { 'rec_5lFaeX56W7bkdKR' }
|
27
|
-
before do
|
28
|
-
stub_get_request("/recursions/#{id}", 'recursions/retrieve')
|
29
|
-
end
|
30
|
-
|
31
|
-
subject(:recursion) { described_class.retrieve(id) }
|
32
|
-
its(:id) { should eq id }
|
33
|
-
its(:object) { should eq 'recursion' }
|
34
|
-
its(:livemode) { should eq false }
|
35
|
-
its(:description) { should eq 'WebPayマガジン購読料' }
|
36
|
-
its(:attempted) { should eq 1397803007 }
|
37
|
-
its(:status) { should eq 'active' }
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '.retrieve deleted instance' do
|
41
|
-
let(:id) { 'rec_5lF8M9bka5Ov4Po' }
|
42
|
-
before do
|
43
|
-
stub_get_request("/recursions/#{id}", 'recursions/retrieve_deleted')
|
44
|
-
end
|
45
|
-
|
46
|
-
subject(:recursion) { described_class.retrieve(id) }
|
47
|
-
its(:id) { should eq id }
|
48
|
-
its(:deleted) { should eq true }
|
49
|
-
it { should be_deleted }
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '.all' do
|
53
|
-
let(:customer_id) { 'cus_5lF6YD7mq3dWdzB' }
|
54
|
-
before do
|
55
|
-
stub_get_request("/recursions?count=3&suspended=false&customer=#{customer_id}", 'recursions/all')
|
56
|
-
end
|
57
|
-
|
58
|
-
subject(:list) { described_class.all(count: 3, suspended: false, customer: customer_id) }
|
59
|
-
its(:url) { should eq '/v1/recursions' }
|
60
|
-
its(:count) { should eq 5 }
|
61
|
-
it 'data[0].customer' do
|
62
|
-
expect(list.data[0].customer).to eq customer_id
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe '#resume' do
|
67
|
-
let(:id) { 'rec_5lF8UpcBrfAj0Rz' }
|
68
|
-
before do
|
69
|
-
stub_get_request("/recursions/#{id}", 'recursions/retrieve_suspended')
|
70
|
-
stub_post_request("/recursions/#{id}/resume", 'recursions/resume', retry: 'false')
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'should update information of the retrieved recursion' do
|
74
|
-
recursion = described_class.retrieve(id)
|
75
|
-
recursion.resume(retry: false)
|
76
|
-
|
77
|
-
expect(recursion.status).to eq 'active'
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe '#delete' do
|
82
|
-
let(:id) { 'rec_5lFaeX56W7bkdKR' }
|
83
|
-
before do
|
84
|
-
stub_get_request("/recursions/#{id}", 'recursions/retrieve')
|
85
|
-
stub_delete_request("/recursions/#{id}", 'recursions/delete')
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'should delete the retrieved recursion' do
|
89
|
-
recursion = described_class.retrieve(id)
|
90
|
-
expect(recursion.delete).to eq true
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
data/spec/webpay/shop_spec.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
describe WebPay::Shop do
|
4
|
-
let(:details) {
|
5
|
-
{
|
6
|
-
"url"=>"https://webpay.jp",
|
7
|
-
"name"=>"WebPay",
|
8
|
-
"name_alphabet"=>"WEBPAY",
|
9
|
-
"name_kana"=>"ウェブペイ",
|
10
|
-
"product"=>"クレジットカード決済API",
|
11
|
-
"pricing_url"=>"https://webpay.jp/pricing",
|
12
|
-
"commercial_law_url"=>"https://webpay.jp/company",
|
13
|
-
"price_min"=>"30",
|
14
|
-
"price_max"=>"50000",
|
15
|
-
"price_average"=>"4000",
|
16
|
-
"zipcode"=>"1410022",
|
17
|
-
"address"=>"東京都品川区東品川2丁目2-28 タチバナビル2F",
|
18
|
-
"address_kana"=>"トウキョウトシナガワクヒガシシナガワ2チョウメ2-28 タチバナビル2F",
|
19
|
-
"applicant_name"=>"曾川景介",
|
20
|
-
"applicant_name_kana"=>"ソガワケイスケ",
|
21
|
-
"applicant_email"=>"sowawa@webpay.jp",
|
22
|
-
"applicant_phone"=>"03-4589-4747",
|
23
|
-
"company_name"=>"ウェブペイ株式会社",
|
24
|
-
"company_name_kana"=>"ウェブペイカブシキガイシャ",
|
25
|
-
"company_phone"=>"03-4589-4747",
|
26
|
-
"company_found_date"=>"20130601",
|
27
|
-
"company_president_name"=>"久保渓",
|
28
|
-
"company_president_name_kana"=>"クボケイ"
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
describe '.create' do
|
33
|
-
let(:params) { {:description => 'Sample Shop', :details => details} }
|
34
|
-
before do
|
35
|
-
stub_post_request('/shops', 'shops/create', params)
|
36
|
-
end
|
37
|
-
subject(:shop) { described_class.create(params)}
|
38
|
-
|
39
|
-
its(:id) { should eq 'sh_4hB3x19La1tr0Lu' }
|
40
|
-
its(:object) { should eq 'shop' }
|
41
|
-
its(:livemode) { should eq false }
|
42
|
-
its(:status) { should eq 'created' }
|
43
|
-
its(:description) { should eq "Sample Shop" }
|
44
|
-
its(:access_key) { should eq 'shop_8Yp3sy4HberKgut6vy4Ss6FA' }
|
45
|
-
its(:created) { should eq 1396706101 }
|
46
|
-
it { expect(shop.details).to eq details }
|
47
|
-
it { expect(shop.details['url']).to eq 'https://webpay.jp' }
|
48
|
-
its(:card_types_supported) { should eq ["Visa", "American Express", "MasterCard", "JCB", "Diners Club"] }
|
49
|
-
end
|
50
|
-
|
51
|
-
describe '.retrieve' do
|
52
|
-
let(:id) { 'sh_4hBfnVcoNdRw0Jj' }
|
53
|
-
before do
|
54
|
-
stub_get_request("/shops/#{id}", 'shops/retrieve')
|
55
|
-
end
|
56
|
-
|
57
|
-
subject(:shop) { described_class.retrieve(id) }
|
58
|
-
its(:id) { should eq id }
|
59
|
-
it { expect(shop.details).to eq details }
|
60
|
-
it { expect(shop.details['url']).to eq 'https://webpay.jp' }
|
61
|
-
end
|
62
|
-
|
63
|
-
describe '.all' do
|
64
|
-
before do
|
65
|
-
stub_get_request("/shops?count=3&offset=0&created[gt]=1378000000", 'shops/all')
|
66
|
-
end
|
67
|
-
|
68
|
-
subject(:list) { described_class.all(count: 3, offset: 0, created: { gt: 1378000000 }) }
|
69
|
-
its(:url) { should eq '/v1/shops' }
|
70
|
-
its(:count) { should eq 7 }
|
71
|
-
it 'data.first.description' do
|
72
|
-
expect(list.data.first.description).to eq 'Sample Shop'
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe '#save' do
|
77
|
-
let(:id) { 'sh_4hBfnVcoNdRw0Jj' }
|
78
|
-
let(:description) { '最新の店子' }
|
79
|
-
|
80
|
-
context 'details is changed' do
|
81
|
-
let(:updated_details) { details.merge('url' => 'https://new.example.com') }
|
82
|
-
before do
|
83
|
-
stub_get_request("/shops/#{id}", 'shops/retrieve')
|
84
|
-
stub_post_request("/shops/#{id}", 'shops/update', description: description, details: updated_details)
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'should update details of the retrieved shop' do
|
88
|
-
shop = described_class.retrieve(id)
|
89
|
-
shop.description = description
|
90
|
-
shop.details['url'] = 'https://new.example.com'
|
91
|
-
shop.save
|
92
|
-
|
93
|
-
expect(shop.description).to eq description
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
context 'details is not changed' do
|
98
|
-
before do
|
99
|
-
stub_get_request("/shops/#{id}", 'shops/retrieve')
|
100
|
-
stub_post_request("/shops/#{id}", 'shops/update', description: description)
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'should update description of the retrieved shop' do
|
104
|
-
shop = described_class.retrieve(id)
|
105
|
-
shop.description = description
|
106
|
-
shop.save
|
107
|
-
|
108
|
-
expect(shop.description).to eq description
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
context 'when description is nil' do
|
114
|
-
it 'should return nil' do
|
115
|
-
shop = WebPay::Shop.new(description: nil)
|
116
|
-
expect(shop.description).to eq nil
|
117
|
-
shop.description = 'new description'
|
118
|
-
expect(shop.description).to eq 'new description'
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|