Lean control center at mini.ladill.com: payment QR CRUD, Paystack checkout with 5% fee settlement via Billing API, payments feed, and payouts. QR codes use a fixed black-and-white preset only. Co-authored-by: Cursor <cursoragent@cursor.com>
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Mini;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\MiniPayment;
|
|
use App\Models\QrCode;
|
|
use App\Services\Billing\BillingClient;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\View\View;
|
|
use Throwable;
|
|
|
|
class PayoutsController extends Controller
|
|
{
|
|
public function __construct(private BillingClient $billing) {}
|
|
|
|
public function index(): View
|
|
{
|
|
$account = ladill_account();
|
|
|
|
$qrIds = $account->qrCodes()
|
|
->where('type', QrCode::TYPE_PAYMENT)
|
|
->pluck('id');
|
|
|
|
$revenueMinor = (int) MiniPayment::query()
|
|
->whereIn('qr_code_id', $qrIds)
|
|
->where('status', MiniPayment::STATUS_PAID)
|
|
->sum('merchant_amount_minor');
|
|
|
|
$balanceMinor = 0;
|
|
try {
|
|
$balanceMinor = $this->billing->balanceMinor($account->public_id);
|
|
} catch (Throwable $e) {
|
|
Log::warning('Mini payouts could not load wallet balance', [
|
|
'user' => $account->public_id,
|
|
'error' => $e->getMessage(),
|
|
]);
|
|
}
|
|
|
|
$accountWalletUrl = 'https://'.config('app.account_domain').'/wallet';
|
|
|
|
return view('mini.payouts', [
|
|
'revenueMinor' => $revenueMinor,
|
|
'balanceMinor' => $balanceMinor,
|
|
'accountWalletUrl' => $accountWalletUrl,
|
|
]);
|
|
}
|
|
}
|