Ressources / Exemples de Code

Exemples de Code & Échantillons

Exemples de code prêts à utiliser pour accélérer votre intégration

📄
Facturation

Créer Facture avec Articles

Exemple complet de création d'une facture avec lignes d'articles et calcul de taxe

JavaScript
Webhooks

Traiter Webhook de Paiement

Gérer les événements webhook pour traitement et vérification de paiement

Python
👥
Clients

Gestion Client

Opérations CRUD pour enregistrements client avec intégration Laravel

PHP
📊
Rapports

Générer Rapports Financiers

Créer des rapports PDF avec graphiques et résumés financiers

JavaScript
📋
Facturation

Création de Factures en Masse

Importer et créer plusieurs factures depuis fichier CSV

Python
📧
Notifications

Notifications Email

Envoyer notifications email personnalisées avec pièces jointes facture

Ruby

Exemple en Vedette

Exemple Complet de Création de Facture

Flux de travail complet incluant création client, calcul de taxe, et livraison email

// 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();

Collections d'Échantillons

Commencer

8 échantillons

Exemples de base pour vous lancer

Exemples Avancés

15 échantillons

Cas d'usage complexes et meilleures pratiques

Modèles d'Intégration

12 échantillons

Scénarios d'intégration courants

Contributions Communauté

Partagez Vos Exemples de Code

Vous avez un exemple de code utile ? Contribuez à notre dépôt d'échantillons et aidez d'autres développeurs de la communauté.

Commencez à Construire Plus Vite

Utilisez nos exemples de code pour intégrer Laabam en minutes, pas en heures