Complyance Logo

Complyance TypeScript SDK

Production ready TypeScript SDK with comprehensive e-invoicing support for multiple countries including UAE, Germany, Saudi Arabia, Malaysia, and Belgium. Built for real-world e-invoice applications with full type safety.

Feature Summary

  • Multi-Country Support - UAE, Germany, KSA, Malaysia, Belgium
  • Full Type Safety - Complete TypeScript definitions
  • Promise-based - Modern async/await support
  • Tree-shakeable - Optimized bundle size

Installation

npm

npm install @complyance/sdk

yarn

yarn add @complyance/sdk

pnpm

pnpm add @complyance/sdk

Quick Start

Initialize the SDK

import { ComplyanceClient } from '@complyance/sdk';

const client = new ComplyanceClient({
  apiKey: 'your-api-key',
  baseUrl: 'https://api.complyance.io'
});

Submit an Invoice

import { Invoice } from '@complyance/sdk';

const invoice: Invoice = {
  documentType: 'Invoice',
  documentNumber: 'INV-001',
  issueDate: new Date(),
  currency: 'SAR',
  seller: {
    name: 'Example Company',
    taxIds: [
      { type: 'VAT', value: '300000000000003' }
    ]
  },
  buyer: {
    name: 'Customer Company'
  },
  lineItems: [
    {
      description: 'Product',
      quantity: 1,
      unitPrice: 100.00,
      taxRate: 15
    }
  ]
};

const result = await client.submitInvoice(invoice, 'SA');
console.log(`Invoice submitted: ${result.invoiceId}`);

Configuration

Environment Variables

export COMPLYANCE_API_KEY="your-api-key"
export COMPLYANCE_BASE_URL="https://api.complyance.io"

Configuration Object

import { ComplyanceClient, ComplyanceConfig } from '@complyance/sdk';

const config: ComplyanceConfig = {
  apiKey: process.env.COMPLYANCE_API_KEY!,
  baseUrl: process.env.COMPLYANCE_BASE_URL || 'https://api.complyance.io',
  timeout: 30000,
  retries: 3
};

const client = new ComplyanceClient(config);

Features

KSA (Saudi Arabia) - ZATCA Compliance

import { KSAInvoice, KSAExtensions } from '@complyance/sdk';

const ksaInvoice: KSAInvoice = {
  documentType: 'Standard',
  documentNumber: 'INV-001',
  // ... standard fields
  extensions: {
    sa_digital: {
      icv: '1',
      pih: 'NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==',
      qrCode: true
    }
  }
};

const result = await client.submitInvoice(ksaInvoice, 'SA');

UAE - FTA PINT Compliance

import { UAEInvoice } from '@complyance/sdk';

const uaeInvoice: UAEInvoice = {
  documentType: 'Tax Invoice',
  // ... standard fields
  extensions: {
    ae_identification: {
      trn: '100000000000003',
      uuid: crypto.randomUUID()
    }
  }
};

const result = await client.submitInvoice(uaeInvoice, 'AE');

Malaysia - MyInvois Integration

import { MalaysiaInvoice } from '@complyance/sdk';

const malaysiaInvoice: MalaysiaInvoice = {
  documentType: 'Invoice',
  // ... standard fields
  extensions: {
    my_identification: {
      softwareProviderId: 'SP-12345',
      documentId: 'DOC-001'
    },
    my_classification: {
      category: '001',
      productServiceCode: '12345'
    }
  }
};

const result = await client.submitInvoice(malaysiaInvoice, 'MY');

Error Handling

import { ComplyanceError, ValidationError } from '@complyance/sdk';

try {
  const result = await client.submitInvoice(invoice, 'SA');
  console.log(`Success: ${result.invoiceId}`);
} catch (error) {
  if (error instanceof ValidationError) {
    console.error('Validation Error:', error.message);
    error.validationErrors.forEach(err => {
      console.error(`- ${err.field}: ${err.message}`);
    });
  } else if (error instanceof ComplyanceError) {
    console.error(`API Error: ${error.statusCode} - ${error.message}`);
  } else {
    console.error('Unexpected error:', error);
  }
}

React Integration

import { useState } from 'react';
import { useComplyance } from '@complyance/sdk/react';

function InvoiceSubmit() {
  const { submitInvoice, loading, error } = useComplyance();
  const [result, setResult] = useState(null);

  const handleSubmit = async (invoice: Invoice) => {
    const response = await submitInvoice(invoice, 'SA');
    setResult(response);
  };

  return (
    <div>
      {loading && <p>Submitting...</p>}
      {error && <p>Error: {error.message}</p>}
      {result && <p>Invoice ID: {result.invoiceId}</p>}
    </div>
  );
}

Support

  • Contact: Contact Complyance for E-Invoicing - Complyance has helped over 1000+ organizations simplify global e-invoicing. Let us help you understand how Complyance can work for you.