@duabalabs/sellub-client
Typed, framework-agnostic client for the Sellub commerce platform. Works in Node, browsers, edge runtimes and React Native.
Install
npm install @duabalabs/sellub-client
# or
pnpm add @duabalabs/sellub-clientSurface (v0.3)
| Namespace | Methods |
|---|---|
externalPayments | initialize(input), verify(reference) |
subscriptions | start(input), status(subscriptionCode), cancel(input) |
invoices | create(input), fetch(requestCode) |
A future
shop(Vendure Shop API: catalog, cart, checkout, orders) andadmin(provisioning, fulfilment) namespace are on the roadmap. Track package-status for readiness.
Authentication
Every request is sent with the X-Sellub-Publishable-Key header. Mint your
key from the dashboard (Settings → API keys); it’s bound to one channel
and pinned to your origin.
import { createSellubClient } from "@duabalabs/sellub-client";
const sellub = createSellubClient({
baseUrl: "https://api.sellub.com",
publishableKey: process.env.SELLUB_PUBLISHABLE_KEY!,
});Take a one-off payment (donations, simple checkout)
const init = await sellub.externalPayments.initialize({
channelSlug: "duabanti",
email: "donor@example.com",
amount: 5000, // GHS 50.00 in pesewas
description: "May fundraiser",
callbackUrl: "https://duabanti.org/donate/thanks",
});
if (init.success && init.authorizationUrl) {
window.location.href = init.authorizationUrl;
}On the callback page:
const result = await sellub.externalPayments.verify(reference);
if (result.success && result.status === "success") {
// mark donation as fulfilled
}Start a subscription
const start = await sellub.subscriptions.start({
channelSlug: "duabaconnect",
email: "user@example.com",
plan: { name: "Pro Monthly", amount: 9900, interval: "monthly" },
callbackUrl: "https://app.duabaconnect.com/billing",
});
window.location.href = start.authorizationUrl!;const s = await sellub.subscriptions.status("SUB_xxx");
if (s.success && s.status === "active") {
// grant access
}Create a hosted invoice
const inv = await sellub.invoices.create({
channelSlug: "duabatrade",
email: "ops@buyer.com",
customerName: "Buyer Ltd.",
lineItems: [
{ name: "Migration setup", amount: 250000 },
{ name: "Training day", amount: 150000, quantity: 2 },
],
dueDate: "2026-06-30",
sendNotification: true,
});
console.log(inv.hostedUrl); // share with the customerErrors
Every method returns an object with success: boolean. On failure, error
contains a human-readable message; check it before acting on data.
const r = await sellub.subscriptions.start({...});
if (!r.success) {
console.error("Sellub error:", r.error);
return;
}Supplying your own fetch
Useful in older Node, custom edge runtimes or when injecting a tracing wrapper:
import undici from "undici";
const sellub = createSellubClient({
publishableKey: "pk_live_…",
fetch: undici.fetch,
});Server-side use
sellub-client is safe to call from a server. For server-only operations
(cancellations, refunds) use a secret key from the dashboard. Don’t ship
secret keys to a browser bundle.
Related
sellub-react—useSubscriptionhook over this client.sellub-webhooks— verify Sellub webhook deliveries.sellub-pricing— quote fees before you callinitialize.