Quickstart

Take a test payment in about five minutes.

1. Install the SDK

bash
npm install @secureprocessing/node

On Deno — including Supabase Edge Functions — import it directly. It has no dependencies and uses only fetch and Web Crypto.

ts
import { SecureProcessing } from "https://esm.sh/@secureprocessing/node@0.1.0";

2. Create a payment

A payment intent tracks one payment from start to finish. The checkout session gives you a URL to send your customer to.

ts
import { SecureProcessing } from "@secureprocessing/node";

const sp = new SecureProcessing(process.env.SECURE_PROCESSING_KEY!);

const intent = await sp.paymentIntents.create({
  amount: 6000,          // minor units — $60.00
  currency: "usd",
  description: "Order 1042",
  metadata: { order_id: "1042" },
});

const session = await sp.checkoutSessions.create({
  payment_intent: intent.id,
  success_url: "https://example.com/thanks",
  cancel_url: "https://example.com/cart",
});

// Send your customer to session.url

3. Pay with a test card

Open the URL and pay with 4000001111111118, expiry 12/30, any CVC. You will land back on your success_url, and the payment will be in your dashboard.

4. Listen for the webhook

Do not treat the redirect as proof of payment — a customer can close the tab. The webhook is what tells you to fulfil the order.

ts
const event = await sp.webhooks.constructEvent(
  rawBody,                                      // the RAW string, not a parsed object
  request.headers.get("Secure-Processing-Signature")!,
  process.env.SECURE_PROCESSING_WEBHOOK_SECRET!,
);

if (event.type === "payment_intent.succeeded") {
  // fulfil the order
}
Pass the raw body. JSON.stringify(JSON.parse(body)) produces different bytes, so the signature will not match — this is the most common reason a first webhook integration fails.

That is the whole flow

Everything else is a variation on it: hold now and charge later, refund all or part, save a card and charge it again. Each has its own page.