@duabalabs/dps-client
v0.1.2
Published
Typed client for the DPS unified checkout/commerce orchestration cloud functions.
Readme
@duabalabs/dps-client
Tiny typed client for the DPS unified checkout / commerce orchestration cloud functions.
Two consumption modes:
// 1) Browser (uses Parse JS SDK, public app id + js key only)
import Parse from "parse";
import { createDpsClient } from "@duabalabs/dps-client";
Parse.initialize(process.env.NEXT_PUBLIC_DPS_APP_ID!, process.env.NEXT_PUBLIC_DPS_JS_KEY!);
Parse.serverURL = process.env.NEXT_PUBLIC_DPS_SERVER_URL!;
const dps = createDpsClient({ Parse });
const session = await dps.createCheckout({
appId: "sellub:store-123",
storeId: "store-123",
flow: "vendure",
channelToken: "abc...",
customer: { email: "[email protected]" },
currency: "GHS",
lineItems: [{ productVariantId: "42", name: "T-shirt", quantity: 1, unitPrice: 50 }],
callbackUrl: "https://shop.example.com/checkout/return",
});
window.location.href = session.checkoutUrl;// 2) Server (uses fetch + master key — never ship master key to the browser)
import { createDpsServerClient } from "@duabalabs/dps-client";
const dps = createDpsServerClient({
serverUrl: process.env.DPS_PARSE_URL!, // e.g. https://dps.example.com/parse
appId: process.env.DPS_APP_ID!,
masterKey: process.env.DPS_MASTER_KEY!,
});
const session = await dps.createCheckout({ ... });Method surface is identical. Returns identical shapes.
Methods
| Method | Cloud function |
| ------ | -------------- |
| createCheckout(input) | dps_checkout_create |
| getCheckout(checkoutId) | dps_checkout_get |
| cancelCheckout(checkoutId) | dps_checkout_cancel |
| getOrder(orderId) | dps_orders_get |
| listOrders(input) | dps_orders_list |
| verifyPayment(reference) | dps_payments_verify |
Generic by design
appId is opaque (any app picks its own). flow is "vendure" or "direct". App-specific concerns (donation campaignId, subscription paystackPlanCode, shipment payload, etc.) live in metadata/paystackPlanCode/splitConfig and are forwarded to the orchestrator.
