42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\Finance;
|
|
|
|
use App\Http\Controllers\Api\Core\BaseApiController;
|
|
use App\Http\Requests\Payments\PaymentNotificationListRequest;
|
|
use App\Http\Requests\Payments\PaymentNotificationSendRequest;
|
|
use App\Http\Resources\Payments\PaymentNotificationLogResource;
|
|
use App\Services\Payments\PaymentNotificationService;
|
|
use Illuminate\Http\JsonResponse;
|
|
|
|
class PaymentNotificationController extends BaseApiController
|
|
{
|
|
public function __construct(private PaymentNotificationService $service)
|
|
{
|
|
parent::__construct();
|
|
}
|
|
|
|
public function index(PaymentNotificationListRequest $request): JsonResponse
|
|
{
|
|
$payload = $request->validated();
|
|
$logs = $this->service->listLogs(
|
|
$payload['from'] ?? null,
|
|
$payload['to'] ?? null,
|
|
$payload['type'] ?? null
|
|
);
|
|
|
|
return response()->json([
|
|
'ok' => true,
|
|
'logs' => PaymentNotificationLogResource::collection($logs),
|
|
]);
|
|
}
|
|
|
|
public function send(PaymentNotificationSendRequest $request): JsonResponse
|
|
{
|
|
$payload = $request->validated();
|
|
$result = $this->service->send($payload);
|
|
|
|
return response()->json(['ok' => true] + $result);
|
|
}
|
|
}
|