GET: Account Transactions

Fetch Your Account Transactions

This endpoint enables you to fetch all your account transactions. You can pass in pagination parameters as illustrated below.

Fetch your account transactions

GET https://backend.payhero.co.ke/api/v2/transactions

Query Parameters

NameTypeDescription

page

Integer

The page number that you want to fecth data for

per

Integer

The total records per page

Headers

NameTypeDescription

Authorization:*

String

Basic authToken

{
  "transactions": [
    {
      "id": 451,
      "account_id": 183,
      "invoice_id": null,
      "transaction_type": "service_charge",
      "description": "Received KES 50 from ",
      "amount": -6,
      "transaction_reference": "EB7C4Z7RXC",
      "provider_reference": "cost_EB7C4Z7RXC",
      "goal_id": null,
      "gateway": "sasapay",
      "cost": 6,
      "wallet_balance": 6775,
      "transaction_name": "Transaction Fee",
      "created_at": "2024-01-19T15:13:11.203273Z",
      "updated_at": "2024-01-19T15:13:11.202741Z"
    },
    {
      "id": 450,
      "account_id": 183,
      "invoice_id": null,
      "transaction_type": "outbound_payment",
      "description": "Received KES 50 from ",
      "amount": 50,
      "transaction_reference": "EB7C4Z7RXC",
      "provider_reference": "EB7C4Z7RXC",
      "goal_id": null,
      "gateway": "sasapay",
      "cost": 6,
      "wallet_balance": 6775,
      "transaction_name": "Outbound Payment",
      "created_at": "2024-01-19T15:13:11.198821Z",
      "updated_at": "2024-01-19T15:13:11.19815Z"
    }
  ],
  "pagination": {
    "count": 284,
    "next_page": 3,
    "num_pages": 142,
    "page": 2,
    "per": 2,
    "prev_page": 1
  }
}

From the response you can pick the next_page and prev_page params to help you navigate easily, You also get a count of all the available transactions

Sample Code

This represents PHP Curl example of how to make the request, you can implement this in your specific language of choice

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://backend.payhero.co.ke/api/v2/transactions?page=2&per=2',
  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(
    'Authorization: Basic 3A6anVoWFZrRk5qSVl0MGNMOERGMlR3dlhrQ0VWUWJHNDVVVnNaMEdDSw=='
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Last updated