Download the PHP package keenops/laravel-tcb-cms without Composer
On this page you can find all versions of the php package keenops/laravel-tcb-cms. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-tcb-cms
Laravel TCB CMS
A Laravel package for integrating with Tanzania Commercial Bank's Cash Management System (CMS) API. This package enables payment reference creation, IPN (Instant Payment Notification) handling, reconciliation, and reference cancellation.
Requirements
- PHP 8.2+
- Laravel 11.x, 12.x, or 13.x
Installation
Install the package via Composer:
The package will auto-register its service provider and facade.
Publish Configuration
Run Migrations
This creates the tcb_cms_transactions table for transaction logging.
Configuration
Add the following environment variables to your .env file:
Configuration Options
| Option | Description | Default |
|---|---|---|
api_key |
Your TCB CMS API key | - |
partner_code |
Your partner code assigned by TCB | - |
profile_id |
Your profile ID | - |
base_url |
TCB CMS API base URL | https://partners.tcbbank.co.tz |
reconciliation_base_url |
Reconciliation API base URL | https://partners.tcbbank.co.tz:8444 |
ipn.route |
IPN callback route | /tcb-cms/ipn |
ipn.middleware |
Middleware for IPN route | ['api'] |
verify_ip |
Enable IP verification for IPN | false |
allowed_ips |
Comma-separated allowed IPs | - |
timeout |
HTTP request timeout (seconds) | 30 |
retry_times |
Number of retry attempts | 3 |
logging.enabled |
Enable transaction logging | true |
Usage
Using the Facade
Create a Payment Reference
Create a payment reference for a customer to make payments:
With optional amount and expiry date:
Cancel a Payment Reference
Reconciliation
Fetch all transactions within a date range:
Handling Payment Notifications (IPN)
The package automatically registers an IPN route at /tcb-cms/ipn (configurable). When TCB Bank sends a payment notification, the package dispatches a PaymentReceived event.
Create an Event Listener
Register the Listener
Or using Laravel 11+ event discovery, the listener will be auto-registered.
Available Events
| Event | Description | Payload |
|---|---|---|
PaymentReceived |
Dispatched when IPN callback is received | IpnPayload $payload |
ReferenceCreated |
Dispatched on successful reference creation | CreateReferenceRequest $request, CreateReferenceResponse $response |
ReferenceCancelled |
Dispatched on successful reference cancellation | CancelReferenceRequest $request, CancelReferenceResponse $response |
ReconciliationCompleted |
Dispatched after successful reconciliation | ReconciliationRequest $request, ReconciliationResponse $response |
Payment Channel Helper
Get payment instructions for different channels:
Available channels:
TCB_MOBILE- TCB Mobile BankingTCB_BRANCH- TCB BranchTCB_ATM- TCB ATMUSSD- USSD BankingINTERNET_BANKING- Internet BankingAGENT_BANKING- Agent BankingPESALINK- PesaLink
Transaction Logging
All API requests and IPN callbacks are logged to the tcb_cms_transactions table when logging is enabled.
Query Transaction Logs
Disable Logging
Set TCB_CMS_LOGGING_ENABLED=false in your .env file or update the config:
IP Verification for IPN
For additional security, enable IP verification to only accept IPN callbacks from TCB Bank's servers:
Error Handling
The package throws specific exceptions for different error scenarios:
Response Status Codes
Testing
Run the package tests:
Or using Pest directly:
Mocking in Your Application Tests
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.
Credits
Support
For issues and feature requests, please use the GitHub issue tracker.
All versions of laravel-tcb-cms with dependencies
illuminate/contracts Version ^11.0|^12.0|^13.0
illuminate/http Version ^11.0|^12.0|^13.0
illuminate/support Version ^11.0|^12.0|^13.0
illuminate/routing Version ^11.0|^12.0|^13.0
illuminate/database Version ^11.0|^12.0|^13.0
illuminate/events Version ^11.0|^12.0|^13.0