Transaction verification
This shows you how to verify transactions using the transaction ID
After a successful charge, you need to verify that the payment was successful with Flutterwave before giving value to your customer on your website. For every transaction, you must supply a transaction ID
Here are some important things to check for when verifying the payment:
- Verify the transaction reference.
- Verify the
data.status
of the transaction to besuccessful
. - Verify the
currency
to be the expected currency - Most importantly validate the amount paid to be equal to or at least greater than the amount of the value to be given.
Below is a sample code of how to implement server-side validation in different programming languages:
curl --location --request GET 'https://api.flutterwave.com/v3/transactions/123456/verify' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {{SEC_KEY}}'
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://api.flutterwave.com/v3/transactions/123456/verify',
'headers': {
'Content-Type': 'application/json',
'Authorization': 'Bearer {{SEC_KEY}}'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.flutterwave.com/v3/transactions/123456/verify",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"Authorization: Bearer {{SEC_KEY}}"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
Verification response
Here's a sample verification response
{
"status": "success",
"message": "Transaction fetched successfully",
"data": {
"id": 1163068,
"tx_ref": "akhlm-pstmn-blkchrge-xx6",
"flw_ref": "FLW-M03K-02c21a8095c7e064b8b9714db834080b",
"device_fingerprint": "N/A",
"amount": 3000,
"currency": "NGN",
"charged_amount": 3000,
"app_fee": 1000,
"merchant_fee": 0,
"processor_response": "Approved",
"auth_model": "noauth",
"ip": "pstmn",
"narration": "Kendrick Graham",
"status": "successful",
"payment_type": "card",
"created_at": "2020-03-11T19:22:07.000Z",
"account_id": 73362,
"amount_settled": 2000,
"card": {
"first_6digits": "553188",
"last_4digits": "2950",
"issuer": " CREDIT",
"country": "NIGERIA NG",
"type": "MASTERCARD",
"token": "flw-t1nf-f9b3bf384cd30d6fca42b6df9d27bd2f-m03k",
"expiry": "09/22"
},
"customer": {
"id": 252759,
"name": "Kendrick Graham",
"phone_number": "0813XXXXXXX",
"email": "[email protected]",
"created_at": "2020-01-15T13:26:24.000Z"
}
}
}
Updated over 2 years ago