omise 0.9.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +9 -6
- data/.gitignore +1 -0
- data/CHANGELOG.md +19 -1
- data/README.md +25 -43
- data/lib/omise/account.rb +12 -1
- data/lib/omise/all.rb +1 -0
- data/lib/omise/charge.rb +8 -0
- data/lib/omise/dispute.rb +4 -0
- data/lib/omise/link.rb +4 -0
- data/lib/omise/receipt.rb +20 -0
- data/lib/omise/scheduler.rb +1 -1
- data/lib/omise/version.rb +1 -1
- data/test/fixtures/api.omise.co/account-get.json +2 -0
- data/test/fixtures/api.omise.co/account-patch.json +8 -0
- data/test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/events-get.json +28 -0
- data/test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/expire-post.json +51 -0
- data/test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/accept-patch.json +12 -0
- data/test/fixtures/api.omise.co/links/link_test_55pcclmznvrv9lc7r9s-delete.json +6 -0
- data/test/fixtures/api.omise.co/receipts-get.json +90 -0
- data/test/fixtures/api.omise.co/receipts/rcpt_5ls0b8zb53qmw3mlvfz-get.json +39 -0
- data/test/omise/test_account.rb +7 -1
- data/test/omise/test_charge.rb +11 -0
- data/test/omise/test_dispute.rb +18 -0
- data/test/omise/test_link.rb +7 -0
- data/test/omise/test_receipt.rb +29 -0
- data/test/omise/test_scheduler.rb +13 -0
- metadata +23 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ba27e7fa52e39678ea8eeea60526fd163e071cdf2fb45177476ba023fc7c64c
|
4
|
+
data.tar.gz: 7e7f22f38b1a716034c27d9f8ded31b3b8a7e97e83056a07d8aef3909819d128
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 738cafc6e546810c4ae8b3de8e2ea788a39de04c5eb4048b9cc90aa72e53cfac1177190c453af097a2e17824e7cf22acca9d0eafb093e5bed12c27554fc0eb74
|
7
|
+
data.tar.gz: 6ec041635455df84aa2063c462c41a5abb4ff23b56565214fb7e84e12702473a1ff4e1372e12feca376078d4a049cdb8bb4973e06494bc00ad7a18c677f55dcc
|
data/.github/workflows/ruby.yml
CHANGED
@@ -1,24 +1,27 @@
|
|
1
1
|
name: Ruby
|
2
2
|
|
3
|
-
on:
|
4
|
-
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ 'master' ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ 'master' ]
|
8
|
+
|
5
9
|
jobs:
|
6
10
|
build:
|
7
11
|
runs-on: ubuntu-latest
|
8
12
|
strategy:
|
9
13
|
matrix:
|
10
|
-
ruby: [ '2.
|
14
|
+
ruby: [ '2.5', '2.6', '2.7', '3.0' ]
|
11
15
|
name: Ruby ${{ matrix.ruby }}
|
12
16
|
steps:
|
13
|
-
- uses: actions/checkout@
|
17
|
+
- uses: actions/checkout@v2
|
14
18
|
- name: Setup ruby
|
15
19
|
uses: actions/setup-ruby@v1
|
16
20
|
with:
|
17
21
|
ruby-version: ${{ matrix.ruby }}
|
18
|
-
architecture: 'x64'
|
19
22
|
|
20
23
|
- name: Build and test with Rake
|
21
24
|
run: |
|
22
25
|
gem install bundler
|
23
26
|
bundle install --jobs 4 --retry 3
|
24
|
-
bundle exec rake test
|
27
|
+
bundle exec rake test
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,24 @@
|
|
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.10.0] 2021-02-16
|
6
|
+
|
7
|
+
- [Added] Add a new method to fetch all events belonging to a charge (https://github.com/omise/omise-ruby/pull/45)
|
8
|
+
- [Added] Add Receipt API (https://github.com/omise/omise-ruby/pull/44)
|
9
|
+
- [Added] Allow shortened form of ordinal numbers on Scheduler (https://github.com/omise/omise-ruby/pull/43)
|
10
|
+
- [Added] Add update method for Account (https://github.com/omise/omise-ruby/pull/42)
|
11
|
+
- [Added] Add accept method for Dispute (https://github.com/omise/omise-ruby/pull/41)
|
12
|
+
- [Added] Add expire method for Charge (https://github.com/omise/omise-ruby/pull/40)
|
13
|
+
- [Added] Add destroy method for Link (https://github.com/omise/omise-ruby/pull/39)
|
14
|
+
|
15
|
+
## [0.9.1] 2019-11-15
|
16
|
+
|
17
|
+
- [Fixed] Tests
|
18
|
+
|
19
|
+
## [0.9.0] 2019-11-15
|
20
|
+
|
21
|
+
- [Added] Integrations support
|
22
|
+
|
5
23
|
## [0.8.0] 2019-11-04
|
6
24
|
|
7
25
|
- [Added] Capability object
|
@@ -73,7 +91,7 @@ An [unreleased] version is not available on rubygems and is subject to changes a
|
|
73
91
|
## [0.1.0] 2015-01-19
|
74
92
|
|
75
93
|
- [Added] Add support for the Refund API.
|
76
|
-
- [Added] Add a test suite that can be run locally without the need for a
|
94
|
+
- [Added] Add a test suite that can be run locally without the need for a
|
77
95
|
network connection or to set Omise keys.
|
78
96
|
- [Added] Add a list method to retrieve a list of objects.
|
79
97
|
- [Changed] Move typecast and load_response methods into a Util module.
|
data/README.md
CHANGED
@@ -3,17 +3,16 @@
|
|
3
3
|
[![Maintainability](https://api.codeclimate.com/v1/badges/8297834e28572da75cf2/maintainability)](https://codeclimate.com/github/omise/omise-ruby/maintainability)
|
4
4
|
<img alt="GitHub Actions status" src="https://github.com/omise/omise-ruby/workflows/Ruby/badge.svg">
|
5
5
|
[![Gem](https://img.shields.io/gem/v/omise.svg?style=flat)](https://rubygems.org/gems/omise)
|
6
|
-
[![Join the chat at https://gitter.im/omise/omise-ruby](https://badges.gitter.im/omise/omise-ruby.svg)](https://gitter.im/omise/omise-ruby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
7
6
|
|
8
7
|
## Installation
|
9
8
|
|
10
|
-
|
9
|
+
Add the following to your `Gemfile` and run `bundle install` to install via [RubyGems](https://rubygems.org/gems/omise):
|
11
10
|
|
12
11
|
```ruby
|
13
12
|
gem 'omise'
|
14
13
|
```
|
15
14
|
|
16
|
-
Or use the cutting-edge version by installing via
|
15
|
+
Or use the cutting-edge version by installing via GitHub:
|
17
16
|
|
18
17
|
```ruby
|
19
18
|
gem 'omise', github: 'omise/omise-ruby'
|
@@ -21,28 +20,38 @@ gem 'omise', github: 'omise/omise-ruby'
|
|
21
20
|
|
22
21
|
## Requirements
|
23
22
|
|
24
|
-
|
23
|
+
Tested on Ruby 2.5 and above
|
25
24
|
|
26
25
|
## Configuration
|
27
26
|
|
28
27
|
First configure your secret key:
|
29
28
|
|
30
29
|
```ruby
|
30
|
+
require "omise"
|
31
|
+
|
31
32
|
Omise.api_key = "skey_test_xxxxxxxxxxxxxxxxxxx"
|
32
33
|
```
|
33
34
|
|
34
|
-
|
35
|
+
After you have implemented [Omise.js](https://www.omise.co/omise-js) on your frontend you can charge the card by passing the token generated by Omise.js into the `card` attribute.
|
35
36
|
|
36
37
|
```ruby
|
37
|
-
|
38
|
-
|
38
|
+
# Charge 1000.00 THB
|
39
|
+
charge = Omise::Charge.create({
|
40
|
+
amount: 1_000_00,
|
41
|
+
currency: "thb",
|
42
|
+
card: params[:omise_token]
|
43
|
+
})
|
39
44
|
|
40
|
-
|
45
|
+
if charge.paid
|
46
|
+
# handle success
|
47
|
+
puts "thanks"
|
48
|
+
else
|
49
|
+
# handle failure
|
50
|
+
raise charge.failure_code
|
51
|
+
end
|
52
|
+
```
|
41
53
|
|
42
|
-
|
43
|
-
[collect cards](https://www.omise.co/collecting-card-information). When creating a token server side you'll need card data
|
44
|
-
transiting to and from your server and this requires that your organization be
|
45
|
-
PCI compliant.
|
54
|
+
You can check the complete documentation at [omise.co/docs](https://omise.co/docs).
|
46
55
|
|
47
56
|
### API version
|
48
57
|
|
@@ -53,18 +62,16 @@ environments with different API versions (e.g. development on the latest but
|
|
53
62
|
production on the older version).
|
54
63
|
|
55
64
|
```ruby
|
56
|
-
|
57
|
-
Omise.api_version = "2014-07-27"
|
65
|
+
Omise.api_version = "2019-05-29"
|
58
66
|
```
|
59
67
|
|
60
|
-
It is highly recommended to set this version to the current version
|
61
|
-
you're using.
|
68
|
+
It is highly recommended to set this version to the current version you're using.
|
62
69
|
|
63
70
|
### Logging
|
64
71
|
|
65
|
-
To enable
|
72
|
+
To enable logging you can set `Omise.logger` with a Ruby logger. All HTTP requests and responses will be logged.
|
66
73
|
|
67
|
-
To disable
|
74
|
+
To disable logging, just configure `Omise.logger` to `nil`. Default is disabled.
|
68
75
|
|
69
76
|
An example configuring Rails logger:
|
70
77
|
|
@@ -72,31 +79,6 @@ An example configuring Rails logger:
|
|
72
79
|
Omise.logger = Rails.logger
|
73
80
|
```
|
74
81
|
|
75
|
-
## Quick Start
|
76
|
-
|
77
|
-
After you have implemented [Omise.js](https://www.omise.co/omise-js-api) on your
|
78
|
-
frontend you can charge the card by passing the token into the `card` attribute.
|
79
|
-
|
80
|
-
```ruby
|
81
|
-
# Charge 1000.00 THB
|
82
|
-
charge = Omise::Charge.create({
|
83
|
-
amount: 1_000_00,
|
84
|
-
currency: "thb",
|
85
|
-
card: params[:omise_token]
|
86
|
-
})
|
87
|
-
|
88
|
-
if charge.paid
|
89
|
-
# handle success
|
90
|
-
puts "thanks"
|
91
|
-
else
|
92
|
-
# handle failure
|
93
|
-
raise charge.failure_code
|
94
|
-
end
|
95
|
-
```
|
96
|
-
|
97
|
-
You can check the complete documentation at
|
98
|
-
[omise.co/docs](https://omise.co/docs).
|
99
|
-
|
100
82
|
## Development
|
101
83
|
|
102
84
|
The test suite can be run with `bundle exec rake test`.
|
data/lib/omise/account.rb
CHANGED
@@ -3,6 +3,17 @@ require "omise/object"
|
|
3
3
|
module Omise
|
4
4
|
class Account < OmiseObject
|
5
5
|
self.endpoint = "/account"
|
6
|
-
|
6
|
+
|
7
|
+
def self.retrieve(attributes = {})
|
8
|
+
new resource(location, attributes).get(attributes)
|
9
|
+
end
|
10
|
+
|
11
|
+
def reload(attributes = {})
|
12
|
+
assign_attributes resource(attributes).get(attributes)
|
13
|
+
end
|
14
|
+
|
15
|
+
def update(attributes = {})
|
16
|
+
assign_attributes resource(attributes).patch(attributes)
|
17
|
+
end
|
7
18
|
end
|
8
19
|
end
|
data/lib/omise/all.rb
CHANGED
data/lib/omise/charge.rb
CHANGED
@@ -44,6 +44,10 @@ module Omise
|
|
44
44
|
assign_attributes nested_resource("reverse", options).post
|
45
45
|
end
|
46
46
|
|
47
|
+
def expire(options = {})
|
48
|
+
assign_attributes nested_resource("expire", options).post
|
49
|
+
end
|
50
|
+
|
47
51
|
def customer(options = {})
|
48
52
|
if !defined?(Customer)
|
49
53
|
require "omise/customer"
|
@@ -68,6 +72,10 @@ module Omise
|
|
68
72
|
expand_attribute Transaction, "transaction", options
|
69
73
|
end
|
70
74
|
|
75
|
+
def events(attributes = {})
|
76
|
+
List.new nested_resource("events", attributes).get(attributes)
|
77
|
+
end
|
78
|
+
|
71
79
|
def refunds
|
72
80
|
list_attribute RefundList, "refunds"
|
73
81
|
end
|
data/lib/omise/dispute.rb
CHANGED
@@ -28,6 +28,10 @@ module Omise
|
|
28
28
|
assign_attributes resource(attributes).patch(attributes)
|
29
29
|
end
|
30
30
|
|
31
|
+
def accept(attributes = {})
|
32
|
+
assign_attributes nested_resource("accept", attributes).patch(attributes)
|
33
|
+
end
|
34
|
+
|
31
35
|
def charge(options = {})
|
32
36
|
if !defined?(Charge)
|
33
37
|
require "omise/charge"
|
data/lib/omise/link.rb
CHANGED
@@ -27,6 +27,10 @@ module Omise
|
|
27
27
|
assign_attributes resource(attributes).get(attributes)
|
28
28
|
end
|
29
29
|
|
30
|
+
def destroy(attributes = {})
|
31
|
+
assign_attributes resource(attributes).delete
|
32
|
+
end
|
33
|
+
|
30
34
|
def charges(options = {})
|
31
35
|
if options.empty?
|
32
36
|
list_attribute ChargeList, "charges"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "omise/object"
|
2
|
+
require "omise/list"
|
3
|
+
|
4
|
+
module Omise
|
5
|
+
class Receipt < OmiseObject
|
6
|
+
self.endpoint = "/receipts"
|
7
|
+
|
8
|
+
def self.retrieve(id, attributes = {})
|
9
|
+
new resource(location(id), attributes).get(attributes)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.list(attributes = {})
|
13
|
+
List.new resource(location, attributes).get(attributes)
|
14
|
+
end
|
15
|
+
|
16
|
+
def reload(attributes = {})
|
17
|
+
assign_attributes resource(attributes).get(attributes)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/omise/scheduler.rb
CHANGED
@@ -5,7 +5,7 @@ require "omise/schedule"
|
|
5
5
|
module Omise
|
6
6
|
class Scheduler
|
7
7
|
WEEKDAYS = Date::DAYNAMES.map(&:downcase).freeze
|
8
|
-
MONTH_WEEKDAYS = %w[first second third fourth last]
|
8
|
+
MONTH_WEEKDAYS = %w[first 1st second 2nd third 3rd fourth 4th last]
|
9
9
|
.product(WEEKDAYS)
|
10
10
|
.map { |d| d.join("_") }
|
11
11
|
.freeze
|
data/lib/omise/version.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
{
|
2
|
+
"object": "list",
|
3
|
+
"data": [
|
4
|
+
{
|
5
|
+
"object": "event",
|
6
|
+
"id": "evnt_test_5moztki4ickw5gxwsrh",
|
7
|
+
"livemode": false,
|
8
|
+
"location": "/events/evnt_test_5moztki4ickw5gxwsrh",
|
9
|
+
"key": "charge.update",
|
10
|
+
"created_at": "2021-01-29T02:05:20Z"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"object": "event",
|
14
|
+
"id": "evnt_test_5mozta5zc6wdx4genou",
|
15
|
+
"livemode": false,
|
16
|
+
"location": "/events/evnt_test_5mozta5zc6wdx4genou",
|
17
|
+
"key": "charge.create",
|
18
|
+
"created_at": "2021-01-29T02:04:31Z"
|
19
|
+
}
|
20
|
+
],
|
21
|
+
"limit": 20,
|
22
|
+
"offset": 0,
|
23
|
+
"total": 2,
|
24
|
+
"location": "/charges/chrg_test_4yq7duw15p9hdrjp8oq/events",
|
25
|
+
"order": "chronological",
|
26
|
+
"from": "1970-01-01T00:00:00Z",
|
27
|
+
"to": "2021-02-07T10:04:29Z"
|
28
|
+
}
|
@@ -0,0 +1,51 @@
|
|
1
|
+
{
|
2
|
+
"object": "charge",
|
3
|
+
"id": "chrg_test_4yq7duw15p9hdrjp8oq",
|
4
|
+
"livemode": false,
|
5
|
+
"location": "/charges/chrg_test_4yq7duw15p9hdrjp8oq",
|
6
|
+
"amount": 100000,
|
7
|
+
"currency": "thb",
|
8
|
+
"description": "Charge for order 3947",
|
9
|
+
"capture": true,
|
10
|
+
"authorized": false,
|
11
|
+
"reversed": false,
|
12
|
+
"captured": false,
|
13
|
+
"expired": true,
|
14
|
+
"transaction": "trxn_test_4yq7duwb9jts1vxgqua",
|
15
|
+
"refunded": 0,
|
16
|
+
"refunds": {
|
17
|
+
"object": "list",
|
18
|
+
"from": "1970-01-01T00:00:00+00:00",
|
19
|
+
"to": "2015-01-16T07:23:49+00:00",
|
20
|
+
"offset": 0,
|
21
|
+
"limit": 20,
|
22
|
+
"total": 1,
|
23
|
+
"data": [
|
24
|
+
|
25
|
+
],
|
26
|
+
"location": "/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds"
|
27
|
+
},
|
28
|
+
"failure_code": null,
|
29
|
+
"failure_message": null,
|
30
|
+
"card": {
|
31
|
+
"object": "card",
|
32
|
+
"id": "card_test_4yq6tuucl9h4erukfl0",
|
33
|
+
"livemode": false,
|
34
|
+
"location": "/customers/cust_test_4yq6txdpfadhbaqnwp3/cards/card_test_4yq6tuucl9h4erukfl0",
|
35
|
+
"country": "",
|
36
|
+
"city": "Bangkok",
|
37
|
+
"postal_code": "10320",
|
38
|
+
"financing": "",
|
39
|
+
"last_digits": "4242",
|
40
|
+
"brand": "Visa",
|
41
|
+
"expiration_month": 1,
|
42
|
+
"expiration_year": 2017,
|
43
|
+
"fingerprint": "sRF/oMw2UQJJp/WbU+2/ZbVzwROjpMf1lyhOHhOqziw=",
|
44
|
+
"name": "JOHN DOE",
|
45
|
+
"security_code_check": true,
|
46
|
+
"created": "2015-01-15T04:03:40Z"
|
47
|
+
},
|
48
|
+
"customer": "cust_test_4yq6txdpfadhbaqnwp3",
|
49
|
+
"ip": null,
|
50
|
+
"created": "2015-01-15T05:00:29Z"
|
51
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
{
|
2
|
+
"object": "dispute",
|
3
|
+
"id": "dspt_test_5089off452g5m5te7xs",
|
4
|
+
"livemode": false,
|
5
|
+
"location": "/disputes/dspt_test_5089off452g5m5te7xs",
|
6
|
+
"amount": 100000,
|
7
|
+
"currency": "thb",
|
8
|
+
"status": "lost",
|
9
|
+
"message": null,
|
10
|
+
"charge": "chrg_test_5089odjlzg9j7tw4i1q",
|
11
|
+
"created": "2015-06-02T10:22:32Z"
|
12
|
+
}
|
@@ -0,0 +1,90 @@
|
|
1
|
+
{
|
2
|
+
"object": "receipt_list",
|
3
|
+
"data": [
|
4
|
+
{
|
5
|
+
"object": "receipt",
|
6
|
+
"id": "rcpt_5lrm8qjcaj5vpu2790m",
|
7
|
+
"livemode": true,
|
8
|
+
"location": "/receipts/rcpt_5lrm8qjcaj5vpu2790m",
|
9
|
+
"credit_note": false,
|
10
|
+
"charge_fee": 7,
|
11
|
+
"subtotal": 7,
|
12
|
+
"transfer_fee": 0,
|
13
|
+
"voided_fee": 0,
|
14
|
+
"vat": 0,
|
15
|
+
"wht": 0,
|
16
|
+
"total": 7,
|
17
|
+
"company_address": "123 The Road, Thailand",
|
18
|
+
"company_name": "Omise",
|
19
|
+
"company_tax_id": "0123456789012",
|
20
|
+
"currency": "THB",
|
21
|
+
"customer_address": "456 The Street, Singapore",
|
22
|
+
"customer_email": "john.doe@omise.co",
|
23
|
+
"customer_name": "John Doe",
|
24
|
+
"customer_statement_name": "John Doe",
|
25
|
+
"customer_tax_id": "10000",
|
26
|
+
"number": "OMTH202011050018",
|
27
|
+
"created_at": "2020-11-05T18:02:05Z",
|
28
|
+
"issued_on": "2020-11-05",
|
29
|
+
"adjustment_transaction": {
|
30
|
+
"object": "transaction",
|
31
|
+
"id": "trxn_5lrm8qjiaye00x5dv4r",
|
32
|
+
"livemode": true,
|
33
|
+
"currency": "THB",
|
34
|
+
"amount": 0,
|
35
|
+
"location": "/transactions/trxn_5lrm8qjiaye00x5dv4r",
|
36
|
+
"direction": "credit",
|
37
|
+
"key": "receipt.vat_adjustment.credit",
|
38
|
+
"origin": "rcpt_5lrm8qjcaj5vpu2790m",
|
39
|
+
"transferable_at": "2020-11-05T18:02:05Z",
|
40
|
+
"created_at": "2020-11-05T18:02:05Z"
|
41
|
+
}
|
42
|
+
},
|
43
|
+
{
|
44
|
+
"object": "receipt",
|
45
|
+
"id": "rcpt_5ls0b8zb53qmw3mlvfz",
|
46
|
+
"livemode": true,
|
47
|
+
"location": "/receipts/rcpt_5ls0b8zb53qmw3mlvfz",
|
48
|
+
"credit_note": false,
|
49
|
+
"charge_fee": 7,
|
50
|
+
"subtotal": 7,
|
51
|
+
"transfer_fee": 0,
|
52
|
+
"voided_fee": 0,
|
53
|
+
"vat": 0,
|
54
|
+
"wht": 0,
|
55
|
+
"total": 7,
|
56
|
+
"company_address": "123 The Road, Thailand",
|
57
|
+
"company_name": "Omise",
|
58
|
+
"company_tax_id": "0123456789012",
|
59
|
+
"currency": "THB",
|
60
|
+
"customer_address": "456 The Street, Singapore",
|
61
|
+
"customer_email": "john.doe@omise.co",
|
62
|
+
"customer_name": "John Doe",
|
63
|
+
"customer_statement_name": "John Doe",
|
64
|
+
"customer_tax_id": "10000",
|
65
|
+
"number": "OMTH202011050019",
|
66
|
+
"created_at": "2020-11-05T18:02:05Z",
|
67
|
+
"issued_on": "2020-11-05",
|
68
|
+
"adjustment_transaction": {
|
69
|
+
"object": "transaction",
|
70
|
+
"id": "trxn_5ls0b8zftdzm5vw90d6",
|
71
|
+
"livemode": true,
|
72
|
+
"currency": "THB",
|
73
|
+
"amount": 0,
|
74
|
+
"location": "/transactions/trxn_5ls0b8zftdzm5vw90d6",
|
75
|
+
"direction": "credit",
|
76
|
+
"key": "receipt.vat_adjustment.credit",
|
77
|
+
"origin": "rcpt_5ls0b8zb53qmw3mlvfz",
|
78
|
+
"transferable_at": "2020-11-05T18:02:05Z",
|
79
|
+
"created_at": "2020-11-05T18:02:05Z"
|
80
|
+
}
|
81
|
+
}
|
82
|
+
],
|
83
|
+
"limit": 20,
|
84
|
+
"offset": 0,
|
85
|
+
"total": 2,
|
86
|
+
"location": "/receipts",
|
87
|
+
"order": "chronological",
|
88
|
+
"from": "1970-01-01T00:00:00Z",
|
89
|
+
"to": "2021-02-07T23:59:59Z"
|
90
|
+
}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"object": "receipt",
|
3
|
+
"id": "rcpt_5ls0b8zb53qmw3mlvfz",
|
4
|
+
"livemode": true,
|
5
|
+
"location": "/receipts/rcpt_5ls0b8zb53qmw3mlvfz",
|
6
|
+
"credit_note": false,
|
7
|
+
"charge_fee": 7,
|
8
|
+
"subtotal": 7,
|
9
|
+
"transfer_fee": 0,
|
10
|
+
"voided_fee": 0,
|
11
|
+
"vat": 0,
|
12
|
+
"wht": 0,
|
13
|
+
"total": 7,
|
14
|
+
"company_address": "123 The Road, Thailand",
|
15
|
+
"company_name": "Omise",
|
16
|
+
"company_tax_id": "0123456789012",
|
17
|
+
"currency": "THB",
|
18
|
+
"customer_address": "456 The Street, Singapore",
|
19
|
+
"customer_email": "john.doe@omise.co",
|
20
|
+
"customer_name": "John Doe",
|
21
|
+
"customer_statement_name": "John Doe",
|
22
|
+
"customer_tax_id": "10000",
|
23
|
+
"number": "OMTH202011050019",
|
24
|
+
"created_at": "2020-11-05T18:02:05Z",
|
25
|
+
"issued_on": "2020-11-05",
|
26
|
+
"adjustment_transaction": {
|
27
|
+
"object": "transaction",
|
28
|
+
"id": "trxn_5ls0b8zftdzm5vw90d6",
|
29
|
+
"livemode": true,
|
30
|
+
"currency": "THB",
|
31
|
+
"amount": 0,
|
32
|
+
"location": "/transactions/trxn_5ls0b8zftdzm5vw90d6",
|
33
|
+
"direction": "credit",
|
34
|
+
"key": "receipt.vat_adjustment.credit",
|
35
|
+
"origin": "rcpt_5ls0b8zb53qmw3mlvfz",
|
36
|
+
"transferable_at": "2020-11-05T18:02:05Z",
|
37
|
+
"created_at": "2020-11-05T18:02:05Z"
|
38
|
+
}
|
39
|
+
}
|
data/test/omise/test_account.rb
CHANGED
@@ -10,10 +10,16 @@ class TestAccount < Omise::Test
|
|
10
10
|
assert_equal "/account", @account.location
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
13
|
+
def test_that_we_can_reload_the_account
|
14
14
|
@account.attributes.taint
|
15
15
|
@account.reload
|
16
16
|
|
17
17
|
refute @account.attributes.tainted?
|
18
18
|
end
|
19
|
+
|
20
|
+
def test_that_we_can_update_the_account
|
21
|
+
@account.update(zero_interest_installments: true)
|
22
|
+
|
23
|
+
assert @account.zero_interest_installments
|
24
|
+
end
|
19
25
|
end
|
data/test/omise/test_charge.rb
CHANGED
@@ -111,6 +111,10 @@ class TestCharge < Omise::Test
|
|
111
111
|
assert @charge.reverse
|
112
112
|
end
|
113
113
|
|
114
|
+
def test_that_we_can_set_a_charge_to_expire
|
115
|
+
assert @charge.expire
|
116
|
+
end
|
117
|
+
|
114
118
|
def test_that_search_returns_a_scoped_search
|
115
119
|
assert_instance_of Omise::SearchScope, Omise::Charge.search
|
116
120
|
assert_equal "charge", Omise::Charge.search.scope
|
@@ -120,4 +124,11 @@ class TestCharge < Omise::Test
|
|
120
124
|
assert_instance_of Omise::Scheduler, Omise::Charge.schedule
|
121
125
|
assert_equal "charge", Omise::Charge.schedule.type
|
122
126
|
end
|
127
|
+
|
128
|
+
def test_that_we_can_fetch_an_event_list_for_a_given_charge
|
129
|
+
events = @charge.events
|
130
|
+
|
131
|
+
assert events
|
132
|
+
assert_instance_of Omise::List, events
|
133
|
+
end
|
123
134
|
end
|
data/test/omise/test_dispute.rb
CHANGED
@@ -34,12 +34,30 @@ class TestDispute < Omise::Test
|
|
34
34
|
assert_equal "dspt_test_5089off452g5m5te7xs", @dispute.id
|
35
35
|
end
|
36
36
|
|
37
|
+
def test_that_we_can_reload_a_dispute
|
38
|
+
@dispute.attributes.taint
|
39
|
+
@dispute.reload
|
40
|
+
|
41
|
+
refute @dispute.attributes.tainted?
|
42
|
+
end
|
43
|
+
|
37
44
|
def test_that_we_can_update_a_dispute
|
38
45
|
@dispute.update(message: "Your dispute message")
|
39
46
|
|
40
47
|
assert_equal @dispute.message, "Your dispute message"
|
41
48
|
end
|
42
49
|
|
50
|
+
def test_that_we_can_accept_a_dispute
|
51
|
+
@dispute.attributes.taint
|
52
|
+
|
53
|
+
assert_equal @dispute.status, "open"
|
54
|
+
|
55
|
+
@dispute.accept
|
56
|
+
|
57
|
+
assert_equal @dispute.status, "lost"
|
58
|
+
refute @dispute.attributes.tainted?
|
59
|
+
end
|
60
|
+
|
43
61
|
def test_that_we_can_retrieve_a_list_of_documents
|
44
62
|
assert_instance_of Omise::DocumentList, @dispute.documents
|
45
63
|
end
|
data/test/omise/test_link.rb
CHANGED
@@ -17,6 +17,13 @@ class TestLink < Omise::Test
|
|
17
17
|
assert_equal "link_test_55pcclmznvrv9lc7r9s", @link.id
|
18
18
|
end
|
19
19
|
|
20
|
+
def test_that_we_can_destroy_a_link
|
21
|
+
@link.destroy
|
22
|
+
|
23
|
+
assert @link.deleted
|
24
|
+
assert @link.destroyed?
|
25
|
+
end
|
26
|
+
|
20
27
|
def test_that_we_can_list_all_links
|
21
28
|
links = Omise::Link.list
|
22
29
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "support"
|
2
|
+
|
3
|
+
class TestReceipt < Omise::Test
|
4
|
+
setup do
|
5
|
+
@receipt = Omise::Receipt.retrieve("rcpt_5ls0b8zb53qmw3mlvfz")
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_that_we_can_list_all_receipts
|
9
|
+
receipts = Omise::Receipt.list
|
10
|
+
|
11
|
+
assert receipts
|
12
|
+
assert_instance_of Omise::List, receipts
|
13
|
+
assert_instance_of Omise::Receipt, receipts.first
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_that_we_can_retrieve_a_receipt
|
17
|
+
receipt = Omise::Receipt.retrieve("rcpt_5ls0b8zb53qmw3mlvfz")
|
18
|
+
|
19
|
+
assert receipt
|
20
|
+
assert_instance_of Omise::Receipt, receipt
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_that_we_can_reload_a_receipt
|
24
|
+
@receipt.attributes.taint
|
25
|
+
@receipt.reload
|
26
|
+
|
27
|
+
refute @receipt.attributes.tainted?
|
28
|
+
end
|
29
|
+
end
|
@@ -87,6 +87,16 @@ class TestScheduler < Omise::Test
|
|
87
87
|
assert_equal "first_monday", scheduler.to_attributes[:on][:weekday_of_month]
|
88
88
|
end
|
89
89
|
|
90
|
+
def test_we_can_set_month_with_weekday_in_other_formats
|
91
|
+
scheduler = @scheduler.every(1).month(on: "1st_monday")
|
92
|
+
|
93
|
+
assert_scheduler_attributes(@scheduler)
|
94
|
+
refute_equal scheduler.object_id, @scheduler.object_id
|
95
|
+
assert_equal 1, scheduler.to_attributes[:every]
|
96
|
+
assert_equal "month", scheduler.to_attributes[:period]
|
97
|
+
assert_equal "1st_monday", scheduler.to_attributes[:on][:weekday_of_month]
|
98
|
+
end
|
99
|
+
|
90
100
|
def test_we_can_set_months_with_weekday
|
91
101
|
scheduler = @scheduler.every(3).months(on: "last_friday")
|
92
102
|
|
@@ -155,6 +165,9 @@ class TestScheduler < Omise::Test
|
|
155
165
|
scheduler = @scheduler.parse("every month on the third Thursday until January 1st 2020")
|
156
166
|
assert_scheduler_attributes(scheduler, 1, "month", "2020-01-01", weekday_of_month: "third_thursday")
|
157
167
|
|
168
|
+
scheduler = @scheduler.parse("every month on the 2nd Monday until January 1st 2020")
|
169
|
+
assert_scheduler_attributes(scheduler, 1, "month", "2020-01-01", weekday_of_month: "2nd_monday")
|
170
|
+
|
158
171
|
scheduler = @scheduler.parse("every 3 months on 1, 2 and 3 until January 1st 2020")
|
159
172
|
assert_scheduler_attributes(scheduler, 3, "month", "2020-01-01", days_of_month: [1, 2, 3])
|
160
173
|
end
|
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.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robin Clart
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '5.4'
|
97
|
-
description:
|
97
|
+
description:
|
98
98
|
email:
|
99
99
|
- robin@omise.co
|
100
100
|
executables: []
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- lib/omise/object.rb
|
138
138
|
- lib/omise/occurrence.rb
|
139
139
|
- lib/omise/occurrence_list.rb
|
140
|
+
- lib/omise/receipt.rb
|
140
141
|
- lib/omise/recipient.rb
|
141
142
|
- lib/omise/refund.rb
|
142
143
|
- lib/omise/refund_list.rb
|
@@ -156,6 +157,7 @@ files:
|
|
156
157
|
- lib/omise/version.rb
|
157
158
|
- omise.gemspec
|
158
159
|
- test/fixtures/api.omise.co/account-get.json
|
160
|
+
- test/fixtures/api.omise.co/account-patch.json
|
159
161
|
- test/fixtures/api.omise.co/balance-get.json
|
160
162
|
- test/fixtures/api.omise.co/capability-get.json
|
161
163
|
- test/fixtures/api.omise.co/chains-get.json
|
@@ -170,6 +172,8 @@ files:
|
|
170
172
|
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq-get.json
|
171
173
|
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq-patch.json
|
172
174
|
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/capture-post.json
|
175
|
+
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/events-get.json
|
176
|
+
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/expire-post.json
|
173
177
|
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds-get.json
|
174
178
|
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds-post.json
|
175
179
|
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds/404-get.json
|
@@ -191,6 +195,7 @@ files:
|
|
191
195
|
- test/fixtures/api.omise.co/disputes/closed-get.json
|
192
196
|
- test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs-get.json
|
193
197
|
- test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs-patch.json
|
198
|
+
- test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/accept-patch.json
|
194
199
|
- test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/documents-get.json
|
195
200
|
- test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/documents-post.json
|
196
201
|
- test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/documents/docu_test_55869onwfm2g3bsw8d8-delete.json
|
@@ -203,8 +208,11 @@ files:
|
|
203
208
|
- test/fixtures/api.omise.co/integrations/integration_test_5h24qlv37qyx537p1ub-get.json
|
204
209
|
- test/fixtures/api.omise.co/links-get.json
|
205
210
|
- test/fixtures/api.omise.co/links-post.json
|
211
|
+
- test/fixtures/api.omise.co/links/link_test_55pcclmznvrv9lc7r9s-delete.json
|
206
212
|
- test/fixtures/api.omise.co/links/link_test_55pcclmznvrv9lc7r9s-get.json
|
207
213
|
- test/fixtures/api.omise.co/occurrences/occu_test_57s33hmja9t3fs4wmop-get.json
|
214
|
+
- test/fixtures/api.omise.co/receipts-get.json
|
215
|
+
- test/fixtures/api.omise.co/receipts/rcpt_5ls0b8zb53qmw3mlvfz-get.json
|
208
216
|
- test/fixtures/api.omise.co/recipients-get.json
|
209
217
|
- test/fixtures/api.omise.co/recipients-post.json
|
210
218
|
- test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-delete.json
|
@@ -247,6 +255,7 @@ files:
|
|
247
255
|
- test/omise/test_link.rb
|
248
256
|
- test/omise/test_list.rb
|
249
257
|
- test/omise/test_occurrence.rb
|
258
|
+
- test/omise/test_receipt.rb
|
250
259
|
- test/omise/test_recipient.rb
|
251
260
|
- test/omise/test_refund.rb
|
252
261
|
- test/omise/test_resource.rb
|
@@ -264,7 +273,7 @@ homepage: https://www.omise.co/
|
|
264
273
|
licenses:
|
265
274
|
- MIT
|
266
275
|
metadata: {}
|
267
|
-
post_install_message:
|
276
|
+
post_install_message:
|
268
277
|
rdoc_options: []
|
269
278
|
require_paths:
|
270
279
|
- lib
|
@@ -280,11 +289,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
280
289
|
version: '0'
|
281
290
|
requirements: []
|
282
291
|
rubygems_version: 3.0.3
|
283
|
-
signing_key:
|
292
|
+
signing_key:
|
284
293
|
specification_version: 4
|
285
294
|
summary: Omise Ruby client
|
286
295
|
test_files:
|
287
296
|
- test/fixtures/api.omise.co/account-get.json
|
297
|
+
- test/fixtures/api.omise.co/account-patch.json
|
288
298
|
- test/fixtures/api.omise.co/balance-get.json
|
289
299
|
- test/fixtures/api.omise.co/capability-get.json
|
290
300
|
- test/fixtures/api.omise.co/chains-get.json
|
@@ -299,6 +309,8 @@ test_files:
|
|
299
309
|
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq-get.json
|
300
310
|
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq-patch.json
|
301
311
|
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/capture-post.json
|
312
|
+
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/events-get.json
|
313
|
+
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/expire-post.json
|
302
314
|
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds-get.json
|
303
315
|
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds-post.json
|
304
316
|
- test/fixtures/api.omise.co/charges/chrg_test_4yq7duw15p9hdrjp8oq/refunds/404-get.json
|
@@ -320,6 +332,7 @@ test_files:
|
|
320
332
|
- test/fixtures/api.omise.co/disputes/closed-get.json
|
321
333
|
- test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs-get.json
|
322
334
|
- test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs-patch.json
|
335
|
+
- test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/accept-patch.json
|
323
336
|
- test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/documents-get.json
|
324
337
|
- test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/documents-post.json
|
325
338
|
- test/fixtures/api.omise.co/disputes/dspt_test_5089off452g5m5te7xs/documents/docu_test_55869onwfm2g3bsw8d8-delete.json
|
@@ -332,8 +345,11 @@ test_files:
|
|
332
345
|
- test/fixtures/api.omise.co/integrations/integration_test_5h24qlv37qyx537p1ub-get.json
|
333
346
|
- test/fixtures/api.omise.co/links-get.json
|
334
347
|
- test/fixtures/api.omise.co/links-post.json
|
348
|
+
- test/fixtures/api.omise.co/links/link_test_55pcclmznvrv9lc7r9s-delete.json
|
335
349
|
- test/fixtures/api.omise.co/links/link_test_55pcclmznvrv9lc7r9s-get.json
|
336
350
|
- test/fixtures/api.omise.co/occurrences/occu_test_57s33hmja9t3fs4wmop-get.json
|
351
|
+
- test/fixtures/api.omise.co/receipts-get.json
|
352
|
+
- test/fixtures/api.omise.co/receipts/rcpt_5ls0b8zb53qmw3mlvfz-get.json
|
337
353
|
- test/fixtures/api.omise.co/recipients-get.json
|
338
354
|
- test/fixtures/api.omise.co/recipients-post.json
|
339
355
|
- test/fixtures/api.omise.co/recipients/recp_test_50894vc13y8z4v51iuc-delete.json
|
@@ -376,6 +392,7 @@ test_files:
|
|
376
392
|
- test/omise/test_link.rb
|
377
393
|
- test/omise/test_list.rb
|
378
394
|
- test/omise/test_occurrence.rb
|
395
|
+
- test/omise/test_receipt.rb
|
379
396
|
- test/omise/test_recipient.rb
|
380
397
|
- test/omise/test_refund.rb
|
381
398
|
- test/omise/test_resource.rb
|