Skip to main content
react-lyel-pay-js provides ready-made React components that embed the full Lyel Pay checkout experience — phone number entry, OTP validation, and payment confirmation — without you building the UI from scratch.

Installation


Basic usage

The simplest integration is two lines: initialize Lyel Pay with loadLyelPay, then drop in <LyelPayElements />.
LyelPayElements automatically renders:
  1. A checkout form asking for the user’s phone number and password
  2. An OTP validation form after the payment intent is created

loadLyelPay(apiKey, amount, clientSecret)

Initializes the Lyel Pay instance asynchronously. Returns a Promise that resolves to a LyelPayInstance.
ParameterTypeDescription
apiKeystringYour merchant API key
amountnumberAmount to charge (e.g. 5000 for 5,000 XAF)
clientSecretstringYour client secret from the dashboard

<LyelPayElements options={promise} />

The main checkout component. Pass the promise returned by loadLyelPay as the options prop.
The component manages its own internal state (step 1: credentials, step 2: OTP). No additional props are required for basic usage.

Using the provider directly

For advanced use cases — custom styling, multi-step flows, or accessing the Lyel Pay context in nested components — you can use LyelPayProvider and useLyelPay directly:

useLyelPay()

React hook that returns the current LyelPayContextData from the nearest LyelPayProvider.
Returns undefined if used outside a LyelPayProvider.

Customization

The React SDK is intentionally minimal. For full UI control:
  • Use the JavaScript SDK to drive the flow manually
  • Build your own form components and call createIntention, initOtp, verifyOtp, and charge directly
Default styling uses inline styles. You can override classes in the rendered form elements using standard CSS.

Next steps

JavaScript SDK

Build a fully custom checkout UI.

Webhooks

Confirm payments server-side with webhooks.