Customers

>>>

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

A time range can be specified with start_time and end_time.

Examples

  • 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": "0a1v1gdj46k0uosjapi2tpkop",
      "resource": "customer",
      "email": "brigettewilkinson@kuphal.com",
      "source": null,
      "metadata": {
        "order_id": "abcdefg"
      },
      "created_at": "2019-12-17T05:13:23Z"
    },
    {
      "id": "5s1uytduy8rbgpwl8le39fv3s",
      "resource": "customer",
      "email": "antwanmills@langoshhettinger.net",
      "source": null,
      "metadata": {
        "order_id": "abcdefg"
      },
      "created_at": "2019-12-17T05:13:23Z"
    },
    {
      "id": "4jhxbjdb91p8avxgkf5ymc0db",
      "resource": "customer",
      "email": "lupe@boehm.co",
      "source": null,
      "metadata": {
        "order_id": "abcdefg"
      },
      "created_at": "2019-12-17T05:13:23Z"
    }
  ]
}

Params

Param name Description
start_time
optional

Query for records created after this time.

end_time
optional

Query for records created before this time.

per_page
optional

How many complete objects per page.

page
optional

Page number to query for.

>>>

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

Examples

  • cURL
  • Node.js
  • Ruby
curl -X GET https://komoju.com/api/v1/customers/b1zit3bs4mxavbjbif5u2ljic \
  -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/b1zit3bs4mxavbjbif5u2ljic',
  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/b1zit3bs4mxavbjbif5u2ljic')
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": "b1zit3bs4mxavbjbif5u2ljic",
  "resource": "customer",
  "email": "edison@barton.name",
  "source": null,
  "metadata": {
    "order_id": "abcdefg"
  },
  "created_at": "2019-12-17T05:13:23Z"
}
>>>

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.

Examples

  • cURL
  • Node.js
  • Ruby
curl -X POST https://komoju.com/api/v1/customers \
  -u sk_123456: \
  -d "debug=true" \
  -d "email=test@example.com" \
  -d "metadata[order_id]=abcdefg" \
  -d "payment_details=tok_eqgm9f8nlko2ynb65u5u6wpi9" 
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({
  'debug': 'true',
  'email': 'test@example.com',
  'metadata[order_id]': 'abcdefg',
  'payment_details': 'tok_eqgm9f8nlko2ynb65u5u6wpi9'
});

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 = {
  debug: "true",
  email: "test@example.com",
  metadata: {
    order_id: "abcdefg"
  },
  payment_details: "tok_eqgm9f8nlko2ynb65u5u6wpi9"
}

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

puts res.body
{
  "id": "dlqkb8ioyinp4jabb3timk0mw",
  "resource": "customer",
  "email": "test@example.com",
  "source": {
    "type": "credit_card",
    "brand": "visa",
    "last_four_digits": "1111",
    "month": 1,
    "year": 2024
  },
  "metadata": {
    "order_id": "abcdefg"
  },
  "created_at": "2019-12-17T05:13:23Z"
}

Params

Param name Description
payment_details
required

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

currency
optional

3 letter ISO currency code used to pay.

email
optional

Customer's email address.

metadata
optional

A set of key-value pairs.

>>>

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

Examples

  • cURL
  • Node.js
  • Ruby
curl -X PATCH https://komoju.com/api/v1/customers/avlkrdls5rkcf70fm9nlvi7xn \
  -u sk_123456: \
  -d "payment_details=tok_38f2ke0mmqnobliq4apg7dgt1" 
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_38f2ke0mmqnobliq4apg7dgt1'
});

var patch_options = {
  host: 'komoju.com',
  port: '443',
  path: '/api/v1/customers/avlkrdls5rkcf70fm9nlvi7xn',
  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/avlkrdls5rkcf70fm9nlvi7xn')
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_38f2ke0mmqnobliq4apg7dgt1"
}

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

puts res.body
{
  "id": "avlkrdls5rkcf70fm9nlvi7xn",
  "resource": "customer",
  "email": "bev@schowalter.org",
  "source": {
    "type": "credit_card",
    "brand": "visa",
    "last_four_digits": "1111",
    "month": 1,
    "year": 2024
  },
  "metadata": {
    "order_id": "abcdefg"
  },
  "created_at": "2019-12-17T05:13:23Z"
}

Params

Param name Description
currency
optional

3 letter ISO currency code used to pay.

payment_details
optional

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

email
optional

Customer's email address.

metadata
optional

A set of key-value pairs.

>>>

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

Examples

  • cURL
  • Node.js
  • Ruby
curl -X DELETE https://komoju.com/api/v1/customers/0tsdthnjtkrwytn8amr9yoo8d \
  -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/0tsdthnjtkrwytn8amr9yoo8d',
  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/0tsdthnjtkrwytn8amr9yoo8d')
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": "0tsdthnjtkrwytn8amr9yoo8d",
  "resource": "customer",
  "email": "jacquelynstokes@tremblay.biz",
  "source": null,
  "metadata": {
    "order_id": "abcdefg"
  },
  "created_at": "2019-12-17T05:13:23Z"
}