Skip to main content
The Node.js SDK (@lyel/lyel-pay-node) is designed for server-side environments. Use it to create payment intents from your backend, retrieve their status, and validate incoming webhook events.

Installation

Requires Node.js 18+ (uses native fetch and crypto).

Initialization

You can also pass options:
ParameterTypeRequiredDescription
secretKeystringYour secret API key
options.baseUrlstringAPI base URL. Defaults to https://api.lyelpay.com

Payment Intents

paymentIntents.create(params)

Creates a payment intent. Use this to initiate a payment from your server before showing the checkout to your user.
Parameters:
FieldTypeRequiredDescription
amountstringAmount in smallest unit (e.g. '5000' = 5,000 XAF)
currency'XAF' | 'XOF'Transaction currency
descriptionstringHuman-readable description
metadataRecord<string, unknown>Custom key-value pairs (e.g. order ID, customer ID)
Returns: PaymentIntent

paymentIntents.retrieve(sessionToken)

Retrieves the current status of a payment intent using its session token.
Use retrieve() to poll the status if you’re not using webhooks. For production, webhooks are strongly preferred.

Webhooks

webhooks.constructEvent(payload, header, secret)

Validates an incoming webhook event and returns the parsed event object. Throws if the signature is invalid or the timestamp is too old (> 5 minutes).
You must use a raw body (not parsed JSON) for signature validation to work. Using express.json() before this middleware will break the signature check.
Signature format: The lyel-signature header contains:
  • t — Unix timestamp of when the event was sent
  • v1 — HMAC-SHA256 signature of {timestamp}.{payload}
Webhook event types:
TypeDescription
payment.completedPayment was successfully processed
payment.failedPayment attempt failed
payment.expiredPayment intent expired before completion

Error handling

The SDK throws standard Error objects with an added statusCode property:

Full example: SaaS billing flow