No Facta library required
Call the public Supabase function URL directly. Keep API keys and signing keys on your server.
Prerequisite
Go net/http
Example
package main
import (
"bytes"
"fmt"
"net/http"
"os"
"strings"
)
func main() {
body := []byte(`{"tipoDte":"01","items":[{"descripcion":"Servicio","cantidad":1,"precioUni":10.0}]}`)
req, _ := http.NewRequest(http.MethodPost, strings.TrimRight(os.Getenv("FACTA_API_BASE_URL"), "/")+"/v1/dte", bytes.NewReader(body))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("X-Facta-Key", os.Getenv("FACTA_API_KEY"))
req.Header.Set("X-Facta-Sign-Key", os.Getenv("FACTA_SIGN_KEY"))
req.Header.Set("Idempotency-Key", "order-123")
response, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer response.Body.Close()
fmt.Println(response.Status)
}
See the HTTP reference for headers, responses and recovery rules.