Aevify

@aevify/node

The server SDK: create and read payments, and verify webhooks. TypeScript types included, no dependencies. Runs on Node 20+, Bun, Deno and edge runtimes (it uses fetch and Web Crypto).

npm install @aevify/node

Setup

import { Aevify } from "@aevify/node";

const aevify = new Aevify(process.env.AEVIFY_SECRET_KEY!, {
  baseUrl: "https://aevify.vercel.app", // or set AEVIFY_BASE_URL
});
OptionDefault
baseUrlAEVIFY_BASE_URL env varRequired one way or the other
timeoutMs30000Per request
maxRetries2For network errors, 429 and 5xx
fetchglobal fetchBring your own (tests, proxies)

It refuses to run in a browser and rejects publishable keys, so a secret key can't end up in front of customers.

Payments

// Create. An idempotency key is always sent (generated if you don't pass one), so retries are safe.
const payment = await aevify.payments.create(
  { amount: "25.00", orderId: "1042", successUrl: "https://shop.example/thanks" },
  { idempotencyKey: "order-1042" },
);

// Retrieve (refreshed from the chain)
const latest = await aevify.payments.retrieve(payment.id);

// List, newest first
const page = await aevify.payments.list({ limit: 20 });
const next = await aevify.payments.list({ limit: 20, startingAfter: page.data.at(-1)!.id });

// Or iterate over everything
for await (const p of aevify.payments.listAll()) console.log(p.id, p.status);

// Public checkout data: what an AI agent needs to pay (no key used)
const checkout = await aevify.payments.retrieveCheckout(payment.id);

create takes the same fields as POST /api/v1/payments: amount (required), orderId, description, expiresInSeconds, payer, successUrl, cancelUrl, metadata.

Webhooks

const event = await aevify.webhooks.constructEvent(rawBody, signatureHeader, process.env.AEVIFY_WEBHOOK_SECRET!);
// or, without a client:
import { constructWebhookEvent } from "@aevify/node";
const event2 = await constructWebhookEvent(rawBody, signatureHeader, secret, { toleranceSeconds: 300 });

rawBody can be a string, Uint8Array or ArrayBuffer. It throws WebhookSignatureError if the signature is missing, wrong or too old. See Webhooks.

Errors

Every API error is an AevifyError with type, status and (for bad input) param:

ClassWhen
InvalidRequestError400: bad input; param names the field
AuthenticationError401: missing, invalid or revoked key
NotFoundError404
ConflictError409: e.g. an idempotency key reused with different parameters
MerchantNotReadyErrorConnect a payout wallet in the dashboard first
APIErrorOther server errors (after retries)
ConnectionErrorCouldn't reach Aevify, or timed out (after retries)
import { InvalidRequestError } from "@aevify/node";

try {
  await aevify.payments.create({ amount: "0" });
} catch (error) {
  if (error instanceof InvalidRequestError) console.log(error.param, error.message);
}

Types

Payment, PaymentStatus, CreatePaymentParams, PaymentList, WebhookEvent and WebhookEventType are exported for your own code.