1. Go to this page and download the library: Download keenops/laravel-tcb-cms library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
// app/Listeners/HandleTcbPayment.php
namespace App\Listeners;
use Keenops\LaravelTcbCms\Events\PaymentReceived;
class HandleTcbPayment
{
public function handle(PaymentReceived $event): void
{
$payload = $event->payload;
// Access payment details
$transactionId = $payload->transactionId;
$reference = $payload->reference;
$amount = $payload->amount;
$payerName = $payload->payerName;
$payerMobile = $payload->payerMobile;
$transactionDate = $payload->transactionDate;
// Update your order/invoice
$order = Order::where('payment_reference', $reference)->first();
if ($order) {
$order->markAsPaid($transactionId, $amount);
}
}
}
// app/Providers/EventServiceProvider.php
use Keenops\LaravelTcbCms\Events\PaymentReceived;
use App\Listeners\HandleTcbPayment;
protected $listen = [
PaymentReceived::class => [
HandleTcbPayment::class,
],
];
use Keenops\LaravelTcbCms\Enums\PaymentChannel;
// Get instructions for a specific channel
$instructions = PaymentChannel::TcbMobile->getPaymentInstructions('999MYREF001');
// "Open TCB Mobile App > Payments > Bill Payments > Enter Reference: 999MYREF001"
// Get all channels with instructions
$channels = PaymentChannel::allWithInstructions('999MYREF001');
foreach ($channels as $value => $channel) {
echo $channel['label']; // "TCB Mobile Banking"
echo $channel['instructions']; // Payment instructions
}
use Keenops\LaravelTcbCms\Models\TcbTransaction;
// Get all transactions for a reference
$transactions = TcbTransaction::forReference('999MYREF001')->get();
// Get all successful transactions
$successful = TcbTransaction::successful()->get();
// Get all failed transactions
$failed = TcbTransaction::failed()->get();
// Get transactions by type
$ipnLogs = TcbTransaction::ofType('ipn')->get();
$createLogs = TcbTransaction::ofType('create_reference')->get();
$cancelLogs = TcbTransaction::ofType('cancel_reference')->get();
$reconcileLogs = TcbTransaction::ofType('reconciliation')->get();