import { LyelPay, OPERATION_TYPE_ENDPOINTS } from '@lyel/lyel-pay-js';
const lyel = new LyelPay({ apiKey: 'YOUR_API_KEY', env: 'production' });
// 1. Create an intention
const intention = await lyel.createIntention(OPERATION_TYPE_ENDPOINTS.PAYMENT, {
amount: 5000,
from: 'MERCHANT_ID',
to: 'CLIENT_ID',
currency: 'XAF',
description: 'Order #1042',
metadata: { orderId: '1042' },
});
// 2. Send OTP to the user
await lyel.initOtp({ userId: 'CLIENT_ID', channel: 'sms' });
// 3. User enters OTP → you verify it
await lyel.verifyOtp({ userId: 'CLIENT_ID', otp: userEnteredCode });
// 4. Execute the transaction
const result = await lyel.charge({ intentionId: intention.id });
console.log('Payment complete ✅', result);