Integrate Wompi in your Node.js apps with ease.
pnpm add @pulgueta/wompi zod npm install @pulgueta/wompi zod yarn add @pulgueta/wompi zod bun add @pulgueta/wompi zod Zod is the only peer dependency — install it alongside the SDK.
import { WompiClient } from "@pulgueta/wompi";
const wompi = new WompiClient({
publicKey: process.env.WOMPI_PUBLIC_KEY!,
privateKey: process.env.WOMPI_PRIVATE_KEY,
sandbox: true,
});
const [error, response] = await wompi.transactions.getTransaction("txn_123");
if (error) {
// error is typed — branch on error.type or instanceof
return;
}
response.status; // "APPROVED" | "PENDING" | "DECLINED" | ... One client, every Wompi flow
Card charges, hosted links, stored payment sources, PSE bank transfers and typed errors all run through the same client. Each tab is a real call against the SDK — copy it, swap in your keys, and run it.
import { WompiClient } from "@pulgueta/wompi";
import { getSignatureKey } from "@pulgueta/wompi/server";
const wompi = new WompiClient({
publicKey: process.env.WOMPI_PUBLIC_KEY!,
sandbox: true,
});
const [merchantError, merchant] = await wompi.merchants.getMerchant();
if (merchantError) throw merchantError;
const reference = `order-${Date.now()}`;
const signature = await getSignatureKey({
reference,
amountInCents: 2_490_000,
integrityKey: process.env.WOMPI_INTEGRITY_KEY!,
});
const [error, tx] = await wompi.transactions.createTransaction({
acceptance_token: merchant.presigned_acceptance!.acceptance_token,
amount_in_cents: 2_490_000,
currency: "COP",
signature,
reference,
customer_email: "buyer@example.com",
payment_method: { type: "CARD", token: cardToken, installments: 1 },
});
if (error) throw error;
tx.status; // "PENDING" — poll getTransaction(tx.id) const [error, response] = await wompi.paymentLinks.createPaymentLink({
name: "Order #1024",
description: "Thanks for shopping.",
single_use: true,
collect_shipping: false,
amount_in_cents: 99_000,
currency: "COP",
});
if (error) throw error;
// Hand the customer a hosted checkout — no card data touches you.
const url = `https://checkout.wompi.co/l/${response.id}`; // Promote a one-time card token into a source you can re-charge.
const [sourceError, source] = await wompi.paymentSources.createPaymentSource({
type: "CARD",
token: cardToken,
acceptance_token: acceptanceToken,
customer_email: "buyer@example.com",
});
if (sourceError) throw sourceError;
// Later, charge it with just the numeric id (private key required).
const [error, tx] = await wompi.transactions.createTransaction({
acceptance_token: acceptanceToken,
amount_in_cents: 1_990_000,
currency: "COP",
signature,
reference: `recur-${Date.now()}`,
customer_email: "buyer@example.com",
payment_source_id: source.id,
}); // 1. List the banks PSE supports, render them as <option>s.
const [error, banks] = await wompi.pse.getFinancialInstitutions();
if (error) throw error;
// 2. Route the chosen bank code through a PSE transaction.
const [txError, tx] = await wompi.transactions.createTransaction({
acceptance_token: acceptanceToken,
amount_in_cents: 750_000,
currency: "COP",
signature,
reference: `pse-${Date.now()}`,
customer_email: "buyer@example.com",
payment_method: {
type: "PSE",
user_type: 0,
user_legal_id_type: "CC",
user_legal_id: "1020304050",
financial_institution_code: banks[0].financial_institution_code,
payment_description: "Order #1024",
},
}); const [error, response] = await wompi.transactions.getTransaction(id);
if (error) {
// Branch on the discriminant — no instanceof, no string matching.
if ("type" in error && error.type === "NOT_FOUND_ERROR") return notFound();
if ("type" in error && error.type === "INPUT_VALIDATION_ERROR") {
return badRequest(error.messages);
}
if ("statusCode" in error) return badGateway(error.statusCode);
throw error; // local WompiError — bad input before the request fired
}
response.status; // fully typed once `error` is ruled out Start receiving payments in your Node.js applications
Install the package, set your environment variables and use the provided skills to integrate Wompi in your Node.js applications.