omise 0.7.1 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +27 -0
- data/.gitignore +1 -0
- data/CHANGELOG.md +27 -1
- data/LICENSE.txt +1 -1
- data/README.md +27 -45
- data/lib/omise/account.rb +12 -1
- data/lib/omise/all.rb +4 -0
- data/lib/omise/capability.rb +32 -0
- data/lib/omise/charge.rb +8 -0
- data/lib/omise/config.rb +5 -1
- data/lib/omise/dispute.rb +4 -0
- data/lib/omise/integration.rb +16 -0
- data/lib/omise/link.rb +4 -0
- data/lib/omise/receipt.rb +20 -0
- data/lib/omise/resource.rb +0 -2
- data/lib/omise/schedule.rb +4 -0
- data/lib/omise/scheduler.rb +1 -1
- data/lib/omise/source.rb +15 -0
- 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/capability-get.json +29 -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/integrations/integration_test_5h24qlv37qyx537p1ub-get.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/fixtures/api.omise.co/schedules/schd_test_4yq7duw15p9hdrjp8oq-delete.json +1 -1
- data/test/fixtures/api.omise.co/schedules/schd_test_4yq7duw15p9hdrjp8oq-get.json +1 -0
- data/test/fixtures/api.omise.co/sources-post.json +6 -0
- data/test/fixtures/api.omise.co/sources/src_test_59trf2nxk43b5nml8z0-get.json +8 -0
- data/test/omise/test_account.rb +7 -1
- data/test/omise/test_capability.rb +30 -0
- data/test/omise/test_charge.rb +11 -0
- data/test/omise/test_dispute.rb +18 -0
- data/test/omise/test_integration.rb +12 -0
- data/test/omise/test_link.rb +7 -0
- data/test/omise/test_receipt.rb +29 -0
- data/test/omise/test_schedule.rb +8 -0
- data/test/omise/test_scheduler.rb +13 -0
- data/test/omise/test_source.rb +20 -0
- data/test/support.rb +1 -0
- metadata +42 -10
- data/circle.yml +0 -3
- data/data/ca_certificates.pem +0 -162
data/lib/omise/source.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require "omise/object"
|
2
|
+
|
3
|
+
module Omise
|
4
|
+
class Source < OmiseObject
|
5
|
+
self.endpoint = "/sources"
|
6
|
+
|
7
|
+
def self.retrieve(id, attributes = {})
|
8
|
+
new resource(location(id), attributes).get(attributes)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.create(attributes = {})
|
12
|
+
new resource(location, attributes).post(attributes)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/omise/version.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"object": "capability",
|
3
|
+
"location": "/capability",
|
4
|
+
"payment_methods": [
|
5
|
+
{
|
6
|
+
"object": "payment_method",
|
7
|
+
"name": "card",
|
8
|
+
"currencies": [
|
9
|
+
"THB",
|
10
|
+
"JPY",
|
11
|
+
"USD",
|
12
|
+
"EUR",
|
13
|
+
"GBP",
|
14
|
+
"SGD",
|
15
|
+
"AUD",
|
16
|
+
"CHF",
|
17
|
+
"CNY",
|
18
|
+
"DKK",
|
19
|
+
"HKD"
|
20
|
+
],
|
21
|
+
"card_brands": [
|
22
|
+
"JCB",
|
23
|
+
"Visa",
|
24
|
+
"MasterCard"
|
25
|
+
],
|
26
|
+
"installment_terms": null
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}
|
@@ -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,12 @@
|
|
1
|
+
{
|
2
|
+
"object": "integration",
|
3
|
+
"id": "integration_test_5h24qlv37qyx537p1ub",
|
4
|
+
"kind": "shopify",
|
5
|
+
"created": "2019-08-29T10:19:19Z",
|
6
|
+
"public_key": "pkey_test_5bfvlxufuuqkrhmzfj1",
|
7
|
+
"secret_key": "skey_test_5hw809m30rlnp4but0m",
|
8
|
+
"data": {
|
9
|
+
"account_id": "integration_test_5h24qlv37qyx537p1ub",
|
10
|
+
"secret": "e4de752bf06483e4949263928757b137"
|
11
|
+
}
|
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
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require "support"
|
2
|
+
|
3
|
+
class TestCapability < Omise::Test
|
4
|
+
setup do
|
5
|
+
@capability = Omise::Capability.retrieve
|
6
|
+
@payment_methods = @capability.payment_methods
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_that_we_can_retrieve_capabilities
|
10
|
+
assert_instance_of Omise::Capability, @capability
|
11
|
+
assert_equal "/capability", @capability.location
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_we_have_payment_backends
|
15
|
+
assert @payment_methods.is_a?(Array)
|
16
|
+
refute @payment_methods.empty?
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_that_we_can_list_payment_methods
|
20
|
+
payment_method = @payment_methods.first
|
21
|
+
|
22
|
+
assert_instance_of Array, @payment_methods
|
23
|
+
assert_instance_of Omise::Capability::PaymentMethod, payment_method
|
24
|
+
assert payment_method.respond_to?(:object)
|
25
|
+
assert payment_method.respond_to?(:name)
|
26
|
+
assert payment_method.respond_to?(:currencies)
|
27
|
+
assert payment_method.respond_to?(:card_brands)
|
28
|
+
assert payment_method.respond_to?(:installment_terms)
|
29
|
+
end
|
30
|
+
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
|