kerliix-pay
v0.1.0
Published
Official JavaScript SDK for Kerliix Pay session creation and checkout integration.
Maintainers
Readme
Kerliix Pay SDK
Official JavaScript SDK for Kerliix Pay.
Install
npm install kerliix-payFor local testing inside this repo:
npm install ./sdkQuick start
import { KerliixPay } from "kerliix-pay";
const kerliixPay = new KerliixPay({
appId: process.env.KERLIIX_PAY_APP_ID,
secretKey: process.env.KERLIIX_PAY_SECRET,
});
const session = await kerliixPay.createOneTimePayment({
amount: 2500,
currency: "KES",
description: "Kerliix Pro Upgrade",
productId: "pro-upgrade",
customerEmail: "[email protected]",
customerName: "Kerliix Customer",
phoneNumber: "254712345678",
metadata: {
source: "my-app",
},
idempotencyKey: "order_12345",
});
console.log(session.checkoutUrl);By default, the SDK talks to https://pay.kerliix.com for both API and hosted checkout.
You only need to override URLs for local development or staging.
const kerliixPay = new KerliixPay({
appId: process.env.KERLIIX_PAY_APP_ID,
secretKey: process.env.KERLIIX_PAY_SECRET,
apiBaseUrl: "http://127.0.0.1:5000",
baseUrl: "http://127.0.0.1:5000",
});Session methods
createSession(payload, options)createOneTimePayment(payload, options)createSubscription(payload, options)createWalletTopup(payload, options)
Webhook verification
import { KerliixPay } from "kerliix-pay";
const kerliixPay = new KerliixPay({
appId: process.env.KERLIIX_PAY_APP_ID,
secretKey: process.env.KERLIIX_PAY_SECRET,
});
const valid = kerliixPay.verifyWebhookSignature(req.body, req.headers["x-kerliix-signature"]);Helper methods
signPayload(payload)verifyWebhookSignature(payload, signature)buildHostedUrl(sessionId, route = "confirm")
Notes
- Requires Node.js 18+ for native
fetch - Supports idempotency via
idempotencyKey - Defaults to
https://pay.kerliix.com - Uses the same HMAC signature format as Kerliix Pay server-side session creation
