@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
fetch and crypto).
Initialization
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.
Returns:
PaymentIntent
paymentIntents.retrieve(sessionToken)
Retrieves the current status of a payment intent using its session token.
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).
lyel-signature header contains:
t— Unix timestamp of when the event was sentv1— HMAC-SHA256 signature of{timestamp}.{payload}
Error handling
The SDK throws standardError objects with an added statusCode property: