(add TicketPurchasingService)

...only to be deleted in the very next commit! 😈
This commit is contained in:
Adam Wathan
2016-12-15 18:44:27 -05:00
parent 4efdc94e2f
commit cf2444da45

View File

@@ -0,0 +1,25 @@
<?php
namespace App;
use App\Order;
use App\Billing\PaymentGateway;
class TicketPurchasingService
{
private $paymentGateway;
public function __construct(PaymentGateway $paymentGateway)
{
$this->paymentGateway = $paymentGateway;
}
public function purchaseTickets($concert, $ticketQuantity, $email, $paymentToken)
{
$reservation = $concert->reserveTickets($ticketQuantity, $email);
$this->paymentGateway->charge($reservation->totalCost(), $paymentToken);
return Order::forTickets($reservation->tickets(), $reservation->email(), $reservation->totalCost());
}
}