Quickstart
Integrate native ATM checkout in test mode, starting with one fixed-price digital purchase.
Compatible with the closed-beta ATM app APIs and versioned ATM event headers. Check atm-api-version on every webhook or XRPC receiver event.
What you build
This quickstart covers one flow: a fixed-price USD digital purchase in test mode, using native money.atmosphere.payment.createCheckout and money.atmosphere.payment.getCheckoutStatus. Everything runs on your backend. The browser only receives the hosted checkout URL. Other product types arrive as ATM admits them; see What ATM admits today.
Test mode
Send environment: “test” on every checkout. Test purchases use ATM’s App Sandbox and never move live money.
POST only
Both methods are POST procedures with JSON bodies. Status is never a GET request or a URL parameter.
Durable attempts
Save the exact request and idempotency key before contacting ATM. Every retry sends those same bytes.
Canonical fulfilment
Grant a purchase only from authenticated completed status. A verified notification wakes that check; a browser return never does.
1. Get your test configuration
App registration is by invitation during the closed beta. ATM assigns each invited app a test configuration. Keep these values together: a later configuration change cannot rebind a purchase you already started.
| App identity | Your registered app DID and the exact HTTPS origin your return and cancel URLs use. |
|---|---|
| Test broker | The assigned test broker DID and its HTTPS checkout origin. Use them as one binding. |
| Dashboard origin | Where buyers open ATM’s authenticated receipt view. The checkout origin does not serve receipts. |
| Test seller | A seller that has granted your app payment permission and accepted the exact seller terms in ATM. |
| Catalog refs | The exact Product and fixed Price strongRefs (AT-URI plus CID) for the item you sell. |
| Notifications | The canonical XRPC receiver, or an explicit signed-HTTP webhook URL and its test signing secret. |
Choose whether the app starts with revenue-share payouts, direct payments for its own products, or both. That registration choice only decides which dashboard surfaces ATM shows first. Seller permission is not buyer consent, and registration alone does not admit a payment flow: ATM checks the seller's permission and accepted terms again on every checkout. ATM derives the price, its fee and any accepted app allocation from those terms, so never send a total or deduct a fee in your request.
2. Install the native SDK
Install the pinned native build of @atmosphere-money/app-node supplied for your integration, and keep its integrity hash in your lockfile. An older @beta release on npm may not include the native helpers, and the version number alone does not identify a native build. The package is MIT licensed, needs Node 22 or newer, has no runtime dependencies, and belongs on your server only. Step 3 also uses @atproto/api, the AT Protocol client, to ask your PDS for each service-auth token.
# For example, a supplied package tarball:
npm install ./atmosphere-money-app-node-<version>.tgz
# The AT Protocol client the service-auth step uses:
npm install @atproto/api
# Confirm the native helpers are present. This prints "function".
node -e "import('@atmosphere-money/app-node').then((sdk) => console.log(typeof sdk.createAtmCheckoutAttempts))"3. Mint service-auth for every call
Every native call carries a fresh app service-auth JWT that your app account's PDS signs through com.atproto.server.getServiceAuth, so your signing key never leaves the PDS. The SDK asks for a new token on every HTTP request, including retries, and passes the exact lxm and aud to sign.
| Field | Type | Required | Description |
|---|---|---|---|
| iss | did | yes | Your app DID. Your PDS sets it. |
| aud | did#service | yes | <test broker DID>#atmosphere_money_broker. A bare DID or any other service fragment is rejected. |
| lxm | nsid | yes | The exact method being called: money.atmosphere.payment.createCheckout or money.atmosphere.payment.getCheckoutStatus. |
| exp | integer | yes | 60 seconds after issue is recommended; ATM rejects more than 300. |
| jti | string | yes | Unique per token. ATM rejects a replayed token, so never cache or reuse one. |
import { AtpAgent } from "@atproto/api";
// Your app account's agent, signed in once. An OAuth session works too; keep an
// app password in your secret store, never in code.
const appAgent = new AtpAgent({ service: "https://your-app-pds.example" });
await appAgent.login({
identifier: process.env.ATM_APP_IDENTIFIER!,
password: process.env.ATM_APP_PASSWORD!,
});
export async function mintMyAppServiceAuthJwt(
{ lxm, aud }: { lxm: string; aud: string },
): Promise<string> {
const exp = Math.floor(Date.now() / 1000) + 60; // ATM allows at most 300 seconds
const { data } = await appAgent.com.atproto.server.getServiceAuth({ aud, lxm, exp });
return data.token;
}App API keys and webhook signing secrets are different credentials and cannot authenticate these calls. The docs/developer/examples/atm-service-auth.ts example shows sign-in and lifetime checks in full.
4. Store durable attempts
An attempt is your app's durable record of one checkout: the exact request, its idempotency key, ATM's response and the latest canonical status. createAtmCheckoutAttempts captures the request before any network call and always retries with the original bytes.
import {
createAtmCheckoutAttempts,
createAtmFileStore,
type AtmCheckoutAttempt,
} from "@atmosphere-money/app-node";
export const attempts = createAtmCheckoutAttempts({
// Your assigned test configuration. Every attempt is bound to these values.
appDid: "did:plc:aaaaaaaaaaaaaaaaaaaaaaaa",
brokerDid: "did:plc:bbbbbbbbbbbbbbbbbbbbbbbb",
brokerUrl: "https://your-assigned-test-checkout.example",
// One server with a private persistent volume. A fleet implements
// AtmDurableStore with compare-and-swap in its shared database instead.
store: createAtmFileStore<AtmCheckoutAttempt>("./private-attempts"),
// Called on every HTTP request with the exact lxm and aud to sign.
getServiceAuthToken: ({ lxm, aud }) => mintMyAppServiceAuthJwt({ lxm, aud }),
});The file store suits one server on a private, backed-up, persistent POSIX volume; it refuses a storage directory that is not private (0700). Ephemeral or serverless filesystems and in-memory maps are not durable. A database store must return each value exactly as written: keep absent fields absent and numbers as numbers.
5. Create the checkout on Buy
Create the checkout only after the buyer clicks Buy in an authenticated session, never on page load, prefetch or hover. Give each purchase one attempt ID, assigned once under a unique database constraint, and use it as the idempotency key.
// Runs on your backend after an authorized Buy click.
export async function startCheckout(order: {
id: string;
attemptId: string; // assigned once per purchase, unique in your database
sellerDid: string;
product: { uri: string; cid: string }; // exact Product strongRef
price: { uri: string; cid: string }; // exact fixed Price strongRef
}) {
await attempts.capture(order.attemptId, {
environment: "test",
idempotencyKey: order.attemptId,
items: [{
recipient: order.sellerDid,
listing: order.product,
price: order.price,
quantity: 1,
paymentType: "shop",
}],
returnUrl: `https://app.example/orders/${order.id}/return`,
cancelUrl: `https://app.example/orders/${order.id}/return`,
metadata: { appOrderId: order.id },
});
// Sends the captured body and key, then saves paymentId, statusToken, url
// and expiresAt before returning. Safe to call again after any failure.
const attempt = await attempts.recover(order.attemptId);
return attempt.checkout!.url; // the only value the browser receives
}Fixed prices omit amount; ATM derives it from the exact Price. After a timeout, lost reply, failed save, CheckoutUnavailable or RateLimitExceeded, call recover again with the same attempt ID. It replays the original body and key with fresh service-auth. Never rebuild the request, change the key, or fall back to another checkout method. The status token stays on your server.
A checkout lasts at most 45 minutes, or less with an earlier checkoutExpiresAt. The buyer must reach payment within about 13 minutes; after that, the checkout page links back to your cancelUrl, or your returnUrl if you set none. Reconcile the original attempt before offering a new purchase.
6. Reconcile from your backend
Run reconciliation in a backend worker on a bounded backoff schedule, even if the buyer never returns. reconcile POSTs the saved status token to getCheckoutStatus with fresh service-auth, saves the newest status, and tells you what to do.
// Background worker: on a schedule, and whenever a verified notification arrives.
export async function reconcileOrder(
attemptId: string,
app: {
grantPurchaseOnce(effectKey: string): Promise<void>;
markUnpaid(): Promise<void>;
pollAgainLater(): Promise<void>;
holdForReview(): Promise<void>;
},
) {
const result = await attempts.reconcile(attemptId);
switch (result.action) {
case "fulfil":
// completed + fulfil. Insert result.effectKey under a unique constraint
// and grant the purchase in the SAME database transaction.
return app.grantPurchaseOnce(result.effectKey!);
case "closed":
// failed, canceled or expired. A new purchase needs a new Buy and attempt.
return app.markUnpaid();
case "wait":
// pending. Passing a deadline is not an outcome; poll again later.
return app.pollAgainLater();
case "order":
// completed, but an order owner must confirm first. Fixed digital
// checkout does not return this; hold the purchase and contact ATM.
return app.holdForReview();
}
}| pending | Keep polling. expiresAt, reservationExpiresAt and the advisory finalizesAt are not reasons to stop. |
|---|---|
| completed | Payment settled. Only fulfillment: “fulfil” authorizes a direct digital grant. |
| failed, canceled, expired | Unpaid terminal outcomes. Show them to the buyer; a new purchase needs a new attempt. |
| CheckoutNotFound, CheckoutUnavailable | Not outcomes. Keep the attempt and retry later; never replace the purchase. |
Show “Confirming payment…” while status is pending or temporarily unavailable, and keep a confirmed payment confirmed during an outage. The low-level equivalent is atm.getCheckoutStatus({ statusToken }): a POST with the token in the JSON body. Never put the token in a URL, a log line or the browser.
7. Verify notifications
Notifications wake the same reconciler early; polling alone is enough when one is delayed or lost. AT Protocol apps default to the canonical #AtmEventReceiver / money.atmosphere.event.receiveEvent receiver. A conventional web app can select signed HTTP instead: verify the raw body before parsing it, claim the delivery, and acknowledge only after the wake-up is durably queued.
import { createNodeWebhookHandler } from "@atmosphere-money/app-node";
export const handleAtmWebhook = createNodeWebhookHandler({
// Current and previous test signing secrets, so rotation never drops events.
secret: [process.env.ATM_WEBHOOK_SECRET, process.env.ATM_WEBHOOK_PREVIOUS_SECRET]
.filter((value): value is string => Boolean(value)),
deliveryStore: {
claim: claimWebhookDelivery,
complete: completeWebhookDelivery,
release: releaseWebhookDelivery,
},
onEvent: async (event) => {
if (event.environment !== "test" || event.apiVersion !== "2026-07")
return { status: 422, body: { error: "UnexpectedEventBinding" } };
await enqueueReconciliation(event); // the worker then reads canonical status
return { body: { ok: true } };
},
});- Read the raw bytes before any JSON middleware; re-serialized JSON fails the signature.
- Atm-Signature carries t=…,v1=…: HMAC-SHA256 over <timestamp>.<deliveryId>.<rawBody>. The SDK compares in constant time and allows five minutes of clock skew.
- Claims need an expiring lease and a random claim ID; complete or release only with that ID. A busy claim returns 503 so ATM retries.
- Retries keep the delivery ID, type, environment, API version and data, but carry a new createdAt. Deduplicate on that stable identity, not the whole body.
- Keep current and previous secrets during rotation. Never log signatures, raw bodies, tokens or secrets.
8. Test the whole path
- Send a test event from Developer settings and verify its signature, environment and API version.
- Force a receiver failure, redrive the same delivery, and confirm the purchase effect does not repeat.
- Complete a test checkout and confirm the worker grants the purchase once, even if the browser never returns.
- Stop the process between capture and ATM’s reply, restart, and confirm recover resumes the same attempt.
- Cancel a test checkout and confirm the order stays unpaid.
- Open the receipt from ATM’s dashboard origin. Your confirmation page is not the payment receipt.
For support, share your attempt ID, ATM payment ID, delivery ID and error code. Never send a status token, checkout URL, JWT, webhook secret or private buyer data.
What ATM admits today
Invited apps start with one fixed-price USD digital purchase: one exact Product and Price, quantity 1, with no amount override, shipping, variants or routed order. Other product types arrive as ATM admits each one, including subscriptions, tips and chosen amounts, discounts, commissions, physical shipping and tickets. Keep their purchase actions unavailable until then. A field in the SDK types is not admission. Fixed monthly subscriptions are not yet available; ATM will publish their recovery API before admitting them. Live payments need a separate review.