Complyance Logo

Complyance Go SDK

Production ready Go 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 idiomatic Go patterns.

Feature Summary

  • Multi-Country Support - UAE, Germany, KSA, Malaysia, Belgium
  • Type Safety - Strong typing with Go structs
  • Concurrent - Goroutine-safe operations
  • Go 1.18+ - Modern Go compatibility

Installation

go get github.com/complyance/go-sdk

Quick Start

Initialize the SDK

package main

import (
    "context"
    "fmt"
    "github.com/complyance/go-sdk"
)

func main() {
    client := complyance.NewClient(&complyance.Config{
        APIKey:  "your-api-key",
        BaseURL: "https://api.complyance.io",
    })
}

Submit an Invoice

package main

import (
    "context"
    "fmt"
    "time"
    "github.com/complyance/go-sdk"
)

func main() {
    client := complyance.NewClient(&complyance.Config{
        APIKey: "your-api-key",
    })

    invoice := &complyance.Invoice{
        DocumentType:   "Invoice",
        DocumentNumber: "INV-001",
        IssueDate:      time.Now(),
        Currency:       "SAR",
        Seller: &complyance.Party{
            Name: "Example Company",
            TaxIDs: []complyance.TaxID{
                {Type: "VAT", Value: "300000000000003"},
            },
        },
        Buyer: &complyance.Party{
            Name: "Customer Company",
        },
        LineItems: []complyance.LineItem{
            {
                Description: "Product",
                Quantity:    1,
                UnitPrice:   100.00,
                TaxRate:     15,
            },
        },
    }

    ctx := context.Background()
    result, err := client.SubmitInvoice(ctx, invoice, "SA")
    if err != nil {
        fmt.Printf("Error: %v\n", err)
        return
    }

    fmt.Printf("Invoice submitted: %s\n", result.InvoiceID)
}

Field Mapping Reference

For a comprehensive understanding of all available fields, validation rules, and country-specific requirements, refer to our detailed Field Mapping Payload Reference.

This reference provides:

  • Complete field documentation for all supported countries (SA, MY, BE, DE, AE)
  • Country-specific requirements and compliance rules
  • Field descriptions with examples and validation rules
  • Required vs Optional field indicators

Review this reference to ensure your payload structure meets all regulatory requirements for your target country.

Configuration

Environment Variables

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

Configuration Struct

config := &complyance.Config{
    APIKey:  os.Getenv("COMPLYANCE_API_KEY"),
    BaseURL: os.Getenv("COMPLYANCE_BASE_URL"),
    Timeout: 30 * time.Second,
    Retries: 3,
}

client := complyance.NewClient(config)

Features

KSA (Saudi Arabia) - ZATCA Compliance

ksaInvoice := &complyance.KSAInvoice{
    DocumentType:   "Standard",
    DocumentNumber: "INV-001",
    // ... standard fields
    Extensions: &complyance.KSAExtensions{
        SADigital: &complyance.SADigital{
            ICV:    "1",
            PIH:    "NWZlY2ViNjZmZmM4NmYzOGQ5NTI3ODZjNmQ2OTZjNzljMmRiYzIzOWRkNGU5MWI0NjcyOWQ3M2EyN2ZiNTdlOQ==",
            QRCode: true,
        },
    },
}

result, err := client.SubmitInvoice(ctx, ksaInvoice, "SA")

UAE - FTA PINT Compliance

uaeInvoice := &complyance.UAEInvoice{
    DocumentType: "Tax Invoice",
    // ... standard fields
    Extensions: &complyance.UAEExtensions{
        AEIdentification: &complyance.AEIdentification{
            TRN:  "100000000000003",
            UUID: generateUUID(),
        },
    },
}

result, err := client.SubmitInvoice(ctx, uaeInvoice, "AE")

Malaysia - MyInvois Integration

malaysiaInvoice := &complyance.MalaysiaInvoice{
    DocumentType: "Invoice",
    // ... standard fields
    Extensions: &complyance.MalaysiaExtensions{
        MYIdentification: &complyance.MYIdentification{
            SoftwareProviderID: "SP-12345",
            DocumentID:         "DOC-001",
        },
        MYClassification: &complyance.MYClassification{
            Category:           "001",
            ProductServiceCode: "12345",
        },
    },
}

result, err := client.SubmitInvoice(ctx, malaysiaInvoice, "MY")

Error Handling

result, err := client.SubmitInvoice(ctx, invoice, "SA")
if err != nil {
    switch e := err.(type) {
    case *complyance.ValidationError:
        fmt.Printf("Validation Error: %s\n", e.Message)
        for _, valErr := range e.ValidationErrors {
            fmt.Printf("- %s: %s\n", valErr.Field, valErr.Message)
        }
    case *complyance.APIError:
        fmt.Printf("API Error: %d - %s\n", e.StatusCode, e.Message)
    default:
        fmt.Printf("Unexpected error: %v\n", err)
    }
    return
}

fmt.Printf("Success: %s\n", result.InvoiceID)

Concurrent Operations

func submitMultipleInvoices(invoices []*complyance.Invoice) error {
    var wg sync.WaitGroup
    errChan := make(chan error, len(invoices))

    for _, invoice := range invoices {
        wg.Add(1)
        go func(inv *complyance.Invoice) {
            defer wg.Done()
            
            ctx := context.Background()
            result, err := client.SubmitInvoice(ctx, inv, "SA")
            if err != nil {
                errChan <- err
                return
            }
            
            fmt.Printf("Submitted: %s\n", result.InvoiceID)
        }(invoice)
    }

    wg.Wait()
    close(errChan)

    for err := range errChan {
        return err
    }

    return nil
}

Context and Cancellation

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

result, err := client.SubmitInvoice(ctx, invoice, "SA")
if err != nil {
    if ctx.Err() == context.DeadlineExceeded {
        fmt.Println("Request timed out")
    }
    return err
}

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.