# Create a checkout session
curl https://api.fluxapay.co.uk/v1/checkout/sessions \
-H "Authorization: Bearer sk_live_..." \
-H "Idempotency-Key: ord_7f3a" \
-d '{
"amount": 14900,
"currency": "gbp",
"mode": "hosted",
"success_url": "https://yoursite.co.uk/thanks",
"cancel_url": "https://yoursite.co.uk/cart",
"reference": "ord_7f3a"
}'
# Response
{
"id": "cs_8f2a...",
"url": "https://pay.fluxapay.co.uk/cs_8f2a...",
"embed_url": "https://pay.fluxapay.co.uk/embed/cs_8f2a...",
"status": "open",
"expires_at": 1748441820,
"fee": 268
}
// server.js
const fluxa = require('fluxa')('sk_live_...');
const session = await fluxa.checkout.create({
amount: 14900,
currency: 'gbp',
mode: 'hosted', // or 'embedded'
success_url: 'https://yoursite.co.uk/thanks',
cancel_url: 'https://yoursite.co.uk/cart',
reference: 'ord_7f3a',
}, { idempotencyKey: 'ord_7f3a' });
// session.fee is in the response, not on an invoice
console.log(session.fee); // → 268
res.redirect(session.url);
// Verify the signature, then handle the event
app.post('/webhooks/fluxa', (req, res) => {
const sig = req.headers['fluxa-signature'];
const event = fluxa.webhooks.construct(req.rawBody, sig, endpointSecret);
if (event.type === 'payment.captured') {
fulfil(event.data.checkout_id);
}
if (event.type === 'payment.settled') {
credit(event.data.checkout_id, event.data.fee);
}
res.status(200).end();
});