PHP Classes

File: php/verifyPaymentPaystack.php

Recommend this page to a friend!
  Classes of bamigboye biodun   Logical Functions   php/verifyPaymentPaystack.php   Download  
File: php/verifyPaymentPaystack.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Logical Functions
General-purpose PHP and JavaScript functions
Author: By
Last change:
Date: 8 months ago
Size: 1,270 bytes


Class file image Download
function verifyPaymentPaystack(String $secretKey, $transactionReference)
: Array{

//The parameter after verify/ is the transaction reference to be verified
$url = ''.$transactionReference;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
'Authorization: Bearer '.$secretKey]
//send request
$request = curl_exec($ch);
//close connection
//declare an array that will contain the result
$result = array();
if (
$request) {
$result = json_decode($request, true);
    return [
'status' => false,
'message' => 'data_fetch_error'
$status =(array_key_exists('data', $result)
array_key_exists('status', $result['data'])
&& (
$result['data']['status'] === 'success'));

Author : Biodun Bamigboye
usage example
First Parameter is the secret key to your paystack account
Second Parameter is the transaction reference to be queried
returns an array
status key which is boolean shows the state of the transaction