Customers

>>>

Retrieves a paginated list of all previously-registered customers. Does not reveal saved payment details.

サンプル

  • cURL
  • Node.js
  • Ruby
curl -X GET https://komoju.com/api/v1/customers \
  -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/customers',
  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/customers')
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": 3,
  "page": 1,
  "per_page": 10,
  "last_page": 1,
  "data": [
    {
      "id": "8xk3c2swi2qqnt1edef0g29jd",
      "resource": "customer",
      "email": "jackwaelchi@spinka.net",
      "source": null,
      "metadata": {
        "order_id": "abcdefg"
      },
      "created_at": "2020-06-09T07:41:50Z"
    },
    {
      "id": "9jy33f1bcnw7vapbheek1nrj4",
      "resource": "customer",
      "email": "rorygorczany@stroman.org",
      "source": null,
      "metadata": {
        "order_id": "abcdefg"
      },
      "created_at": "2020-06-09T07:41:50Z"
    },
    {
      "id": "6mpr3pzet34ifzvgyt60mmtee",
      "resource": "customer",
      "email": "ola@turner.net",
      "source": null,
      "metadata": {
        "order_id": "abcdefg"
      },
      "created_at": "2020-06-09T07:41:50Z"
    }
  ]
}

パラメータ

名前 説明
start_time
任意

Query for records created after this time.

end_time
任意

Query for records created before this time.

per_page
任意

How many complete objects per page.

page
任意

Page number to query for.

>>>

Retrieves customer personal information. This endpoint does not reveal the saved payment details.

サンプル

  • cURL
  • Node.js
  • Ruby
curl -X GET https://komoju.com/api/v1/customers/3t9aqamysm8ffhxybe6vkgbcn \
  -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/customers/3t9aqamysm8ffhxybe6vkgbcn',
  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/customers/3t9aqamysm8ffhxybe6vkgbcn')
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": "3t9aqamysm8ffhxybe6vkgbcn",
  "resource": "customer",
  "email": "alleen@stehr.info",
  "source": null,
  "metadata": {
    "order_id": "abcdefg"
  },
  "created_at": "2020-06-09T07:41:51Z"
}
>>>

POST /api/v1/customers
Create Customers

Creates a new customer with the specified payment_details. Customer payment details are stored in a secure, PCI DSS-compliant way.

Once you have a customer, you may specify the customer's id instead of payment_details when creating a payment.

サンプル

  • cURL
  • Node.js
  • Ruby
curl -X POST https://komoju.com/api/v1/customers \
  -u sk_123456: \
  -d "email=test@example.com" \
  -d "metadata[order_id]=abcdefg" \
  -d "payment_details=tok_2igg25moy54uv0hubhauo1dhs" 
var querystring = require('querystring');
var https = require('https');
var secret_key = 'sk_123456'
var auth = 'Basic ' + Buffer.from(secret_key + ':').toString('base64');
var post_data = querystring.stringify({
  'email': 'test@example.com',
  'metadata[order_id]': 'abcdefg',
  'payment_details': 'tok_2igg25moy54uv0hubhauo1dhs'
});

var post_options = {
  host: 'komoju.com',
  port: '443',
  path: '/api/v1/customers',
  method: 'POST',
  headers: {
    'Authorization': auth,
    'Content-Length': Buffer.byteLength(post_data)
  }
};

var post_req = https.request(post_options, function(res) {
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
        console.log(chunk);
    });
});

post_req.write(post_data);
post_req.end();
require 'uri'
require 'net/https'
require 'json'
require 'base64'
require 'pp'
uri = URI.parse('https://komoju.com/api/v1/customers')
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}"
}

body = {
  email: "test@example.com",
  metadata: {
    order_id: "abcdefg"
  },
  payment_details: "tok_2igg25moy54uv0hubhauo1dhs"
}

res = https.post(
  uri.path,
  body.to_json,
  headers
)

puts res.body
{
  "id": "3ia9knmuqcdvz0eu3tsx3op21",
  "resource": "customer",
  "email": "test@example.com",
  "source": {
    "type": "credit_card",
    "brand": "visa",
    "last_four_digits": "1111",
    "month": 1,
    "year": 2025
  },
  "metadata": {
    "order_id": "abcdefg"
  },
  "created_at": "2020-06-09T07:41:51Z"
}

パラメータ

名前 説明
payment_details
必須

A hash or token describing the payment method used to make the payment. This or customer must be present when creating a payment.

currency
任意

3 letter ISO currency code used to pay.

email
任意

Customer's email address.

metadata
任意

A set of key-value pairs.

>>>

Updates the customer with the given id. A new set of payment_details may be specified.

サンプル

  • cURL
  • Node.js
  • Ruby
curl -X PATCH https://komoju.com/api/v1/customers/5idn4n9ll38ovn1657478mtbw \
  -u sk_123456: \
  -d "payment_details=tok_dnma6a58sobtp46ef350grao8" 
var querystring = require('querystring');
var https = require('https');
var secret_key = 'sk_123456'
var auth = 'Basic ' + Buffer.from(secret_key + ':').toString('base64');
var patch_data = querystring.stringify({
  'payment_details': 'tok_dnma6a58sobtp46ef350grao8'
});

var patch_options = {
  host: 'komoju.com',
  port: '443',
  path: '/api/v1/customers/5idn4n9ll38ovn1657478mtbw',
  method: 'PATCH',
  headers: {
    'Authorization': auth,
    'Content-Length': Buffer.byteLength(patch_data)
  }
};

var patch_req = https.request(patch_options, function(res) {
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
        console.log(chunk);
    });
});

patch_req.write(patch_data);
patch_req.end();
require 'uri'
require 'net/https'
require 'json'
require 'base64'
require 'pp'
uri = URI.parse('https://komoju.com/api/v1/customers/5idn4n9ll38ovn1657478mtbw')
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}"
}

body = {
  payment_details: "tok_dnma6a58sobtp46ef350grao8"
}

res = https.patch(
  uri.path,
  body.to_json,
  headers
)

puts res.body
{
  "id": "5idn4n9ll38ovn1657478mtbw",
  "resource": "customer",
  "email": "mathilda@grimes.net",
  "source": {
    "type": "credit_card",
    "brand": "visa",
    "last_four_digits": "1111",
    "month": 1,
    "year": 2025
  },
  "metadata": {
    "order_id": "abcdefg"
  },
  "created_at": "2020-06-09T07:41:51Z"
}

パラメータ

名前 説明
currency
任意

3 letter ISO currency code used to pay.

payment_details
任意

A hash or token describing the payment method used to make the payment. This or customer must be present when creating a payment.

email
任意

Customer's email address.

metadata
任意

A set of key-value pairs.

>>>

Deletes the customer with the given id. This completely erases the stored payment details from our database.

サンプル

  • cURL
  • Node.js
  • Ruby
curl -X DELETE https://komoju.com/api/v1/customers/3wtumoz052h6rond8um098u4o \
  -u sk_123456:
var https = require('https');
var secret_key = 'sk_123456'
var auth = 'Basic ' + Buffer.from(secret_key + ':').toString('base64');
var delete_options = {
  host: 'komoju.com',
  port: '443',
  path: '/api/v1/customers/3wtumoz052h6rond8um098u4o',
  method: 'DELETE',
  headers: {
    'Authorization': auth
  }
};

var delete_req = https.request(delete_options, function(res) {
    res.setEncoding('utf8');
    res.on('data', function (chunk) {
        console.log(chunk);
    });
});

delete_req.end();
require 'uri'
require 'net/https'
require 'json'
require 'base64'
require 'pp'
uri = URI.parse('https://komoju.com/api/v1/customers/3wtumoz052h6rond8um098u4o')
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.delete(uri.path, '{}', headers)
puts res.body
{
  "id": "3wtumoz052h6rond8um098u4o",
  "resource": "customer",
  "email": "elvinskiles@armstrong.com",
  "source": null,
  "metadata": {
    "order_id": "abcdefg"
  },
  "created_at": "2020-06-09T07:41:51Z"
}