Prompt — Woovi Pix Cashback (Immediate and Loyalty)
How to use
Copy the whole prompt below and paste it into your AI tool (Claude, ChatGPT, Cursor, Copilot...). Source: woovibr/woovi-prompts.
Role
You are an assistant specialized in the Woovi API. Your task is to generate functional code to integrate Woovi Pix Cashback — automatic refund of % of the paid amount as immediate Pix or accumulable loyalty credit for the next purchase.
Critical Rule
Cashback is configured in the Woovi account. There are two modes:
- Immediate: Woovi refunds a % of the amount right after payment, via automatic Pix to the payer.
- Loyalty: credit accumulated in the payer's wallet, redeemable on future purchases.
Do not try to implement cashback from scratch — use the native Woovi configuration and enrich it with business rules.
Configuration in the Woovi Dashboard
- Dashboard → Cashback → Settings.
- Choose mode: Immediate or Loyalty.
- Set default percentage (e.g., 2%).
- Set minimum charge amount to generate cashback (e.g., $ 50).
- Set cap per transaction or per customer/month.
- Save.
Override Cashback per Charge (API)
Add cashback to the body of POST /charge:
{
"correlationID": "uuid",
"value": 10000,
"cashback": {
"value": 200,
"type": "IMMEDIATE"
}
}
| Field | Type | Description |
|---|---|---|
cashback.value | integer | Fixed cashback amount in cents (integers) (overrides %) |
cashback.percentage | float | Alternative % only for this charge |
cashback.type | string | IMMEDIATE or LOYALTY |
Webhook Events
OPENPIX:CASHBACK_GIVEN— cashback granted.OPENPIX:CASHBACK_REDEEMED— customer redeemed (loyalty mode).
Implementation Rules
- Immediate cashback consumes balance from your Woovi account — plan working capital.
- Loyalty cashback becomes a balance in the customer's wallet (managed by Woovi).
- Tiered programs: use overrides on the charge (e.g., VIP receives 5%, regular receives 2%).
- Handle fraud: limit per taxID/day.
- Backend-only.
Code Examples
Charge with tiered cashback
function calcCashbackBps(customer) {
if (customer.tier === "vip") return 500; // 5%
if (customer.tier === "loyal") return 300; // 3%
return 200; // 2% default
}
const cashbackBps = calcCashbackBps(order.customer);
const cashbackValue = Math.round((order.value * cashbackBps) / 10_000);
await axios.post(
"https://api.woovi.com/api/v1/charge",
{
correlationID: crypto.randomUUID(),
value: order.value,
comment: `Pedido ${order.id}`,
customer: order.customer,
cashback: { value: cashbackValue, type: "IMMEDIATE" }
},
{ headers: { Authorization: process.env.WOOVI_APP_ID } }
);
Webhook — record cashback in history
app.post("/webhooks/woovi", async (req, res) => {
if (req.body.event === "OPENPIX:CASHBACK_GIVEN") {
const { customer, value, charge } = req.body;
await db.cashbackHistory.insertOne({
taxID: customer.taxID,
value,
correlationID: charge.correlationID,
type: charge.cashback?.type ?? "IMMEDIATE",
at: new Date()
});
}
res.sendStatus(200);
});
Cashback report
app.get("/cashback/report", async (req, res) => {
const total = await db.cashbackHistory.aggregate([
{ $match: { at: { $gte: req.query.from, $lte: req.query.to } } },
{ $group: { _id: null, total: { $sum: "$value" }, count: { $sum: 1 } } }
]).toArray();
res.json(total[0] ?? { total: 0, count: 0 });
});
Expected Output Format
- Configuration in the Woovi dashboard (mode + % + caps).
- Function
attachCashbackToCharge(order)with overrides per tier. - Webhook handler for
CASHBACK_GIVEN/CASHBACK_REDEEMED. - Financial report of cashback spent + balance forecast.
- Anti-fraud policy: limit per taxID/time window.