Authenticate with API keys and prevent duplicate requests with Idempotency-Key
Authorization
Authorization: Bearer <YOUR_SECRET_KEY>
X-Request-Id
Idempotency-Key: <a-unique-uuid-per-merchantTransactionId>
merchantTransactionId
409 conflict
import crypto from 'node:crypto' async function charge(body) { const idempotencyKey = crypto.randomUUID(); const res = await fetch('https://api.fingopay.io/v1/mpesa/charge', { method: 'POST', headers: { 'Authorization': `Bearer ${process.env.FINGO_API_KEY}`, 'Content-Type': 'application/json', 'Idempotency-Key': idempotencyKey }, body: JSON.stringify(body) }); return res.json(); }