Hosted Checkout
Accept payments with a single redirect. No frontend code required -- Elebne handles the payment UI.
Hosted Checkout
Hosted Checkout is the fastest way to accept Elebne payments. You create a payment intent with redirect URLs, then send your customer to the Elebne payment page. After payment, they are redirected back to your site.
Flow
Your server Elebne Customer
| | |
|-- POST /dev/intents ----->| |
|<-- { payUrl, ref } -------| |
| | |
|-- Redirect customer ----->|-- Payment page ---------->|
| | |
| |<-- Pays with wallet ------|
| | |
|<-- webhook: confirmed ----|-- Redirect success_url -->|
| | |
|-- GET /dev/intents/{ref} ->| |
|<-- { status: "PAID" } ----| |Step 1: Create a payment intent
Create an intent with success_url and cancel_url. The response includes a payUrl where you redirect the customer.
curl -X POST https://api.elebne.ai/api/v1/dev/intents \
-H "Authorization: Bearer sk_test_YOUR_KEY" \
-H "Content-Type: application/json" \
-H "X-Idempotency-Key: order-1234-$(date +%s)" \
-d '{
"amount": 50000,
"label": "Commande #1234",
"success_url": "https://yoursite.com/payment/success",
"cancel_url": "https://yoursite.com/payment/cancel",
"metadata": {
"order_id": "1234",
"customer_email": "[email protected]"
}
}'const response = await fetch('https://api.elebne.ai/api/v1/dev/intents', {
method: 'POST',
headers: {
'Authorization': 'Bearer sk_test_YOUR_KEY',
'Content-Type': 'application/json',
'X-Idempotency-Key': `order-1234-${Date.now()}`,
},
body: JSON.stringify({
amount: 50000,
label: 'Commande #1234',
success_url: 'https://yoursite.com/payment/success',
cancel_url: 'https://yoursite.com/payment/cancel',
metadata: {
order_id: '1234',
customer_email: '[email protected]',
},
}),
});
const { data } = await response.json();
// Redirect customer to data.payUrlimport requests
import time
response = requests.post(
'https://api.elebne.ai/api/v1/dev/intents',
headers={
'Authorization': 'Bearer sk_test_YOUR_KEY',
'Content-Type': 'application/json',
'X-Idempotency-Key': f'order-1234-{int(time.time())}',
},
json={
'amount': 50000,
'label': 'Commande #1234',
'success_url': 'https://yoursite.com/payment/success',
'cancel_url': 'https://yoursite.com/payment/cancel',
'metadata': {
'order_id': '1234',
'customer_email': '[email protected]',
},
},
)
data = response.json()['data']
# Redirect customer to data['payUrl']The response includes the hosted payment URL:
{
"success": true,
"data": {
"referenceNumber": "PI-3XXXXXXXXXXXXXX",
"shortCode": "A1B2C3",
"code": "482917",
"payUrl": "https://pay.elebne.ai/p/A1B2C3",
"amount": 50000,
"amountType": "FIXED",
"currency": "MRU",
"label": "Commande #1234",
"status": "PENDING",
"sandbox": true,
"metadata": { "order_id": "1234", "customer_email": "[email protected]" },
"expiresAt": "2026-04-05T10:30:00.000Z",
"createdAt": "2026-04-04T10:30:00.000Z"
}
}Step 2: Redirect the customer
Send the customer to the payUrl returned in the response:
// Express.js example
app.post('/checkout', async (req, res) => {
const intent = await createPaymentIntent(req.body);
res.redirect(303, intent.payUrl);
});The customer sees the Elebne payment page with your merchant name, logo, amount, and label. They confirm payment using their Elebne wallet PIN.
Step 3: Handle the redirect
After payment, the customer is redirected to your success_url with the reference number appended:
https://yoursite.com/payment/success?ref=PI-3XXXXXXXXXXXXXXIf the customer cancels, they are redirected to your cancel_url.
Always verify server-side
The redirect to success_url only means the customer completed the flow. Always verify the payment status server-side before fulfilling an order. A customer could manually navigate to your success URL.
Step 4: Verify payment status
Use the ref query parameter to check the payment status from your server:
curl https://api.elebne.ai/api/v1/dev/intents/PI-3XXXXXXXXXXXXXX \
-H "Authorization: Bearer sk_test_YOUR_KEY"const response = await fetch(
`https://api.elebne.ai/api/v1/dev/intents/${ref}`,
{
headers: { 'Authorization': 'Bearer sk_test_YOUR_KEY' },
}
);
const { data } = await response.json();
if (data.status === 'PAID') {
// Fulfill the order
}response = requests.get(
f'https://api.elebne.ai/api/v1/dev/intents/{ref}',
headers={'Authorization': 'Bearer sk_test_YOUR_KEY'},
)
data = response.json()['data']
if data['status'] == 'PAID':
# Fulfill the orderError handling
| Scenario | What happens |
|---|---|
| Customer closes the page | Intent stays PENDING, expires after 24h |
| Customer clicks "Cancel" | Redirected to cancel_url, intent stays PENDING |
| Payment fails | Customer sees error on payment page, can retry |
| Intent expires (24h) | payment.expired webhook fired, intent moves to CANCELLED |
| Network error creating intent | Retry with the same X-Idempotency-Key -- safe and returns the same response |
Next steps
- Payment Intents -- full lifecycle and status flow
- Webhooks & Events -- get notified in real-time instead of polling
- Refunds -- refund a completed payment
Was this page helpful?