payjp 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21b1328487d0db17d3b7e78afe2b1a9f00df6506c2da1b896c216eec238b4936
4
- data.tar.gz: 6416cc480d88f3fcf135ed0005ee37a2d2d8d70e4d10c7ed4fa68f9a408dbe78
3
+ metadata.gz: e56a8b6072c8f7bf70ae67ddf6e4d2650bae25abf2d0f7ad73292a6d8849ba5e
4
+ data.tar.gz: 964b24363b6ea92c347e87579c14480952a6f4722bc01113facd4f31a2ee3cd2
5
5
  SHA512:
6
- metadata.gz: 9d907d975eb58780bd31183c3e6fd68fa99c21fa34bcbe545be98b8d9f18453d822c1cb98e7f6020235dbcf70aeedaf3e2b5022132b97c62671be847d5326923
7
- data.tar.gz: 0be34aabaceb678126e61f71d8a0832140972f554789e135e043693996cf288875aa196383fe3f97b87073e448df265ed028ffc32c3bf26ac1a3ce10226a7be7
6
+ metadata.gz: b8e03295fe9396b884ae2998a5f05d99070812425fda873550920dcf8a3d7824077175820ee86f5a050171a6925b6f676d42d0310b46eace7eef921c3589f594
7
+ data.tar.gz: e457443ea5beca2294f37b524578fcd4ba2a79470c82fe822eb1195527db0dfd30851041f80ae5206880f3b39cfc9a3b1e4c33ecb5ab634f34afa5db26f58dc8
@@ -8,7 +8,7 @@ jobs:
8
8
  runs-on: ubuntu-latest
9
9
  strategy:
10
10
  matrix:
11
- ruby-version: [2.0.0, 2.1, 2.2, 2.3.0, jruby-9.2.17.0]
11
+ ruby-version: [2.0.0, 2.1, 2.2, 2.3.0, 2.7.0, jruby-9.2.17.0]
12
12
  steps:
13
13
  - uses: actions/checkout@v2
14
14
  - name: Set up Ruby ${{ matrix.ruby-version }}
data/README.md CHANGED
@@ -41,6 +41,34 @@ gem build payjp.gemspec
41
41
  * Ruby 2.0.0 or above.
42
42
  * rest-client
43
43
 
44
+ ### Retry on HTTP Status Code 429
45
+ * See [Rate Limit Guideline](https://pay.jp/docs/guideline-rate-limit#2-%E3%83%AA%E3%83%88%E3%83%A9%E3%82%A4)
46
+ * When you exceeded rate-limit, you can retry request by setting `max_retry`
47
+ like `Payjp.max_retry = 3` .
48
+ * The retry interval base value is `retry_initial_delay`
49
+ Adjust the value like `Payjp.retry_initial_delay = 4`
50
+ The smaller is shorter.
51
+ * The Maximum retry time is `retry_max_delay`.
52
+ Adjust the value like 'Payjp.retry_max_delay = 32'
53
+ * The retry interval calcurating is based on "Exponential backoff with equal jitter" algorithm.
54
+ See https://aws.amazon.com/jp/blogs/architecture/exponential-backoff-and-jitter/
55
+
56
+ how to use
57
+
58
+ ```ruby
59
+ require 'payjp'
60
+ Payjp.api_key = 'sk_test_c62fade9d045b54cd76d7036'
61
+ Payjp.max_retry = 3
62
+ Payjp.retry_initial_delay = 2
63
+ Payjp.retry_max_delay = 32
64
+
65
+ charge = Payjp::Charge.create(
66
+ :amount => 3500,
67
+ :card => 'token_id',
68
+ :currency => 'jpy',
69
+ )
70
+ ```
71
+
44
72
  ### Bundler
45
73
 
46
74
  If you are installing via bundler, you should be sure to use the https
@@ -0,0 +1,19 @@
1
+ module Payjp
2
+ class Tenant < APIResource
3
+ include Payjp::APIOperations::Create
4
+ include Payjp::APIOperations::Delete
5
+ include Payjp::APIOperations::Update
6
+ include Payjp::APIOperations::List
7
+
8
+ def create_application_urls(params = {}, opts = {})
9
+ response, opts = request(:post, create_application_urls_url, params, opts)
10
+ response
11
+ end
12
+
13
+ private
14
+
15
+ def create_application_urls_url
16
+ url + '/application_urls'
17
+ end
18
+ end
19
+ end
data/lib/payjp/util.rb CHANGED
@@ -25,6 +25,7 @@ module Payjp
25
25
  'card' => Card,
26
26
  'charge' => Charge,
27
27
  'customer' => Customer,
28
+ 'tenant' => Tenant,
28
29
  'event' => Event,
29
30
  'plan' => Plan,
30
31
  'subscription' => Subscription,
data/lib/payjp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Payjp
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
data/lib/payjp.rb CHANGED
@@ -34,6 +34,7 @@ require 'payjp/event'
34
34
  require 'payjp/transfer'
35
35
  require 'payjp/card'
36
36
  require 'payjp/subscription'
37
+ require 'payjp/tenant'
37
38
 
38
39
  # Errors
39
40
  require 'payjp/errors/payjp_error'
@@ -0,0 +1,42 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Payjp
4
+ class TenantTest < Test::Unit::TestCase
5
+ should "tenants should be listable" do
6
+ @mock.expects(:get).once.returns(test_response(test_tenant_array))
7
+ c = Payjp::Tenant.all.data
8
+ assert c.is_a? Array
9
+ assert c[0].is_a? Payjp::Tenant
10
+ end
11
+
12
+ should "tenants should be deletable" do
13
+ @mock.expects(:delete).once.returns(test_response(test_tenant))
14
+ c = Payjp::Tenant.new("test_tenant")
15
+ c.delete
16
+ end
17
+
18
+ should "tenants should be updateable" do
19
+ @mock.expects(:get).once.returns(test_response(test_tenant({ :name => "foo" })))
20
+ @mock.expects(:post).once.returns(test_response(test_tenant({ :name => "bar" })))
21
+ c = Payjp::Tenant.new("test_tenant").refresh
22
+ assert_equal "foo", c.name
23
+ c.name = "bar"
24
+ c.save
25
+ assert_equal "bar", c.name
26
+ end
27
+
28
+ should "create should return a new tenant" do
29
+ @mock.expects(:post).once.returns(test_response(test_tenant(:id => 'test_tenant1')))
30
+ c = Payjp::Tenant.create(:id => 'test_tenant1')
31
+ assert_equal "test_tenant1", c.id
32
+ end
33
+
34
+ should "create_application_urls should be callable" do
35
+ @mock.expects(:get).never
36
+ @mock.expects(:post).once.returns(test_response({ :object => "application_url", :url => 'https://pay.jp/_/applications/start/c24368137e384aa9xxxxxxxxxxxxxxxx', :expires => 1476676539 }))
37
+ c = Payjp::Tenant.new('test_tenant')
38
+ response = c.create_application_urls()
39
+ assert_equal response[:url], 'https://pay.jp/_/applications/start/c24368137e384aa9xxxxxxxxxxxxxxxx'
40
+ end
41
+ end
42
+ end
data/test/test_data.rb CHANGED
@@ -250,6 +250,35 @@ module Payjp
250
250
  }
251
251
  end
252
252
 
253
+ def test_tenant(params = {})
254
+ {
255
+ :created => 1433127983,
256
+ :name => "test",
257
+ :id => "test",
258
+ :livemode => false,
259
+ :metadata => nil,
260
+ :object => "tenant",
261
+ :platform_fee_rate => "10.15",
262
+ :payjp_fee_included => false,
263
+ :minimum_transfer_amount => 1000,
264
+ :bank_account_number => "0001000",
265
+ :bank_branch_code => "000",
266
+ :bank_code => "0000",
267
+ :bank_account_holder_name => "ヤマダ タロウ",
268
+ :bank_account_type => "普通",
269
+ :bank_account_status => "pending"
270
+ }.merge(params)
271
+ end
272
+
273
+ def test_tenant_array
274
+ {
275
+ :count => 3,
276
+ :data => [test_tenant, test_tenant, test_tenant],
277
+ :object => 'list',
278
+ :url => '/v1/tenants'
279
+ }
280
+ end
281
+
253
282
  def test_invalid_api_key_error
254
283
  {
255
284
  :error => {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payjp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - PAY.JP
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-11 00:00:00.000000000 Z
11
+ date: 2022-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -139,6 +139,7 @@ files:
139
139
  - lib/payjp/payjp_object.rb
140
140
  - lib/payjp/plan.rb
141
141
  - lib/payjp/subscription.rb
142
+ - lib/payjp/tenant.rb
142
143
  - lib/payjp/token.rb
143
144
  - lib/payjp/transfer.rb
144
145
  - lib/payjp/util.rb
@@ -155,6 +156,7 @@ files:
155
156
  - test/payjp/payjp_object_test.rb
156
157
  - test/payjp/plan_test.rb
157
158
  - test/payjp/subscription_test.rb
159
+ - test/payjp/tenant_test.rb
158
160
  - test/payjp/token_test.rb
159
161
  - test/payjp/transfer_test.rb
160
162
  - test/payjp/util_test.rb
@@ -165,7 +167,7 @@ licenses:
165
167
  - MIT
166
168
  metadata:
167
169
  source_code_uri: https://github.com/payjp/payjp-ruby
168
- post_install_message:
170
+ post_install_message:
169
171
  rdoc_options: []
170
172
  require_paths:
171
173
  - lib
@@ -180,8 +182,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
182
  - !ruby/object:Gem::Version
181
183
  version: '0'
182
184
  requirements: []
183
- rubygems_version: 3.1.2
184
- signing_key:
185
+ rubygems_version: 3.1.6
186
+ signing_key:
185
187
  specification_version: 4
186
188
  summary: Ruby bindings for the Payjp API
187
189
  test_files:
@@ -196,6 +198,7 @@ test_files:
196
198
  - test/payjp/payjp_object_test.rb
197
199
  - test/payjp/plan_test.rb
198
200
  - test/payjp/subscription_test.rb
201
+ - test/payjp/tenant_test.rb
199
202
  - test/payjp/token_test.rb
200
203
  - test/payjp/transfer_test.rb
201
204
  - test/payjp/util_test.rb