Ready-to-use code examples to accelerate your integration
Complete example of creating an invoice with line items and tax calculation
Handle webhook events for payment processing and verification
CRUD operations for customer records with Laravel integration
Create PDF reports with charts and financial summaries
Import and create multiple invoices from CSV file
Send custom email notifications with invoice attachments
Full workflow including customer creation, tax calculation, and email delivery
// Invoice Creation with Tax Calculation
const Laabam = require('laabam-sdk');
const laabam = new Laabam(process.env.LAABAM_API_KEY);
async function createInvoiceWithTax() {
try {
// Create customer if doesn't exist
const customer = await laabam.customers.create({
name: "Acme Corporation",
email: "billing@acme.com",
phone: "+91-9876543210",
gstin: "29ABCDE1234F1Z5"
});
// Prepare invoice items
const items = [
{
description: "Professional Services - Month 1",
quantity: 1,
rate: 50000,
tax_rate: 18 // GST 18%
},
{
description: "Consulting Hours",
quantity: 40,
rate: 1500,
tax_rate: 18
}
];
// Calculate totals
const subtotal = items.reduce((sum, item) =>
sum + (item.quantity * item.rate), 0
);
const tax = subtotal * 0.18;
const total = subtotal + tax;
// Create invoice
const invoice = await laabam.invoices.create({
customer_id: customer.id,
invoice_date: new Date().toISOString().split('T')[0],
due_date: new Date(Date.now() + 30*24*60*60*1000)
.toISOString().split('T')[0],
items: items,
subtotal: subtotal,
tax: tax,
total: total,
currency: "INR",
notes: "Payment due within 30 days"
});
console.log(`Invoice created: ${invoice.id}`);
console.log(`Total amount: ₹${total}`);
// Send invoice via email
await laabam.invoices.send(invoice.id, {
to: customer.email,
subject: `Invoice #${invoice.invoice_number}`,
message: "Thank you for your business!"
});
return invoice;
} catch (error) {
console.error('Error creating invoice:', error);
throw error;
}
}
createInvoiceWithTax();8 samples
Basis examples to get you up and running
15 samples
Complex use cases and best practices
12 samples
Common integration scenarios
Have a useful code example? Contribute to our samples repository and help other developers in the community.
Use our code samples to integrate Laabam in minutes, not hours