update lisensi prosess
tests / ci (push) Has been cancelled

This commit is contained in:
Wian Drs
2026-08-25 13:43:55 +07:00
parent 1e80be180e
commit 60946ddf37
58 changed files with 2903 additions and 165 deletions
@@ -0,0 +1,30 @@
<?php
namespace App\Http\Controllers;
use App\Billing\PaymentGatewayManager;
use App\Models\BillingOrder;
use App\Services\BillingService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
class PaymentWebhookController extends Controller
{
public function __invoke(string $gateway, Request $request, PaymentGatewayManager $gateways, BillingService $billing): JsonResponse
{
$driver = $gateways->driver($gateway);
$payload = $request->all();
abort_unless($driver->verifyWebhook($payload, $request->headers->all()), 401, 'Invalid payment signature.');
$externalId = $driver->externalIdFromWebhook($payload);
$order = BillingOrder::withoutGlobalScope('tenant')->where('gateway', $gateway)->where('external_id', $externalId)->firstOrFail();
abort_unless((int) ($payload['amount'] ?? 0) === (int) $order->total, 422, 'Payment amount mismatch.');
$status = $driver->statusFromWebhook($payload);
if ($status === 'paid') {
$billing->activate($order);
} elseif ($order->status === 'pending') {
$order->update(['status' => $status]);
}
return response()->json(['success' => true]);
}
}