mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
2.4 - Faking the Payment Gateway
This commit is contained in:
27
app/Http/Controllers/ConcertOrdersController.php
Normal file
27
app/Http/Controllers/ConcertOrdersController.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Concert;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Billing\PaymentGateway;
|
||||
|
||||
class ConcertOrdersController extends Controller
|
||||
{
|
||||
private $paymentGateway;
|
||||
|
||||
public function __construct(PaymentGateway $paymentGateway)
|
||||
{
|
||||
$this->paymentGateway = $paymentGateway;
|
||||
}
|
||||
|
||||
public function store($concertId)
|
||||
{
|
||||
$concert = Concert::find($concertId);
|
||||
$ticketQuantity = request('ticket_quantity');
|
||||
$amount = $ticketQuantity * $concert->ticket_price;
|
||||
$token = request('payment_token');
|
||||
$this->paymentGateway->charge($amount, $token);
|
||||
return response()->json([], 201);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user