Verify Transactions

Confirm a payment and ensure that the transaction details match the details you set

After a successful transaction, a call to verify said transaction needsto be made to ensure the details of the transaction are correctbefore the transaction is confirmed.

Transactions can be verified on the client-side but it is strongly recommended that all transactions be verified on your server to prevent man-in-the-middle attacks.

On your server-side check, ensure that the following are correct:

  1. Transaction Reference
  2. "transaction_information.data.responsecode" of the transaction. Successful transactions have a value "00"
  3. Currency
  4. Amount. Ensure that the amount is equal to or greater than the amount for the transaction

1
2
3
4
curl --request POST
--url {{base_url}}/status/
--header 'content-type: application/json'
--data '{"reference":"XXXXX","secret":"XXXXX"}'

Verifying transactions on your server

This examples shows you how to get the txRef & flwRef from the callback response on the client page and send it to a server page to verify and log the transaction before giving value.

The code snippet below shows you how to get the reference needed from the response on the frontend, send it to a sample server script and then complete the transaction.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<button type="button" onclick="getpaid();">Pay Now</button>
<script type="text/javascript" src="{{base_url}}/bp-inline.js"></script>
<script type="text/javascript">
function getpaid(){
const public_key = "XXXXX";
var reference = "BP_PB_TRANSACTIONS_" + Math.random();
boltpaySetup({
bp_public_key: public_key,
txref: reference,
customer_email: "example@domain.com",
customer_phone: "15551234567",
customer_firstname: "Example",
customer_lastname: "User",
amount: 100, //amount in cents, ergo 100 equals 1 USD
currency: "USD",
callback: function(response) {
var transaction_reference = response.transaction_information.data.transaction_reference;
var transaction_response_code = response.transaction_information.data.responsecode;
if (transaction_response_code == "00") {
//Redirect to success page
window.location="https://domain.com/verify.php?reference="+transaction_reference;
} else {
//Redirect to failure page
window.location="https://domain.com/verify.php?reference="+transaction_reference;
}
}
});
}
</script>

Sample Responses

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
{
"status": "success",
"message": "Transaction fetched",
"data": {
"transaction_reference": "bp-checkout-00",
"payment_reference": "BP_LIVE_XXXX",
"responsecode": "00",
"responsemessage": "Approved",
"amount": "10.00",
"currency": "USD",
"transaction_date": "2018-01-01 01:23:45",
"card": {
"first6": "424242",
"last4": "4242"
}
}
}

Content

  • Verify transactions
  • Verifying transactions on your server
  • Sample responses
  • Still questions?