Verify Payments
Confirm on your server that a payment really succeeded, for the right amount, before you deliver anything.
Never trust the browser alone
A success message in a popup, a redirect to your callback URL, or a reference typed into your app can all be faked. Only a verify call from your server, with your secret key, tells you the truth.
When to verify
Verify a transaction:
- when your customer returns to your callback URL after the redirect checkout;
- when your page receives a reference from the popup;
- when you receive a
charge.successwebhook (an extra check is good practice); - before you retry or cancel an order whose status you are unsure of.
Verify a transaction
Call Verify Transaction with the reference:
curl https://api.wiregh.com/transaction/verify/WG2611096D4HQE52FMY9KW \
-H "Authorization: Bearer YOUR_SECRET_KEY" \
-X GETconst response = await fetch('https://api.wiregh.com/transaction/verify/WG2611096D4HQE52FMY9KW', {
method: 'GET',
headers: {
Authorization: 'Bearer YOUR_SECRET_KEY'
}
});
const result = await response.json();
console.log(result);<?php
$ch = curl_init('https://api.wiregh.com/transaction/verify/WG2611096D4HQE52FMY9KW');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_SECRET_KEY',
],
]);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
print_r($result);{
"status": true,
"message": "Verification successful",
"data": {
"id": 173,
"domain": "test",
"status": "success",
"reference": "WG2611096D4HQE52FMY9KW",
"amount": 5000,
"requested_amount": 5000,
"message": null,
"gateway_response": "Approved",
"paid_at": "2026-11-09T01:03:40.000Z",
"created_at": "2026-11-09T01:03:40.000Z",
"channel": "mobile_money",
"currency": "GHS",
"ip_address": "154.160.2.17",
"metadata": {
"order_id": "1042"
},
"fees": 98,
"fee_bearer": "merchant",
"refunded_amount": 0,
"customer": {
"id": 169,
"first_name": null,
"last_name": null,
"email": "customer@email.com",
"customer_code": "CUS_c0473agwwkdxmih",
"phone": null,
"metadata": null,
"risk_action": "default",
"createdAt": "2026-11-09T01:03:40.000Z",
"updatedAt": "2026-11-09T01:03:40.000Z"
},
"authorization": {
"channel": "mobile_money",
"bank": "MTN",
"last4": "4987",
"country_code": "GH",
"reusable": false,
"mobile_money_number": "23355****87"
}
}
}What to check
Give value only when all of these are true:
- The top level
statusistrue. That only means the request worked. data.statusissuccess. Any other value means you have not been paid.data.amountequals the amount you expected, in pesewas.data.currencyisGHS.- You have not already delivered for this reference. Record each reference you fulfil and ignore repeats.
async function confirmPayment(reference, expectedAmount) {
const res = await fetch(
'https://api.wiregh.com/transaction/verify/' + encodeURIComponent(reference),
{ headers: { Authorization: 'Bearer ' + process.env.WIREGH_SECRET_KEY } }
);
const result = await res.json();
if (!result.status) return false; // request failed or reference unknown
const tx = result.data;
return tx.status === 'success'
&& tx.amount === expectedAmount // in pesewas
&& tx.currency === 'GHS';
}
// Look up the order by reference in YOUR database, then:
// if (await confirmPayment(order.reference, order.amountPesewas)) markOrderPaid(order);<?php
function confirm_payment(string $reference, int $expectedAmount): bool
{
$ch = curl_init('https://api.wiregh.com/transaction/verify/' . rawurlencode($reference));
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . getenv('WIREGH_SECRET_KEY')],
]);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
if (empty($result['status'])) {
return false; // request failed or reference unknown
}
$tx = $result['data'];
return $tx['status'] === 'success'
&& (int) $tx['amount'] === $expectedAmount // in pesewas
&& $tx['currency'] === 'GHS';
}
// Look up the order by reference in YOUR database, then:
// if (confirm_payment($order['reference'], $order['amount_pesewas'])) mark_order_paid($order);Transaction statuses
| Status | Meaning |
|---|---|
pending | Created, the customer has not paid yet. |
ongoing | The customer is approving the payment on their phone. |
success | Paid. You can give value. |
failed | The payment did not go through. gateway_response says why. |
abandoned | The customer never paid and the checkout expired. |
reversed | The payment was fully refunded. |
When you verify a pending or ongoing transaction, we check with the network first, so you always get the most current status.