SDKs
Two client libraries, one for Go and one for TypeScript, cover every /v1 route at API version 2026-10-23. Each sets the key, the version and the Idempotency-Key for you, signs requests when your account requires it, retries safely and verifies webhooks. Neither has a third-party runtime dependency.
Getting the SDKs
Both are open source under the MIT license, in the lemakpay organization on GitHub. Each release is a tag named after its version, for example v0.1.0.
- lemakpay/client-go
- The Go module
github.com/lemakpay/client-go. Go 1.24 or later, standard library only. - lemakpay/client-typescript
- The package
@lemakpay/client: ES modules with type declarations, built. Node 20.3 or later, Cloudflare Workers, Deno, and browsers for webhook verification. It usesfetchand WebCrypto only.
Install
Go
go get github.com/lemakpay/client-go@v0.1.0
TypeScript
npm install github:lemakpay/client-typescript#v0.1.0
Pin the tag, so every build installs the same code. The package is not on the npm registry yet.
Quickstart
Create a test payment intent, make it succeed, and read it back. The channel_preference and the simulate call are for test mode; see Testing.
Go
import lemak "github.com/lemakpay/client-go"
c := &lemak.Client{Key: "sk_test_MFWZLFDEM5X3WDBPM7ULRVDKCE"}
method := "promptpay"
pi, err := c.CreatePaymentIntent(ctx, lemak.PaymentIntentCreate{
Amount: 100000, // 1,000.00 THB in minor units
Currency: "THB",
MerchantOrderId: "order-1001",
PaymentMethod: &method,
}, nil)
if err != nil {
return err
}
_, err = c.SimulatePaymentIntent(ctx, pi.Id, lemak.PaymentIntentSimulate{
Outcome: lemak.PaymentIntentSimulateOutcomeSucceeded,
}, nil)
// The result follows by webhook. Read the intent before you act on it.
pi, err = c.PaymentIntent(ctx, pi.Id, nil)
TypeScript
import { Client } from "@lemakpay/client";
const lemak = new Client({ apiKey: "sk_test_MFWZLFDEM5X3WDBPM7ULRVDKCE" });
let pi = await lemak.createPaymentIntent({
amount: 100000, // 1,000.00 THB in minor units
currency: "THB",
merchant_order_id: "order-1001",
payment_method: "promptpay",
});
await lemak.simulatePaymentIntent(pi.id, { outcome: "succeeded" });
// The result follows by webhook. Read the intent before you act on it.
pi = await lemak.paymentIntent(pi.id);
Methods
One method per route, named after the route's operationId in the specification. Request and response types are generated from that specification.
| Route | Go | TypeScript |
|---|---|---|
POST /v1/payment_intents | CreatePaymentIntent | createPaymentIntent |
GET /v1/payment_intents | ListPaymentIntents | listPaymentIntents |
GET /v1/payment_intents/{id} | PaymentIntent | paymentIntent |
POST /v1/payment_intents/{id}/cancel | CancelPaymentIntent | cancelPaymentIntent |
POST /v1/payment_intents/{id}/attempts | CreatePaymentAttempt | createPaymentAttempt |
GET /v1/payment_intents/{id}/attempts | ListPaymentAttempts | listPaymentAttempts |
POST /v1/test/payment_intents/{id}/simulate | SimulatePaymentIntent | simulatePaymentIntent |
POST /v1/test/payment_intents/{id}/advance | AdvancePaymentIntent | advancePaymentIntent |
GET /v1/disputes | ListDisputes | listDisputes |
GET /v1/disputes/{id} | Dispute | dispute |
POST /v1/disputes/{id}/evidence | SubmitDisputeEvidence | submitDisputeEvidence |
POST /v1/settlements | CreateSettlement | createSettlement |
GET /v1/balance | Balance | balance |
GET /v1/fx/quotes | FxQuote | fxQuote |
GET /v1/events | Events | events |
GET /v1/webhook_public_keys | WebhookPublicKeys | webhookPublicKeys |
A list with a cursor is an iterator that fetches the next page with starting_after as you go: a Go iter.Seq2, a TypeScript async iterator. limit sets the page size.
for await (const pi of lemak.listPaymentIntents({ status: "succeeded", limit: 100 })) {
console.log(pi.id, pi.amount, pi.currency);
}
What the client does for you
- Base URL and key
https://api.lemak.cashunless you set another, and your key asAuthorization: Bearer.- Api-Version
- Every request names
2026-10-23, the version the types describe. Set the client's version, or one request's, to name another. - Idempotency-Key
- Every POST carries one: a fresh random key, or the one you pass. Pass your own when you may resend the same request from another process, for example after a restart.
- Retries
- A network error, a
429and a5xxare retried, twice by default, with jittered backoff from half a second; aRetry-Afterheader sets the wait. A retry keeps theIdempotency-Keyand the body, so it is never a second charge. Any other4xxis returned at once. - Timeout
- Each attempt is bounded, 30 seconds by default.
- Errors
- An error answer becomes a typed error,
APIErrorin Go andLemakErrorin TypeScript, with the HTTP status,type,code,paramandrequest_id. Branch oncode; see Errors.
Request signing
If your account requires a signature_scheme, give the client a signer. It signs every attempt exactly as Signatures describes: a fresh X-Timestamp, the canonical string over the path and query as sent, and padded base64. A retry is signed again with a later timestamp, because we accept one timestamp and signature once.
c := &lemak.Client{
Key: "sk_live_…",
Signer: lemak.Ed25519Signer{KeyID: "key_…", Key: privateKey}, // or lemak.HMACSigner{Secret: "…"}
}
const lemak = new Client({
apiKey: "sk_live_…",
signer: { scheme: "ed25519", keyId: "key_…", privateKey: seed }, // a CryptoKey, or the 32-byte seed
// signer: { scheme: "hmac_sha256", secret: "…64 hex characters…" },
});
Verifying webhooks
Pass the X-Webhook-Signature header, the raw body exactly as it arrived, and the keys you hold. The endpoint secret checks v1; the published public keys check v2 with the key that v2_kid names. Each key you give must match, and you must give at least one. A delivery whose timestamp is more than 300 seconds from your clock is refused, and header fields the SDK does not know are ignored.
body, _ := io.ReadAll(r.Body)
err := lemak.VerifyWebhook(r.Header.Get(lemak.WebhookHeader), body,
lemak.WebhookKeys{Secret: endpointSecret}, time.Now())
if err != nil {
http.Error(w, "signature", http.StatusBadRequest) // errors.Is(err, lemak.ErrWebhookStale) for the clock
return
}
event, err := lemak.ParseEvent(body)
import { verifyWebhook, parseEvent, publicKeyMap } from "@lemakpay/client";
const raw = new Uint8Array(await request.arrayBuffer());
const publicKeys = publicKeyMap(await lemak.webhookPublicKeys()); // cache it; fetch again on an unknown v2_kid
await verifyWebhook(request.headers.get("X-Webhook-Signature") ?? "", raw, { publicKeys }); // throws WebhookError
const event = parseEvent(raw);
if (event.type === "payment_intent.succeeded") { /* store event.id, answer 200, then read the intent */ }
The TypeScript verifier needs nothing but WebCrypto, so it runs in a Worker, in Deno and in a browser as well as in Node.
How the SDKs are tested
Both SDKs check their signatures and their webhook verdicts against one file of test values, testdata/vectors.json, which is produced by the same code that signs and verifies on our servers. It includes the values on the Signatures page. Both also run end to end against our server in test mode: a signed create, a simulated success, a read, and the webhook that the success sends.