d19a14a45e
- InitiatePaymentAction + POST /api/v1/payments/{booking}/initiate
- Generic KBZ webhook (POST /api/v1/webhooks/{method}/{encryptBookingId?}),
signature verification per KBZ's real callback spec, PaymentGatewayInterface::handleWebhook()
- ConfirmPaymentAction: idempotent confirmation, PaymentCompleted/PaymentFailed events,
MarkBookingPaid listener
- RefundBookingAction + POST /api/v1/bookings/{booking}/refund: partial refunds validated
against remaining balance, RefundProcessed event, MarkBookingRefunded listener
- CancelBookingAction now refunds confirmed bookings instead of rejecting; BookingPolicy::cancel
requires process_refunds for confirmed bookings
- PaymentPlugin + PaymentResource/RefundResource Filament admin UI (read-only payments,
refund list + Process action)
- Booking detail page now shows related payments
- Fix CACHE_STORE mismatch (database -> redis) so tagged route caching works
- CLAUDE.md: never run migrate:fresh/migrate:refresh/db:wipe on dev without being asked
27 lines
1.1 KiB
PHP
27 lines
1.1 KiB
PHP
<?php
|
|
|
|
use Modules\Booking\Enums\BookingStatus;
|
|
use Modules\Booking\Models\Booking;
|
|
use Modules\Payment\Enums\PaymentStatus;
|
|
use Modules\Payment\Events\PaymentCompleted;
|
|
use Modules\Payment\Listeners\MarkBookingPaid;
|
|
use Modules\Payment\Models\Payment;
|
|
|
|
test('flips a pending_payment booking to confirmed', function () {
|
|
$booking = Booking::factory()->create(['status' => BookingStatus::PendingPayment]);
|
|
$payment = Payment::factory()->completed()->create(['booking_id' => $booking->id]);
|
|
|
|
(new MarkBookingPaid)->handle(new PaymentCompleted($payment));
|
|
|
|
expect($booking->refresh()->status)->toBe(BookingStatus::Confirmed);
|
|
});
|
|
|
|
test('does not touch a booking that already moved on for another reason', function () {
|
|
$booking = Booking::factory()->create(['status' => BookingStatus::Cancelled]);
|
|
$payment = Payment::factory()->completed()->create(['booking_id' => $booking->id, 'status' => PaymentStatus::Completed]);
|
|
|
|
(new MarkBookingPaid)->handle(new PaymentCompleted($payment));
|
|
|
|
expect($booking->refresh()->status)->toBe(BookingStatus::Cancelled);
|
|
});
|