Files
ticketbeast/app/TicketPurchasingService.php
Adam Wathan cf2444da45 (add TicketPurchasingService)
...only to be deleted in the very next commit! 😈
2016-12-15 18:44:27 -05:00

26 lines
625 B
PHP

<?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());
}
}