ดึงข้อมูลลูกค้า
ดึงข้อมูลทั้งหมดเกี่ยวกับลูกค้า รวมถึงบัตรที่บันทึก, อีเมล, คำอธิบาย และ metadata
พารามิเตอร์คำขอ
จำเป็น - 1 ฟิลด์พารามิเตอร์ที่จำเป็น
`id`STRING(required)
Customer ID ที่ต้องการดึงข้อมูล (ต้องขึ้นต้นด้วย cust_)
การตอบกลับ
200
ดึงข้อมูลลูกค้าสำเร็จส่งคืน customer object พร้อมรายละเอียดทั้งหมดรวมถึงบัตรที่บันทึก
Customer object ประกอบด้วย:
id- Customer IDemail- ที่อยู่อีเมลลูกค้าdescription- ชื่อห รือคำอธิบายลูกค้าdefault_card- ID ของบัตรชำระเงินเริ่มต้นcards- List object ที่มีบัตรที่บันทึกทั้งหมดmetadata- ข้อมูล key-value ที่กำหนดเองcreated_at- เวลาสร้าง (ISO 8601)
401
ไม่ได้รับอนุญาตการยืนยันตัวตนล้มเหลว API key ไม่ถูกต้องหรือไม่มี
สาเหตุทั่วไป:
- ไม่มี Authorization header
- Secret key ไม่ถูกต้อง
- ใช้ public key แทน secret key
- รูปแบบ HTTP Basic Auth ไม่ถูกต้อง
404
ไม่พบไม่พบ Customer ID
สาเหตุทั่วไป:
- Customer ID ไม่มีอยู่
- ลูกค้าถูกลบไปแล้ว
- รูปแบบ customer ID ไม่ถูกต้อง
5xx
ข้อผิดพลาดเซิร์ฟเวอร์เกิดข้อผิดพลาดฝั่งเซิร์ฟเวอร์ ซึ่งเกิดขึ้นไม่บ่อยแต่ควรจัดการอย่างเหมาะ สม
วิธีจัดการ:
- ลองส่งคำขอใหม่ด้วย exponential backoff
- ตรวจสอบเหตุการณ์บริการที่ status.omise.co
- ดูการจัดการข้อผิดพลาดสำหรับคำแนะนำโดยละเอียด
ตัวอย่างโค้ด
- cURL
- Ruby
- Python
- Node.js
- PHP
- Java
- C#
- Go
curl https://api.omise.co/customers/cust_test_5xuy4w91xqz7d1w9u0t \
-u skey_test_5xuy4w91xqz7d1w9u0t:
require 'omise'
Omise.api_key = 'skey_test_5xuy4w91xqz7d1w9u0t'
customer = Omise::Customer.retrieve('cust_test_5xuy4w91xqz7d1w9u0t')
import omise
omise.api_secret = 'skey_test_5xuy4w91xqz7d1w9u0t'
customer = omise.Customer.retrieve('cust_test_5xuy4w91xqz7d1w9u0t')
const omise = require('omise')({
secretKey: 'skey_test_5xuy4w91xqz7d1w9u0t'
});
const customer = await omise.customers.retrieve('cust_test_5xuy4w91xqz7d1w9u0t');
<?php
define('OMISE_SECRET_KEY', 'skey_test_5xuy4w91xqz7d1w9u0t');
$customer = OmiseCustomer::retrieve('cust_test_5xuy4w91xqz7d1w9u0t');
Client client = new Client.Builder()
.secretKey("skey_test_5xuy4w91xqz7d1w9u0t")
.build();
Customer customer = client.customers().get("cust_test_5xuy4w91xqz7d1w9u0t");
var client = new Client("skey_test_5xuy4w91xqz7d1w9u0t");
var customer = await client.Customers.Get("cust_test_5xuy4w91xqz7d1w9u0t");
client, _ := omise.NewClient(
"pkey_test_5xuy4w91xqz7d1w9u0t",
"skey_test_5xuy4w91xqz7d1w9u0t",
)
customer, _ := client.Customers().Retrieve("cust_test_5xuy4w91xqz7d1w9u0t", nil)
รหัสข้อผิดพลาดและผลลัพธ์
รหัสข้อผิดพลาดทั่วไป
| รหัส | คำอธิบาย | วิธีแก้ไข |
|---|---|---|
authentication_failure | API key ไม่ถูกต้อง | ตรวจสอบว่า secret key ถูกต้อง |
not_found | ไม่พบลูกค้า | ตรวจสอบว่า customer ID มีอยู่ |
bad_request | รูปแบบ customer ID ไม่ถูกต้อง | ตรวจสอบ ID ขึ้นต้นด้วย cust_ |
ฟิลด์การตอบกลับ Customer
| ฟิลด์ | คำอธิบาย |
|---|---|
id | Customer ID (cust_*) |
email | ที่อยู่อีเมลลูกค้า |
description | ชื่อหรือคำอธิบายลูกค้า |
default_card | ID ของบัตรชำระเงินเริ่มต้น |
cards | List object ที่มีบัตรที่บันทึกทั้งหมด |
cards.data | Array ของ card objects |
cards.total | จำนวนบัตรที่บันทึกทั้งหมด |
metadata | ข้อมูล key-value ที่กำหนดเอง |
created_at | เวลาสร้างลูกค้า |
ข้อมูลยืนยันตัวตน API
ลองใช้งาน
จำเป็น - 1 ฟิลด์
IP ของคุณ:
...กำลังโหลด...