Installation
npm install @plexos-pay/sdk
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
| Resource | Methods |
|---|---|
payments | create, get, list, confirm, cancel |
customers | create, get, list, update |
products | create, get, list, update, delete |
checkout | create, get, list, expire |
refunds | create, get, list |
webhooks | create, get, list, update, delete |
balance | get |
settlements | get, list, process |
transactions | list |
analytics | revenue |
auditLogs | list |
GitHub
View source code and report issues