gwop-checkout v2.0.0
Environment variables
Set these in your.env or deployment config before using the SDK:
| Variable | Description | Example |
|---|---|---|
GWOP_CHECKOUT_API_KEY | Merchant API key. Generate in Merchant Dashboard → Settings. | sk_m_6vyv...I131 |
GWOP_WEBHOOK_SECRET | Webhook signing secret. Generate in Merchant Dashboard → Settings. | whsec_d1... |
Constructor
| Option | Type | Default | Description |
|---|---|---|---|
merchantApiKey | string | — | Merchant API key (sk_m_*). Required for create/list/cancel. |
apiKey | string | — | Alias for merchantApiKey. |
baseUrl | string | https://agents.gwop.io | API base URL. |
maxRetries | number | 2 | Max retries on 429/503/network errors. |
timeout | number | 30000 | Request timeout in ms. |
debug | boolean | false | Log requests to console.debug. Also enabled by env var GWOP_DEBUG=1. |
Invoices
Create
| Field | Type | Required | Description |
|---|---|---|---|
amount_usdc | number | Yes | Amount in USDC minor units. 1_000_000 = $1.00. |
description | string | No | Human-readable description (max 500 chars). |
metadata | object | No | Arbitrary key-value pairs (max 1024 bytes). |
metadata_public | boolean | No | Expose metadata in public invoice view. |
expires_in_seconds | number | No | Invoice TTL (60–86400). Default: 900 (15 min). |
idempotencyKey?: string — safe retry key. Same key returns the original invoice.
Returns: CreateInvoiceResponse — id, public_invoice_id, status: 'OPEN', expires_at, created_at.
Retrieve
Public endpoint — no API key needed.InvoicePublic — full v3 response with payment_methods, pricing, completion_check, and links.
List
| Param | Type | Default | Description |
|---|---|---|---|
status | string | — | Filter: OPEN, PAYING, PAID, EXPIRED, CANCELED. |
limit | number | 20 | Results per page (1–100). |
offset | number | 0 | Pagination offset. |
Cancel
OPEN invoices can be canceled. Returns 409 if the invoice is already paid or in a non-cancellable state.
Wait for status
Poll until the invoice reaches a target status. Uses exponential backoff with jitter.GwopCheckoutError with code WAIT_TIMEOUT if the timeout is reached.
Webhooks
Construct event
Verify a webhook signature and parse the event.InvalidRequestError with code WEBHOOK_SIGNATURE_ERROR on failure.
Dispatch
Route a verified event to typed handlers.Error handling
All errors extendGwopCheckoutError with code, statusCode, requestId, and details.
| Class | Status | When |
|---|---|---|
AuthenticationError | 401 | Missing or invalid API key. |
InvalidRequestError | 400, 422 | Validation error or bad input. |
NotFoundError | 404 | Invoice not found. |
RateLimitError | 429 | Too many requests. Check details.retry_after_seconds. |
GwopCheckoutError | * | Base class for all other errors. |
Retries
The SDK retries automatically on transient failures (max 2 by default).| Status | Retried? | Behavior |
|---|---|---|
| 429 | Yes | Respects Retry-After header. |
| 503 | Yes | Exponential backoff with jitter. |
| Network error | Yes | Retries on TypeError from fetch. |
| 400, 401, 404, 409 | No | Throws immediately. |
GwopCheckoutError with code MAX_RETRIES_EXCEEDED.