ensureAcceptable($booking, $offerVersion); $booking->update([ 'accepted_at' => now(), 'acceptance' => [ 'offer_version' => $booking->offer_version, 'accepted_at' => now()->toIso8601String(), 'total' => $booking->total, 'quote_sha256' => hash('sha256', json_encode($booking->quote)), 'terms_sha256' => hash('sha256', (string) Content::get('contract.terms').'|'.Content::get('stay.cancellation')), 'via' => 'offer_link', ], ]); $this->confirm->handle($booking); try { Mail::to(config('fewo.notification_email'))->send(new OfferAnswered($booking, accepted: true)); } catch (Throwable $exception) { report($exception); } } /** * @throws ReservationException */ public function ensureAcceptable(Booking $booking, int $offerVersion): void { if ($offerVersion !== $booking->offer_version) { throw ReservationException::offerOutdated(); } if ($booking->status !== BookingStatus::OfferSent) { throw ReservationException::invalidTransition($booking->status->getLabel(), 'angenommen'); } if (! $booking->hold_expires_at?->isFuture()) { throw ReservationException::offerExpired(); } } }