modified logic slightly so that controller can be refactored at some point
This commit is contained in:
parent
d07ecc79d1
commit
bf40fd7088
|
|
@ -99,12 +99,8 @@ class EventCheckoutController extends Controller
|
|||
}
|
||||
|
||||
$total_ticket_quantity = $total_ticket_quantity + $current_ticket_quantity;
|
||||
|
||||
$ticket = Ticket::find($ticket_id);
|
||||
|
||||
$ticket_quantity_remaining = $ticket->quantity_remaining;
|
||||
|
||||
|
||||
$max_per_person = min($ticket_quantity_remaining, $ticket->max_per_person);
|
||||
|
||||
$quantity_available_validation_rules['ticket_' . $ticket_id] = [
|
||||
|
|
@ -169,16 +165,12 @@ class EventCheckoutController extends Controller
|
|||
* Validation rules for custom questions
|
||||
*/
|
||||
foreach ($ticket->questions as $question) {
|
||||
|
||||
if ($question->is_required && $question->is_enabled) {
|
||||
$validation_rules['ticket_holder_questions.' . $ticket_id . '.' . $i . '.' . $question->id] = ['required'];
|
||||
$validation_messages['ticket_holder_questions.' . $ticket_id . '.' . $i . '.' . $question->id . '.required'] = "This question is required";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (empty($tickets)) {
|
||||
|
|
@ -286,10 +278,7 @@ class EventCheckoutController extends Controller
|
|||
*/
|
||||
public function postCreateOrder(Request $request, $event_id)
|
||||
{
|
||||
|
||||
/*
|
||||
* If there's no session kill the request and redirect back to the event homepage.
|
||||
*/
|
||||
//If there's no session kill the request and redirect back to the event homepage.
|
||||
if (!session()->get('ticket_order_' . $event_id)) {
|
||||
return response()->json([
|
||||
'status' => 'error',
|
||||
|
|
@ -301,7 +290,7 @@ class EventCheckoutController extends Controller
|
|||
}
|
||||
|
||||
$event = Event::findOrFail($event_id);
|
||||
$order = new Order;
|
||||
$order = new Order();
|
||||
$ticket_order = session()->get('ticket_order_' . $event_id);
|
||||
|
||||
$validation_rules = $ticket_order['validation_rules'];
|
||||
|
|
@ -317,25 +306,21 @@ class EventCheckoutController extends Controller
|
|||
]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add the request data to a session in case payment is required off-site
|
||||
*/
|
||||
//Add the request data to a session in case payment is required off-site
|
||||
session()->push('ticket_order_' . $event_id . '.request_data', $request->except(['card-number', 'card-cvc']));
|
||||
|
||||
/*
|
||||
* Begin payment attempt before creating the attendees etc.
|
||||
* */
|
||||
if ($ticket_order['order_requires_payment']) {
|
||||
$orderRequiresPayment = $ticket_order['order_requires_payment'];
|
||||
|
||||
/*
|
||||
* Check if the user has chosen to pay offline
|
||||
* and if they are allowed
|
||||
*/
|
||||
if ($request->get('pay_offline') && $event->enable_offline_payments) {
|
||||
if ($orderRequiresPayment && $request->get('pay_offline') && $event->enable_offline_payments) {
|
||||
return $this->completeOrder($event_id);
|
||||
}
|
||||
|
||||
if (!$orderRequiresPayment) {
|
||||
return $this->completeOrder($event_id);
|
||||
}
|
||||
|
||||
try {
|
||||
//more transation data being put in here.
|
||||
$transaction_data = [];
|
||||
if (config('attendize.enable_dummy_payment_gateway') == TRUE) {
|
||||
$formData = config('attendize.fake_card_data');
|
||||
|
|
@ -362,6 +347,7 @@ class EventCheckoutController extends Controller
|
|||
'description' => 'Order for customer: ' . $request->get('order_email'),
|
||||
];
|
||||
|
||||
//TODO: class with an interface that builds the transaction data.
|
||||
switch ($ticket_order['payment_gateway']->id) {
|
||||
case config('attendize.payment_gateway_dummy'):
|
||||
$token = uniqid();
|
||||
|
|
@ -454,13 +440,6 @@ class EventCheckoutController extends Controller
|
|||
'message' => $error,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* No payment required so go ahead and complete the order
|
||||
*/
|
||||
return $this->completeOrder($event_id);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue