ข้ามไปยังเนื้อหาหลัก

การจัดการลูกค้า

เรียนรู้วิธีการสร้างและจัดการลูกค้าใน Omise สำหรับการชำระเงินที่เกิดขึ้นซ้ำ วิธีการชำระเงินที่บันทึก และการเรียกเก็บเงินตามสมาชิก วัตถุลูกค้าจะจัดเก็บข้อมูลการชำระเงินและรายละเอียดลูกค้าสำหรับการทำธุรกรรมในอนาคต

ภาพรวม

API ลูกค้าช่วยให้คุณสามารถจัดเก็บข้อมูลลูกค้าและวิธีการชำระเงินสำหรับการใช้ในอนาคต โดยช่วยให้สามารถ:

  • การเรียกเก็บเงินที่เกิดขึ้นซ้ำและสมาชิก
  • ประสบการณ์การชำระเงินแบบคลิกเดียว
  • วิธีการชำระเงินหลายแบบที่บันทึก
  • การจัดการวงจรชีวิตของลูกค้า
  • การติดตามประวัติการชำระเงิน

ประโยชน์หลัก

  • การชำระเงินที่เกิดขึ้นซ้ำที่ง่ายขึ้น - เรียกเก็บเงินจากลูกค้าโดยไม่ต้องรวบรวมรายละเอียดบัตรทุกครั้ง
  • ขอบเขต PCI ลดลง - จัดเก็บวิธีการชำระเงินแบบโทเคน์อย่างปลอดภัย
  • ประสบการณ์ลูกค้าที่ดีขึ้น - เปิดใช้งานการซื้อแบบคลิกเดียว
  • ตัวเลือกการชำระเงินที่มีความยืดหยุ่น - รองรับบัตรหลายใบต่อลูกค้า
  • การติดตามที่ครอบคลุม - เก็บประวัติการชำระเงินของลูกค้า

เมื่อใดที่ควรใช้ลูกค้า

ใช้วัตถุลูกค้าเมื่อคุณต้อง:

  • ยอมรับการชำระเงินที่เกิดขึ้นซ้ำหรือสมาชิก
  • นำเสนอวิธีการชำระเงินที่บันทึก
  • สร้างการเรียกเก็บเงินตามกำหนดเวลา
  • ใช้บริการสมาชิก
  • สร้างแพลตฟอร์มสมาชิก
  • เปิดใช้งานฟีเจอร์การต่ออายุอัตโนมัติ

การสร้างลูกค้า

การสร้างลูกค้าขั้นพื้นฐาน

curl https://api.omise.co/customers \
-u skey_test_123: \
-d "email=john@example.com" \
-d "description=John Doe - Premium Member"
const omise = require('omise')({
secretKey: 'skey_test_123'
});

const customer = await omise.customers.create({
email: 'john@example.com',
description: 'John Doe - Premium Member',
metadata: {
user_id: '12345',
plan: 'premium'
}
});

console.log('Customer ID:', customer.id);
import omise

omise.api_secret = 'skey_test_123'

customer = omise.Customer.create(
email='john@example.com',
description='John Doe - Premium Member',
metadata={
'user_id': '12345',
'plan': 'premium'
}
)

print(f'Customer ID: {customer.id}')
<?php
$omise = new Omise([
'secretKey' => 'skey_test_123'
]);

$customer = $omise['customers']->create([
'email' => 'john@example.com',
'description' => 'John Doe - Premium Member',
'metadata' => [
'user_id' => '12345',
'plan' => 'premium'
]
]);

echo "Customer ID: " . $customer['id'];
require 'omise'

Omise.api_key = 'skey_test_123'

customer = Omise::Customer.create(
email: 'john@example.com',
description: 'John Doe - Premium Member',
metadata: {
user_id: '12345',
plan: 'premium'
}
)

puts "Customer ID: #{customer.id}"

การสร้างลูกค้าด้วยบัตร

// ตัวเลือกที่ 1: สร้างด้วยโทเคน
const customer = await omise.customers.create({
email: 'john@example.com',
description: 'John Doe',
card: 'tokn_test_123456'
});

// ตัวเลือกที่ 2: กระบวนการสองขั้นตอน
const customer = await omise.customers.create({
email: 'john@example.com'
});

await omise.customers.update(customer.id, {
card: 'tokn_test_123456'
});
# ตัวเลือกที่ 1: สร้างด้วยโทเคน
customer = omise.Customer.create(
email='john@example.com',
description='John Doe',
card='tokn_test_123456'
)

# ตัวเลือกที่ 2: กระบวนการสองขั้นตอน
customer = omise.Customer.create(
email='john@example.com'
)

customer.update(card='tokn_test_123456')

ตอบสนองของลูกค้า

{
"object": "customer",
"id": "cust_test_123456",
"livemode": false,
"location": "/customers/cust_test_123456",
"default_card": "card_test_123456",
"email": "john@example.com",
"description": "John Doe - Premium Member",
"created_at": "2024-01-15T10:30:00Z",
"cards": {
"object": "list",
"data": [
{
"object": "card",
"id": "card_test_123456",
"livemode": false,
"location": "/customers/cust_test_123456/cards/card_test_123456",
"country": "TH",
"city": "Bangkok",
"postal_code": "10200",
"financing": "",
"bank": "",
"brand": "Visa",
"fingerprint": "XjOdjbZr6KPdljhG0fGAT2E=",
"first_digits": null,
"last_digits": "4242",
"name": "JOHN DOE",
"expiration_month": 12,
"expiration_year": 2025,
"security_code_check": true,
"tokenization_method": null,
"created_at": "2024-01-15T10:30:00Z"
}
],
"limit": 20,
"offset": 0,
"total": 1,
"order": null,
"from": "1970-01-01T00:00:00Z",
"to": "2024-01-15T10:30:00Z"
},
"metadata": {
"user_id": "12345",
"plan": "premium"
}
}

การดึงข้อมูลลูกค้า

รับลูกค้ารายเดียว

const customer = await omise.customers.retrieve('cust_test_123456');

console.log('Customer:', customer.email);
console.log('Cards:', customer.cards.total);
console.log('Default Card:', customer.default_card);
customer = omise.Customer.retrieve('cust_test_123456')

print(f'Customer: {customer.email}')
print(f'Cards: {customer.cards.total}')
print(f'Default Card: {customer.default_card}')
<?php
$customer = $omise['customers']->retrieve('cust_test_123456');

echo "Customer: " . $customer['email'] . "\n";
echo "Cards: " . $customer['cards']['total'] . "\n";
echo "Default Card: " . $customer['default_card'];

รายชื่อลูกค้าทั้งหมด

// รายชื่อพร้อมการแบ่งหน้า
const customers = await omise.customers.list({
limit: 20,
offset: 0,
order: 'reverse_chronological'
});

customers.data.forEach(customer => {
console.log(`${customer.email} - ${customer.id}`);
});

// ด้วยตัวกรอง
const premiumCustomers = await omise.customers.list({
limit: 100,
from: '2024-01-01T00:00:00Z',
to: '2024-12-31T23:59:59Z'
});
# รายชื่อพร้อมการแบ่งหน้า
customers = omise.Customer.list(
limit=20,
offset=0,
order='reverse_chronological'
)

for customer in customers.data:
print(f'{customer.email} - {customer.id}')

# ด้วยตัวกรอง
premium_customers = omise.Customer.list(
limit=100,
from_date='2024-01-01T00:00:00Z',
to_date='2024-12-31T23:59:59Z'
)

ค้นหาลูกค้า

// ค้นหาด้วยอีเมล
async function findCustomerByEmail(email) {
let offset = 0;
const limit = 100;

while (true) {
const customers = await omise.customers.list({ limit, offset });

const found = customers.data.find(c => c.email === email);
if (found) return found;

if (customers.data.length < limit) break;
offset += limit;
}

return null;
}

const customer = await findCustomerByEmail('john@example.com');
def find_customer_by_email(email):
offset = 0
limit = 100

while True:
customers = omise.Customer.list(limit=limit, offset=offset)

for customer in customers.data:
if customer.email == email:
return customer

if len(customers.data) < limit:
break
offset += limit

return None

customer = find_customer_by_email('john@example.com')

การอัปเดตลูกค้า

อัปเดตข้อมูลลูกค้า

const customer = await omise.customers.update('cust_test_123456', {
email: 'newemail@example.com',
description: 'John Doe - Enterprise Member',
metadata: {
user_id: '12345',
plan: 'enterprise',
upgraded_at: new Date().toISOString()
}
});
customer = omise.Customer.retrieve('cust_test_123456')
customer.update(
email='newemail@example.com',
description='John Doe - Enterprise Member',
metadata={
'user_id': '12345',
'plan': 'enterprise',
'upgraded_at': datetime.now().isoformat()
}
)
<?php
$customer = $omise['customers']->update('cust_test_123456', [
'email' => 'newemail@example.com',
'description' => 'John Doe - Enterprise Member',
'metadata' => [
'user_id' => '12345',
'plan' => 'enterprise',
'upgraded_at' => date('c')
]
]);

เปลี่ยนบัตรเริ่มต้น

// ตั้งค่าบัตรเริ่มต้น
await omise.customers.update('cust_test_123456', {
default_card: 'card_test_789012'
});

// ตรวจสอบการเปลี่ยนแปลง
const customer = await omise.customers.retrieve('cust_test_123456');
console.log('New default card:', customer.default_card);
# ตั้งค่าบัตรเริ่มต้น
customer = omise.Customer.retrieve('cust_test_123456')
customer.update(default_card='card_test_789012')

# ตรวจสอบการเปลี่ยนแปลง
customer.reload()
print(f'New default card: {customer.default_card}')

การลบลูกค้า

ลบลูกค้า

// ลบลูกค้าและบัตรที่เกี่ยวข้องทั้งหมด
await omise.customers.destroy('cust_test_123456');

// ตรวจสอบการลบ
try {
await omise.customers.retrieve('cust_test_123456');
} catch (error) {
console.log('Customer successfully deleted');
}
# ลบลูกค้า
customer = omise.Customer.retrieve('cust_test_123456')
customer.destroy()

# ตรวจสอบการลบ
try:
omise.Customer.retrieve('cust_test_123456')
except omise.errors.NotFoundError:
print('Customer successfully deleted')
curl https://api.omise.co/customers/cust_test_123456 \
-u skey_test_123: \
-X DELETE

ตอบสนอง

{
"object": "customer",
"id": "cust_test_123456",
"livemode": false,
"deleted": true
}

การจัดการบัตรลูกค้า

รายชื่อบัตรลูกค้า

const customer = await omise.customers.retrieve('cust_test_123456');
const cards = customer.cards.data;

cards.forEach(card => {
console.log(`${card.brand} ending in ${card.last_digits}`);
console.log(`Expires: ${card.expiration_month}/${card.expiration_year}`);
});
customer = omise.Customer.retrieve('cust_test_123456')
cards = customer.cards.data

for card in cards:
print(f'{card.brand} ending in {card.last_digits}')
print(f'Expires: {card.expiration_month}/{card.expiration_year}')

เพิ่มบัตรให้กับลูกค้า

// เพิ่มบัตรโดยใช้โทเคน
await omise.customers.update('cust_test_123456', {
card: 'tokn_test_new_card'
});

// ดึงข้อมูลลูกค้าที่ได้รับการอัปเดต
const customer = await omise.customers.retrieve('cust_test_123456');
console.log(`Total cards: ${customer.cards.total}`);
# เพิ่มบัตรโดยใช้โทเคน
customer = omise.Customer.retrieve('cust_test_123456')
customer.update(card='tokn_test_new_card')

# ดึงข้อมูลลูกค้าที่ได้รับการอัปเดต
customer.reload()
print(f'Total cards: {customer.cards.total}')

นำบัตรออกจากลูกค้า

// รับ ID ของบัตรที่จะลบ
const customer = await omise.customers.retrieve('cust_test_123456');
const cardToRemove = customer.cards.data[0].id;

// ลบบัตร
await omise.customers.destroyCard('cust_test_123456', cardToRemove);

// ตรวจสอบการลบ
const updatedCustomer = await omise.customers.retrieve('cust_test_123456');
console.log(`Remaining cards: ${updatedCustomer.cards.total}`);
# รับ ID ของบัตรที่จะลบ
customer = omise.Customer.retrieve('cust_test_123456')
card_to_remove = customer.cards.data[0].id

# ลบบัตร
customer.destroy_card(card_to_remove)

# ตรวจสอบการลบ
customer.reload()
print(f'Remaining cards: {customer.cards.total}')
curl https://api.omise.co/customers/cust_test_123456/cards/card_test_789 \
-u skey_test_123: \
-X DELETE

เรียกเก็บเงินจากลูกค้า

เรียกเก็บเงินจากบัตรเริ่มต้น

const charge = await omise.charges.create({
customer: 'cust_test_123456',
amount: 100000, // 1,000.00 THB
currency: 'THB',
description: 'Monthly subscription - January 2024'
});
charge = omise.Charge.create(
customer='cust_test_123456',
amount=100000,
currency='THB',
description='Monthly subscription - January 2024'
)

เรียกเก็บเงินจากบัตรเฉพาะ

const charge = await omise.charges.create({
customer: 'cust_test_123456',
card: 'card_test_789012',
amount: 100000,
currency: 'THB',
description: 'One-time purchase'
});
charge = omise.Charge.create(
customer='cust_test_123456',
card='card_test_789012',
amount=100000,
currency='THB',
description='One-time purchase'
)

เรียกเก็บเงินด้วย 3D Secure

const charge = await omise.charges.create({
customer: 'cust_test_123456',
amount: 100000,
currency: 'THB',
return_uri: 'https://example.com/payment/complete',
metadata: {
subscription_id: 'sub_123',
billing_cycle: 'January 2024'
}
});

if (charge.authorize_uri) {
// เปลี่ยนเส้นทางลูกค้าสำหรับการพิสูจน์ตัวตน 3D Secure
console.log('Authorize at:', charge.authorize_uri);
}

ตัวอย่างการใช้งานทั่วไป

บริการสมาชิก

class SubscriptionService {
constructor(omise) {
this.omise = omise;
}

async createSubscription(email, plan, cardToken) {
// สร้างลูกค้า
const customer = await this.omise.customers.create({
email,
description: `${plan} subscription`,
card: cardToken,
metadata: {
plan,
subscribed_at: new Date().toISOString()
}
});

// สร้างการเรียกเก็บเงินเบื้องต้น
const charge = await this.omise.charges.create({
customer: customer.id,
amount: this.getPlanAmount(plan),
currency: 'THB',
description: `${plan} - First payment`
});

return { customer, charge };
}

async chargeSubscription(customerId, plan) {
const charge = await this.omise.charges.create({
customer: customerId,
amount: this.getPlanAmount(plan),
currency: 'THB',
description: `${plan} - Monthly payment`
});

return charge;
}

getPlanAmount(plan) {
const plans = {
basic: 29900, // 299.00 THB
premium: 59900, // 599.00 THB
enterprise: 99900 // 999.00 THB
};
return plans[plan] || 0;
}
}

// การใช้งาน
const subscriptionService = new SubscriptionService(omise);
const subscription = await subscriptionService.createSubscription(
'john@example.com',
'premium',
'tokn_test_123456'
);

ชำระเงินแบบคลิกเดียว

class CheckoutService {
async processCheckout(userId, amount, currency) {
// ค้นหาลูกค้าที่มีอยู่จากID ผู้ใช้
const customer = await this.findCustomerByUserId(userId);

if (customer && customer.default_card) {
// ลูกค้ามีบัตรที่บันทึก - ชำระเงินแบบคลิกเดียว
return await omise.charges.create({
customer: customer.id,
amount,
currency,
description: 'One-click purchase'
});
} else {
// ลูกค้าใหม่หรือไม่มีบัตรที่บันทึก - รวบรวมข้อมูลการชำระเงิน
return { requiresPaymentInfo: true };
}
}

async findCustomerByUserId(userId) {
const customers = await omise.customers.list({ limit: 100 });
return customers.data.find(
c => c.metadata?.user_id === userId.toString()
);
}
}

การจัดการบัตรหลายใบ

class CardManager {
async addCard(customerId, cardToken, setAsDefault = false) {
// เพิ่มบัตรใหม่
await omise.customers.update(customerId, {
card: cardToken
});

const customer = await omise.customers.retrieve(customerId);
const newCard = customer.cards.data[0];

// ตั้งค่าเป็นค่าเริ่มต้นหากได้รับการร้องขอ
if (setAsDefault) {
await omise.customers.update(customerId, {
default_card: newCard.id
});
}

return newCard;
}

async removeCard(customerId, cardId) {
const customer = await omise.customers.retrieve(customerId);

// ป้องกันการลบวิธีการชำระเงินเพียงวิธีเดียว
if (customer.cards.total <= 1) {
throw new Error('Cannot remove the only payment method');
}

// ป้องกันการลบบัตรเริ่มต้นโดยไม่มีการแทนที่
if (customer.default_card === cardId) {
const otherCard = customer.cards.data.find(c => c.id !== cardId);
await omise.customers.update(customerId, {
default_card: otherCard.id
});
}

await omise.customers.destroyCard(customerId, cardId);
}

async setDefaultCard(customerId, cardId) {
await omise.customers.update(customerId, {
default_card: cardId
});
}
}

การจัดการวงจรชีวิตของลูกค้า

class CustomerLifecycleManager {
async upgradeSubscription(customerId, newPlan) {
const customer = await omise.customers.retrieve(customerId);

// อัปเดตข้อมูลเมตาของลูกค้า
await omise.customers.update(customerId, {
description: `${newPlan} subscription`,
metadata: {
...customer.metadata,
plan: newPlan,
upgraded_at: new Date().toISOString()
}
});

// เรียกเก็บเงินจำนวนที่ปรับตาม
const charge = await this.chargeProrated(customerId, newPlan);

return { customer, charge };
}

async cancelSubscription(customerId) {
const customer = await omise.customers.retrieve(customerId);

// อัปเดตข้อมูลเมตาเพื่อทำเครื่องหมายว่าเป็นการยกเลิก
await omise.customers.update(customerId, {
metadata: {
...customer.metadata,
status: 'cancelled',
cancelled_at: new Date().toISOString()
}
});

// ลบบัตรทั้งหมดตามเลือกจำเป็น
// await this.removeAllCards(customerId);
}

async reactivateSubscription(customerId, plan) {
// ตรวจสอบว่าลูกค้ามีวิธีการชำระเงิน
const customer = await omise.customers.retrieve(customerId);

if (!customer.default_card) {
throw new Error('No payment method available');
}

// อัปเดตข้อมูลเมตา
await omise.customers.update(customerId, {
metadata: {
...customer.metadata,
plan,
status: 'active',
reactivated_at: new Date().toISOString()
}
});

// เรียกเก็บเงินการชำระครั้งแรก
return await omise.charges.create({
customer: customerId,
amount: this.getPlanAmount(plan),
currency: 'THB',
description: `${plan} - Reactivation payment`
});
}
}

วิธีปฏิบัติที่ดีที่สุด

การจัดการอีเมล

// ตรวจสอบอีเมลเสมอก่อนสร้างลูกค้า
function validateEmail(email) {
const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
return regex.test(email);
}

async function createCustomerSafely(email, data) {
if (!validateEmail(email)) {
throw new Error('Invalid email address');
}

// ตรวจสอบลูกค้าที่มีอยู่
const existing = await findCustomerByEmail(email);
if (existing) {
return existing;
}

return await omise.customers.create({
email,
...data
});
}

การใช้ข้อมูลเมตา

// ใช้ข้อมูลเมตาเพื่อเชื่อมโยงกับระบบของคุณ
const customer = await omise.customers.create({
email: 'john@example.com',
metadata: {
// เชื่อมโยงกับระบบผู้ใช้ของคุณ
user_id: '12345',

// ติดตามระดับลูกค้า
tier: 'premium',

// จัดเก็บวันที่สำคัญ
subscribed_at: new Date().toISOString(),

// ติดตามวงจรชีวิต
status: 'active',

// จัดเก็บค่ากำหนด
marketing_consent: 'true',

// ช่องข้อมูลกำหนดเอง
referral_code: 'FRIEND20'
}
});

การจัดการข้อผิดพลาด

async function chargeCustomerSafely(customerId, amount, currency) {
try {
// ตรวจสอบว่าลูกค้ามีอยู่
const customer = await omise.customers.retrieve(customerId);

if (!customer.default_card) {
throw new Error('No payment method available');
}

// สร้างการเรียกเก็บเงิน
const charge = await omise.charges.create({
customer: customerId,
amount,
currency
});

return { success: true, charge };

} catch (error) {
if (error.code === 'not_found') {
return { success: false, error: 'Customer not found' };
}

if (error.code === 'insufficient_funds') {
return { success: false, error: 'Insufficient funds' };
}

if (error.code === 'failed_processing') {
return { success: false, error: 'Payment processing failed' };
}

throw error;
}
}

ข้อควรพิจารณาเรื่องความปลอดภัย

// ไม่ต้องเปิดเผย ID ลูกค้าใน URL หรือโค้ดฝั่งไคลเอนต์
// ใช้ ID ผู้ใช้ของคุณเองสำหรับการค้นหา

class SecureCustomerService {
async getCustomerByUserId(userId) {
// การค้นหาโดยใช้ข้อมูลเมตา
const customers = await omise.customers.list({ limit: 100 });
return customers.data.find(
c => c.metadata?.user_id === userId.toString()
);
}

async chargeUser(userId, amount, currency) {
const customer = await this.getCustomerByUserId(userId);

if (!customer) {
throw new Error('Customer not found');
}

return await omise.charges.create({
customer: customer.id,
amount,
currency
});
}
}

การแก้ไขปัญหา

ไม่พบลูกค้า

// ตรวจสอบว่าลูกค้ามีอยู่เสมอก่อนปฏิบัติการ
async function safeRetrieveCustomer(customerId) {
try {
return await omise.customers.retrieve(customerId);
} catch (error) {
if (error.code === 'not_found') {
console.error('Customer does not exist:', customerId);
return null;
}
throw error;
}
}

ไม่มีวิธีการชำระเงิน

async function ensurePaymentMethod(customerId) {
const customer = await omise.customers.retrieve(customerId);

if (!customer.default_card) {
throw new Error('Customer has no payment method. Please add a card.');
}

return customer;
}

ลูกค้าที่ซ้ำกัน

// ป้องกันลูกค้าที่ซ้ำกัน
async function getOrCreateCustomer(email, data) {
// ค้นหาลูกค้าที่มีอยู่
const existing = await findCustomerByEmail(email);

if (existing) {
console.log('Customer already exists:', existing.id);
return existing;
}

// สร้างลูกค้าใหม่
return await omise.customers.create({
email,
...data
});
}

คำถามที่พบบ่อย

คำถามทั่วไป

ถาม: จะเกิดอะไรขึ้นกับข้อมูลลูกค้าเมื่อลบ?

ตอบ: เมื่อคุณลบลูกค้า บัตรที่เกี่ยวข้องทั้งหมดจะถูกลบด้วย การดำเนินการนี้ไม่สามารถย้อนกลับได้ การเรียกเก็บเงินหรือธุรกรรมยังคงอยู่ในประวัติบัญชีของคุณ

ถาม: ฉันสามารถคืนค่าลูกค้าที่ถูกลบได้หรือไม่?

ตอบ: ไม่ การลบลูกค้าเป็นแบบถาวร คุณจะต้องสร้างลูกค้าใหม่ด้วยข้อมูลเดียวกัน

ถาม: ลูกค้าสามารถมีบัตรได้กี่ใบ?

ตอบ: ไม่มีขีดจำกัดที่เข้มงวด แต่เราขอแนะนำให้จัดการจำนวนที่เหมาะสม (โดยปกติ 3-5 บัตรที่ใช้งาน) เพื่อประสบการณ์ผู้ใช้ที่ดีขึ้น

ถาม: ฉันสามารถมีที่อยู่อีเมลที่ซ้ำกันได้หรือไม่?

ตอบ: ใช่ ฟิลด์อีเมลไม่ไม่ซ้ำกัน คุณรับผิดชอบในการจัดการความไม่ซ้ำกันในแอปพลิเคชันของคุณหากจำเป็น

ถาม: ฉันจะเชื่อมโยงลูกค้ากับระบบผู้ใช้ของฉันได้อย่างไร?

ตอบ: ใช้ฟิลด์ข้อมูลเมตาเพื่อจัดเก็บ ID ผู้ใช้ภายในของคุณ ซึ่งช่วยให้คุณค้นหาลูกค้า Omise ได้อย่างง่ายดายตามระเบียนผู้ใช้ของคุณ

ถาม: ID ลูกค้าเหมือนกันในโหมดทดสอบและการทำงาน?

ตอบ: ไม่ ลูกค้าโหมดทดสอบ (cust_test_xxx) แยกจากลูกค้าโหมดการทำงาน (cust_xxx) คุณจะต้องสร้างลูกค้าแยกต่างหากในแต่ละโหมด

คำถามเกี่ยวกับการชำระเงิน

ถาม: ฉันสามารถเรียกเก็บเงินจากลูกค้าโดยไม่มี CVV ได้หรือไม่?

ตอบ: ใช่ เมื่อบัตรถูกบันทึกไปยังลูกค้า คุณสามารถเรียกเก็บเงินได้โดยไม่ต้องใช้ CVV โทเคนบัตรนั้นรวมข้อมูลความปลอดภัยที่จำเป็นอยู่แล้ว

ถาม: จะเกิดอะไรขึ้นหากบัตรของลูกค้าหมดอายุ?

ตอบ: การเรียกเก็บเงินจะล้มเหลว คุณควรตรวจสอบหัตถนาการ์ดที่กำลังจะหมดอายุและขอข้อมูลการชำระเงินที่อัปเดตจากลูกค้าอย่างลึกซึ้ง

ถาม: ฉันสามารถเรียกเก็บเงินจากลูกค้าในสกุลเงินต่างๆ ได้หรือไม่?

ตอบ: ใช่ คุณสามารถสร้างการเรียกเก็บเงินในสกุลเงินใดๆ ที่รองรับ ตามข้อจำกัดสกุลเงินของบัญชีของคุณ

ถาม: ฉันจัดการกับการชำระเงินสมาชิกที่ล้มเหลวได้อย่างไร?

ตอบ: ใช้ตรรมชาติการลองใหม่ด้วยการถ่อนความเสี่ยงแบบเลขชี้กำลัง แจ้งให้ลูกค้าทราบเกี่ยวกับการชำระเงินที่ล้มเหลว และให้วิธีง่ายๆ ในการอัปเดตข้อมูลการชำระเงิน

คำถามเกี่ยวกับวิธีปฏิบัติที่ดีที่สุด

ถาม: ฉันควรสร้างลูกค้าสำหรับการชำระเงินแบบครั้งเดียวหรือไม่?

ตอบ: ไม่จำเป็นสำหรับการชำระเงินแบบครั้งเดียวที่แท้จริง สร้างลูกค้าเมื่อคุณต้องการบันทึกข้อมูลการชำระเงินสำหรับการใช้ในอนาคต

ถาม: ฉันจัดการการย้ายข้อมูลลูกค้าได้อย่างไร?

ตอบ: ส่งออกข้อมูลลูกค้าจากระบบเก่า สร้างลูกค้า Omise และให้ผู้ใช้ป้อนข้อมูลการชำระเงินใหม่ (คุณไม่สามารถย้ายข้อมูลบัตรโดยตรงด้วยเหตุผลด้านความปลอดภัย)

ถาม: ฉันควรจัดเก็บอะไรในข้อมูลเมตา?

ตอบ: จัดเก็บ ID ภายในของคุณ สถานะการสมาชิก ข้อมูลแผน และข้อมูลอื่นๆ ที่จำเป็นสำหรับตรรมชาติทางธุรกิจ อย่าจัดเก็บข้อมูลที่ละเอียดอ่อน

ทรัพยากรที่เกี่ยวข้อง

ขั้นตอนถัดไป