Events

>>>

Lists out past webhook events from most-recent to least-recent.

A time range can be specified with start_time and end_time.

サンプル

  • 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": "6boj5yttzf1vonmqvr8lrvk1w",
      "type": "payment.captured",
      "resource": "event",
      "data": {
        "id": "b954mditegy4ildomz92f3v7j",
        "resource": "payment",
        "status": "captured",
        "amount": 300,
        "tax": 30,
        "customer": null,
        "payment_deadline": "2019-12-24T14:59:59Z",
        "payment_details": {
          "type": "credit_card",
          "email": "gordon@example.com",
          "brand": "visa",
          "last_four_digits": "1111",
          "month": 3,
          "year": 2020
        },
        "payment_method_fee": 0,
        "total": 330,
        "currency": "JPY",
        "description": null,
        "captured_at": "2019-12-15T14:59:59Z",
        "external_order_num": "ORDER1",
        "metadata": {
        },
        "created_at": "2019-12-17T05:13:26Z",
        "amount_refunded": 0,
        "locale": "en",
        "refunds": [

        ],
        "refund_requests": [

        ]
      },
      "created_at": "2019-12-17T05:13:26Z"
    },
    {
      "id": "b08doyaxwi776bc2g49soilv6",
      "type": "payment.updated",
      "resource": "event",
      "data": {
        "id": "b954mditegy4ildomz92f3v7j",
        "resource": "payment",
        "status": "captured",
        "amount": 300,
        "tax": 30,
        "customer": null,
        "payment_deadline": "2019-12-24T14:59:59Z",
        "payment_details": {
          "type": "credit_card",
          "email": "gordon@example.com",
          "brand": "visa",
          "last_four_digits": "1111",
          "month": 3,
          "year": 2020
        },
        "payment_method_fee": 0,
        "total": 330,
        "currency": "JPY",
        "description": null,
        "captured_at": "2019-12-15T14:59:59Z",
        "external_order_num": "ORDER1",
        "metadata": {
        },
        "created_at": "2019-12-17T05:13:26Z",
        "amount_refunded": 0,
        "locale": "en",
        "refunds": [

        ],
        "refund_requests": [

        ]
      },
      "created_at": "2019-12-17T05:13:26Z"
    }
  ]
}

パラメータ

名前 説明
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.

>>>

View an event given an id. Event ids 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/2l3mvr7aqwgd44l9uw0izg0s5 \
  -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/2l3mvr7aqwgd44l9uw0izg0s5',
  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/2l3mvr7aqwgd44l9uw0izg0s5')
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": "2l3mvr7aqwgd44l9uw0izg0s5",
  "type": "payment.captured",
  "resource": "event",
  "data": {
    "id": "7i416e3cymsi00ax4a8ebxkib",
    "resource": "payment",
    "status": "captured",
    "amount": 300,
    "tax": 30,
    "customer": null,
    "payment_deadline": "2019-12-24T14:59:59Z",
    "payment_details": {
      "type": "credit_card",
      "email": "gordon@example.com",
      "brand": "visa",
      "last_four_digits": "1111",
      "month": 3,
      "year": 2020
    },
    "payment_method_fee": 0,
    "total": 330,
    "currency": "JPY",
    "description": null,
    "captured_at": "2019-12-15T14:59:59Z",
    "external_order_num": "ORDER2",
    "metadata": {
    },
    "created_at": "2019-12-17T05:13:26Z",
    "amount_refunded": 0,
    "locale": "en",
    "refunds": [

    ],
    "refund_requests": [

    ]
  },
  "created_at": "2019-12-17T05:13:26Z"
}