mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-02-01 11:47:22 +00:00
52 - Avoiding Service Classes with Method Injection
This commit is contained in:
@@ -30,17 +30,9 @@ class ConcertOrdersController extends Controller
|
||||
]);
|
||||
|
||||
try {
|
||||
// Find some tickets
|
||||
$reservation = $concert->reserveTickets(request('ticket_quantity'), request('email'));
|
||||
|
||||
// Charge the customer for the tickets
|
||||
$this->paymentGateway->charge($reservation->totalCost(), request('payment_token'));
|
||||
|
||||
// Create an order for those tickets
|
||||
$order = $reservation->complete();
|
||||
|
||||
$order = $reservation->complete($this->paymentGateway, request('payment_token'));
|
||||
return response()->json($order, 201);
|
||||
|
||||
} catch (PaymentFailedException $e) {
|
||||
$reservation->cancel();
|
||||
return response()->json([], 422);
|
||||
|
||||
Reference in New Issue
Block a user