omise 0.10.1 → 0.11.0

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: 86f667adb02844ae4a28e2a27d5dc510f525bb6c5b7466e8498fddb09d3f793c
4
- data.tar.gz: cf02aa9699535883c6ff342fd93dcbb5bd4e39dbcd65d7737b50cf98748cf94a
3
+ metadata.gz: ff6023854587a10ee706952df91b1fbb5fb71a0ba31548735c1bd2f8400bf65e
4
+ data.tar.gz: 48e83f9d73465c8bb53545e86a0d6f0b32ee6162c143d72cc34cbaa2774bf120
5
5
  SHA512:
6
- metadata.gz: 36c8120f9b002f22c684bf6b7926209c31310d7fcb7a0a47b04a9988cf2f6f13a70e5d177fbd133ec923d619da770a812e7cce901dd60ceef36d670abdea1bad
7
- data.tar.gz: f0d8ff93d321ada34b1a848ebcebc39b313023ed77fbead69af9d0e67b42d4a3dba05e69788160e61593edc4e4f8ccc14e95c4fdefd13ef1db9c2d5aec6bd347
6
+ metadata.gz: f85290d51701920bb0e43cdc6c0a80f550bf6e2c579f8ed862b410ac00d24e3ad69c3a88ae79d7089cf704a8dc8734d6a8665578f79ce45ed85cc0c79b41d5d8
7
+ data.tar.gz: 352db370629f9fbe0221783c8ec64e278096d7e633919ebff92a2859fc359cdf022dacc22f813f0fb372ac66cf64aac2d4a8bc10dfdfed9c164432e83d661f50
@@ -0,0 +1,27 @@
1
+ name: Push Test Coverage to SonarCloud
2
+
3
+ on:
4
+ push:
5
+
6
+ jobs:
7
+ build:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v3
11
+ - uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: "3.2"
14
+ bundler-cache: true
15
+ - name: Build and test with Rake
16
+ run: |
17
+ gem install bundler
18
+ bundle install --jobs 4 --retry 3
19
+ bundle exec rake test
20
+ - run: |
21
+ rm -rf vendor
22
+ - name: Fix Code Coverage Paths
23
+ run: sed -i 's@'$GITHUB_WORKSPACE'@/github/workspace/@g' coverage/coverage.json
24
+ - name: SonarCloud Scan
25
+ uses: SonarSource/sonarcloud-github-action@master
26
+ env:
27
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  An [unreleased] version is not available on rubygems and is subject to changes and must not be considered final. Elements of unreleased list may be edited or removed at any time.
4
4
 
5
+ ## [0.11.0] 2023-10-03
6
+
7
+ - [Added] Support partial capture of charges (https://github.com/omise/omise-ruby/pull/55)
8
+
5
9
  ## [0.10.1] 2023-04-20
6
10
 
7
11
  - [Updated] Updated test case for ruby >= 3.0 (https://github.com/omise/omise-ruby/pull/48)
data/lib/omise/charge.rb CHANGED
@@ -37,7 +37,7 @@ module Omise
37
37
  end
38
38
 
39
39
  def capture(options = {})
40
- assign_attributes nested_resource("capture", options).post
40
+ assign_attributes nested_resource("capture", options).post(options)
41
41
  end
42
42
 
43
43
  def reverse(options = {})
data/lib/omise/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Omise
2
- VERSION = "0.10.1"
2
+ VERSION = "0.11.0"
3
3
  end
data/omise.gemspec CHANGED
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "rake"
25
25
  spec.add_development_dependency "pry"
26
26
  spec.add_development_dependency "minitest", ">= 5.4"
27
+ spec.add_development_dependency "simplecov"
27
28
  end
@@ -0,0 +1,3 @@
1
+ sonar.projectKey=omise_omise-ruby
2
+ sonar.organization=omise
3
+ sonar.exclusions=**/test/**
@@ -0,0 +1,99 @@
1
+ {
2
+ "object": "charge",
3
+ "id": "chrg_test_5x8glktwl62j63dr3me",
4
+ "location": "/charges/chrg_test_5x8glktwl62j63dr3me",
5
+ "amount": 100000,
6
+ "authorization_type": "pre_auth",
7
+ "authorized_amount": 100000,
8
+ "captured_amount": 3000,
9
+ "net": 2882,
10
+ "fee": 110,
11
+ "fee_vat": 8,
12
+ "interest": 0,
13
+ "interest_vat": 0,
14
+ "funding_amount": 3000,
15
+ "refunded_amount": 0,
16
+ "transaction_fees": {
17
+ "fee_flat": "0.0",
18
+ "fee_rate": "3.65",
19
+ "vat_rate": "7.0"
20
+ },
21
+ "platform_fee": {
22
+ "fixed": null,
23
+ "amount": null,
24
+ "percentage": null
25
+ },
26
+ "currency": "THB",
27
+ "funding_currency": "THB",
28
+ "ip": null,
29
+ "refunds": {
30
+ "object": "list",
31
+ "data": [],
32
+ "limit": 20,
33
+ "offset": 0,
34
+ "total": 0,
35
+ "location": "/charges/chrg_test_5x8glktwl62j63dr3me/refunds",
36
+ "order": "chronological",
37
+ "from": "1970-01-01T00:00:00Z",
38
+ "to": "2023-09-26T06:15:31Z"
39
+ },
40
+ "link": null,
41
+ "description": null,
42
+ "metadata": {},
43
+ "card": {
44
+ "object": "card",
45
+ "id": "card_test_5x17kjqylbrla8t3elw",
46
+ "livemode": false,
47
+ "location": "/customers/cust_test_5x17kjuemequnrjiy3y/cards/card_test_5x17kjqylbrla8t3elw",
48
+ "deleted": false,
49
+ "street1": null,
50
+ "street2": null,
51
+ "city": "Bangkok",
52
+ "state": null,
53
+ "phone_number": null,
54
+ "postal_code": "10320",
55
+ "country": "us",
56
+ "financing": "credit",
57
+ "bank": "JPMORGAN CHASE BANK N.A.",
58
+ "brand": "Visa",
59
+ "fingerprint": "ZmYHTfxzcB4xH5GTzXaPWRRpScr5nGNEDaPJ2XYJQfw=",
60
+ "first_digits": null,
61
+ "last_digits": "4242",
62
+ "name": "JOHN DOE",
63
+ "expiration_month": 2,
64
+ "expiration_year": 2024,
65
+ "security_code_check": true,
66
+ "tokenization_method": null,
67
+ "created_at": "2023-09-07T17:20:36Z"
68
+ },
69
+ "source": null,
70
+ "schedule": null,
71
+ "customer": "cust_test_5x17kjuemequnrjiy3y",
72
+ "dispute": null,
73
+ "transaction": "trxn_test_5x8gll1ic0gxf8y4wfd",
74
+ "failure_code": null,
75
+ "failure_message": null,
76
+ "status": "successful",
77
+ "authorize_uri": null,
78
+ "return_uri": null,
79
+ "created_at": "2023-09-26T06:15:17Z",
80
+ "paid_at": "2023-09-26T06:15:17Z",
81
+ "expires_at": "2023-10-03T06:15:16Z",
82
+ "expired_at": null,
83
+ "reversed_at": null,
84
+ "zero_interest_installments": false,
85
+ "branch": null,
86
+ "terminal": null,
87
+ "device": null,
88
+ "authorized": true,
89
+ "capturable": false,
90
+ "capture": false,
91
+ "disputable": true,
92
+ "livemode": false,
93
+ "refundable": true,
94
+ "reversed": false,
95
+ "reversible": false,
96
+ "voided": false,
97
+ "paid": true,
98
+ "expired": false
99
+ }
@@ -12,6 +12,15 @@ class TestCharge < Omise::Test
12
12
  assert_equal "chrg_test_4yq7duw15p9hdrjp8oq", charge.id
13
13
  end
14
14
 
15
+ def test_that_we_can_create_a_partial_charge
16
+ @partial_charge_create = Omise::Charge.new(JSON.load('{ "capture": false,"authorization_type":"pre_auth","captured_amount": 0 }'))
17
+
18
+ assert_instance_of Omise::Charge, @partial_charge_create
19
+ assert_equal false, @partial_charge_create['capture']
20
+ assert_equal "pre_auth", @partial_charge_create.authorization_type
21
+ assert_equal 0, @partial_charge_create.captured_amount
22
+ end
23
+
15
24
  def test_that_we_can_create_a_charge_even_if_api_key_is_nil
16
25
  without_keys do
17
26
  charge = Omise::Charge.create(key: "skey_test_4yq6tct0lblmed2yp5t")
@@ -44,6 +53,18 @@ class TestCharge < Omise::Test
44
53
  assert_instance_of Omise::RefundList, @charge.refunds
45
54
  end
46
55
 
56
+ def test_that_we_can_retrieve_a_partial_charge
57
+ @partialCharge = Omise::Charge.retrieve("chrg_test_5x8glktwl62j63dr3me")
58
+
59
+ assert_instance_of Omise::Charge, @partialCharge
60
+ assert_equal "chrg_test_5x8glktwl62j63dr3me", @partialCharge.id
61
+ assert_equal "pre_auth", @partialCharge.authorization_type
62
+ assert_equal 100000, @partialCharge.authorized_amount
63
+ assert_equal 3000, @partialCharge.captured_amount
64
+ assert_equal false, @partialCharge['capture']
65
+
66
+ end
67
+
47
68
  def test_that_we_can_list_all_charge
48
69
  charges = Omise::Charge.list
49
70
 
@@ -107,6 +128,10 @@ class TestCharge < Omise::Test
107
128
  assert @charge.capture
108
129
  end
109
130
 
131
+ def test_that_we_can_send_a_capture_request_with_parameters
132
+ assert @charge.capture({capture_amount:3000})
133
+ end
134
+
110
135
  def test_that_we_can_send_a_reverse_request
111
136
  assert @charge.reverse
112
137
  end
@@ -17,7 +17,7 @@ class TestHTTPLogger < Omise::Test
17
17
  end
18
18
 
19
19
  def setup
20
- @log_mock = MiniTest::Mock.new
20
+ @log_mock = Minitest::Mock.new
21
21
  end
22
22
 
23
23
  def test_we_can_log_an_http_request
data/test/support.rb CHANGED
@@ -1,3 +1,10 @@
1
+ require "simplecov"
2
+ require "simplecov_json_formatter"
3
+ SimpleCov.formatter = SimpleCov::Formatter::JSONFormatter
4
+ SimpleCov.start do
5
+ add_filter "test/"
6
+ end
7
+
1
8
  require "rubygems"
2
9
  require "bundler/setup"
3
10
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robin Clart
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-20 00:00:00.000000000 Z
11
+ date: 2023-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '5.4'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description:
98
112
  email:
99
113
  - robin@omise.co
@@ -101,6 +115,7 @@ executables: []
101
115
  extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
118
+ - ".github/workflows/code-coverage.yml"
104
119
  - ".github/workflows/publish.yml"
105
120
  - ".github/workflows/ruby.yml"
106
121
  - ".gitignore"
@@ -157,6 +172,7 @@ files:
157
172
  - lib/omise/vault.rb
158
173
  - lib/omise/version.rb
159
174
  - omise.gemspec
175
+ - sonar-project.properties
160
176
  - test/fixtures/api.omise.co/account-get.json
161
177
  - test/fixtures/api.omise.co/account-patch.json
162
178
  - test/fixtures/api.omise.co/balance-get.json
@@ -180,6 +196,7 @@ files:
180
196
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds/404-get.json
181
197
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds/rfnd_test_4yqmv79ahghsiz23y3c-get.json
182
198
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/reverse-post.json
199
+ - test/fixtures/api.omise.co/charges/chrg_test_5x8glktwl62j63dr3me-get.json
183
200
  - test/fixtures/api.omise.co/customers-get.json
184
201
  - test/fixtures/api.omise.co/customers-post.json
185
202
  - test/fixtures/api.omise.co/customers/404-get.json
@@ -317,6 +334,7 @@ test_files:
317
334
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds/404-get.json
318
335
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds/rfnd_test_4yqmv79ahghsiz23y3c-get.json
319
336
  - test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/reverse-post.json
337
+ - test/fixtures/api.omise.co/charges/chrg_test_5x8glktwl62j63dr3me-get.json
320
338
  - test/fixtures/api.omise.co/customers-get.json
321
339
  - test/fixtures/api.omise.co/customers-post.json
322
340
  - test/fixtures/api.omise.co/customers/404-get.json