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

การจัดการผู้รับ

ผู้รับคือบัญชีธนาคารที่สามารถรับการโอนได้ คู่มือนี้อธิบายวิธีการสร้าง ตรวจสอบ และจัดการผู้รับ

ภาพรวม

ผู้รับช่วยให้คุณสามารถ:

  • บัญชีธนาคารที่บันทึก: จัดเก็บรายละเอียดธนาคารอย่างปลอดภัย
  • ตรวจสอบและยืนยัน: KYC ตรวจสอบรายละเอียด
  • ผู้รับหลายคน: จัดการบัญชีธนาคารหลายแห่ง
  • การโอน: ส่งเงินไปยังผู้รับ
  • ตารางเวลา: เงินอุดหนุนปกติสำหรับผู้รับ

การสร้างผู้รับ

การสร้างผู้รับขั้นพื้นฐาน

const omise = require('omise')({
secretKey: 'skey_test_123456789'
});

async function createRecipient(bankDetails) {
const recipient = await omise.recipients.create({
name: bankDetails.accountHolder,
email: bankDetails.email,
description: bankDetails.description,
bank_account: {
brand: bankDetails.bankCode,
number: bankDetails.accountNumber,
name: bankDetails.accountHolder
}
});

console.log('Recipient created:', recipient.id);
console.log('Status:', recipient.active ? 'Active' : 'Inactive');
console.log('Verified:', recipient.verified ? 'Yes' : 'No');

return recipient;
}

// ตัวอย่างการใช้งาน
createRecipient({
accountHolder: 'John Doe',
email: 'john@example.com',
description: 'Main vendor account',
bankCode: 'bbl', // ธนาคารกรุงเทพ
accountNumber: '1234567890'
});
import omise

omise.api_secret = 'skey_test_123456789'

def create_recipient(bank_details):
"""สร้างผู้รับบัญชีธนาคาร"""
recipient = omise.Recipient.create(
name=bank_details['account_holder'],
email=bank_details['email'],
description=bank_details['description'],
bank_account={
'brand': bank_details['bank_code'],
'number': bank_details['account_number'],
'name': bank_details['account_holder']
}
)

print(f"Recipient created: {recipient.id}")
print(f"Active: {recipient.active}")
print(f"Verified: {recipient.verified}")

return recipient

การรับผู้รับและการแสดงรายชื่อ

รับผู้รับรายเดียว

async function getRecipient(recipientId) {
const recipient = await omise.recipients.retrieve(recipientId);

console.log('Recipient:', recipient.name);
console.log('Email:', recipient.email);
console.log('Bank:', recipient.bank_account.brand);
console.log('Last 4 digits:', recipient.bank_account.last_digits);
console.log('Verified:', recipient.verified);
console.log('Active:', recipient.active);

return recipient;
}

รายชื่อผู้รับทั้งหมด

async function listRecipients(status = 'verified') {
const recipients = await omise.recipients.list({
limit: 100,
order: 'reverse_chronological'
});

recipients.data.forEach(recipient => {
console.log(`${recipient.id}: ${recipient.name} (${recipient.verified ? 'Verified' : 'Unverified'})`);
});

return recipients;
}

การอัปเดตผู้รับ

อัปเดตข้อมูลผู้รับ

async function updateRecipient(recipientId, updates) {
const recipient = await omise.recipients.update(recipientId, {
name: updates.name,
email: updates.email,
description: updates.description,
metadata: updates.metadata
});

console.log('Recipient updated:', recipient.id);
return recipient;
}

อัปเดตบัญชีธนาคาร

async function updateBankAccount(recipientId, bankDetails) {
const recipient = await omise.recipients.update(recipientId, {
bank_account: {
brand: bankDetails.bankCode,
number: bankDetails.accountNumber,
name: bankDetails.accountHolder
}
});

console.log('Bank account updated');
return recipient;
}

การตรวจสอบผู้รับ

กระบวนการตรวจสอบ

def verify_recipient(recipient_id):
"""ตรวจสอบผู้รับด้วยตนเอง (จำเป็นต้องมีสิทธิ์การสนับสนุน)"""
recipient = omise.Recipient.retrieve(recipient_id)

if recipient.verified:
print(f"Recipient {recipient_id} is already verified")
return recipient

# อัปโหลดเอกสารการตรวจสอบ
verification = omise.Recipient.verify(
recipient_id,
documents={
'id_document': open('id.pdf', 'rb'),
'bank_account_verification': open('bank_verification.pdf', 'rb')
}
)

print(f"Verification submitted for {recipient_id}")
return verification

ตรวจสอบสถานะการตรวจสอบ

async function checkVerificationStatus(recipientId) {
const recipient = await omise.recipients.retrieve(recipientId);

const status = {
id: recipient.id,
name: recipient.name,
verified: recipient.verified,
active: recipient.active,
verification_status: recipient.verification?.status,
created: recipient.created_at
};

console.log('Verification Status:', JSON.stringify(status, null, 2));
return status;
}

การลบผู้รับ

ลบผู้รับ

async function deleteRecipient(recipientId) {
const result = await omise.recipients.destroy(recipientId);

console.log('Recipient deleted:', result.id);
console.log('Deleted:', result.deleted);

return result;
}

กรณีการใช้งานทั่วไป

ระบบการจัดการผู้ขาย

class VendorRecipientManager:
def __init__(self):
pass

def create_vendor_recipient(self, vendor_info):
"""สร้างผู้รับจากข้อมูลผู้ขาย"""
recipient = omise.Recipient.create(
name=vendor_info['vendor_name'],
email=vendor_info['contact_email'],
description=f"{vendor_info['vendor_category']} - {vendor_info['vendor_id']}",
bank_account={
'brand': vendor_info['bank_code'],
'number': vendor_info['account_number'],
'name': vendor_info['account_holder_name']
},
metadata={
'vendor_id': vendor_info['vendor_id'],
'vendor_category': vendor_info['vendor_category'],
'tax_id': vendor_info['tax_id']
}
)

return recipient

def bulk_create_vendors(self, vendor_list):
"""สร้างผู้ขายหลายรายเป็นกลุ่ม"""
results = {
'created': [],
'failed': []
}

for vendor in vendor_list:
try:
recipient = self.create_vendor_recipient(vendor)
results['created'].append({
'vendor_id': vendor['vendor_id'],
'recipient_id': recipient.id
})
print(f"✓ Created recipient for {vendor['vendor_name']}")

except Exception as e:
results['failed'].append({
'vendor_id': vendor['vendor_id'],
'error': str(e)
})
print(f"✗ Failed: {vendor['vendor_name']} - {str(e)}")

return results

ระบบเงินเดือนพนักงาน

class EmployeePaymentManager {
async createEmployeeRecipients(employees) {
const recipients = [];

for (const employee of employees) {
try {
const recipient = await omise.recipients.create({
name: employee.fullName,
email: employee.email,
description: `Employee: ${employee.employeeId}`,
bank_account: {
brand: employee.bankCode,
number: employee.accountNumber,
name: employee.fullName
},
metadata: {
employee_id: employee.employeeId,
department: employee.department,
position: employee.position,
salary: employee.baseSalary
}
});

recipients.push({
employeeId: employee.employeeId,
recipientId: recipient.id,
status: 'created'
});

console.log(`✓ Created for ${employee.fullName}`);

} catch (error) {
recipients.push({
employeeId: employee.employeeId,
error: error.message,
status: 'failed'
});
}
}

return recipients;
}

async updateEmployeeSalary(recipientId, newSalary) {
const recipient = await omise.recipients.retrieve(recipientId);

await omise.recipients.update(recipientId, {
metadata: {
...recipient.metadata,
salary: newSalary,
salary_updated_at: new Date().toISOString()
}
});

console.log(`Salary updated for ${recipient.name}`);
}
}

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

1. ตรวจสอบก่อนสร้างผู้รับ

function validateBankDetails(bankDetails) {
const errors = [];

if (!bankDetails.accountHolder) {
errors.push('Account holder name is required');
}

if (!bankDetails.accountNumber || bankDetails.accountNumber.length < 8) {
errors.push('Invalid account number');
}

if (!bankDetails.bankCode) {
errors.push('Bank code is required');
}

if (!bankDetails.email || !bankDetails.email.includes('@')) {
errors.push('Valid email is required');
}

return {
valid: errors.length === 0,
errors: errors
};
}

async function createValidatedRecipient(bankDetails) {
const validation = validateBankDetails(bankDetails);

if (!validation.valid) {
throw new Error(`Validation errors: ${validation.errors.join(', ')}`);
}

return await omise.recipients.create({
name: bankDetails.accountHolder,
email: bankDetails.email,
bank_account: {
brand: bankDetails.bankCode,
number: bankDetails.accountNumber,
name: bankDetails.accountHolder
}
});
}

2. ใช้ข้อมูลเมตาเพื่อเชื่อมโยงผู้รับ

async function createLinkedRecipient(bankDetails, internalId) {
const recipient = await omise.recipients.create({
name: bankDetails.accountHolder,
email: bankDetails.email,
description: `Internal ID: ${internalId}`,
bank_account: {
brand: bankDetails.bankCode,
number: bankDetails.accountNumber,
name: bankDetails.accountHolder
},
metadata: {
internal_id: internalId,
created_at: new Date().toISOString(),
source: 'api',
department: bankDetails.department
}
});

return recipient;
}

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

ฉันตรวจสอบข้อมูลผู้รับได้อย่างไร?

ผู้รับจะได้รับการตรวจสอบโดยอัตโนมัติหรืออาจต้องตรวจสอบด้วยตนเองโดยผู้สนับสนุน ปฏิบัติตามกระบวนการ KYC (Know Your Customer) โดยอัปโหลดหนังสือประจำตัวและเอกสารการยืนยันบัญชีธนาคาร

ฉันสามารถลบผู้รับได้หรือไม่?

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

ฉันสามารถมีผู้รับได้กี่คน?

ไม่มีข้อจำกัดที่เข้มงวดสำหรับจำนวนผู้รับ แต่แนะนำให้จัดการผู้รับที่ใช้งาน

ฉันสามารถอัปเดตที่อยู่อีเมลของผู้รับได้หรือไม่?

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

ฉันสามารถสร้างผู้รับสำหรับบัญชีธนาคารนอก ไทยได้หรือไม่?

ปัจจุบัน Omise รองรับการโอนไปยังบัญชีธนาคารไทยเท่านั้น

จะเกิดอะไรขึ้นหากผู้รับไม่ทำงาน?

คุณไม่สามารถสร้างการโอนไปยังผู้รับที่ไม่ทำงาน ติดต่อการสนับสนุน Omise เพื่อตรวจสอบสถานะผู้รับ

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