PHPackages                             tecksolke-tpay/app-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. tecksolke-tpay/app-api

ActiveLibrary[HTTP &amp; Networking](/categories/http)

tecksolke-tpay/app-api
======================

This package contains all t-pay/api, that is api for making requests to t-pay payment gateway for any app.

v2.2.2(6y ago)11831MITPHP

Since Jun 3Pushed 5y agoCompare

[ Source](https://github.com/dev-tecksolke/tecksolke-tpay-app-api)[ Packagist](https://packagist.org/packages/tecksolke-tpay/app-api)[ RSS](/packages/tecksolke-tpay-app-api/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (17)Used By (0)

[![](https://camo.githubusercontent.com/e4922173547734a9b82a18d077a5e5a6de7d8decdd33b4952eb4047296dcf455/68747470733a2f2f747061792e636f2e6b652f696d672f6c6f676f2d626c61636b2e706e67)](https://tpay.co.ke/)

[](#)

 **Make It Happen**
 [ ![](https://camo.githubusercontent.com/231f13b8abe107e5865771a2569844f929f856f944acb3301c9df613abccbfc3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6465762d7465636b736f6c6b652f7465636b736f6c6b652d747061792d6170702d6170692e737667) ](https://github.com/dev-tecksolke/tecksolke-tpay-app-api/issues) [ ![](https://camo.githubusercontent.com/4c2efdf0a05bb6c7dbad90531f3d3dfd9fd000c6e95f239a7624d3fd86ba7023/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6465762d7465636b736f6c6b652f7465636b736f6c6b652d747061792d6170702d6170692e737667) ](https://github.com/dev-tecksolke/tecksolke-tpay-app-api/network/members) [ ![](https://camo.githubusercontent.com/1f33f63e92cf46419e2dce4f1d7ca9ae35d8d4ed287f71bb0bf38b1f17fc7963/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6465762d7465636b736f6c6b652f7465636b736f6c6b652d747061792d6170702d6170692e737667) ](https://github.com/dev-tecksolke/tecksolke-tpay-app-api/stargazers) [ ![](https://camo.githubusercontent.com/0e0899ed0374c04fcd87677af0db6e34e1c8d1aa1d28909f9ff503fac35e4a16/68747470733a2f2f706f7365722e707567782e6f72672f7465636b736f6c6b652d747061792f6170702d6170692f762f737461626c65) ](https://packagist.org/packages/tecksolke-tpay/app-api) [ ![](https://camo.githubusercontent.com/be99e0a2df604bc81cc9e1a52625ad6153b3c0648f4ef0cfd59374654d200a2b/68747470733a2f2f706f7365722e707567782e6f72672f7465636b736f6c6b652d747061792f6170702d6170692f646f776e6c6f616473) ](https://packagist.org/packages/tecksolke-tpay/app-api)

 [![](https://camo.githubusercontent.com/96fd8e6ef415047e5bd43744795a4bb3ff3e954b778e2626a44d3b7de33b920e/68747470733a2f2f747061792e636f2e6b652f696d672f747061792d6170692e676966)](https://camo.githubusercontent.com/96fd8e6ef415047e5bd43744795a4bb3ff3e954b778e2626a44d3b7de33b920e/68747470733a2f2f747061792e636f2e6b652f696d672f747061792d6170692e676966)

Introduction
------------

[](#introduction)

T-Pay API is REST-API that makes it easy for one to make request to the T-Pay Payment Gateway for his/her App.

- The API is simple and easy to install.
- Has both B2C and C2B API for your App's.
- The API can only be used by those having apps, in T-Pay Payment Gateway.
- The API is based on PHP *[Laravel Framework](https://laravel.com/)*. But you can try to install and customize it basing on your *PHP* development platform.

Help and docs
-------------

[](#help-and-docs)

- [API Documentation](https://dev.tpay.co.ke/)

Installing
----------

[](#installing)

The recommended way to install tpay-app-api is through [Composer](http://getcomposer.org).

```
# Install package via composer
composer require tecksolke-tpay/app-api
```

Next, run the Composer command to install the latest stable version of *tpay/app-api*:

```
# Update package via composer
 composer update tecksolke-tpay/app-api --lock
```

After installing, the package will be auto discovered, But if need you may run:

```
# run for auto discovery
composer dump-autoload
```

Then run this, to get the *config/tpay.php* for api configurations:

```
# run this to get the configuartion file at config/tpay.php
php artisan vendor:publish --provider="TPay\API\TPayServiceProvider"
```

You will have to provide this in the *.env* for the api configurations:

```
# https://sandbox.tpay.co.ke or https://production.tpay.co.ke
T_PAY_END_POINT_URL=

# TP4*****82F
T_PAY_APP_KEY=

#
T_PAY_APP_SECRET_CODE=

# 60  ->default(58 minutes);
T_PAY_TOKEN_SESSION=

# 120
# This is not a must you may choose to use the dafault value defined in the config/tpay.php;
T_PAY_RESPONSE_TIMEOUT=

# 60
# This is not a must you may choose to use the dafault value defined in the config/tpay.php;
T_PAY_CONNECTION_TIMEOUT=
```

Usage
-----

[](#usage)

Follow the steps below on how to use the api:

#### How to use the API

[](#how-to-use-the-api)

This how the api will be accessed via this package...

```
     /**
        * ---------------------------------
        *  Requesting app balance [ GET Request  ]
        * ---------------------------------
        * @throws Exception
        */
       use TPay\API\API\AppBalances;
       public function appBalance() {
           try {
               //Set request options as shown here
               $options = [
                   'secretCode' => '',//This has to be your app T_PAY_APP_SECRET_CODE
               ];

               //make request here
               $response = (new AppBalances())->appBalances($options);

               //continue with what you what to do with the $response here
           } catch (Exception $exception) {
               //TODO If an exception occurs
           }
       }

        /**
         * ------------------
         * Express Payment [ POST Request ]
         * -----------------
         * This is used to directly get payment from
         * a client account to your application
         */
        use TPay\API\API\ExpressPayment;
        public function expressPayment() {
            try {
                $options = [
                    'referenceCode' => '',//Unique referenceCode i.e TPXXXXX
                    'redirectURL' => '',//This is the URL that the user will be redirect after payment
                    'resultURL' => '',//This is the url that will receive the response data after successful payment. Note that this has to be a post callback so remember to use post in your callback.
                    'amount' => 1,//amount to be paid
                ];

                //make the request here
                $response = (new ExpressPayment())->expressPayment($options);

                //proceed with the response

            } catch (Exception $exception) {
                //TODO If an exception occurs
            }
        }

       /**
        * ------------------------------------
        * Making app stk push request for c2b  [ POS Request ]
        * ------------------------------------
        */
       use TPay\API\API\AppC2BSTKPush;
       public function appC2BSTKPush() {
           try {
               //Set request options as shown here
               $options = [
                   'secretCode' => '',//This has to be your app T_PAY_APP_SECRET_CODE
                   'phoneNumber' => '',//The phone number has to be 2547xxxxxxx
                   'referenceCode' => '',//The secret code should be unique in every request you send and must start with TPXXXX
                   'amount' => 1,//Amount has to be an integer and less than or equal to KES 70000
                   'resultURL' => '',//This has to be your callback i.e https://mydomain/callback or http://mydomain/callback. Also note that this has to be a post callback so remember to use post in your callback.
               ];

               //make the c2b stk push here
               $response = (new AppC2BSTKPush())->appC2BSTKPush($options);

               //continue with what you what to do with the $response here
           } catch (\Exception $exception) {
               //TODO If an exception occurs
           }
       }

       /**
        * ------------------------------------
        * Making app withdraw request for b2c  [ POST Request ]
        * ------------------------------------
        */
       use TPay\API\API\AppB2C;
       public function appB2C() {
           try {
               //Set request options as shown here
               $options = [
                   'secretCode' => '',//This has to be your app T_PAY_APP_SECRET_CODE
                   'phoneNumber' => '',//The phone number has to be 2547xxxxxxx
                   'referenceCode' => '',//The secret code should be unique in every request you send and must start with TPXXXX
                   'amount' => 1,//Amount has to be an integer and has to be greater than KES 10
                   'resultURL' => '',//This has to be your callback i.e https://mydomain/callback or http://mydomain/callback. Also note that this has to be a post callback so remember to use post in your callback.
               ];

               //make the b2c withdraw here
               $response = (new AppB2C())->appB2C($options);

               //continue with what you what to do with the $response here
           } catch (\Exception $exception) {
               //TODO If an exception occurs
           }
       }

```

#### API Response(s)

[](#api-responses)

This is for Express Payment success -- The express payment callback will only be sent if the client pays --

```
{
    "success":true,
    "data":{
    "amount":1,//This will be the amount paid to your application
    "referenceCode":"TP0******6F7"//This the reference code you used to make your request
    }
}
```

This is for B2C success -- The withdraw has been received --

```
{
    "success":true,
    "data":{
        "appName":"",//Your App Name
        "referenceCode":"",//This will be your reference Code that you used to make the request
        "receiver":"",//The number that receives the payment
        "transactionID":"",//Unique transaction ID
        "amount"://The amount withdrawn
         }
}
```

This is for B2C failed -- The withdraw has not been received --

```
{
    "success":false,
    "data":{
        "appName":"",//Your App Name
        "referenceCode":"",//This will be your reference Code that you used to make the request
         }
}
```

This is for C2B success -- The Payment has been made --

```
{
    "success":true,
    "data":{
         "appName":"",//Your App Name
         "referenceCode":"",//This will be your reference Code that you used to make the request
         "phoneNumber":"",//The number that makes the payment
         "transactionID":"",//Unique transaction ID
         "amount"://The amount deposited/Paid
        }
}
```

This is for C2B failed -- The Payment has not been made --

```
{
    "success":false,
    "data":{
        "appName":"",//Your App Name
        "referenceCode":"",//This will be your reference Code that you used to make the request
         }
}
```

Version Guidance
----------------

[](#version-guidance)

VersionStatusPackagistNamespaceRepo1.xEOL`tecksolke-tpay/app-api``TPay\API`[v1.9.9](https://github.com/dev-tecksolke/tecksolke-tpay-app-api/releases/tag/v1.9.9)2.xLatest`tecksolke-tpay/app-api``TPay\API`[v2.2.2](https://github.com/dev-tecksolke/tecksolke-tpay-app-api/releases/tag/v2.2.2)Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

For any security vulnerabilities, please email to [TecksolKE](mailto:client@tecksol.co.ke).

License
-------

[](#license)

This package is open-source API licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 97.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~23 days

Recently: every ~33 days

Total

15

Last Release

2250d ago

Major Versions

1.0.x-dev → v2.0.02019-12-13

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/875797?v=4)[TechGuy](/maintainers/TechGuy)[@techguy](https://github.com/techguy)

---

Top Contributors

[![general-oisebe](https://avatars.githubusercontent.com/u/154009443?v=4)](https://github.com/general-oisebe "general-oisebe (47 commits)")[![dev-techguy](https://avatars.githubusercontent.com/u/36882600?v=4)](https://github.com/dev-techguy "dev-techguy (1 commits)")

---

Tags

apiguzzlelaravelphptpay

### Embed Badge

![Health badge](/badges/tecksolke-tpay-app-api/health.svg)

```
[![Health](https://phpackages.com/badges/tecksolke-tpay-app-api/health.svg)](https://phpackages.com/packages/tecksolke-tpay-app-api)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k532.1M2.5k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)[illuminate/http

The Illuminate Http package.

11937.2M6.5k](/packages/illuminate-http)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3661.2M46](/packages/tencentcloud-tencentcloud-sdk-php)[dreamfactory/df-core

DreamFactory(tm) Core Components

1652.0k38](/packages/dreamfactory-df-core)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

252.5k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
