Skip to main content

Installation

npm install @plexos-pay/sdk
Requires Node.js 18+ or Bun 1.0+ (ESM only).

Usage

import { PlexosPay } from "@plexos-pay/sdk"

const plexos = PlexosPay({ apiKey: "sk_test_..." })

// Create a payment
const payment = await plexos.payments.create({
  amount: 10000,
  operator: "CVMOVEL",
  operatorPhone: "+2389001234",
})

// Create a checkout session
const session = await plexos.checkout.create({
  items: [
    { name: "T-Shirt", quantity: 2, unitPrice: 15000 },
  ],
  returnUrl: "https://myshop.com/thanks",
})
console.log(session.url)

// Get balance
const balance = await plexos.balance.get()
console.log(balance.available.amountFormatted)

Configuration

const plexos = PlexosPay({
  apiKey: "sk_test_...",       // or PLEXOS_PAY_SECRET_KEY env var
  baseUrl: "https://...",      // or PLEXOS_PAY_BASE_URL env var
  timeout: 30000,              // ms (default: 30s)
  maxRetries: 3,               // default: 3
})

Webhook Verification

import { verifyWebhookSignature } from "@plexos-pay/sdk"

const event = verifyWebhookSignature(
  rawBody, signature, timestamp, "whsec_..."
)

Error Handling

import { APIError, NetworkError } from "@plexos-pay/sdk"

try {
  await plexos.payments.get("pi_nonexistent")
} catch (err) {
  if (err instanceof APIError) {
    console.log(err.code, err.status) // "NOT_FOUND", 404
  }
}

Resources

ResourceMethods
paymentscreate, get, list, confirm, cancel
customerscreate, get, list, update
productscreate, get, list, update, delete
checkoutcreate, get, list, expire
refundscreate, get, list
webhookscreate, get, list, update, delete
balanceget
settlementsget, list, process
transactionslist
analyticsrevenue
auditLogslist

GitHub

View source code and report issues