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

WeChat Pay

รับชำระเงินจาก WeChat Pay ซึ่งรวมเข้ากับแอป WeChat ที่มีผู้ใช้ 1.3 พันล้านคน โดย WeChat Pay เป็นหนึ่งในแพลตฟอร์มการชำระเงินผ่านมือถือที่โดดเด่นที่สุดในจีน มีการรวมเข้ากับระบบนิเวศ WeChat อย่างราบรื่น

ภาพรวม

WeChat Pay (เรียกว่า Weixin Pay ในจีน) เป็นโซลูชันการชำระเงินผ่านมือถือของ Tencent ที่รวมเข้าโดยตรงในแอป WeChat Messaging ด้วยการรวมเข้ากับ WeChat messaging (มีผู้ใช้ 1.3 พันล้านคน) WeChat Pay เป็นหนึ่งในแพลตฟอร์มการชำระเงินที่โดดเด่นที่สุดในจีน เป็นหนึ่งในสองวิธีการชำระเงินที่ใหญ่ที่สุดในจีนพร้อมกับ Alipay WeChat Pay ช่วยให้การชำระเงินทันทีผ่านรหัส QR การซื้อในแอป และมินิโปรแกรมได้

คุณสมบัติหลัก:

  • รวมเข้ากับ WeChat - เข้าถึงผู้ใช้ 1.3 พันล้าน+ คนทั่วจีนและชุมชนจีนต่างประเทศ
  • การรวมเข้า WeChat - การชำระเงินแบบราบรื่นภายในระบบนิเวศแอป WeChat
  • การชำระเงินผ่านรหัส QR - ประสบการณ์การชำระเงินที่รวดเร็วและไม่ต้องสัมผัส
  • รองรับข้ามพรมแดน - รับชำระเงินจากนักท่องเที่ยวชาวจีนทั่วโลก
  • หลายสกุลเงิน - ชำระเงินเป็น THB, SGD, MYR, JPY, USD
  • มินิโปรแกรม - สร้างประสบการณ์อีคอมเมิร์ซภายใน WeChat

ภูมิภาคที่รองรับ

ภูมิภาคสกุลเงินจำนวนเงินขั้นต่ำจำนวนเงินสูงสุดชำระเงิน
ไทยTHB฿1.00฿100,000THB
สิงคโปร์SGDS$0.10S$5,000SGD
มาเลเซียMYRRM1.00RM20,000MYR
ญี่ปุ่นJPY¥100¥1,000,000JPY
ฮ่องกงHKDHK$1.00HK$50,000HKD
การชำระเงินข้ามพรมแดน

WeChat Pay มีค่ามากโดยเฉพาะสำหรับผู้ค้าที่มุ่งเน้นนักท่องเที่ยวชาวจีนหรืออีคอมเมิร์ซข้ามพรมแดน ลูกค้าชำระเงินเป็น CNY คุณได้รับชำระเงินเป็นสกุลเงินท้องถิ่นของคุณ

วิธีการทำงาน

ประสบการณ์ลูกค้า:

  1. ลูกค้าเลือก "WeChat Pay" ที่หน้าชำระเงิน
  2. รหัส QR ถูกแสดงบนหน้าจอ
  3. ลูกค้าเปิดแอป WeChat และสแกนรหัส QR
  4. ตรวจสอบรายละเอียดการทำรายการใน WeChat
  5. ยืนยันการชำระเงินด้วยรหัสผ่าน WeChat Pay หรือลายนิ้วมือ
  6. กลับไปยังเว็บไซต์ผู้ค้า
  7. รับการยืนยันการชำระเงิน

เวลาในการทำรายการโดยทั่วไป: 30-90 วินาที

การใช้งาน

ขั้นตอนที่ 1: สร้าง WeChat Pay Source

curl https://api.omise.co/sources \
-u skey_test_YOUR_SECRET_KEY: \
-d "type=wechat_pay" \
-d "amount=10000" \
-d "currency=THB"

การตอบสนอง:

{
"object": "source",
"id": "src_test_5rt6s9vah5lkvi1rh9c",
"type": "wechat_pay",
"flow": "redirect",
"amount": 10000,
"currency": "THB",
"scannable_code": {
"type": "qr",
"image": {
"uri": "https://omise.co/qr/...",
"download_uri": "https://api.omise.co/..."
}
}
}

ขั้นตอนที่ 2: สร้าง Charge

curl https://api.omise.co/charges \
-u skey_test_YOUR_SECRET_KEY: \
-d "amount=10000" \
-d "currency=THB" \
-d "source=src_test_5rt6s9vah5lkvi1rh9c" \
-d "return_uri=https://yourdomain.com/payment/callback"

ขั้นตอนที่ 3: แสดงรหัส QR

app.post('/checkout/wechat-pay', async (req, res) => {
try {
const { amount, order_id } = req.body;

// ตรวจสอบจำนวนเงิน
if (amount < 100 || amount > 10000000) {
return res.status(400).json({
error: 'Amount must be between ฿1 and ฿100,000'
});
}

// สร้าง source
const source = await omise.sources.create({
type: 'wechat_pay',
amount: amount,
currency: 'THB'
});

// สร้าง charge
const charge = await omise.charges.create({
amount: amount,
currency: 'THB',
source: source.id,
return_uri: `${process.env.BASE_URL}/payment/callback`,
metadata: {
order_id: order_id
}
});

// ส่งกลับ URL รหัส QR เพื่อแสดง
res.json({
qr_code_url: charge.source.scannable_code.image.uri,
charge_id: charge.id,
expires_at: new Date(Date.now() + 5 * 60 * 1000) // 5 นาที
});

} catch (error) {
console.error('WeChat Pay error:', error);
res.status(500).json({ error: error.message });
}
});

ขั้นตอนที่ 4: แสดง UI รหัส QR

<!DOCTYPE html>
<html>
<head>
<title>WeChat Pay Checkout</title>
<style>
.wechat-pay-container {
max-width: 400px;
margin: 50px auto;
text-align: center;
padding: 30px;
border: 1px solid #e0e0e0;
border-radius: 10px;
}
.qr-code {
width: 300px;
height: 300px;
margin: 20px auto;
border: 1px solid #ddd;
padding: 10px;
background: white;
}
.wechat-logo {
width: 60px;
height: 60px;
margin-bottom: 15px;
}
.countdown {
font-size: 18px;
color: #666;
margin-top: 15px;
}
.instructions {
color: #666;
margin: 20px 0;
line-height: 1.6;
}
</style>
</head>
<body>
<div class="wechat-pay-container">
<img src="/images/wechat-logo.svg" class="wechat-logo" alt="WeChat Pay">
<h2>Scan to Pay with WeChat</h2>

<div class="qr-code">
<img id="qr-image" src="" alt="WeChat Pay QR Code" style="width: 100%; height: 100%;">
</div>

<div class="instructions">
<ol style="text-align: left;">
<li>Open WeChat app on your phone</li>
<li>Tap the "+" icon and select "Scan QR Code"</li>
<li>Scan the QR code above</li>
<li>Confirm payment in WeChat</li>
</ol>
</div>

<div class="countdown">
Time remaining: <span id="timer">5:00</span>
</div>

<p style="color: #999; font-size: 14px; margin-top: 20px;">
Payment amount: <strong id="amount"></strong>
</p>
</div>

<script>
// Countdown timer
let timeLeft = 300; // 5 นาที
const timerElement = document.getElementById('timer');

const countdown = setInterval(() => {
timeLeft--;
const minutes = Math.floor(timeLeft / 60);
const seconds = timeLeft % 60;
timerElement.textContent = `${minutes}:${seconds.toString().padStart(2, '0')}`;

if (timeLeft <= 0) {
clearInterval(countdown);
alert('QR code expired. Please try again.');
window.location.href = '/checkout';
}
}, 1000);

// Poll for payment status
const chargeId = new URLSearchParams(window.location.search).get('charge_id');

const checkStatus = setInterval(async () => {
try {
const response = await fetch(`/api/check-payment-status/${chargeId}`);
const data = await response.json();

if (data.status === 'successful') {
clearInterval(checkStatus);
clearInterval(countdown);
window.location.href = '/payment-success';
} else if (data.status === 'failed') {
clearInterval(checkStatus);
clearInterval(countdown);
window.location.href = '/payment-failed';
}
} catch (error) {
console.error('Status check error:', error);
}
}, 3000); // ตรวจสอบทุก 3 วินาที

// Load QR code
fetch('/api/create-wechat-payment', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
amount: 10000,
order_id: 'ORD-12345'
})
})
.then(res => res.json())
.then(data => {
document.getElementById('qr-image').src = data.qr_code_url;
document.getElementById('amount').textContent = `฿${(data.amount / 100).toFixed(2)}`;
});
</script>
</body>
</html>

ขั้นตอนที่ 5: จัดการ Webhook

app.post('/webhooks/omise', (req, res) => {
const event = req.body;

if (event.key === 'charge.complete' && event.data.source.type === 'wechat_pay') {
const charge = event.data;

if (charge.status === 'successful') {
processOrder(charge.metadata.order_id);
sendConfirmationEmail(charge.metadata.customer_email);
} else if (charge.status === 'failed') {
handleFailedPayment(charge.metadata.order_id);
}
}

res.sendStatus(200);
});

ตัวอย่างการใช้งานแบบสมบูรณ์

// Express.js server
const express = require('express');
const omise = require('omise')({
secretKey: process.env.OMISE_SECRET_KEY
});

const app = express();
app.use(express.json());

// สร้างการชำระเงิน WeChat Pay
app.post('/api/create-wechat-payment', async (req, res) => {
try {
const { amount, order_id, customer_email } = req.body;

// ตรวจสอบจำนวนเงิน (฿1 - ฿100,000)
if (amount < 100 || amount > 10000000) {
return res.status(400).json({
error: 'Amount must be between ฿1 and ฿100,000'
});
}

// สร้าง source
const source = await omise.sources.create({
type: 'wechat_pay',
amount: amount,
currency: 'THB'
});

// สร้าง charge
const charge = await omise.charges.create({
amount: amount,
currency: 'THB',
source: source.id,
return_uri: `${process.env.BASE_URL}/payment/callback`,
metadata: {
order_id: order_id,
customer_email: customer_email,
payment_method: 'wechat_pay'
}
});

// ส่งกลับรหัส QR
res.json({
charge_id: charge.id,
qr_code_url: charge.source.scannable_code.image.uri,
amount: charge.amount,
expires_at: new Date(Date.now() + 5 * 60 * 1000)
});

} catch (error) {
console.error('WeChat Pay error:', error);
res.status(500).json({ error: error.message });
}
});

// ตรวจสอบสถานะการชำระเงิน (สำหรับการสอบถาม)
app.get('/api/check-payment-status/:chargeId', async (req, res) => {
try {
const charge = await omise.charges.retrieve(req.params.chargeId);
res.json({
status: charge.status,
paid: charge.paid
});
} catch (error) {
res.status(500).json({ error: error.message });
}
});

// ตัวจัดการ webhook (วิธีการแจ้งเตือนหลัก)
app.post('/webhooks/omise', (req, res) => {
const event = req.body;

if (event.key === 'charge.complete') {
const charge = event.data;

if (charge.source.type === 'wechat_pay') {
if (charge.status === 'successful') {
updateOrderStatus(charge.metadata.order_id, 'paid');
sendConfirmationEmail(charge.metadata.customer_email);

// บันทึกการชำระเงินที่สำเร็จ
console.log(`WeChat Pay payment successful: ${charge.id}`);
} else {
updateOrderStatus(charge.metadata.order_id, 'failed');

// บันทึกการชำระเงินที่ล้มเหลว
console.log(`WeChat Pay payment failed: ${charge.id}, reason: ${charge.failure_message}`);
}
}
}

res.sendStatus(200);
});

// ฟังก์ชันวิธีการช่วยเหลือ
async function updateOrderStatus(orderId, status) {
// อัปเดตคำสั่งซื้อในฐานข้อมูล
await db.orders.update({ id: orderId }, { status: status });
}

async function sendConfirmationEmail(email) {
// ส่งการยืนยันอีเมล
// การใช้งานขึ้นอยู่กับบริการอีเมล
}

app.listen(3000, () => {
console.log('Server running on port 3000');
});

การรองรับการคืนเงิน

WeChat Pay รองรับ การคืนเงินแบบเต็มและบางส่วน ภายใน 90 วัน:

// การคืนเงินแบบเต็ม
const fullRefund = await omise.charges.refund('chrg_test_...', {
amount: 10000
});

// การคืนเงินบางส่วน
const partialRefund = await omise.charges.refund('chrg_test_...', {
amount: 5000 // การคืนเงินครึ่งหนึ่ง
});
เส้นเวลาการคืนเงิน
  • การคืนเงินจะประมวลผลภายใน 1-3 วันธุรกิจ
  • ลูกค้าได้รับการคืนเงินในกระเป๋า WeChat ของพวกเขา
  • รองรับภายใน 90 วันของการทำรายการเดิม
นโยบายการคืนเงิน

หน้าต่างการคืนเงินและนโยบายอาจมีการเปลี่ยนแปลง ตรวจสอบความสามารถในการคืนเงินปัจจุบันเสมอผ่านเอกสาร API ของ Omise หรือแดชบอร์ดผู้ค้าของคุณ

ปัญหาทั่วไปและการแก้ไขปัญหา

ปัญหา: ไม่สามารถสแกนรหัส QR

สาเหตุ: ลูกค้าใช้เครื่องสแกน QR ที่ไม่เข้ากันหรือรหัสที่หมดอายุ

วิธีแก้:

// ตรวจสอบให้แน่ใจว่ารหัส QR ใหม่และถูกต้อง
function displayQRCode(qrCodeUrl, expiresAt) {
const qrImage = document.getElementById('qr-code');
qrImage.src = qrCodeUrl;

// แสดงการเตือนเรื่องการหมดอายุ
const timeUntilExpiry = new Date(expiresAt) - Date.now();
if (timeUntilExpiry < 60000) { // น้อยกว่า 1 นาที
showWarning('QR code expiring soon! Please scan now.');
}
}

// ให้ตัวเลือกในการรีเฟรช
function refreshQRCode() {
// สร้างรหัส QR ใหม่
createNewPayment();
}

ปัญหา: หมดเวลาการชำระเงิน

สาเหตุ: ลูกค้าไม่ได้ทำการชำระเงินให้เสร็จสิ้นภายใน 5 นาที

วิธีแก้:

// ตั้งค่าเวลาที่เหมาะสม
const QR_EXPIRY_TIME = 5 * 60 * 1000; // 5 นาที

setTimeout(() => {
if (!paymentConfirmed) {
showMessage('Payment session expired. Please create a new payment.');
enableRetry();
}
}, QR_EXPIRY_TIME);

ปัญหา: แอป WeChat ไม่เปิดบนมือถือ

สาเหตุ: ปัญหา Deep link บนเบราว์เซอร์มือถือ

วิธีแก้:

function isMobileDevice() {
return /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
}

if (isMobileDevice()) {
// พยายามเปิดแอป WeChat โดยตรง
window.location = `weixin://dl/business/?t=${encodeURIComponent(qrCodeData)}`;

// กลับไปที่การแสดงรหัส QR
setTimeout(() => {
if (document.hidden === false) {
displayQRCodeFallback();
}
}, 2000);
} else {
// เดสก์ท็อป: แสดงรหัส QR
displayQRCode();
}

ปัญหา: ความสับสนในการแปลงเงินตรา

สาเหตุ: ลูกค้าเห็น CNY ผู้ค้าเห็น THB

วิธีแก้:

// แสดงสกุลเงินทั้งสองอย่างชัดเจน
function displayPaymentAmount(amountTHB, exchangeRate) {
const amountCNY = amountTHB * exchangeRate;

return `
<div class="payment-amount">
<p>You pay: ¥${amountCNY.toFixed(2)} CNY</p>
<p class="small">ร้านค้า receives: ฿${(amountTHB / 100).toFixed(2)} THB</p>
<p class="small">Exchange rate: 1 THB = ${exchangeRate.toFixed(4)} CNY</p>
</div>
`;
}

ปัญหา: การชำระเงินติดอยู่ในสถานะค้างอยู่

สาเหตุ: ปัญหาเครือข่ายหรือการแจ้งเตือนที่ล่าช้าจาก WeChat

วิธีแก้:

// ใช้การตรวจสอบสถานะที่มั่นคง
async function checkPaymentStatus(chargeId, maxAttempts = 10) {
let attempts = 0;

const checkInterval = setInterval(async () => {
attempts++;

try {
const charge = await omise.charges.retrieve(chargeId);

if (charge.status === 'successful') {
clearInterval(checkInterval);
handleSuccess(charge);
} else if (charge.status === 'failed') {
clearInterval(checkInterval);
handleFailure(charge);
} else if (attempts >= maxAttempts) {
clearInterval(checkInterval);
handleTimeout(charge);
}
} catch (error) {
console.error('Status check error:', error);
}
}, 3000); // ตรวจสอบทุก 3 วินาที
}

แนวทางปฏิบัติที่ดีที่สุด

1. แสดงรหัส QR ที่ชัดเจน

// สร้างการแสดงรหัส QR คุณภาพสูง
function displayQRCode(qrUrl) {
return `
<div class="qr-container">
<img src="${qrUrl}"
alt="WeChat Pay QR Code"
style="width: 300px; height: 300px; padding: 20px; background: white; border: 2px solid #09BB07;">
<p style="color: #09BB07; margin-top: 15px;">
<strong>Scan with WeChat to Pay</strong>
</p>
</div>
`;
}

2. ใช้ Countdown Timer

function startCountdown(duration, onExpire) {
let timeLeft = duration;
const display = document.getElementById('timer');

const timer = setInterval(() => {
const minutes = Math.floor(timeLeft / 60);
const seconds = timeLeft % 60;

display.textContent = `${minutes}:${seconds.toString().padStart(2, '0')}`;

// การเตือนหลังจาก 1 นาที
if (timeLeft === 60) {
display.style.color = 'red';
showWarning('Only 1 minute remaining!');
}

if (--timeLeft < 0) {
clearInterval(timer);
onExpire();
}
}, 1000);

return timer;
}

3. ใช้ Webhooks เพื่อความน่าเชื่อถือ

// Webhook ที่เชื่อถือได้มากกว่าการสอบถาม
app.post('/webhooks/omise', handleWebhook);

// การสอบถามเป็นการสำรองสำหรับการอัปเดต UI
const statusCheckInterval = setInterval(checkStatus, 3000);

4. ตรวจสอบข้อจำกัดจำนวนเงิน

function validateWeChatPayAmount(amount, currency) {
const limits = {
'THB': { min: 100, max: 10000000 },
'SGD': { min: 10, max: 500000 },
'MYR': { min: 100, max: 2000000 },
'JPY': { min: 100, max: 100000000 }
};

const limit = limits[currency];
if (!limit) {
return 'Currency not supported';
}

if (amount < limit.min) {
return `Minimum amount is ${formatCurrency(limit.min, currency)}`;
}

if (amount > limit.max) {
return `Maximum amount is ${formatCurrency(limit.max, currency)}`;
}

return null; // ถูกต้อง
}

5. จัดการสถานการณ์ข้ามพรมแดน

// ให้ข้อมูลที่ชัดเจนเกี่ยวกับการแปลงเงินตรา
function displayCrossBorderInfo(amountLocal, currency) {
return `
<div class="cross-border-info">
<h4>Cross-Border Payment</h4>
<ul>
<li>You will be charged in Chinese Yuan (CNY)</li>
<li>Your bank/WeChat will handle currency conversion</li>
<li>ร้านค้า receives: ${formatCurrency(amountLocal, currency)}</li>
<li>Final amount depends on exchange rate at payment time</li>
</ul>
</div>
`;
}

6. เพิ่มประสิทธิภาพสำหรับมือถือ

// ตรวจหา mobile และให้ UX ที่ดีขึ้น
if (isMobileDevice()) {
// แสดงรหัส QR ที่ใหญ่ขึ้นบน mobile
qrCodeElement.style.width = '90vw';
qrCodeElement.style.maxWidth = '400px';

// เพิ่มคำแนะนำสำหรับ mobile
showInstructions('Take a screenshot or tap to save QR code, then open WeChat to scan');
}

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

WeChat Pay คืออะไร?

WeChat Pay คือโซลูชันการชำระเงินผ่านมือถือของ Tencent ที่รวมเข้าในแอป WeChat messaging ด้วยผู้ใช้มากกว่า 1.3 พันล้านคน เป็นหนึ่งในสองวิธีการชำระเงินที่โดดเด่นที่สุดในจีนพร้อมกับ Alipay ลูกค้าสามารถชำระเงินได้ทันทีโดยใช้รหัส QR หรือการชำระเงินในแอป

ฉันต้องมีบัญชีธนาคารจีนเพื่อรับ WeChat Pay หรือไม่?

ไม่ คุณไม่ต้องมีบัญชีธนาคารจีน Omise จัดการกับความซับซ้อนของการชำระเงินข้ามพรมแดน ลูกค้าของคุณชำระเงินเป็น CNY จากกระเป๋า WeChat ของพวกเขา และคุณได้รับชำระเงินเป็นสกุลเงินท้องถิ่นของคุณ (THB, SGD, MYR, JPY ฯลฯ)

ข้อจำกัดการทำรายการคืออะไร?

ข้อจำกัดแตกต่างกันตามภูมิภาค:

  • ไทย: ฿1 - ฿100,000
  • สิงคโปร์: S$0.10 - S$5,000
  • มาเลเซีย: RM1 - RM20,000
  • ญี่ปุ่น: ¥100 - ¥1,000,000

ข้อจำกัดของลูกค้าแต่ละรายอาจแตกต่างกันไปตามระดับการยืนยันตัวตน WeChat Pay และการตั้งค่าธนาคารของพวกเขา

การชำระเงินใช้เวลานานเท่าใด?

การชำระเงิน WeChat Pay โดยทั่วไปจะเกิดขึ้นภายใน 2-3 วันธุรกิจหลังจากการทำรายการ เวลาที่แน่นอนขึ้นอยู่กับสัญญาผู้ค้าและตารางเวลาการชำระเงินของคุณ ตรวจสอบแดชบอร์ด Omise ของคุณสำหรับวันที่เฉพาะ

ฉันสามารถคืนเงินการชำระเงิน WeChat Pay ได้หรือไม่?

ใช่ WeChat Pay รองรับการคืนเงินแบบเต็มและบางส่วนภายใน 90 วันนับจากการทำรายการเดิม การคืนเงินจะประมวลผลภายใน 1-3 วันธุรกิจและส่งกลับไปยังกระเป๋า WeChat ของลูกค้า

รหัส QR จะใช้ได้นานแค่ไหน?

รหัส QR WeChat Pay โดยทั่วไปหมดอายุหลังจาก 5 นาที หลังจากหมดอายุ คุณต้องสร้างรหัส QR ใหม่สำหรับลูกค้า แสดง countdown timer เสมอเพื่อแจ้งให้ลูกค้าทราบเวลาที่เหลือ

ลูกค้าสามารถชำระเงินจากนอกจีนได้หรือไม่?

ใช่ WeChat Pay รองรับการชำระเงินข้ามพรมแดน นักท่องเที่ยวชาวจีนและผู้ใช้จีนต่างประเทศสามารถชำระเงินโดยใช้บัญชี WeChat Pay ที่ใช้ในจีนได้ อย่างไรก็ตาม ผู้ใช้ที่มีบัญชี WeChat ที่ไม่ใช่จีนอาจมีความสามารถในการชำระเงินที่จำกัดขึ้นอยู่กับภูมิภาคและสถานะการยืนยันตัวตนของพวกเขา

ความแตกต่างระหว่าง WeChat Pay และ Alipay คืออะไร?

ทั้งสองเป็นกระเป๋าเงินดิจิทัลจีนที่มีคุณสมบัติที่คล้ายคลึงกัน:

  • WeChat Pay: ผู้ใช้ 1.3B ผู้ใช้ รวมเข้ากับการส่งข้อความ WeChat มีความเข้มแข็งในการชำระเงินทางสังคม
  • Alipay: ผู้ใช้ 1B+ เจ้าของโดย Alibaba มีความเข้มแข็งในอีคอมเมิร์ซ

เพื่อให้บรรลุสูงสุดในตลาดจีน ให้ใช้วิธีการชำระเงินทั้งสอง

ฉันต้องแสดงภาษาจีนหรือไม่?

แม้ว่าจะไม่จำเป็น แต่การแสดงคำแนะนำการชำระเงินเป็นภาษาจีนสามารถปรับปรุงอัตราการแปลงสำหรับลูกค้าชาวจีน อินเทอร์เฟซ WeChat Pay นั้นอยู่ในภาษาที่ลูกค้าต้องการเสมอ (โดยปกติเป็นภาษาจีน)

การทดสอบ

โหมดทดสอบ

WeChat Pay สามารถทดสอบได้โดยใช้คีย์ API ทดสอบของคุณ ในโหมดทดสอบ:

ข้อมูลประจำตัวสำหรับการทดสอบ:

  • ใช้คีย์ API ทดสอบ (skey_test_xxx)
  • สกุลเงินที่รองรับการทดสอบ: THB, SGD, MYR, JPY
  • ไม่จำเป็นต้องมีบัญชี WeChat จริงสำหรับการทดสอบ

ขั้นตอนการทดสอบ:

  1. สร้าง source และ charge ด้วยคีย์ API ทดสอบ
  2. มีการสร้างรหัส QR ในโหมดทดสอบ
  3. รหัส QR ทดสอบแสดง แต่จะไม่เชื่อมต่อกับ WeChat จริง
  4. ใช้ Omise Dashboard Actions เพื่อทำเครื่องหมายการเรียกเก็บเงินว่าสำเร็จ/ล้มเหลว
  5. ตรวจสอบการจัดการ webhook

การใช้งานการทดสอบ:

// ทดสอบ WeChat Pay สำหรับสกุลเงินต่างๆ
const testConfigs = [
{ currency: 'THB', amount: 10000 },
{ currency: 'SGD', amount: 1000 },
{ currency: 'MYR', amount: 1000 },
{ currency: 'JPY', amount: 10000 }
];

for (const config of testConfigs) {
const source = await omise.sources.create({
type: 'wechat_pay',
amount: config.amount,
currency: config.currency
});

const charge = await omise.charges.create({
amount: config.amount,
currency: config.currency,
source: source.id
});

console.log(`Test ${config.currency} QR:`, charge.source.scannable_code.image.download_uri);
}

สถานการณ์การทดสอบ:

  • การชำระเงินที่สำเร็จ: ตรวจสอบขั้นตอนการทำงานเสร็จสิ้นการสั่งซื้อ
  • การชำระเงินที่ล้มเหลว: ทดสอบการจัดการข้อผิดพลาด
  • การแสดงรหัส QR: ทดสอบการแสดงรหัส QR บนเดสก์ท็อป/มือถือ
  • สกุลเงินหลายรายการ: ทดสอบสกุลเงินที่รองรับทั้งหมด
  • ข้อจำกัดจำนวนเงิน: ตรวจสอบ min/max ต่อสกุลเงิน
  • การหมดอายุของรหัส QR: ทดสอบการจัดการเวลาหมดอายุ
  • มือถือเทียบกับเดสก์ท็อป: ทดสอบทั้งขั้นตอน
  • การส่งมอบ Webhook: ตรวจสอบการแจ้งเตือน webhook ทั้งหมด

หมายเหตุที่สำคัญ:

  • รหัส QR ในโหมดทดสอบจะไม่สแกนด้วยแอป WeChat จริง
  • ใช้แดชบอร์ดเพื่อจำลองการเสร็จสิ้นการชำระเงิน
  • ทดสอบสกุลเงินที่รองรับทั้งหมดก่อนปรับใช้งาน
  • ตรวจสอบการจัดการ webhook สำหรับสถานะทั้งหมด
  • ทดสอบทั้งการสแกน QR ของมือถือและการแสดง QR ของเดสก์ท็อป
  • ทดสอบการรองรับภาษาจีนหากกำลังกำหนดเป้าหมายลูกค้าชาวจีน

สำหรับคำแนะนำการทดสอบที่ครอบคลุม โปรดดูเอกสารการทดสอบ

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

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

  1. สร้าง WeChat Pay source
  2. ใช้งานการแสดงรหัส QR
  3. ตั้งค่าการจัดการ webhook
  4. ทดสอบขั้นตอนการชำระเงิน
  5. ปรับใช้งาน