Go SDK — crypto orders
The client.CryptoOrders resource wraps every
customer-facing endpoint on the V-666 surface. Admin endpoints
are not exposed; integrators that need them call the REST
surface directly.
Quote
import (
"context"
"github.com/driftstackdev/driftstack-api/packages/sdk-go"
)
client := driftstack.New("ds_live_…")
quote, err := client.CryptoOrders.Quote(ctx, map[string]any{
"product": "solo_manual",
})
if err != nil { return err }
fmt.Println(quote["price_cents"], quote["price_currency"]) Mint a checkout
Always pair the call with an idempotency key so accidental
double-submits don't mint duplicate orders. The SDK forwards it
as the Idempotency-Key header; on a duplicate key
within the 24h window the server returns the original order.
key := uuid.NewString()
order, err := client.CryptoOrders.CreateCheckout(
ctx,
map[string]any{
"product": "team_manual",
"price_cents": 4900,
"price_currency": "USD",
},
&driftstack.CreateCheckoutOptions{IdempotencyKey: &key},
) List + drill down
// Newest-first; defaults to limit=50.
page, err := client.CryptoOrders.List(ctx, nil)
for _, o := range page.Orders {
fmt.Println(o["order_id"], o["status"], o["expires_at"])
}
// Narrow to a single status server-side (V-666.BR).
status := "paid"
limit := 25
paid, _ := client.CryptoOrders.List(ctx, &driftstack.ListCryptoOrdersOptions{
Status: &status,
Limit: &limit,
})
single, _ := client.CryptoOrders.Get(ctx, "ord_abc123def456")
fmt.Println(single["events"]) // V-666.AU timeline Status accepts pending,
confirming, paid, failed,
partial, or cancelled. Unknown values
return a 400. Limit is clamped to 1..=100.
Pagination — prefer Iterate
Iterate walks every page until the server stops
emitting a NextCursor. Cursor handoff is managed
internally — do not set
opts.Cursor when calling Iterate.
Return false from the visit callback to stop
iteration early (no further pages are fetched).
// Recommended: stream every paid order from the last 7d.
since := time.Now().Add(-7 * 24 * time.Hour).UTC().Format(time.RFC3339)
status := "paid"
limit := 100
err := client.CryptoOrders.Iterate(
ctx,
&driftstack.ListCryptoOrdersOptions{
Status: &status,
Limit: &limit,
CreatedAfter: &since,
},
func(o driftstack.CryptoOrderEnvelope) bool {
fmt.Println(o["order_id"])
return true // keep going
},
)
// Or drive the cursor by hand.
var cursor *string
for {
page, err := client.CryptoOrders.List(ctx, &driftstack.ListCryptoOrdersOptions{
Status: &status, Cursor: cursor,
})
if err != nil { return err }
for _, o := range page.Orders { fmt.Println(o["order_id"]) }
if page.NextCursor == nil { break }
cursor = page.NextCursor
} Update the customer note
_, err := client.CryptoOrders.UpdateNote(ctx, "ord_abc", map[string]any{
"customer_note": "PO-9921",
}) Cancel a pending order
_, err := client.CryptoOrders.Cancel(ctx, "ord_abc")
// 409: order has moved past pending; cancellation is no longer self-service.
// 404: order doesn't exist or belongs to another account. Crypto payments are non-refundable. Cancelling a pending order halts its pay window; cancelling a paid order is not supported — past billing periods stay billed. See /legal/refunds.
Fetch the receipt
receipt, err := client.CryptoOrders.Receipt(ctx, "ord_abc")
fmt.Println(receipt["paid_at"], receipt["price_cents"]) Listening for settlement
crypto.order.paid / crypto.order.failed
events are emitted server-side and are now subscribable — see
/docs/webhooks-crypto-events
for the payload contract. For integrations without an inbound
HTTPS endpoint, poll
client.CryptoOrders.Get(ctx, orderID) until
status transitions to paid or
failed. The Go SDK ships
VerifyWebhookSignature for every live event type,
including the now-live crypto.order.* events alongside the
session + quota + api-key + egress-capability event domains.
End-to-end example
A runnable end-to-end walkthrough ships with the SDK as
packages/sdk-go/examples/crypto_checkout/main.go.
Run with DRIFTSTACK_API_KEY=... go run ./examples/crypto_checkout.