SDKs
Official Gatelithix SDKs provide typed, idiomatic wrappers around the REST API. Each SDK handles authentication, idempotency headers, and error parsing automatically.
Go SDK
Installation
go get github.com/paylithix/gatelithix-gateway/sdks/goQuick Start
package main
import (
"context"
"fmt"
"log"
gatelithix "github.com/paylithix/gatelithix-gateway/sdks/go"
)
func main() {
client := gatelithix.NewClient("sk_test_your_key_here",
gatelithix.WithBaseURL("https://sandbox.api.gatelithix.com"),
)
// Tokenize a card
token, err := client.Tokens.Create(context.Background(), &gatelithix.TokenizeParams{
PAN: "4242424242424242",
ExpMonth: 12,
ExpYear: 2028,
CardBrand: "visa",
})
if err != nil {
log.Fatal(err)
}
fmt.Println("Token:", token.Token)
// Authorize a payment
pi, err := client.Payments.Authorize(context.Background(), &gatelithix.AuthorizeParams{
Amount: 5000,
Currency: "usd",
GatewayToken: token.Token,
CaptureMethod: "manual",
})
if err != nil {
log.Fatal(err)
}
fmt.Println("Payment:", pi.ID, "Status:", pi.Status)
// Capture
captured, err := client.Payments.Capture(context.Background(), &gatelithix.CaptureParams{
PaymentIntentID: pi.ID,
})
if err != nil {
log.Fatal(err)
}
fmt.Println("Captured:", captured.Status)
}Error Handling
pi, err := client.Payments.Authorize(ctx, params)
if err != nil {
var apiErr *gatelithix.APIError
if errors.As(err, &apiErr) {
fmt.Println("Type:", apiErr.Type)
fmt.Println("Code:", apiErr.Code)
fmt.Println("Message:", apiErr.Message)
}
}Webhook Verification
valid := gatelithix.VerifyWebhookSignature(
requestBody,
signatureHeader,
webhookSecret,
5*time.Minute,
)TypeScript / Node SDK
Installation
npm install @gatelithix/sdkQuick Start
import { GatelithixClient } from "@gatelithix/sdk";
const client = new GatelithixClient("sk_test_your_key_here", {
baseURL: "https://sandbox.api.gatelithix.com",
});
// Tokenize a card
const token = await client.tokens.create(
{
pan: "4242424242424242",
exp_month: 12,
exp_year: 2028,
card_brand: "visa",
},
{ idempotencyKey: crypto.randomUUID() }
);
console.log("Token:", token.token);
// Authorize a payment
const payment = await client.payments.authorize(
{
amount: 5000,
currency: "usd",
gateway_token: token.token,
capture_method: "manual",
},
{ idempotencyKey: crypto.randomUUID() }
);
console.log("Payment:", payment.id, "Status:", payment.status);
// Capture
const captured = await client.payments.capture(
{ payment_intent_id: payment.id },
{ idempotencyKey: crypto.randomUUID() }
);
console.log("Captured:", captured.status);Error Handling
import { GatelithixError } from "@gatelithix/sdk";
try {
await client.payments.authorize(params);
} catch (err) {
if (err instanceof GatelithixError) {
console.log("Type:", err.type);
console.log("Code:", err.code);
console.log("Message:", err.message);
}
}Webhook Verification
import { verifyWebhookSignature } from "@gatelithix/sdk";
const isValid = verifyWebhookSignature(
requestBody,
signatureHeader,
webhookSecret,
300 // tolerance in seconds
);Python
There is no official Python SDK at this time. Use the requests library to call the REST API directly. See Getting Started for Python examples of all core flows.
import requests
import uuid
class GatelithixClient:
def __init__(self, api_key: str, base_url: str = "https://api.gatelithix.com"):
self.api_key = api_key
self.base_url = base_url
def _headers(self, idempotency_key: str = None):
headers = {
"Authorization": f"Bearer {self.api_key}",
"Content-Type": "application/json",
}
if idempotency_key:
headers["Idempotency-Key"] = idempotency_key
return headers
def authorize(self, amount: int, gateway_token: str, **kwargs):
return requests.post(
f"{self.base_url}/v1/payments/authorize",
headers=self._headers(str(uuid.uuid4())),
json={"amount": amount, "currency": "usd", "gateway_token": gateway_token, **kwargs},
).json()