Skip to content

Quick Start

Pick your platform, install two packages (Sanwo core + a provider), and start accepting payments.

Terminal window
npm i @sanwohq/web @sanwohq/paystack
import { createSanwo } from "@sanwohq/web";
import { paystack } from "@sanwohq/paystack";
const sanwo = createSanwo(paystack({ publicKey: "pk_test_xxx" }));
const result = await sanwo({
amount: 500000, // 5,000.00 NGN in kobo
currency: "NGN",
customer: { email: "customer@example.com" },
});
if (result.status === "successful") {
console.log("Payment ref:", result.reference);
}

All platforms share the same checkout options:

Field Type Required Description
amount number Yes Amount in minor units (kobo, cents, paise). 500000 = 5,000.00 NGN.
currency string Yes ISO 4217 currency code ("NGN", "USD", "INR", etc.).
customer { email: string } Yes Customer info. email is always required.
reference string No Your own transaction reference. Sanwo generates one if omitted.
metadata Record<string, unknown> No Arbitrary key-value data passed through to the provider.
description string No Human-readable description of the charge.
sanwoProviderOptions object No Provider-specific overrides. Escape hatch for options Sanwo doesn’t abstract.

The result is a discriminated union on status:

// Payment succeeded
{ status: "successful", reference: string, providerResponse: unknown }
// User closed the checkout
{ status: "cancelled" }
// Something went wrong
{ status: "failed", error: string }
// Payment initiated but not yet confirmed (e.g. bank transfer)
{ status: "pending", reference: string }

Always check result.status before accessing other fields.

  • Choose a provider to see supported regions, currencies, and payment methods.
  • Explore your platform’s SDK guide under SDKs in the sidebar for advanced usage.