alvoo / tanda
Laravel package for Tanda API
Requires
- php: ^7.1|^8.0|^8.1.8
- illuminate/support: ^5.0|^6.0|^7.0|^8.0|^9.0
README
Laravel package for Tanda payments API
This package helps you integrate Tanda payment APIs into your laravel app.
The following APIs can be integrated through the package:
- Airtime topup
- Utility bill payments
- Airtime voucher purchase
- Pay TV subscriptions
- Transaction status
- Account balances
This package is based on Tanda's REST API which can be found here: https://docs.tanda.co.ke/reference
Installation
You can install this package via composer
composer require alvoo/tanda
Configuration
After installing the package, run;
php artisan tanda:install
or
php artisan vendor:publish
This will publish config/tanda.php
file.
This file is where you will add Tanda API configurations. By default, the configuration is set to sandbox
so update to 'live' if you're using live credentials.
In your app's .env
add your Tanda credentials as follows:
TANDA_CLIENT_ID=[Client ID]
TANDA_CLIENT_SECRET=[Client Secret]
TANDA_ORG_ID=[Organization ID]
TANDA_ENV=[sandbox or live]
The callback URLs MUST be updated in config/tanda.php
.
After updating your .env
update the config:
php artisan config:cache
Usage
Import Tanda
Facade
use Tanda;
Airtime Purchase (Pinless prepaid airtime)
You can use this API for direct airtime topups.
Accepted parameters:
Provider
- Service provider IDSAFARICOM
,AIRTEL
,TELKOM
.MSISDN
- Phone number in international format.Amount
- Recharge amount (Should be between 10 and 10000).
$topup = Tanda::pinlessAirtime("SAFARICOM", "254712345678", 100);
Pay Tv
This method is used to make payments for TV subscriptions.
Accepted parameters:
Provider
- Pay TV service provider(GOTV
,DSTV
,ZUKU
,STARTIMES
).Account
- A valid box account number.Amount
- Bill Amount (Should be between 10 and 20000).
$pay = Tanda::payTV("GOTV", 201712256, 100);
Bill Pay
Use this to make bill payments.
Accepted parameters:
Provider
- Nairobi water (NAIROBI_WTR
).Account
- A Nairobi Wtr Meter Number.Amount
- Bill value in KES (Should be between 100 and 35000).
$bill = Tanda::billPay("NAIROBI_WTR", 25419321, 100);
Airtime Voucher
This method is used to generate airtime voucher pins which you can use to recharge normally as you would with scratch cards.
Accepted parameters:
Provider
- Service provider ID (SAFARICOM
,TELKOM
,AIRTEL
).Amount
- Voucher value.- Airtel - 20, 50, 100, 250, 500, 1000.
- Safaricom - 20, 50, 100, 250, 500, 1000.
- Telkom - 20, 50, 100, 200, 500, 1000.
$voucher = Tanda::voucherFix("SAFARICOM", 254712345678, 100);
Balance
This method is used to query the API for account balances.
$balances = Tanda::balances();
Transaction Status
Use this to query the transaction status API.
Accepted parameters:
Transaction ID
- Unique request id returned during the initialization stage.
$status = Tanda::query("ee92d1cb-625c-4e0a-8f28-8e86d929f9d7");
Contributing
Pull requests and issues are welcome. Refer to CONTRIBUTING.md
Security Vulnerabilities
If you discover any security vulnerability, please send an e-mail to alvinmayende@gmail.com.
License
This package is open-source software licensed under the MIT license.