This commit is contained in:
@@ -8,6 +8,7 @@ use Illuminate\Routing\Controller;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
use Modules\Booking\Models\Booking;
|
||||
use Modules\Payment\Actions\InitiatePaymentAction;
|
||||
use Modules\Payment\Enums\PaymentStatus;
|
||||
use Modules\Payment\Http\Resources\PaymentResource;
|
||||
|
||||
class PaymentController extends Controller
|
||||
@@ -26,6 +27,15 @@ class PaymentController extends Controller
|
||||
|
||||
$payment = $this->initiatePaymentAction->handle($booking);
|
||||
|
||||
if ($payment->status === PaymentStatus::Failed) {
|
||||
return response()->json([
|
||||
'message' => 'Payment initiation failed',
|
||||
'errors' => [
|
||||
'payment' => ['Payment initiation failed'],
|
||||
],
|
||||
], 422);
|
||||
}
|
||||
|
||||
return (new PaymentResource($payment))
|
||||
->response()
|
||||
->setStatusCode(201);
|
||||
|
||||
Reference in New Issue
Block a user