Files
famous-ly4-ev/app-modules/payment/src/Http/Controllers/PaymentController.php
T

29 lines
740 B
PHP
Raw Normal View History

<?php
namespace Modules\Payment\Http\Controllers;
use Illuminate\Http\JsonResponse;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\Gate;
use Modules\Booking\Models\Booking;
use Modules\Payment\Actions\InitiatePaymentAction;
use Modules\Payment\Http\Resources\PaymentResource;
class PaymentController extends Controller
{
public function __construct(
private InitiatePaymentAction $initiatePaymentAction,
) {}
public function initiate(Booking $booking): JsonResponse
{
Gate::authorize('pay', $booking);
$payment = $this->initiatePaymentAction->handle($booking);
return (new PaymentResource($payment))
->response()
->setStatusCode(201);
}
}