Events
GET /api/v1/events
List Events
Lists out past webhook events from most-recent to least-recent.
サンプル
- cURL
- Node.js
- Ruby
curl -X GET https://komoju.com/api/v1/events \
-u sk_123456:
var https = require('https');
var secret_key = 'sk_123456'
var auth = 'Basic ' + Buffer.from(secret_key + ':').toString('base64');
var get_options = {
host: 'komoju.com',
port: '443',
path: '/api/v1/events',
method: 'GET',
headers: {
'Authorization': auth
}
};
var get_req = https.request(get_options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log(chunk);
});
});
get_req.end();
require 'uri'
require 'net/https'
require 'json'
require 'base64'
require 'pp'
uri = URI.parse('https://komoju.com/api/v1/events')
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
secret_key = 'sk_123456'
auth = Base64.encode64("#{secret_key}:")
headers = {
'Content-Type' => 'application/json',
'Authorization' => "Basic #{auth}"
}
res = https.get(uri.path, headers)
puts res.body
{
"resource": "list",
"total": 2,
"page": 1,
"per_page": 10,
"last_page": 1,
"data": [
{
"id": "7tgmdnrg30yyxtnznij4oczbj",
"type": "payment.captured",
"resource": "event",
"data": {
"id": "d7007k5jb94zidwnmufvb8voy",
"resource": "payment",
"status": "captured",
"amount": 300,
"tax": 30,
"customer": null,
"payment_deadline": "2020-06-16T14:59:59Z",
"payment_details": {
"type": "credit_card",
"email": "gordon@example.com",
"brand": "visa",
"last_four_digits": "1111",
"month": 3,
"year": 2021
},
"payment_method_fee": 0,
"total": 330,
"currency": "JPY",
"description": null,
"captured_at": "2020-06-07T14:59:59Z",
"external_order_num": "ORDER12",
"metadata": {
},
"created_at": "2020-06-09T07:42:01Z",
"amount_refunded": 0,
"locale": "en",
"refunds": [
],
"refund_requests": [
]
},
"created_at": "2020-06-09T07:42:01Z",
"reason": null
},
{
"id": "a3iwkddrvy34m8ca3trrk2p28",
"type": "payment.updated",
"resource": "event",
"data": {
"id": "d7007k5jb94zidwnmufvb8voy",
"resource": "payment",
"status": "captured",
"amount": 300,
"tax": 30,
"customer": null,
"payment_deadline": "2020-06-16T14:59:59Z",
"payment_details": {
"type": "credit_card",
"email": "gordon@example.com",
"brand": "visa",
"last_four_digits": "1111",
"month": 3,
"year": 2021
},
"payment_method_fee": 0,
"total": 330,
"currency": "JPY",
"description": null,
"captured_at": "2020-06-07T14:59:59Z",
"external_order_num": "ORDER12",
"metadata": {
},
"created_at": "2020-06-09T07:42:01Z",
"amount_refunded": 0,
"locale": "en",
"refunds": [
],
"refund_requests": [
]
},
"created_at": "2020-06-09T07:42:01Z",
"reason": null
}
]
}
パラメータ
名前 | 説明 |
---|---|
start_time 任意 |
Query for records created after this time. |
end_time 任意 |
Query for records created before this time. |
page 任意 |
Page number to query for. |
per_page 任意 |
How many complete objects per page. |
GET /api/v1/events/:id
Show Events
View an event given an id
. Event id
s can be saved from a webhook or found by querying all events.
サンプル
- cURL
- Node.js
- Ruby
curl -X GET https://komoju.com/api/v1/events/3c9ks6xl2pyuvbxv26pa3zmfe \
-u sk_123456:
var https = require('https');
var secret_key = 'sk_123456'
var auth = 'Basic ' + Buffer.from(secret_key + ':').toString('base64');
var get_options = {
host: 'komoju.com',
port: '443',
path: '/api/v1/events/3c9ks6xl2pyuvbxv26pa3zmfe',
method: 'GET',
headers: {
'Authorization': auth
}
};
var get_req = https.request(get_options, function(res) {
res.setEncoding('utf8');
res.on('data', function (chunk) {
console.log(chunk);
});
});
get_req.end();
require 'uri'
require 'net/https'
require 'json'
require 'base64'
require 'pp'
uri = URI.parse('https://komoju.com/api/v1/events/3c9ks6xl2pyuvbxv26pa3zmfe')
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
secret_key = 'sk_123456'
auth = Base64.encode64("#{secret_key}:")
headers = {
'Content-Type' => 'application/json',
'Authorization' => "Basic #{auth}"
}
res = https.get(uri.path, headers)
puts res.body
{
"id": "3c9ks6xl2pyuvbxv26pa3zmfe",
"type": "payment.captured",
"resource": "event",
"data": {
"id": "0i4ispqaqz4l13heuqge5uvf0",
"resource": "payment",
"status": "captured",
"amount": 300,
"tax": 30,
"customer": null,
"payment_deadline": "2020-06-16T14:59:59Z",
"payment_details": {
"type": "credit_card",
"email": "gordon@example.com",
"brand": "visa",
"last_four_digits": "1111",
"month": 3,
"year": 2021
},
"payment_method_fee": 0,
"total": 330,
"currency": "JPY",
"description": null,
"captured_at": "2020-06-07T14:59:59Z",
"external_order_num": "ORDER11",
"metadata": {
},
"created_at": "2020-06-09T07:42:01Z",
"amount_refunded": 0,
"locale": "en",
"refunds": [
],
"refund_requests": [
]
},
"created_at": "2020-06-09T07:42:01Z",
"reason": null
}