payjp 0.0.9 → 0.0.12

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: e56a8b6072c8f7bf70ae67ddf6e4d2650bae25abf2d0f7ad73292a6d8849ba5e
4
- data.tar.gz: 964b24363b6ea92c347e87579c14480952a6f4722bc01113facd4f31a2ee3cd2
3
+ metadata.gz: e04927ede4192a112eada01f9cbed0446c5be53239fa4e6a0ad0428e7bc5f223
4
+ data.tar.gz: 255cb29b0aaa221b636c2bac80e4076e3847581511d115593c7fd6e835f38f6f
5
5
  SHA512:
6
- metadata.gz: b8e03295fe9396b884ae2998a5f05d99070812425fda873550920dcf8a3d7824077175820ee86f5a050171a6925b6f676d42d0310b46eace7eef921c3589f594
7
- data.tar.gz: e457443ea5beca2294f37b524578fcd4ba2a79470c82fe822eb1195527db0dfd30851041f80ae5206880f3b39cfc9a3b1e4c33ecb5ab634f34afa5db26f58dc8
6
+ metadata.gz: 5dca21abfcb1d46a5da179129c6331cb0ed47c32601e1c144dc76d549a6d04a11294e198c2c8e0ab637c396620492a75a3e00aed74b0f6919c9a55aa694cd669
7
+ data.tar.gz: ffbeed6e352fe7ff832f375e335877c184e0b136cba6df6df97fe502ae56fd6c961092f3125c7286ffef8315f9579e25b9b2d8972945d3c51b5c1981150294e1
@@ -0,0 +1,24 @@
1
+ name: Publish Ruby Package
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ deploy:
9
+
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v3
14
+ - name: Set up Ruby
15
+ uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: '2.7'
18
+ bundler-cache: true
19
+ - name: Build and publish
20
+ env:
21
+ GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
22
+ run: |
23
+ bundle exec rake build
24
+ bundle exec gem push pkg/payjp-*.gem
@@ -5,12 +5,12 @@ on: push
5
5
  jobs:
6
6
  build-test:
7
7
 
8
- runs-on: ubuntu-latest
8
+ runs-on: ubuntu-20.04
9
9
  strategy:
10
10
  matrix:
11
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
- - uses: actions/checkout@v2
13
+ - uses: actions/checkout@v3
14
14
  - name: Set up Ruby ${{ matrix.ruby-version }}
15
15
  uses: ruby/setup-ruby@v1
16
16
  with:
data/lib/payjp/charge.rb CHANGED
@@ -19,6 +19,11 @@ module Payjp
19
19
  refresh_from(response, opts)
20
20
  end
21
21
 
22
+ def tds_finish(params = {}, opts = {})
23
+ response, opts = request(:post, tds_finish_url, params, opts)
24
+ refresh_from(response, opts)
25
+ end
26
+
22
27
  private
23
28
 
24
29
  def refund_url
@@ -32,5 +37,9 @@ module Payjp
32
37
  def reauth_url
33
38
  url + '/reauth'
34
39
  end
40
+
41
+ def tds_finish_url
42
+ url + '/tds_finish'
43
+ end
35
44
  end
36
45
  end
@@ -0,0 +1,16 @@
1
+ module Payjp
2
+ class Statement < APIResource
3
+ include Payjp::APIOperations::List
4
+
5
+ def create_statement_urls(params = {}, opts = {})
6
+ response, opts = request(:post, create_statement_urls_url, params, opts)
7
+ response
8
+ end
9
+
10
+ private
11
+
12
+ def create_statement_urls_url
13
+ url + '/statement_urls'
14
+ end
15
+ end
16
+ end
data/lib/payjp/util.rb CHANGED
@@ -28,6 +28,7 @@ module Payjp
28
28
  'tenant' => Tenant,
29
29
  'event' => Event,
30
30
  'plan' => Plan,
31
+ 'statement' => Statement,
31
32
  'subscription' => Subscription,
32
33
  'token' => Token,
33
34
  'transfer' => Transfer
data/lib/payjp/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Payjp
2
- VERSION = '0.0.9'
2
+ VERSION = '0.0.12'
3
3
  end
data/lib/payjp.rb CHANGED
@@ -33,6 +33,7 @@ require 'payjp/token'
33
33
  require 'payjp/event'
34
34
  require 'payjp/transfer'
35
35
  require 'payjp/card'
36
+ require 'payjp/statement'
36
37
  require 'payjp/subscription'
37
38
  require 'payjp/tenant'
38
39
 
@@ -91,5 +91,17 @@ module Payjp
91
91
  c.reauth
92
92
  assert_equal expired_at.to_i, c.expired_at
93
93
  end
94
+
95
+ should "charges should be three_d_secure finishable" do
96
+ @mock.expects(:get).never
97
+ @mock.expects(:post).with do |url, api_key, params|
98
+ url == "#{Payjp.api_base}/v1/charges/test_charge/tds_finish" && api_key.nil? && CGI.parse(params) == {}
99
+ end.once.returns(test_response({ :id => "test_charge", :paid => true, :captured => true }))
100
+
101
+ c = Payjp::Charge.new("test_charge")
102
+ c.tds_finish
103
+ assert c.paid
104
+ assert c.captured
105
+ end
94
106
  end
95
107
  end
@@ -0,0 +1,33 @@
1
+ require File.expand_path('../../test_helper', __FILE__)
2
+
3
+ module Payjp
4
+ class StatementTest < Test::Unit::TestCase
5
+ should "statement should be listable" do
6
+ @mock.expects(:get).once.returns(test_response(test_statement_array))
7
+ statements = Payjp::Statement.all.data
8
+ assert statements.is_a? Array
9
+ assert statements[0].is_a? Payjp::Statement
10
+ end
11
+
12
+ should "be retrievable" do
13
+ @mock.expects(:get).once.returns(test_response(test_statement))
14
+ statement = Payjp::Statement.retrieve('st_test')
15
+ assert statement.is_a? Payjp::Statement
16
+ assert_equal 'st_test', statement.id
17
+ assert_equal 'statement', statement.object
18
+ assert statement.to_hash.has_key?(:items)
19
+ assert statement.items[0].to_hash.has_key?(:amount)
20
+ assert statement.items[0].to_hash.has_key?(:name)
21
+ assert statement.items[0].to_hash.has_key?(:subject)
22
+ assert statement.items[0].to_hash.has_key?(:tax_rate)
23
+ end
24
+
25
+ should "create_statement_urls should be callable" do
26
+ @mock.expects(:get).never
27
+ @mock.expects(:post).once.returns(test_response({ :object => "statement_url", :url => 'https://pay.jp/_/statements/8f9ec721bc734dbcxxxxxxxxxxxxxxxx', :expires => 1476676539 }))
28
+ c = Payjp::Statement.new('st_test')
29
+ response = c.create_statement_urls()
30
+ assert_equal response[:url], 'https://pay.jp/_/statements/8f9ec721bc734dbcxxxxxxxxxxxxxxxx'
31
+ end
32
+ end
33
+ end
data/test/test_data.rb CHANGED
@@ -235,7 +235,9 @@ module Payjp
235
235
  :charge_gross => 1000,
236
236
  :net => 1000,
237
237
  :refund_amount => 0,
238
- :refund_count => 0
238
+ :refund_count => 0,
239
+ :dispute_amount => 0,
240
+ :dispute_count => 0
239
241
  },
240
242
  :metadata => {}
241
243
  }.merge(params)
@@ -325,5 +327,49 @@ module Payjp
325
327
  }
326
328
  }
327
329
  end
330
+
331
+ def test_statement(params = {})
332
+ {
333
+ :created => 1695620296,
334
+ :id => "st_test",
335
+ :items => [
336
+ {
337
+ :amount => 282358654,
338
+ :name => "売上",
339
+ :subject => "gross_sales",
340
+ :tax_rate => "0.00"
341
+ },
342
+ {
343
+ :amount => -65699624,
344
+ :name => "返金",
345
+ :subject => "gross_refund",
346
+ :tax_rate => "0.00"
347
+ },
348
+ {
349
+ :amount => -7054912,
350
+ :name => "決済手数料",
351
+ :subject => "fee",
352
+ :tax_rate => "0.10"
353
+ },
354
+ {
355
+ :amount => 1644315,
356
+ :name => "返金による手数料返還",
357
+ :subject => "refund_fee_offset",
358
+ :tax_rate => "0.10"
359
+ }
360
+ ],
361
+ :object => "statement",
362
+ :title => nil
363
+ }.merge(params)
364
+ end
365
+
366
+ def test_statement_array
367
+ {
368
+ :count => 2,
369
+ :data => [test_statement, test_statement],
370
+ :object => 'list',
371
+ :url => '/v1/statements'
372
+ }
373
+ end
328
374
  end
329
375
  end
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.9
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - PAY.JP
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-17 00:00:00.000000000 Z
11
+ date: 2023-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -107,6 +107,7 @@ executables: []
107
107
  extensions: []
108
108
  extra_rdoc_files: []
109
109
  files:
110
+ - ".github/workflows/ruby-publish.yml"
110
111
  - ".github/workflows/test.yml"
111
112
  - ".gitignore"
112
113
  - ".rubocop.yml"
@@ -138,6 +139,7 @@ files:
138
139
  - lib/payjp/list_object.rb
139
140
  - lib/payjp/payjp_object.rb
140
141
  - lib/payjp/plan.rb
142
+ - lib/payjp/statement.rb
141
143
  - lib/payjp/subscription.rb
142
144
  - lib/payjp/tenant.rb
143
145
  - lib/payjp/token.rb
@@ -155,6 +157,7 @@ files:
155
157
  - test/payjp/metadata_test.rb
156
158
  - test/payjp/payjp_object_test.rb
157
159
  - test/payjp/plan_test.rb
160
+ - test/payjp/statement_test.rb
158
161
  - test/payjp/subscription_test.rb
159
162
  - test/payjp/tenant_test.rb
160
163
  - test/payjp/token_test.rb
@@ -197,6 +200,7 @@ test_files:
197
200
  - test/payjp/metadata_test.rb
198
201
  - test/payjp/payjp_object_test.rb
199
202
  - test/payjp/plan_test.rb
203
+ - test/payjp/statement_test.rb
200
204
  - test/payjp/subscription_test.rb
201
205
  - test/payjp/tenant_test.rb
202
206
  - test/payjp/token_test.rb