Customer API

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

Attribute

Name Type Description
object string

The string customer.

id object_id

The CUSTOMER_ID matching /cust(_test)?_[1-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

A list of cards belonging to the customer.

created datetime

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

default_card object_id

The CARD_ID of the default card used when creating charges. The default card is the first card assigned to a customer. If the current default_card is destroyed, the latest card added will be set as default. This field will be null if there are no cards.

deleted boolean

Whether the customer is deleted.

description string

The human-readable description of the customer.

email string

Email address associated with the customer.

metadata Object

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

Example

  • Json Response

List all customers

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

Returns a list of all customer objects belonging to your account.

Request Parameter

Name Type Description
offset integer

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

limit integer

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

from datetime

(optional, default: 1970-01-01T00:00:00Z) The earliest UTC date and time for returned records in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

to datetime

(optional, default: current UTC datetime) The latest UTC date and time for returned records in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

order string

(optional, default: chronological) The order of the list returned. Either chronological (earliest to latest) or reverse_chronological (latest to earliest).

Example

  • List all customers

Create a customer

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

Returns a new customer object

Request Parameter

Name Type Description
email string

(optional) Customer's email.

description string

(optional) A custom description for the customer.

metadata Object

(optional) Any JSON hash you would like to attach to this customer. You can use this key to store email, user ID or internal reference ID.

card object_id

(optional) A card token in case you want to add a card to the customer.

Example

  • Create a customer

  • Create a customer and attach a card

Retrieve a customer

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

Returns an existing customer object

Example

  • Retrieve a customer

Update a customer

- PATCH https://api.omise.co/customers/CUSTOMER_ID

Returns the updated customer object

Request Parameter

Name Type Description
email string

(optional) Customer's email.

description string

(optional) A custom description for the customer.

metadata Object

(optional) Any JSON hash you would like to attach to this charge. You can use this key to store email, user ID or internal reference ID.

default_card object_id

(optional) A CARD_ID to become the customer's default card. The card must already belong to the customer.

card object_id

(optional) A card token in case you want to add a card to the customer.

Example

  • Update a customer

  • Attach a card to a customer

Destroy a customer

- DELETE https://api.omise.co/customers/CUSTOMER_ID

Returns the destroyed customer object

Example

  • Destroy a customer

  • Response (JSON)