Xendit sends webhooks (callbacks) for invoice events, such as successful payments. While you don't instantiate these objects yourself, you can use the InvoiceCallback type from xendit-node/invoice/models to type your webhook handler for better developer experience.
import { InvoiceCallback } from 'xendit-node/invoice/models'
// Example of how a callback object looks when received
const invoiceCallback: InvoiceCallback = {
"amount" : 2000000,
"paymentDestination" : "TEST815",
"created" : "2020-01-13T02:32:49.827Z",
"externalId" : "testing-invoice",
"description" : "Invoice webhook test",
"userId" : "5848fdf860053555135587e7",
"merchantName" : "Xendit",
"paymentChannel" : "ALFAMART",
"paymentMethod" : "RETAIL_OUTLET",
"paidAt" : "2020-01-14T02:32:50.912Z",
"currency" : "IDR",
"id" : "593f4ed1c3d3bb7f39733d83",
"paidAmount" : 2000000,
"payerEmail" : "test@xendit.co",
"updated" : "2020-01-13T02:32:50.912Z",
"status" : "PAID"
}
// Usage in a handler
function handleWebhook(invoiceCallback: InvoiceCallback) {
const { id } = invoiceCallback
// process the callback
}