const apiKey = process.env.REWARDS_API_KEY;
async function sendReward(rewardsUserId, amount) {
const response = await fetch('https://api.zbdpay.com/api/v2/rewards/limited-achievement/reward', {
method: 'POST',
headers: {
'x-api-key': apiKey,
'z-client': 'developer-dashboard',
'Content-Type': 'application/json'
},
body: JSON.stringify({
rewardsUserId,
amount
})
});
const data = await response.json();
if (data.success) {
console.log(`Reward sent! Transaction ID: ${data.data[0].transactionId}`);
return data.data[0];
} else {
throw new Error(`Failed to send reward: ${data.message}`);
}
}
// Example: Send 10 reward units
await sendReward('f2154d1a-67e6-46f2-b293-b4b226948dc9', 10);