> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ignyt.si/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript SDK

> Use the typed server client, webhook verifier and branded web and mobile checkout helpers.

Server-side SDK
Call the public API with generated method, path, body and response types while keeping authority and retries explicit.

## Get the reviewed distribution

The `@808labs/ignite-sdk` package is implemented for Node.js 22.13+ and ESM, with no runtime dependencies. npm publication is a separate release step. Ask Ignyt for the reviewed distribution and version; do not assume a similarly named registry package is ours. Public OpenAPI remains the contract authority.

The root API client is server-only and rejects browser use. Keep server keys, customer access tokens
and delegation secrets out of browser bundles, prompts and logs. For web or mobile checkout, use the
[browser-safe checkout entry points](#branded-web-and-mobile-checkout) with your own backend.

## Make a typed request

```typescript theme={"theme":{"light":"github-light","dark":"vesper"}}
import { IgniteClient } from '@808labs/ignite-sdk';

const ignite = new IgniteClient({
  baseUrl: process.env.IGNITE_API_URL!,
  apiKey: process.env.IGNITE_SERVER_KEY!,
  environment: 'sandbox',
});

const cart = await ignite.request('post', '/v1/carts', {
  body: { shopper_ref: 'your-authenticated-shopper-reference' },
});

const current = await ignite.request('get', '/v1/carts/{cart_id}', {
  path: { cart_id: cart.data.id },
});
```

Use the assigned API URL and credentials for the same environment. Before its first operation, the SDK checks identity/environment through `/v1/me`; that preflight counts as an API call. Ignyt still checks the key's permissions on every request. HTTPS is required except loopback Sandbox.

## Results and safe write handling

`request()` returns `{ data, status, requestId }`. Method/path parameters, queries, bodies and success responses are generated from public OpenAPI. Pass `idempotencyKey` only where an operation supports it; persist the exact command key and payload before sending. Plain cart creation does not currently support idempotent replay.

The SDK follows no redirects and performs no automatic retries. `IgniteError.outcomeUnknown` means the write may have been accepted: use its documented lookup/replay contract before another effect. Do not create a new command merely because a response was lost.

The default timeout is 15 seconds, configurable up to 60 seconds; calls also accept an `AbortSignal`. JSON requests are bounded to 1 MiB and responses to 4 MiB. Errors retain safe status/code, request ID and Retry-After metadata rather than copying upstream response bodies into logs.

## Verify raw webhook bytes

```typescript theme={"theme":{"light":"github-light","dark":"vesper"}}
import { verifyWebhook } from '@808labs/ignite-sdk';

const event = verifyWebhook(
  rawBody,
  signatureHeader,
  [activeSecret, retiringSecret],
);
```

`rawBody` must contain the original bytes and `signatureHeader` the `Ignite-Signature` value. Verify before parsing or acting, then durably deduplicate the returned event ID. Verification alone does not provide exactly-once business processing. The verifier accepts at most two rotation secrets and a timestamp tolerance up to 300 seconds. Never log signatures or secrets.

## Branded web and mobile checkout

The Ignyt TypeScript SDK lets you place Mamo's payment form inside your branded checkout. Your app owns the logo,
layout, order summary, loading states and confirmation. Mamo renders the card fields, wallet controls and bank challenge.
The checkout modules support UAE Mamo Sandbox.

### Set up your platform app

1. Get the reviewed `@808labs/ignite-sdk` 0.2.0 distribution from Ignyt. The root entry point is server-side. Use the
   `/checkout`, `/checkout/browser` and `/checkout/mobile` entry points in your web and mobile integration.
2. Give Ignyt your Sandbox app ID and a verified HTTPS return URL template with one `{cart_id}`, such as
   `https://shop.example.com/checkout/return/{cart_id}`. Ignyt registers it and enables inline checkout for your app.
3. After shopper approval, submit the quote from your backend with a stable idempotency key and
   `shopper_contact.email`. Store the original cart ID and returned purchase ID on the shopper's checkout record.
   A missing or invalid email results in a hosted payment action.
4. Expose an authenticated, read-only route on your backend for your own checkout. Check the shopper owns
   the checkout, then read `GET /v1/carts/{cart_id}/purchase` using the saved cart ID. Return just
   `purchase.id`, `purchase.status`, `payment.provider`, `payment.status` and `payment.payment_action`.
   Preserve an explicit `payment: null` on a failed purchase. The SDK reports `not_started` for that case.
   Use `Cache-Control: no-store`. Keep Ignyt credentials on your server and payment URLs out of logs.

### Embed on the web

Place the SDK's iframe in a dedicated container on your HTTPS checkout page. Style the container and its surrounding
layout with your existing design system. The iframe fills its container. Give the container an explicit height and
reserve space for errors. Allow
`https://sandbox.dev.business.mamopay.com` in your page's `frame-src` and permit the iframe's `payment` feature if your
page restricts it. Mamo's form and bank challenge keep their provider-controlled appearance.

```css theme={"theme":{"light":"github-light","dark":"vesper"}}
.payment-container {
  width: 100%;
  height: 36rem;
}
```

```typescript theme={"theme":{"light":"github-light","dark":"vesper"}}
import { createCheckout } from '@808labs/ignite-sdk/checkout';
import { mountMamoCheckout, openHostedCheckout } from '@808labs/ignite-sdk/checkout/browser';

// Your application provides authenticated, server-rendered checkout data and localized UI handlers.
const lifecycle = new AbortController();
const session = createCheckout({
  purchaseId: checkout.purchaseId,
  async read(signal) {
    const response = await fetch(checkout.statusPath, {
      signal, credentials: 'same-origin', cache: 'no-store', redirect: 'error',
    });
    if (!response.ok) throw new Error('Checkout status is unavailable');
    return response.json();
  },
});

let unmount: (() => void) | undefined;
let confirming = false;
async function confirm() {
  if (confirming) return;
  confirming = true;
  try {
    const result = await session.waitFor('result', { signal: lifecycle.signal });
    showStatus(result);
    if (result.paymentFinal) unmount?.();
    else showRetry(confirm);
  } catch {
    if (!lifecycle.signal.aborted) showRetry(confirm);
  } finally {
    confirming = false;
  }
}

async function present() {
  try {
    const state = await session.waitFor('action', { signal: lifecycle.signal });
    showStatus(state);
    const action = state.paymentAction;
    if (action?.presentation === 'embed') {
      unmount = mountMamoCheckout(paymentContainer, action, {
        title: 'Secure card payment',
        onRefresh: () => { void confirm(); },
        onChallenge: (url) => window.location.replace(url),
      });
    } else if (action?.presentation === 'redirect') {
      showPayButton(() => openHostedCheckout(action));
    } else if (!state.paymentFinal) {
      showRetry(present);
    }
  } catch {
    if (!lifecycle.signal.aborted) showRetry(present);
  }
}
await present();

// Call on route change or component disposal.
function dispose() {
  lifecycle.abort();
  unmount?.();
}
```

If the server temporarily hides the action during a payment attempt, keep the already-mounted form until
the server confirms the outcome or the shopper leaves. An exhausted wait returns the last observed state.
Use `paymentFinal` to distinguish a completed payment decision from a pending read. A paid purchase can
still be placing its store orders.
The SDK accepts a challenge only from the mounted Mamo frame. The provider supplies the HTTPS issuer
destination. Your challenge handler can return `false` if it cannot open the page yet.
After the return, resolve the original checkout through your backend and run `waitFor('result')`.
Ignore payment status and charge identifiers in the return query. Show a pending state until the backend
confirms the payment. Show paid and merchant order placement separately.

### Launch from iOS or Android

Use your own HTTPS web checkout page as the payment screen from the app. Present it in Safari or
`SFSafariViewController` on iOS, or a Custom Tab on Android. The same form, branding and 3-D Secure flow
can run on that page. Use an associated-domain Universal Link on iOS and a verified App Link on Android.
Keep a platform-branded web return page with a **Return to app** link when the OS keeps navigation in the browser.

Your mobile session may be separate from the browser session. To resume without another sign-in, have your
backend issue a short-lived, single-use handoff for the original checkout. Redeem it at your HTTPS origin,
establish a checkout-scoped browser session, and redirect to a clean URL before mounting the payment form.

```typescript theme={"theme":{"light":"github-light","dark":"vesper"}}
import { createMobileCheckout } from '@808labs/ignite-sdk/checkout/mobile';

// URLs and origins come from your platform's configuration and original checkout record.
const mobile = createMobileCheckout({
  checkoutOrigin: 'https://shop.example.com',
  returnOrigin: 'https://return.example.com',
  checkoutUrl: checkout.webUrl,
  returnUrl: checkout.expectedAppLink,
});
await mobile.open(openSystemBrowser);

// On a Universal Link or App Link, check that it belongs to this checkout.
if (mobile.matchesReturn(incomingLink)) await refreshOriginalCheckout();
// Refresh the same server record when the app comes to the foreground without a link.
```

The mobile helper validates the partner origins and the checkout-specific return path or query parameter.
For a Swift or Kotlin app, use the same routes with the native browser surface and link handler.
Refresh using your normal app session. Browser dismissal, a bank challenge and an app restart all retain
the same persisted cart and purchase IDs. Qualify these flows and supported wallet behavior on real devices
before enabling them for shoppers.

## Related guides

> [card] [Signed webhooks](https://docs.ignyt.si/webhooks.md)
>
> Receive, verify and recover events safely.

> [card] [Errors and retries](https://docs.ignyt.si/errors-and-retries.md)
>
> Distinguish definite errors from uncertain writes.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.