Module 02 · Lesson 04
Verify on your server
Check status, amount, currency, and that the reference is new.
Build it6 min
const res = await fetch(
`https://api.paystack.co/transaction/verify/${encodeURIComponent(reference)}`,
{ headers: { Authorization: `Bearer ${process.env.PAYSTACK_SECRET_KEY}` } },
);
const { data } = await res.json();
const ok =
data.status === "success" &&
data.amount === order.totalPesewas &&
data.currency === "GHS" &&
!order.paid;