SDK Libraries

NPM SDK

Install the official MakePay JavaScript and TypeScript SDK for payment links, settings, and webhook verification.

MakePay NPM SDK

Overview

The MakePay npm SDK is a typed JavaScript and TypeScript library for server-side MakePay integrations. It wraps API-key authentication, hosted payment-link operations, MakePay settings, and signed webhook verification.

Package:

@makecrypto/makepay

Installation

npm install @makecrypto/makepay
pnpm add @makecrypto/makepay

The SDK targets Node.js 18 or newer and uses the runtime fetch implementation.

Authentication

Create a MakePay API key from the MakeCrypto merchant developer area and store the key secret only on your server.

import { MakePayClient } from "@makecrypto/makepay";

const makepay = new MakePayClient({
  keyId: process.env.MAKEPAY_KEY_ID!,
  keySecret: process.env.MAKEPAY_KEY_SECRET!,
  // Optional: override only when MakePay gives you a custom checkout origin.
  checkoutBaseUrl: "https://makepay.io",
});

The SDK sends x-makecrypto-key-id and x-makecrypto-key-secret headers to the MakePay partner API.

const response = await makepay.createPaymentLink({
  title: "Order #1042",
  description: "Checkout for order #1042",
  amount: "129.99",
  currency: "USDT",
  orderId: "order_1042",
  customerEmail: "buyer@example.com",
  returnUrl: "https://merchant.example/orders/1042",
  successUrl: "https://merchant.example/orders/1042/success",
  failureUrl: "https://merchant.example/orders/1042/pay",
  expirationTime: "12h",
});

console.log(response.paymentLink);

Send a MakePay payment request email during creation:

await makepay.createPaymentLink(payload, {
  sendPaymentRequestEmail: true,
});

Embedded Checkout

Use hosted checkout URLs for redirects, or the embed helpers when your frontend keeps the shopper on the merchant page.

import {
  buildMakePayEmbeddedCheckoutUrl,
  buildMakePayHostedCheckoutUrl,
  mountMakePayCheckout,
  openMakePayCheckout,
} from "@makecrypto/makepay";

const paymentUid = response.paymentLink.uid;

const hostedUrl = buildMakePayHostedCheckoutUrl(paymentUid);
const embedUrl = buildMakePayEmbeddedCheckoutUrl(paymentUid, {
  parentOrigin: "https://merchant.example",
});

await openMakePayCheckout({
  paymentUid,
  onEvent(event) {
    if (event.type === "makepay.payment.redirect_requested") {
      window.location.assign(String(event.payload?.redirectUrl || hostedUrl));
    }
  },
});

mountMakePayCheckout({
  container: "#makepay-checkout",
  paymentUid,
});

For static CMS pages, buildMakePayEmbedButtonHtml(paymentUid) returns a button snippet that loads the MakePay modal script.

await makepay.listPaymentLinks();
await makepay.getPaymentLink("PAYMENT_LINK_UID");

await makepay.updatePaymentLink("PAYMENT_LINK_UID", {
  status: "paused",
});

await makepay.sendPaymentRequestEmail(
  "PAYMENT_LINK_UID",
  "buyer@example.com",
);

Settings

await makepay.getSettings();

await makepay.updateSettings({
  callbackUrl: "https://merchant.example/webhooks/makepay",
});

Webhook Verification

Read the exact raw body before parsing JSON.

import { parseMakePayWebhook } from "@makecrypto/makepay";

export async function POST(request: Request) {
  const rawBody = await request.text();
  const event = parseMakePayWebhook(
    rawBody,
    request.headers.get("x-makepay-signature"),
    process.env.MAKEPAY_WEBHOOK_SECRET!,
  );

  if (event.event?.type === "status_changed") {
    // Update your local order.
  }

  return new Response("ok");
}

Use verifyMakePayWebhook when you only need a boolean result.

Error Handling

API calls throw MakePayError. It includes the HTTP status and decoded response body.

import { MakePayError } from "@makecrypto/makepay";

try {
  await makepay.getPaymentLink("PAYMENT_LINK_UID");
} catch (error) {
  if (error instanceof MakePayError) {
    console.error(error.status, error.responseBody);
  }
}

Source Layout

The canonical source lives in apps/plugins/npm-sdk. The published npm package contains compiled ESM JavaScript and TypeScript declarations from dist.

Release Notes

The package is published as @makecrypto/makepay with public access. Release publishing should use an npm automation token in the makecrypto organization or an OTP-capable token when 2FA is required.

Need partner setup help?

Open the payment link details view in MakeCrypto to copy the generated snippets for a real payment UID, or return to the portal to manage merchant settings.

Open portal