Tài Nguyên / Webhooks

Thông Báo Sự Kiện Thời Gian Thực

Nhận thông báo ngay lập tức khi sự kiện xảy ra trong tài khoản Laabam của bạn

Thời Gian Thực

Được thông báo ngay lập tức khi sự kiện xảy ra

Đáng Tin Cậy

Tự động thử lại với backoff theo cấp số nhân

Được Giám Sát

Theo dõi trạng thái giao hàng và debug vấn đề

Sự Kiện Có Sẵn

invoice.created

Kích hoạt khi tạo hóa đơn mới

Payload Ví Dụ:

{
  "invoice_id": "inv_123",
  "status": "draft",
  "amount": 50000
}
invoice.paid

Kích hoạt khi nhận được thanh toán hóa đơn

Payload Ví Dụ:

{
  "invoice_id": "inv_123",
  "payment_id": "pay_456",
  "amount": 50000
}
customer.created

Kích hoạt khi thêm khách hàng mới

Payload Ví Dụ:

{
  "customer_id": "cust_789",
  "name": "John Doe",
  "email": "john@example.com"
}
payment.failed

Kích hoạt khi nỗ lực thanh toán thất bại

Payload Ví Dụ:

{
  "payment_id": "pay_456",
  "reason": "insufficient_funds"
}

Ví Dụ Triển Khai

Đây là cách xử lý webhook trong ứng dụng của bạn:

// Webhook endpoint example (Node.js/Express)
const express = require('express');
const app = express();

app.post('/webhooks/laabam', express.json(), (req, res) => {
  const event = req.body;
  
  // Verify webhook signature
  const signature = req.headers['x-laabam-signature'];
  if (!verifySignature(signature, req.body)) {
    return res.status(401).send('Invalid signature');
  }
  
  // Handle different event types
  switch (event.type) {
    case 'invoice.created':
      console.log('New invoice:', event.data.invoice_id);
      // Your business logic here
      break;
      
    case 'invoice.paid':
      console.log('Payment received:', event.data.payment_id);
      // Update your database, send email, etc.
      break;
  }
  
  res.status(200).send('Webhook received');
});

Webhook Của Bạn

https://api.yoursite.com/webhooks/laabam
HOẠT ĐỘNG
invoice.createdinvoice.paid

Giao Hàng Cuối

2 minutes ago

Tỷ Lệ Thành Công

99.8%

https://staging.yoursite.com/webhooks
HOẠT ĐỘNG
customer.createdpayment.failed

Giao Hàng Cuối

15 minutes ago

Tỷ Lệ Thành Công

100%

Thực Hành Tốt Nhất Webhook

  • Luôn xác minh chữ ký webhook để đảm bảo tính xác thực
  • Trả về mã trạng thái 200 nhanh chóng để xác nhận đã nhận
  • Xử lý dữ liệu webhook bất đồng bộ trong hàng đợi
  • Sử dụng điểm cuối HTTPS để đảm bảo bảo mật dữ liệu
  • Triển khai tính idempotency để xử lý các sự kiện trùng lặp

Bắt Đầu Sử Dụng Webhook

Xây dựng tích hợp thời gian thực với webhook Laabam