29 lines
740 B
PHP
29 lines
740 B
PHP
|
|
<?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);
|
||
|
|
}
|
||
|
|
}
|