Customer API

Customer API จะช่วยสร้าง, เรียกข้อมูล, อัปเดต และ ลบลูกค้าออกได้ โดย “ลูกค้า” ในที่นี้เปรียบเหมือนตัวแทนของผู้ซื้อคืออาจมีหรือไม่มีบัตรที่บันทึกไว้กับระบบ โดยหากมีการกลับมาซื้อซ้ำจะสามารถเรียกใช้ได้อีก

Attributes

Name Type Description
object string

The string customer.

id object_id

The customer identifier matching /cust(_test)?_[0-9a-z]+/.

livemode boolean

Whether this is a live (true) or test (false) customer.

location string

API path to retrieve the current customer object.

cards list

List of cards belonging to the customer.

created_at datetime

UTC datetime of customer creation in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

default_card object_id

Identifier of default card for creating charges. Initially, value is first card assigned to a customer. If default card is deleted, the latest card added will be set as default. null if no cards.

deleted boolean

Whether customer is deleted.

description string

Customer description.

email string

Customer email address.

metadata object

Custom metadata (e.g. {"answer": 42}) for customer.

Example

  • JSON Response

Create a customer (and card)

- POST https://api.omise.co/customers

Creates and returns a new customer. This endpoint can also create a new card if an unused token is provided for the card parameter.

Request Parameters

Name Type Description
description string

(optional, but recommended) Description for customer. Supplying any additional details about the customer helps Omise better conduct fraud analysis.

email string

(optional, but recommended) Email address for customer. Supplying the customer's email address helps Omise better conduct fraud analysis.

card object_id

(optional) An unused token identifier to add as a new card to the customer.

metadata object

(optional) Custom metadata (e.g. {"answer": 42}) for customer.

Example

  • Create a customer

  • Create a customer while attaching a card

Retrieve a customer

- GET https://api.omise.co/customers/{id}

Returns the customer matching :id.

Example

  • Retrieve a customer

Update a customer

- PATCH https://api.omise.co/customers/{id}

Updates and returns the updated customer matching :id.

Request Parameters

Name Type Description
description string

(optional, but recommended) Description for customer. Supplying any additional details about the customer helps Omise better conduct fraud analysis.

email string

(optional, but recommended) Email address for customer. Supplying the customer's email address helps Omise better conduct fraud analysis.

card object_id

(optional) An unused token identifier to add as a new card to the customer.

default_card object_id

(optional) Identifier of the default card for creating charges.

metadata object

(optional) Custom metadata (e.g. {"answer": 42}) for customer.

Example

  • Update customer email and description

  • Update customer default card

  • Attach a card to a customer

Destroy a customer

- DELETE https://api.omise.co/customers/{id}

Destroys the customer matching :id.

Example

  • Destroy a customer

  • JSON Response

List customers

- GET https://api.omise.co/customers

Returns a list of customers belonging to your account.

Request Parameters

Name Type Description
from datetime

(optional, default: 1970-01-01T00:00:00Z) Earliest UTC datetime for returned records in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

limit integer

(optional, default: 20, maximum: 100) Number of records returned.

offset integer

(optional, default: 0) Offset of the first record returned (i.e. how many records to skip from the beginning).

order string

(optional, default: chronological) Order of records returned. One of chronological (earliest to latest) or reverse_chronological (latest to earliest).

to datetime

(optional, default: current UTC datetime) Latest UTC datetime for returned records in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

Example

  • List all customers

List schedules

- GET https://api.omise.co/customers/{id}/schedules

Returns a list of schedules belonging to customer matching :id.

Request Parameters

Name Type Description
from datetime

(optional, default: 1970-01-01T00:00:00Z) Earliest UTC datetime for returned records in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

limit integer

(optional, default: 20, maximum: 100) Number of records returned.

offset integer

(optional, default: 0) Offset of the first record returned (i.e. how many records to skip from the beginning).

order string

(optional, default: chronological) Order of records returned. One of chronological (earliest to latest) or reverse_chronological (latest to earliest).

to datetime

(optional, default: current UTC datetime) Latest UTC datetime for returned records in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

Example

  • List all charge schedules for a customer