feat(admin): add payment verification flow for bookings
This commit is contained in:
parent
f85c7e1809
commit
22b9694588
|
|
@ -566,6 +566,34 @@ public function togglePaymentStatus(Request $request, Booking $booking)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifikasi pembayaran (status verification -> paid)
|
||||||
|
*/
|
||||||
|
public function verifyPayment(Request $request, Booking $booking)
|
||||||
|
{
|
||||||
|
// ========== AUTHORIZATION ===========
|
||||||
|
$admin = auth()->guard('admin')->user();
|
||||||
|
if ($admin) {
|
||||||
|
if ($booking->kontrakan->admin_id !== $admin->id) {
|
||||||
|
abort(403, 'Anda tidak memiliki akses ke booking ini.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only allow verification when status is verification
|
||||||
|
if ($booking->payment_status !== 'verification') {
|
||||||
|
return back()->with('error', 'Status pembayaran bukan verifikasi.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$method = $request->input('payment_method', 'cash');
|
||||||
|
$booking->update([
|
||||||
|
'payment_status' => 'paid',
|
||||||
|
'payment_method' => $method,
|
||||||
|
'paid_at' => now(),
|
||||||
|
]);
|
||||||
|
|
||||||
|
return back()->with('success', 'Pembayaran berhasil diverifikasi dan ditandai lunas.');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hapus booking
|
* Hapus booking
|
||||||
*/
|
*/
|
||||||
|
|
@ -579,6 +607,13 @@ public function destroy(Booking $booking)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$admin = auth()->guard('admin')->user();
|
||||||
|
if ($admin) {
|
||||||
|
if ($booking->kontrakan->admin_id !== $admin->id) {
|
||||||
|
abort(403, 'Anda tidak memiliki akses ke booking ini.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// delete() akan trigger boot()->deleted() yang auto sync status kontrakan
|
// delete() akan trigger boot()->deleted() yang auto sync status kontrakan
|
||||||
$booking->delete();
|
$booking->delete();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -189,6 +189,19 @@
|
||||||
<span class="badge {{ $booking->payment_status == 'paid' ? 'bg-success' : 'bg-secondary' }}">
|
<span class="badge {{ $booking->payment_status == 'paid' ? 'bg-success' : 'bg-secondary' }}">
|
||||||
{{ $booking->payment_status_label }}
|
{{ $booking->payment_status_label }}
|
||||||
</span>
|
</span>
|
||||||
|
@if($booking->payment_status == 'verification')
|
||||||
|
<form action="{{ route('admin.bookings.verify-payment', $booking->id) }}" method="POST" class="d-inline ms-2">
|
||||||
|
@csrf
|
||||||
|
<select name="payment_method" class="form-select d-inline w-auto" required>
|
||||||
|
<option value="cash">Cash</option>
|
||||||
|
<option value="transfer">Transfer</option>
|
||||||
|
<option value="other">Lainnya</option>
|
||||||
|
</select>
|
||||||
|
<button type="submit" class="btn btn-sm btn-success" onclick="return confirm('Verifikasi pembayaran?')">
|
||||||
|
Verifikasi
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
@if($booking->payment_proof)
|
@if($booking->payment_proof)
|
||||||
<a href="{{ route('admin.bookings.payment-proof', $booking->id) }}" target="_blank" class="btn btn-sm btn-outline-success ms-1" title="Lihat Bukti Transfer">
|
<a href="{{ route('admin.bookings.payment-proof', $booking->id) }}" target="_blank" class="btn btn-sm btn-outline-success ms-1" title="Lihat Bukti Transfer">
|
||||||
<i class="bi bi-image"></i>
|
<i class="bi bi-image"></i>
|
||||||
|
|
|
||||||
|
|
@ -290,6 +290,21 @@ class="btn btn-sm btn-outline-success mt-1">
|
||||||
</button>
|
</button>
|
||||||
@endif
|
@endif
|
||||||
</form>
|
</form>
|
||||||
|
@if($booking->payment_status == 'verification')
|
||||||
|
<form action="{{ route('admin.bookings.verify-payment', $booking->id) }}" method="POST" class="mt-2">
|
||||||
|
@csrf
|
||||||
|
<div class="input-group">
|
||||||
|
<select name="payment_method" class="form-select" required>
|
||||||
|
<option value="cash">Cash</option>
|
||||||
|
<option value="transfer">Transfer</option>
|
||||||
|
<option value="other">Lainnya</option>
|
||||||
|
</select>
|
||||||
|
<button type="submit" class="btn btn-success" onclick="return confirm('Verifikasi pembayaran?')">
|
||||||
|
Verifikasi
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
{{-- Cancel --}}
|
{{-- Cancel --}}
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,7 @@
|
||||||
Route::post('/{booking}/cancel', [BookingController::class, 'cancel'])->name('cancel');
|
Route::post('/{booking}/cancel', [BookingController::class, 'cancel'])->name('cancel');
|
||||||
Route::post('/{booking}/mark-paid', [BookingController::class, 'markPaid'])->name('mark-paid');
|
Route::post('/{booking}/mark-paid', [BookingController::class, 'markPaid'])->name('mark-paid');
|
||||||
Route::post('/{booking}/toggle-payment', [BookingController::class, 'togglePaymentStatus'])->name('toggle-payment');
|
Route::post('/{booking}/toggle-payment', [BookingController::class, 'togglePaymentStatus'])->name('toggle-payment');
|
||||||
|
Route::post('/{booking}/verify-payment', [BookingController::class, 'verifyPayment'])->name('verify-payment');
|
||||||
|
|
||||||
// API & History
|
// API & History
|
||||||
Route::post('/check-availability', [BookingController::class, 'checkAvailability'])->name('check-availability');
|
Route::post('/check-availability', [BookingController::class, 'checkAvailability'])->name('check-availability');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue