LLM chargeback drafting workflow: 1) Gather inputs: Paystack transaction record (reference, amount, date, authorization), order fulfillment record, customer email history, delivery confirmation. 2) Feed to LLM: "Draft a chargeback dispute response using only these facts. Do not invent delivery details or customer communications not shown here." 3) LLM drafts dispute in standard format. 4) Human reviews: verify every factual claim against actual records. 5) Human submits via Paystack Disputes section in dashboard. The LLM writes the argument structure. You supply and verify every fact.
// Build context package for LLM dispute drafting
async function buildDisputeContext(transactionReference) {
var headers = { Authorization: 'Bearer ' + process.env.PAYSTACK_SECRET_KEY };
// 1. Get Paystack transaction details
var txnRes = await fetch('https://api.paystack.co/transaction/verify/' + transactionReference, { headers });
var txn = (await txnRes.json()).data;
// 2. Get your order record
var order = await db.orders.findByReference(transactionReference);
// 3. Get customer email history from your CRM/email tool
var emails = await crm.getEmailThread(txn.customer.email, { since: new Date(txn.paid_at) });
return {
transaction: {
reference: txn.reference,
amount_ngn: txn.amount / 100,
date: txn.paid_at,
channel: txn.channel,
card_last_four: txn.authorization?.last4,
card_brand: txn.authorization?.brand,
ip_address: txn.ip_address,
authorization_code: txn.authorization?.authorization_code,
},
order: {
items: order.line_items,
fulfillment_status: order.status,
fulfillment_date: order.fulfilled_at,
delivery_proof: order.delivery_proof_url, // tracking URL or delivery confirmation
},
customer_communications: emails.map(e => ({
date: e.date,
subject: e.subject,
direction: e.direction, // 'sent' | 'received'
summary: e.body.slice(0, 200), // brief summary, not full body
})),
};
}
// Generate dispute draft
async function draftChargebackDispute(transactionReference) {
var context = await buildDisputeContext(transactionReference);
var prompt = `You are helping draft a chargeback dispute response for a Paystack merchant.
Transaction evidence:
${JSON.stringify(context, null, 2)}
Draft a chargeback dispute response that:
1. Clearly states the transaction was authorized and legitimate
2. References specific evidence from the data provided (dates, amounts, fulfillment proof)
3. Summarizes customer communication showing the customer was engaged with the purchase
4. Notes any delivery or fulfillment confirmation
IMPORTANT: Use only the facts provided above. Do not invent or assume any details not present.
If any evidence is missing (e.g., no delivery confirmation), note what is missing rather than fabricating it.
Format as a professional dispute letter.`;
var response = await anthropic.messages.create({
model: 'claude-opus-4-6',
max_tokens: 1024,
messages: [{ role: 'user', content: prompt }],
});
return {
draft: response.content[0].text,
context, // human reviews context + draft together
warning: 'This is an AI draft. Verify every factual claim against your actual records before submission.',
};
}
Gather this before asking the LLM to draft. Missing evidence weakens your dispute:
Get weekly developer tips
Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.
No spam. Unsubscribe anytime.
See audit trails for AI financial actions to understand logging requirements around AI-assisted dispute processes.
KES 2,999
The definitive guide to building payment systems with Paystack — from your first transaction to production-grade payment infrastructure across Africa. 9 modules, 47 lessons. Free preview available.
Start Paystack Course