const ACOUNTPAY_BASE = 'https://api.acountpay.com/v1';
const headers = {
'X-Partner-Client-Id': process.env.ACOUNTPAY_CLIENT_ID,
'X-Partner-Client-Secret': process.env.ACOUNTPAY_CLIENT_SECRET,
'Content-Type': 'application/json',
};
async function processOrder(order) {
// 1. Create payment
// IMPORTANT: merchantClientId must be the UUID clientId from merchant creation,
// not the numeric merchant ID.
const res = await fetch(`${ACOUNTPAY_BASE}/partner/payments`, {
method: 'POST',
headers,
body: JSON.stringify({
merchantClientId: order.clientId,
amount: order.total,
referenceNumber: order.id,
description: `Order ${order.id}`,
}),
});
const { paymentId, paymentUrl } = await res.json();
// 2. Show QR on POS screen
displayQrCode(paymentUrl);
// 3. Payment status comes via webhook (see Webhooks guide)
// Or poll: GET /partner/payments/{paymentId}/status
}