mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
(add TicketPurchasingService)
...only to be deleted in the very next commit! 😈
This commit is contained in:
25
app/TicketPurchasingService.php
Normal file
25
app/TicketPurchasingService.php
Normal 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user