2016-03-05 00:18:10 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
2016-06-15 10:14:27 +00:00
|
|
|
use App\Events\OrderCompletedEvent;
|
2019-10-16 13:27:46 +00:00
|
|
|
//use App\Models\Account;
|
|
|
|
|
//use App\Models\AccountPaymentGateway;
|
2020-02-01 10:20:05 +00:00
|
|
|
//use App\Models\Affiliate;
|
2016-02-29 15:59:36 +00:00
|
|
|
use App\Models\Attendee;
|
2016-03-05 00:18:10 +00:00
|
|
|
use App\Models\Event;
|
2016-02-29 15:59:36 +00:00
|
|
|
use App\Models\EventStats;
|
2016-03-05 00:18:10 +00:00
|
|
|
use App\Models\Order;
|
2016-02-29 15:59:36 +00:00
|
|
|
use App\Models\OrderItem;
|
2019-10-16 13:27:46 +00:00
|
|
|
//use App\Models\PaymentGateway;
|
2016-04-04 11:21:09 +00:00
|
|
|
use App\Models\QuestionAnswer;
|
2016-09-06 20:39:27 +00:00
|
|
|
use App\Models\ReservedTickets;
|
2016-03-05 00:18:10 +00:00
|
|
|
use App\Models\Ticket;
|
2020-02-01 10:20:05 +00:00
|
|
|
//use App\Models\Venue;
|
2019-08-16 13:04:50 +00:00
|
|
|
use App\Payment\CardPayment;
|
2018-07-10 08:36:42 +00:00
|
|
|
use App\Services\Order as OrderService;
|
2016-03-05 00:18:10 +00:00
|
|
|
use Carbon\Carbon;
|
|
|
|
|
use Cookie;
|
|
|
|
|
use DB;
|
2016-05-08 15:36:26 +00:00
|
|
|
use Illuminate\Http\Request;
|
2016-03-05 00:18:10 +00:00
|
|
|
use Log;
|
2019-10-16 13:27:46 +00:00
|
|
|
//use Omnipay;
|
2016-03-05 00:18:10 +00:00
|
|
|
use PDF;
|
2016-05-20 22:54:45 +00:00
|
|
|
use PhpSpec\Exception\Exception;
|
2016-03-05 00:18:10 +00:00
|
|
|
use Validator;
|
2016-03-07 17:18:55 +00:00
|
|
|
|
2016-02-29 15:59:36 +00:00
|
|
|
class EventCheckoutController extends Controller
|
|
|
|
|
{
|
2016-03-16 01:13:49 +00:00
|
|
|
/**
|
|
|
|
|
* Is the checkout in an embedded Iframe?
|
|
|
|
|
*
|
|
|
|
|
* @var bool
|
|
|
|
|
*/
|
2016-02-29 15:59:36 +00:00
|
|
|
protected $is_embedded;
|
2019-08-16 13:04:50 +00:00
|
|
|
/**
|
|
|
|
|
* Payment gateway
|
|
|
|
|
* @var CardPayment
|
|
|
|
|
*/
|
|
|
|
|
protected $gateway;
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-03-16 01:13:49 +00:00
|
|
|
/**
|
|
|
|
|
* EventCheckoutController constructor.
|
|
|
|
|
* @param Request $request
|
|
|
|
|
*/
|
2019-08-16 13:04:50 +00:00
|
|
|
public function __construct(Request $request, CardPayment $gateway)
|
2016-02-29 15:59:36 +00:00
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* See if the checkout is being called from an embedded iframe.
|
|
|
|
|
*/
|
2016-03-16 01:13:49 +00:00
|
|
|
$this->is_embedded = $request->get('is_embedded') == '1';
|
2019-08-16 13:04:50 +00:00
|
|
|
$this->gateway = $gateway;
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2019-11-02 10:32:23 +00:00
|
|
|
public function postValidateDate(Request $request, $event_id){
|
|
|
|
|
|
|
|
|
|
$this->validate($request,['ticket_date'=>'required|date']);
|
|
|
|
|
// $validator = Validator::make($request->all(),['ticket_date'=>'required|date']);
|
|
|
|
|
// if($validator->fails()){
|
|
|
|
|
// return response()->json([
|
|
|
|
|
// 'status' => 'error',
|
|
|
|
|
// 'message' => 'Please choose date',
|
|
|
|
|
// ]);
|
|
|
|
|
// }
|
|
|
|
|
$event = Event::with('venue')->findOrFail($event_id);
|
2019-11-06 10:05:24 +00:00
|
|
|
$tickets = Ticket::with(['section','reserved:seat_no,ticket_id','booked:seat_no,ticket_id'])
|
2019-11-02 10:32:23 +00:00
|
|
|
->where('event_id',$event_id)
|
|
|
|
|
->where('ticket_date',$request->get('ticket_date'))
|
|
|
|
|
->where('is_hidden', false)
|
|
|
|
|
->orderBy('sort_order','asc')
|
|
|
|
|
->get();
|
2019-11-05 12:28:51 +00:00
|
|
|
//dd($tickets->first()->booked->pluck('seat_no')->toJson());
|
|
|
|
|
if($tickets->count()==0){
|
2019-11-02 10:32:23 +00:00
|
|
|
//todo flash message
|
|
|
|
|
session()->flash('error','There is no tickets available');
|
|
|
|
|
return redirect()->back();
|
|
|
|
|
}
|
2019-11-05 12:28:51 +00:00
|
|
|
|
2020-02-12 11:00:54 +00:00
|
|
|
return view('desktop.ViewEvent.SeatsPage',compact('event','tickets'));
|
2019-11-02 10:32:23 +00:00
|
|
|
}
|
2016-03-16 01:13:49 +00:00
|
|
|
/**
|
|
|
|
|
* Validate a ticket request. If successful reserve the tickets and redirect to checkout
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
|
|
|
|
*/
|
2019-11-05 12:28:51 +00:00
|
|
|
public function postValidateSeats(Request $request, $event_id){
|
|
|
|
|
if (!$request->has('seats')) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
'status' => 'error',
|
|
|
|
|
'message' => 'No seats selected',
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Order expires after X min
|
|
|
|
|
*/
|
|
|
|
|
$order_expires_time = Carbon::now()->addMinutes(config('attendize.checkout_timeout_after'));
|
|
|
|
|
|
|
|
|
|
$event = Event::findOrFail($event_id);
|
|
|
|
|
$seats = $request->get('seats');
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Remove any tickets the user has reserved
|
|
|
|
|
*/
|
|
|
|
|
ReservedTickets::where('session_id', '=', session()->getId())->delete();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Go though the selected tickets and check if they're available
|
|
|
|
|
* , tot up the price and reserve them to prevent over selling.
|
|
|
|
|
*/
|
|
|
|
|
$quantity_available_validation_rules = [];
|
|
|
|
|
$order_total = 0;
|
|
|
|
|
$booking_fee = 0;
|
|
|
|
|
$organiser_booking_fee = 0;
|
|
|
|
|
$total_ticket_quantity = 0;
|
|
|
|
|
$reserved = [];
|
|
|
|
|
$tickets = [];
|
|
|
|
|
$validation_rules = [];
|
|
|
|
|
$validation_messages = [];
|
|
|
|
|
foreach ($seats as $ticket_id=>$ticket_seats){
|
|
|
|
|
$seats_count = count($ticket_seats);
|
|
|
|
|
if($seats_count<1)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
$seat_nos = array_values($ticket_seats);
|
|
|
|
|
$reserved_tickets = ReservedTickets::where('ticket_id',$ticket_id)
|
|
|
|
|
->where('expires','>',Carbon::now())
|
|
|
|
|
->whereIn('seat_no',$seat_nos)
|
|
|
|
|
->pluck('seat_no');
|
|
|
|
|
|
|
|
|
|
$booked_tickets = Attendee::where('ticket_id',$ticket_id)
|
|
|
|
|
->where('event_id',$event_id)
|
|
|
|
|
->whereIn('seat_no',$seat_nos)
|
|
|
|
|
->pluck('seat_no');
|
|
|
|
|
|
|
|
|
|
if(count($reserved_tickets)>0 || count($booked_tickets)>0)
|
|
|
|
|
return response()->json([
|
|
|
|
|
'status' => 'error',
|
|
|
|
|
'messages' => 'Some of selected seats are already reserved',//todo show which are reserved
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$ticket = Ticket::findOrFail($ticket_id);
|
|
|
|
|
$max_per_person = min($ticket->quantity_remaining, $ticket->max_per_person);
|
|
|
|
|
/*
|
|
|
|
|
* Validation max min ticket count
|
|
|
|
|
*/
|
|
|
|
|
if($seats_count < $ticket->min_per_person){
|
|
|
|
|
$message = 'You must select at least ' . $ticket->min_per_person . ' tickets.';
|
|
|
|
|
}elseif ($seats_count > $max_per_person){
|
|
|
|
|
$message = 'The maximum number of tickets you can register is ' . $ticket->quantity_remaining;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($message)) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
'status' => 'error',
|
|
|
|
|
'messages' => $message,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$total_ticket_quantity += $seats_count;
|
|
|
|
|
$order_total += ($seats_count * $ticket->price);
|
|
|
|
|
$booking_fee += ($seats_count * $ticket->booking_fee);
|
|
|
|
|
$organiser_booking_fee += ($seats_count * $ticket->organiser_booking_fee);
|
|
|
|
|
$tickets[] = [
|
|
|
|
|
'ticket' => $ticket,
|
|
|
|
|
'qty' => $seats_count,
|
|
|
|
|
'seats' => $ticket_seats,
|
|
|
|
|
'price' => ($seats_count * $ticket->price),
|
|
|
|
|
'booking_fee' => ($seats_count * $ticket->booking_fee),
|
|
|
|
|
'organiser_booking_fee' => ($seats_count * $ticket->organiser_booking_fee),
|
2020-02-03 07:23:51 +00:00
|
|
|
'total_booking_fee' => $ticket->total_booking_fee,
|
2020-02-03 07:39:45 +00:00
|
|
|
'original_price' => $ticket->price,
|
2019-11-05 12:28:51 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($ticket_seats as $seat_no){
|
|
|
|
|
$reservedTickets = new ReservedTickets();
|
|
|
|
|
$reservedTickets->ticket_id = $ticket_id;
|
|
|
|
|
$reservedTickets->event_id = $event_id;
|
|
|
|
|
$reservedTickets->quantity_reserved = 1;
|
|
|
|
|
$reservedTickets->expires = $order_expires_time;
|
|
|
|
|
$reservedTickets->session_id = session()->getId();
|
|
|
|
|
$reservedTickets->seat_no = $seat_no;
|
|
|
|
|
$reserved[] = $reservedTickets->attributesToArray();
|
|
|
|
|
/*
|
|
|
|
|
* Create our validation rules here
|
|
|
|
|
*/
|
|
|
|
|
$validation_rules['ticket_holder_first_name.' . $seat_no . '.' . $ticket_id] = ['required'];
|
|
|
|
|
$validation_rules['ticket_holder_last_name.' . $seat_no . '.' . $ticket_id] = ['required'];
|
|
|
|
|
$validation_rules['ticket_holder_email.' . $seat_no . '.' . $ticket_id] = ['required', 'email'];
|
|
|
|
|
|
|
|
|
|
$validation_messages['ticket_holder_first_name.' . $seat_no . '.' . $ticket_id . '.required'] = 'Ticket holder ' . $seat_no . '\'s first name is required';
|
|
|
|
|
$validation_messages['ticket_holder_last_name.' . $seat_no . '.' . $ticket_id . '.required'] = 'Ticket holder ' . $seat_no . '\'s last name is required';
|
|
|
|
|
$validation_messages['ticket_holder_email.' . $seat_no . '.' . $ticket_id . '.required'] = 'Ticket holder ' . $seat_no . '\'s email is required';
|
|
|
|
|
$validation_messages['ticket_holder_email.' . $seat_no . '.' . $ticket_id . '.email'] = 'Ticket holder ' . $seat_no . '\'s email appears to be invalid';
|
|
|
|
|
/*
|
|
|
|
|
* Validation rules for custom questions
|
|
|
|
|
*/
|
|
|
|
|
foreach ($ticket->questions as $question) {
|
|
|
|
|
if ($question->is_required && $question->is_enabled) {
|
|
|
|
|
$validation_rules['ticket_holder_questions.' . $ticket_id . '.' . $seat_no . '.' . $question->id] = ['required'];
|
|
|
|
|
$validation_messages['ticket_holder_questions.' . $ticket_id . '.' . $seat_no . '.' . $question->id . '.required'] = "This question is required";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ReservedTickets::insert($reserved);
|
|
|
|
|
|
|
|
|
|
if (empty($tickets)) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
'status' => 'error',
|
|
|
|
|
'message' => 'No tickets selected.',
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
* The 'ticket_order_{event_id}' session stores everything we need to complete the transaction.
|
|
|
|
|
*/
|
|
|
|
|
session()->put('ticket_order_' . $event->id, [
|
|
|
|
|
'validation_rules' => $validation_rules,
|
|
|
|
|
'validation_messages' => $validation_messages,
|
|
|
|
|
'event_id' => $event->id,
|
|
|
|
|
'tickets' => $tickets,
|
|
|
|
|
'total_ticket_quantity' => $total_ticket_quantity,
|
|
|
|
|
'order_started' => time(),
|
|
|
|
|
'expires' => $order_expires_time,
|
|
|
|
|
// 'reserved_tickets_id' => $reservedTickets->id,
|
|
|
|
|
'order_total' => $order_total,
|
|
|
|
|
'booking_fee' => $booking_fee,
|
|
|
|
|
'organiser_booking_fee' => $organiser_booking_fee,
|
|
|
|
|
'total_booking_fee' => $booking_fee + $organiser_booking_fee,
|
|
|
|
|
'order_requires_payment' => (ceil($order_total) == 0) ? false : true,
|
|
|
|
|
'account_id' => $event->account->id,
|
|
|
|
|
'affiliate_referral' => Cookie::get('affiliate_' . $event_id),
|
|
|
|
|
// 'account_payment_gateway' => $activeAccountPaymentGateway,
|
|
|
|
|
// 'payment_gateway' => $paymentGateway
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If we're this far assume everything is OK and redirect them
|
|
|
|
|
* to the the checkout page.
|
|
|
|
|
*/
|
|
|
|
|
if ($request->ajax()) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
'status' => 'success',
|
|
|
|
|
'redirectUrl' => route('showEventCheckout', [
|
|
|
|
|
'event_id' => $event_id,
|
|
|
|
|
'is_embedded' => $this->is_embedded,
|
|
|
|
|
]) . '#order_form',
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* todo Maybe display something prettier than this?
|
|
|
|
|
*/
|
|
|
|
|
exit('Please enable Javascript in your browser.');
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-06 12:26:48 +00:00
|
|
|
// public function postValidateTickets(Request $request, $event_id)
|
|
|
|
|
// {
|
|
|
|
|
// if (!$request->has('seats')) {
|
|
|
|
|
// return response()->json([
|
|
|
|
|
// 'status' => 'error',
|
|
|
|
|
// 'message' => 'No seats selected',
|
|
|
|
|
// ]);
|
|
|
|
|
// }
|
|
|
|
|
// /*
|
|
|
|
|
// * Order expires after X min
|
|
|
|
|
// */
|
|
|
|
|
// $order_expires_time = Carbon::now()->addMinutes(config('attendize.checkout_timeout_after'));
|
|
|
|
|
//
|
|
|
|
|
// $event = Event::findOrFail($event_id);
|
|
|
|
|
// $ticket_ids = $request->get('tickets');
|
|
|
|
|
//
|
|
|
|
|
// /*
|
|
|
|
|
// * Remove any tickets the user has reserved
|
|
|
|
|
// */
|
|
|
|
|
// ReservedTickets::where('session_id', '=', session()->getId())->delete();
|
|
|
|
|
//
|
|
|
|
|
// /*
|
|
|
|
|
// * Go though the selected tickets and check if they're available
|
|
|
|
|
// * , tot up the price and reserve them to prevent over selling.
|
|
|
|
|
// */
|
|
|
|
|
//
|
|
|
|
|
// $validation_rules = [];
|
|
|
|
|
// $validation_messages = [];
|
|
|
|
|
// $tickets = [];
|
|
|
|
|
// $order_total = 0;
|
|
|
|
|
// $total_ticket_quantity = 0;
|
|
|
|
|
// $booking_fee = 0;
|
|
|
|
|
// $organiser_booking_fee = 0;
|
|
|
|
|
// $quantity_available_validation_rules = [];
|
|
|
|
|
//
|
|
|
|
|
// foreach ($ticket_ids as $ticket_id) {
|
|
|
|
|
// $current_ticket_quantity = (int)$request->get('ticket_' . $ticket_id);
|
|
|
|
|
//
|
|
|
|
|
// if ($current_ticket_quantity < 1) {
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// $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] = [
|
|
|
|
|
// 'numeric',
|
|
|
|
|
// 'min:' . $ticket->min_per_person,
|
|
|
|
|
// 'max:' . $max_per_person
|
|
|
|
|
// ];
|
|
|
|
|
//
|
|
|
|
|
// $quantity_available_validation_messages = [
|
|
|
|
|
// 'ticket_' . $ticket_id . '.max' => 'The maximum number of tickets you can register is ' . $ticket_quantity_remaining,
|
|
|
|
|
// 'ticket_' . $ticket_id . '.min' => 'You must select at least ' . $ticket->min_per_person . ' tickets.',
|
|
|
|
|
// ];
|
|
|
|
|
//
|
|
|
|
|
// $validator = Validator::make(['ticket_' . $ticket_id => (int)$request->get('ticket_' . $ticket_id)],
|
|
|
|
|
// $quantity_available_validation_rules, $quantity_available_validation_messages);
|
|
|
|
|
//
|
|
|
|
|
// if ($validator->fails()) {
|
2019-08-16 13:04:50 +00:00
|
|
|
// return response()->json([
|
2020-01-06 12:26:48 +00:00
|
|
|
// 'status' => 'error',
|
|
|
|
|
// 'messages' => $validator->messages()->toArray(),
|
2019-08-16 13:04:50 +00:00
|
|
|
// ]);
|
|
|
|
|
// }
|
2020-01-06 12:26:48 +00:00
|
|
|
//
|
|
|
|
|
// $order_total = $order_total + ($current_ticket_quantity * $ticket->price);
|
|
|
|
|
// $booking_fee = $booking_fee + ($current_ticket_quantity * $ticket->booking_fee);
|
|
|
|
|
// $organiser_booking_fee = $organiser_booking_fee + ($current_ticket_quantity * $ticket->organiser_booking_fee);
|
|
|
|
|
//
|
|
|
|
|
// $tickets[] = [
|
|
|
|
|
// 'ticket' => $ticket,
|
|
|
|
|
// 'qty' => $current_ticket_quantity,
|
|
|
|
|
// 'price' => ($current_ticket_quantity * $ticket->price),
|
|
|
|
|
// 'booking_fee' => ($current_ticket_quantity * $ticket->booking_fee),
|
|
|
|
|
// 'organiser_booking_fee' => ($current_ticket_quantity * $ticket->organiser_booking_fee),
|
|
|
|
|
// 'full_price' => $ticket->price + $ticket->total_booking_fee,
|
|
|
|
|
// ];
|
|
|
|
|
//
|
|
|
|
|
// /*
|
|
|
|
|
// * Reserve the tickets for X amount of minutes
|
|
|
|
|
// */
|
|
|
|
|
// $reservedTickets = new ReservedTickets();
|
|
|
|
|
// $reservedTickets->ticket_id = $ticket_id;
|
|
|
|
|
// $reservedTickets->event_id = $event_id;
|
|
|
|
|
// $reservedTickets->quantity_reserved = $current_ticket_quantity;
|
|
|
|
|
// $reservedTickets->expires = $order_expires_time;
|
|
|
|
|
// $reservedTickets->session_id = session()->getId();
|
|
|
|
|
// $reservedTickets->save();
|
|
|
|
|
//
|
|
|
|
|
// for ($i = 0; $i < $current_ticket_quantity; $i++) {
|
|
|
|
|
// /*
|
|
|
|
|
// * Create our validation rules here
|
|
|
|
|
// */
|
|
|
|
|
// $validation_rules['ticket_holder_first_name.' . $i . '.' . $ticket_id] = ['required'];
|
|
|
|
|
// $validation_rules['ticket_holder_last_name.' . $i . '.' . $ticket_id] = ['required'];
|
|
|
|
|
// $validation_rules['ticket_holder_email.' . $i . '.' . $ticket_id] = ['required', 'email'];
|
|
|
|
|
//
|
|
|
|
|
// $validation_messages['ticket_holder_first_name.' . $i . '.' . $ticket_id . '.required'] = 'Ticket holder ' . ($i + 1) . '\'s first name is required';
|
|
|
|
|
// $validation_messages['ticket_holder_last_name.' . $i . '.' . $ticket_id . '.required'] = 'Ticket holder ' . ($i + 1) . '\'s last name is required';
|
|
|
|
|
// $validation_messages['ticket_holder_email.' . $i . '.' . $ticket_id . '.required'] = 'Ticket holder ' . ($i + 1) . '\'s email is required';
|
|
|
|
|
// $validation_messages['ticket_holder_email.' . $i . '.' . $ticket_id . '.email'] = 'Ticket holder ' . ($i + 1) . '\'s email appears to be invalid';
|
|
|
|
|
//
|
|
|
|
|
// /*
|
|
|
|
|
// * 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";
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2019-08-16 13:04:50 +00:00
|
|
|
// }
|
2020-01-06 12:26:48 +00:00
|
|
|
//
|
|
|
|
|
// if (empty($tickets)) {
|
|
|
|
|
// return response()->json([
|
|
|
|
|
// 'status' => 'error',
|
|
|
|
|
// 'message' => 'No tickets selected.',
|
|
|
|
|
// ]);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//// if (config('attendize.enable_dummy_payment_gateway') == TRUE) {
|
|
|
|
|
//// $activeAccountPaymentGateway = new AccountPaymentGateway();
|
|
|
|
|
//// $activeAccountPaymentGateway->fill(['payment_gateway_id' => config('attendize.payment_gateway_dummy')]);
|
|
|
|
|
//// $paymentGateway = $activeAccountPaymentGateway;
|
|
|
|
|
//// } else {
|
|
|
|
|
//// $activeAccountPaymentGateway = $event->account->getGateway($event->account->payment_gateway_id);
|
|
|
|
|
//// //if no payment gateway configured and no offline pay, don't go to the next step and show user error
|
|
|
|
|
//// if (empty($activeAccountPaymentGateway) && !$event->enable_offline_payments) {
|
|
|
|
|
//// return response()->json([
|
|
|
|
|
//// 'status' => 'error',
|
|
|
|
|
//// 'message' => 'No payment gateway configured',
|
|
|
|
|
//// ]);
|
|
|
|
|
//// }
|
|
|
|
|
//// $paymentGateway = $activeAccountPaymentGateway ? $activeAccountPaymentGateway->payment_gateway : false;
|
|
|
|
|
//// }
|
|
|
|
|
//
|
|
|
|
|
// /*
|
|
|
|
|
// * The 'ticket_order_{event_id}' session stores everything we need to complete the transaction.
|
|
|
|
|
// */
|
|
|
|
|
// session()->put('ticket_order_' . $event->id, [
|
|
|
|
|
// 'validation_rules' => $validation_rules,
|
|
|
|
|
// 'validation_messages' => $validation_messages,
|
|
|
|
|
// 'event_id' => $event->id,
|
|
|
|
|
// 'tickets' => $tickets,
|
|
|
|
|
// 'total_ticket_quantity' => $total_ticket_quantity,
|
|
|
|
|
// 'order_started' => time(),
|
|
|
|
|
// 'expires' => $order_expires_time,
|
|
|
|
|
// 'reserved_tickets_id' => $reservedTickets->id,
|
|
|
|
|
// 'order_total' => $order_total,
|
|
|
|
|
// 'booking_fee' => $booking_fee,
|
|
|
|
|
// 'organiser_booking_fee' => $organiser_booking_fee,
|
|
|
|
|
// 'total_booking_fee' => $booking_fee + $organiser_booking_fee,
|
|
|
|
|
// 'order_requires_payment' => (ceil($order_total) == 0) ? false : true,
|
|
|
|
|
// 'account_id' => $event->account->id,
|
|
|
|
|
// 'affiliate_referral' => Cookie::get('affiliate_' . $event_id),
|
|
|
|
|
//// 'account_payment_gateway' => $activeAccountPaymentGateway,
|
|
|
|
|
//// 'payment_gateway' => $paymentGateway
|
|
|
|
|
// ]);
|
|
|
|
|
//
|
|
|
|
|
// /*
|
|
|
|
|
// * If we're this far assume everything is OK and redirect them
|
|
|
|
|
// * to the the checkout page.
|
|
|
|
|
// */
|
|
|
|
|
// if ($request->ajax()) {
|
|
|
|
|
// return response()->json([
|
|
|
|
|
// 'status' => 'success',
|
|
|
|
|
// 'redirectUrl' => route('showEventCheckout', [
|
|
|
|
|
// 'event_id' => $event_id,
|
|
|
|
|
// 'is_embedded' => $this->is_embedded,
|
|
|
|
|
// ]) . '#order_form',
|
|
|
|
|
// ]);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /*
|
|
|
|
|
// * todo Maybe display something prettier than this?
|
|
|
|
|
// */
|
|
|
|
|
// exit('Please enable Javascript in your browser.');
|
|
|
|
|
// }
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-03-16 01:13:49 +00:00
|
|
|
/**
|
|
|
|
|
* Show the checkout page
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
|
|
|
|
*/
|
|
|
|
|
public function showEventCheckout(Request $request, $event_id)
|
2016-02-29 15:59:36 +00:00
|
|
|
{
|
2016-04-04 11:21:09 +00:00
|
|
|
$order_session = session()->get('ticket_order_' . $event_id);
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
if (!$order_session || $order_session['expires'] < Carbon::now()) {
|
2016-11-06 21:56:35 +00:00
|
|
|
$route_name = $this->is_embedded ? 'showEmbeddedEventPage' : 'showEventPage';
|
|
|
|
|
return redirect()->route($route_name, ['event_id' => $event_id]);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$secondsToExpire = Carbon::now()->diffInSeconds($order_session['expires']);
|
|
|
|
|
|
2019-11-05 12:28:51 +00:00
|
|
|
$event = Event::with('venue')->findorFail($order_session['event_id']);
|
2018-07-10 08:36:42 +00:00
|
|
|
|
2018-07-10 10:19:20 +00:00
|
|
|
$orderService = new OrderService($order_session['order_total'], $order_session['total_booking_fee'], $event);
|
|
|
|
|
$orderService->calculateFinalCosts();
|
2018-07-10 08:36:42 +00:00
|
|
|
|
2016-02-29 15:59:36 +00:00
|
|
|
$data = $order_session + [
|
2018-07-10 08:36:42 +00:00
|
|
|
'event' => $event,
|
2016-02-29 15:59:36 +00:00
|
|
|
'secondsToExpire' => $secondsToExpire,
|
2016-05-08 15:36:26 +00:00
|
|
|
'is_embedded' => $this->is_embedded,
|
2018-07-10 14:50:46 +00:00
|
|
|
'orderService' => $orderService
|
2018-07-10 08:36:42 +00:00
|
|
|
];
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
if ($this->is_embedded) {
|
2019-09-14 12:27:41 +00:00
|
|
|
return view('Public.ViewEvent.Embedded.EventPageCheckout', $data); // <--- todo check this out
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
2016-03-05 00:18:10 +00:00
|
|
|
|
2019-09-23 10:35:40 +00:00
|
|
|
// return view('Public.ViewEvent.EventPageCheckout', $data);
|
2020-02-12 11:00:54 +00:00
|
|
|
return view('desktop.ViewEvent.CheckoutPage', $data);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2019-08-16 13:04:50 +00:00
|
|
|
/**
|
|
|
|
|
* Create the order, handle payment, update stats, fire off email jobs then redirect user
|
|
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @return \Illuminate\Http\JsonResponse
|
|
|
|
|
*/
|
|
|
|
|
public function postCreateOrder(Request $request, $event_id)
|
2016-02-29 15:59:36 +00:00
|
|
|
{
|
2018-10-16 19:03:55 +00:00
|
|
|
//If there's no session kill the request and redirect back to the event homepage.
|
2019-09-17 14:19:57 +00:00
|
|
|
$order_session = session()->get('ticket_order_' . $event_id);
|
|
|
|
|
if (!$order_session) {
|
2016-05-05 23:18:52 +00:00
|
|
|
return response()->json([
|
|
|
|
|
'status' => 'error',
|
|
|
|
|
'message' => 'Your session has expired.',
|
|
|
|
|
'redirectUrl' => route('showEventPage', [
|
|
|
|
|
'event_id' => $event_id,
|
|
|
|
|
])
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-29 15:59:36 +00:00
|
|
|
$event = Event::findOrFail($event_id);
|
2018-10-16 19:03:55 +00:00
|
|
|
$order = new Order();
|
2016-04-04 11:21:09 +00:00
|
|
|
$ticket_order = session()->get('ticket_order_' . $event_id);
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
$validation_rules = $ticket_order['validation_rules'];
|
|
|
|
|
$validation_messages = $ticket_order['validation_messages'];
|
|
|
|
|
|
2016-05-21 17:37:15 +00:00
|
|
|
$order->rules = $order->rules + $validation_rules;
|
|
|
|
|
$order->messages = $order->messages + $validation_messages;
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-03-16 01:13:49 +00:00
|
|
|
if (!$order->validate($request->all())) {
|
|
|
|
|
return response()->json([
|
2016-05-08 15:36:26 +00:00
|
|
|
'status' => 'error',
|
2016-03-05 00:18:10 +00:00
|
|
|
'messages' => $order->errors(),
|
|
|
|
|
]);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2019-08-29 19:23:05 +00:00
|
|
|
//Add the request data to a session in case payment is required off-site
|
2019-08-16 13:04:50 +00:00
|
|
|
session()->push('ticket_order_' . $event_id . '.request_data', $request->except(['card-number', 'card-cvc']));
|
2016-03-20 16:01:50 +00:00
|
|
|
|
2019-08-29 19:23:05 +00:00
|
|
|
$orderRequiresPayment = $ticket_order['order_requires_payment'];
|
2016-07-09 11:06:44 +00:00
|
|
|
|
2019-08-29 19:23:05 +00:00
|
|
|
if ($orderRequiresPayment && $request->get('pay_offline') && $event->enable_offline_payments) {
|
2018-10-16 19:03:55 +00:00
|
|
|
return $this->completeOrder($event_id);
|
|
|
|
|
}
|
2016-07-09 11:06:44 +00:00
|
|
|
|
2019-08-29 19:23:05 +00:00
|
|
|
if (!$orderRequiresPayment) {
|
2018-10-16 19:03:55 +00:00
|
|
|
return $this->completeOrder($event_id);
|
|
|
|
|
}
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2018-10-16 19:03:55 +00:00
|
|
|
try {
|
2019-08-16 13:04:50 +00:00
|
|
|
//more transaction data being put in here.
|
2019-08-29 19:23:05 +00:00
|
|
|
$transaction_data = [];
|
|
|
|
|
$orderService = new OrderService($ticket_order['order_total'], $ticket_order['total_booking_fee'], $event);
|
|
|
|
|
$orderService->calculateFinalCosts();
|
2019-09-17 14:19:57 +00:00
|
|
|
$secondsToExpire = Carbon::now()->diffInSeconds($order_session['expires']);
|
2019-08-29 19:23:05 +00:00
|
|
|
$transaction_data += [
|
2019-09-23 14:07:27 +00:00
|
|
|
'amount' => $orderService->getGrandTotal()*100,//multiply by 100 to obtain tenge
|
2019-08-16 13:04:50 +00:00
|
|
|
'currency' => 934,
|
2019-09-17 14:19:57 +00:00
|
|
|
'sessionTimeoutSecs' => $secondsToExpire,
|
2020-02-12 11:00:54 +00:00
|
|
|
'description' => 'desktop sargyt: ' . $request->get('order_email'),
|
2019-08-16 13:04:50 +00:00
|
|
|
'orderNumber' => uniqid(),
|
2020-01-29 17:16:15 +00:00
|
|
|
|
2019-08-16 13:04:50 +00:00
|
|
|
'failUrl' => route('showEventCheckoutPaymentReturn', [
|
|
|
|
|
'event_id' => $event_id,
|
|
|
|
|
'is_payment_cancelled' => 1
|
|
|
|
|
]),
|
|
|
|
|
'returnUrl' => route('showEventCheckoutPaymentReturn', [
|
|
|
|
|
'event_id' => $event_id,
|
|
|
|
|
'is_payment_successful' => 1
|
|
|
|
|
]),
|
|
|
|
|
|
2019-08-29 19:23:05 +00:00
|
|
|
];
|
2016-03-20 16:01:50 +00:00
|
|
|
|
2019-08-16 13:04:50 +00:00
|
|
|
$response = $this->gateway->registerPayment($transaction_data);
|
|
|
|
|
|
|
|
|
|
//todo start resolving payment here /////////////////////////////////////////////////////
|
|
|
|
|
if($response->isSuccessfull()){
|
2019-08-29 19:23:05 +00:00
|
|
|
/*
|
|
|
|
|
* As we're going off-site for payment we need to store some data in a session so it's available
|
|
|
|
|
* when we return
|
|
|
|
|
*/
|
2019-08-16 13:04:50 +00:00
|
|
|
$transaction_data['orderId'] = $response->getPaymentReferenceId();
|
2019-08-29 19:23:05 +00:00
|
|
|
session()->push('ticket_order_' . $event_id . '.transaction_data', $transaction_data);
|
2018-10-16 19:03:55 +00:00
|
|
|
Log::info("Redirect url: " . $response->getRedirectUrl());
|
2016-09-07 21:48:07 +00:00
|
|
|
|
2018-10-16 19:03:55 +00:00
|
|
|
$return = [
|
|
|
|
|
'status' => 'success',
|
|
|
|
|
'redirectUrl' => $response->getRedirectUrl(),
|
2019-08-16 13:04:50 +00:00
|
|
|
'message' => 'Redirecting to payment gateway'
|
2018-10-16 19:03:55 +00:00
|
|
|
];
|
2016-03-20 16:01:50 +00:00
|
|
|
|
2018-10-16 19:03:55 +00:00
|
|
|
// GET method requests should not have redirectData on the JSON return string
|
2019-08-16 13:04:50 +00:00
|
|
|
// if($response->getRedirectMethod() == 'POST') {
|
|
|
|
|
// $return['redirectData'] = $response->getRedirectData();
|
|
|
|
|
// }
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2018-10-16 19:03:55 +00:00
|
|
|
return response()->json($return);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
// display error to customer
|
2016-03-16 01:13:49 +00:00
|
|
|
return response()->json([
|
2016-05-08 15:36:26 +00:00
|
|
|
'status' => 'error',
|
2019-08-16 13:04:50 +00:00
|
|
|
'message' => $response->errorMessage(),
|
2016-03-05 00:18:10 +00:00
|
|
|
]);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
2018-10-16 19:03:55 +00:00
|
|
|
} catch (\Exeption $e) {
|
2019-08-16 13:04:50 +00:00
|
|
|
// dd($e);
|
2018-10-16 19:03:55 +00:00
|
|
|
Log::error($e);
|
|
|
|
|
$error = 'Sorry, there was an error processing your payment. Please try again.';
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2018-10-16 19:03:55 +00:00
|
|
|
if ($error) {
|
|
|
|
|
return response()->json([
|
|
|
|
|
'status' => 'error',
|
|
|
|
|
'message' => $error,
|
|
|
|
|
]);
|
|
|
|
|
}
|
2016-03-20 16:01:50 +00:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-20 22:54:45 +00:00
|
|
|
/**
|
2019-08-29 19:23:05 +00:00
|
|
|
* Attempt to complete a user's payment when they return from
|
|
|
|
|
* an off-site gateway
|
2016-05-20 22:54:45 +00:00
|
|
|
*
|
|
|
|
|
* @param Request $request
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
|
|
|
|
*/
|
2016-03-20 16:01:50 +00:00
|
|
|
public function showEventCheckoutPaymentReturn(Request $request, $event_id)
|
|
|
|
|
{
|
2019-08-29 19:23:05 +00:00
|
|
|
if ($request->get('is_payment_cancelled') == '1') {
|
|
|
|
|
session()->flash('message', trans('Event.payment_cancelled'));
|
|
|
|
|
return response()->redirectToRoute('showEventCheckout', [
|
|
|
|
|
'event_id' => $event_id,
|
|
|
|
|
'is_payment_cancelled' => 1,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-16 13:04:50 +00:00
|
|
|
$transaction_data = session()->get('ticket_order_' . $event_id . '.transaction_data');
|
2020-01-09 12:10:46 +00:00
|
|
|
|
2019-08-16 13:04:50 +00:00
|
|
|
$response = $this->gateway->getPaymentStatus($transaction_data[0]['orderId']);
|
2020-01-09 12:10:46 +00:00
|
|
|
|
2020-01-09 12:32:12 +00:00
|
|
|
//todo try catch for connection errors
|
2019-08-16 13:04:50 +00:00
|
|
|
if ($response->isSuccessfull()) {
|
|
|
|
|
session()->push('ticket_order_' . $event_id . '.transaction_id', $response->getPaymentReferenceId());
|
2016-03-20 16:01:50 +00:00
|
|
|
return $this->completeOrder($event_id, false);
|
|
|
|
|
} else {
|
2019-08-16 13:04:50 +00:00
|
|
|
session()->flash('message', $response->errorMessage());
|
2019-08-29 19:23:05 +00:00
|
|
|
return response()->redirectToRoute('showEventCheckout', [
|
2016-05-08 15:36:26 +00:00
|
|
|
'event_id' => $event_id,
|
2016-03-20 16:01:50 +00:00
|
|
|
'is_payment_failed' => 1,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-30 15:31:15 +00:00
|
|
|
public function mobileCheckoutPaymentReturn(Request $request, $event_id){
|
2020-01-31 12:57:40 +00:00
|
|
|
if ($request->get('is_payment_cancelled') == '1') {
|
2020-02-12 11:00:54 +00:00
|
|
|
return view('mobile.CheckoutFailed',['message'=>'Toleg besedildi']);
|
2020-01-30 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
2020-01-31 12:57:40 +00:00
|
|
|
if(!$request->has('orderId')){
|
2020-02-12 11:00:54 +00:00
|
|
|
return view('mobile.CheckoutFailed',['message'=>'order id yok']);
|
2020-01-31 12:57:40 +00:00
|
|
|
}
|
|
|
|
|
|
2020-01-30 15:31:15 +00:00
|
|
|
$response = $this->gateway->getPaymentStatus($request->get('orderId'));
|
|
|
|
|
|
|
|
|
|
if ($response->isSuccessfull()) {
|
|
|
|
|
return $this->mobileCompleteOrder($event_id,$request->get('orderId'));
|
|
|
|
|
} else {
|
2020-02-12 11:00:54 +00:00
|
|
|
return view('mobile.CheckoutFailed',['message'=>$response->errorMessage()]);
|
2020-01-30 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2016-03-20 16:01:50 +00:00
|
|
|
/**
|
|
|
|
|
* Complete an order
|
|
|
|
|
*
|
|
|
|
|
* @param $event_id
|
|
|
|
|
* @param bool|true $return_json
|
|
|
|
|
* @return \Illuminate\Http\JsonResponse|\Illuminate\Http\RedirectResponse
|
|
|
|
|
*/
|
2016-04-04 11:21:09 +00:00
|
|
|
public function completeOrder($event_id, $return_json = true)
|
2016-03-20 16:01:50 +00:00
|
|
|
{
|
|
|
|
|
|
2016-05-28 08:28:53 +00:00
|
|
|
DB::beginTransaction();
|
2016-04-04 11:21:09 +00:00
|
|
|
|
2016-05-28 08:28:53 +00:00
|
|
|
try {
|
2016-03-20 16:01:50 +00:00
|
|
|
|
2016-05-28 08:28:53 +00:00
|
|
|
$order = new Order();
|
|
|
|
|
$ticket_order = session()->get('ticket_order_' . $event_id);
|
|
|
|
|
$request_data = $ticket_order['request_data'][0];
|
|
|
|
|
$event = Event::findOrFail($ticket_order['event_id']);
|
|
|
|
|
$attendee_increment = 1;
|
|
|
|
|
$ticket_questions = isset($request_data['ticket_holder_questions']) ? $request_data['ticket_holder_questions'] : [];
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-05-28 08:28:53 +00:00
|
|
|
/*
|
|
|
|
|
* Create the order
|
|
|
|
|
*/
|
|
|
|
|
if (isset($ticket_order['transaction_id'])) {
|
|
|
|
|
$order->transaction_id = $ticket_order['transaction_id'][0];
|
|
|
|
|
}
|
2019-08-16 13:04:50 +00:00
|
|
|
// if ($ticket_order['order_requires_payment'] && !isset($request_data['pay_offline'])) {
|
|
|
|
|
// $order->payment_gateway_id = $ticket_order['payment_gateway']->id;
|
|
|
|
|
// }
|
2019-04-25 07:13:59 +00:00
|
|
|
$order->first_name = sanitise($request_data['order_first_name']);
|
|
|
|
|
$order->last_name = sanitise($request_data['order_last_name']);
|
|
|
|
|
$order->email = sanitise($request_data['order_email']);
|
2016-05-28 08:28:53 +00:00
|
|
|
$order->amount = $ticket_order['order_total'];
|
|
|
|
|
$order->booking_fee = $ticket_order['booking_fee'];
|
|
|
|
|
$order->organiser_booking_fee = $ticket_order['organiser_booking_fee'];
|
|
|
|
|
$order->discount = 0.00;
|
|
|
|
|
$order->account_id = $event->account->id;
|
|
|
|
|
$order->event_id = $ticket_order['event_id'];
|
2020-01-30 15:31:15 +00:00
|
|
|
$order->order_status_id = isset($request_data['pay_offline']) ? config('attendize.order_awaiting_payment') : config('attendize.order_complete');
|
2016-07-09 14:19:09 +00:00
|
|
|
$order->is_payment_received = isset($request_data['pay_offline']) ? 0 : 1;
|
2018-02-27 18:26:23 +00:00
|
|
|
|
|
|
|
|
// Calculating grand total including tax
|
2018-07-10 14:50:46 +00:00
|
|
|
$orderService = new OrderService($ticket_order['order_total'], $ticket_order['total_booking_fee'], $event);
|
2018-07-10 10:19:20 +00:00
|
|
|
$orderService->calculateFinalCosts();
|
2018-02-27 18:26:23 +00:00
|
|
|
|
2018-07-10 10:19:20 +00:00
|
|
|
$order->taxamt = $orderService->getTaxAmount();
|
2016-05-28 08:28:53 +00:00
|
|
|
$order->save();
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
/*
|
2016-05-28 08:28:53 +00:00
|
|
|
* Update the event sales volume
|
2016-02-29 15:59:36 +00:00
|
|
|
*/
|
2018-09-11 19:57:52 +00:00
|
|
|
$event->increment('sales_volume', $orderService->getGrandTotal());
|
2016-05-28 08:28:53 +00:00
|
|
|
$event->increment('organiser_fees_volume', $order->organiser_booking_fee);
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
/*
|
2016-05-28 08:28:53 +00:00
|
|
|
* Update affiliates stats stats
|
2016-02-29 15:59:36 +00:00
|
|
|
*/
|
2020-01-16 11:44:56 +00:00
|
|
|
// if ($ticket_order['affiliate_referral']) {
|
|
|
|
|
// $affiliate = Affiliate::where('name', '=', $ticket_order['affiliate_referral'])
|
|
|
|
|
// ->where('event_id', '=', $event_id)->first();
|
|
|
|
|
// $affiliate->increment('sales_volume', $order->amount + $order->organiser_booking_fee);
|
|
|
|
|
// $affiliate->increment('tickets_sold', $ticket_order['total_ticket_quantity']);
|
|
|
|
|
// }
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
/*
|
2016-05-28 08:28:53 +00:00
|
|
|
* Update the event stats
|
2016-02-29 15:59:36 +00:00
|
|
|
*/
|
2018-04-24 18:25:07 +00:00
|
|
|
$event_stats = EventStats::updateOrCreate([
|
2016-05-28 08:28:53 +00:00
|
|
|
'event_id' => $event_id,
|
|
|
|
|
'date' => DB::raw('CURRENT_DATE'),
|
|
|
|
|
]);
|
|
|
|
|
$event_stats->increment('tickets_sold', $ticket_order['total_ticket_quantity']);
|
|
|
|
|
|
|
|
|
|
if ($ticket_order['order_requires_payment']) {
|
|
|
|
|
$event_stats->increment('sales_volume', $order->amount);
|
|
|
|
|
$event_stats->increment('organiser_fees_volume', $order->organiser_booking_fee);
|
|
|
|
|
}
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
/*
|
2016-05-28 08:28:53 +00:00
|
|
|
* Add the attendees
|
2016-02-29 15:59:36 +00:00
|
|
|
*/
|
2016-05-28 08:28:53 +00:00
|
|
|
foreach ($ticket_order['tickets'] as $attendee_details) {
|
2016-04-04 11:21:09 +00:00
|
|
|
|
2016-05-28 08:28:53 +00:00
|
|
|
/*
|
|
|
|
|
* Update ticket's quantity sold
|
|
|
|
|
*/
|
|
|
|
|
$ticket = Ticket::findOrFail($attendee_details['ticket']['id']);
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Update some ticket info
|
|
|
|
|
*/
|
|
|
|
|
$ticket->increment('quantity_sold', $attendee_details['qty']);
|
|
|
|
|
$ticket->increment('sales_volume', ($attendee_details['ticket']['price'] * $attendee_details['qty']));
|
|
|
|
|
$ticket->increment('organiser_fees_volume',
|
|
|
|
|
($attendee_details['ticket']['organiser_booking_fee'] * $attendee_details['qty']));
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-04-04 15:20:35 +00:00
|
|
|
|
2016-05-08 15:36:26 +00:00
|
|
|
/*
|
2016-05-28 08:28:53 +00:00
|
|
|
* Insert order items (for use in generating invoices)
|
2016-02-29 15:59:36 +00:00
|
|
|
*/
|
2016-05-28 08:28:53 +00:00
|
|
|
$orderItem = new OrderItem();
|
|
|
|
|
$orderItem->title = $attendee_details['ticket']['title'];
|
|
|
|
|
$orderItem->quantity = $attendee_details['qty'];
|
|
|
|
|
$orderItem->order_id = $order->id;
|
|
|
|
|
$orderItem->unit_price = $attendee_details['ticket']['price'];
|
|
|
|
|
$orderItem->unit_booking_fee = $attendee_details['ticket']['booking_fee'] + $attendee_details['ticket']['organiser_booking_fee'];
|
|
|
|
|
$orderItem->save();
|
2016-05-08 15:36:26 +00:00
|
|
|
|
2016-05-28 08:28:53 +00:00
|
|
|
/*
|
|
|
|
|
* Create the attendees
|
|
|
|
|
*/
|
2019-11-05 12:28:51 +00:00
|
|
|
foreach ($attendee_details['seats'] as $i) {
|
2016-05-20 22:54:45 +00:00
|
|
|
|
2016-05-28 08:28:53 +00:00
|
|
|
$attendee = new Attendee();
|
2018-09-24 09:09:37 +00:00
|
|
|
$attendee->first_name = strip_tags($request_data["ticket_holder_first_name"][$i][$attendee_details['ticket']['id']]);
|
|
|
|
|
$attendee->last_name = strip_tags($request_data["ticket_holder_last_name"][$i][$attendee_details['ticket']['id']]);
|
2016-05-28 08:28:53 +00:00
|
|
|
$attendee->email = $request_data["ticket_holder_email"][$i][$attendee_details['ticket']['id']];
|
|
|
|
|
$attendee->event_id = $event_id;
|
|
|
|
|
$attendee->order_id = $order->id;
|
|
|
|
|
$attendee->ticket_id = $attendee_details['ticket']['id'];
|
|
|
|
|
$attendee->account_id = $event->account->id;
|
|
|
|
|
$attendee->reference_index = $attendee_increment;
|
2019-11-05 12:28:51 +00:00
|
|
|
$attendee->seat_no = $i;
|
2016-05-28 08:28:53 +00:00
|
|
|
$attendee->save();
|
2016-05-20 22:54:45 +00:00
|
|
|
|
|
|
|
|
|
2016-05-08 15:36:26 +00:00
|
|
|
/*
|
2016-05-28 08:28:53 +00:00
|
|
|
* Save the attendee's questions
|
2016-05-08 15:36:26 +00:00
|
|
|
*/
|
2016-05-28 08:28:53 +00:00
|
|
|
foreach ($attendee_details['ticket']->questions as $question) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$ticket_answer = isset($ticket_questions[$attendee_details['ticket']->id][$i][$question->id]) ? $ticket_questions[$attendee_details['ticket']->id][$i][$question->id] : null;
|
|
|
|
|
|
|
|
|
|
if (is_null($ticket_answer)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* If there are multiple answers to a question then join them with a comma
|
|
|
|
|
* and treat them as a single answer.
|
|
|
|
|
*/
|
|
|
|
|
$ticket_answer = is_array($ticket_answer) ? implode(', ', $ticket_answer) : $ticket_answer;
|
2016-05-08 15:36:26 +00:00
|
|
|
|
2016-05-28 08:28:53 +00:00
|
|
|
if (!empty($ticket_answer)) {
|
|
|
|
|
QuestionAnswer::create([
|
|
|
|
|
'answer_text' => $ticket_answer,
|
|
|
|
|
'attendee_id' => $attendee->id,
|
|
|
|
|
'event_id' => $event->id,
|
|
|
|
|
'account_id' => $event->account->id,
|
|
|
|
|
'question_id' => $question->id
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
}
|
2016-04-04 11:21:09 +00:00
|
|
|
}
|
2016-04-04 15:20:35 +00:00
|
|
|
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-05-28 08:28:53 +00:00
|
|
|
/* Keep track of total number of attendees */
|
|
|
|
|
$attendee_increment++;
|
|
|
|
|
}
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-05-28 08:28:53 +00:00
|
|
|
} catch (Exception $e) {
|
|
|
|
|
|
|
|
|
|
Log::error($e);
|
|
|
|
|
DB::rollBack();
|
|
|
|
|
|
|
|
|
|
return response()->json([
|
|
|
|
|
'status' => 'error',
|
|
|
|
|
'message' => 'Whoops! There was a problem processing your order. Please try again.'
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
}
|
2018-08-17 14:15:31 +00:00
|
|
|
//save the order to the database
|
2016-05-28 08:28:53 +00:00
|
|
|
DB::commit();
|
2018-08-17 14:15:31 +00:00
|
|
|
//forget the order in the session
|
|
|
|
|
session()->forget('ticket_order_' . $event->id);
|
|
|
|
|
|
2019-01-12 11:03:28 +00:00
|
|
|
/*
|
|
|
|
|
* Remove any tickets the user has reserved after they have been ordered for the user
|
|
|
|
|
*/
|
|
|
|
|
ReservedTickets::where('session_id', '=', session()->getId())->delete();
|
|
|
|
|
|
2018-08-17 14:15:31 +00:00
|
|
|
// Queue up some tasks - Emails to be sent, PDFs etc.
|
|
|
|
|
Log::info('Firing the event');
|
|
|
|
|
event(new OrderCompletedEvent($order));
|
|
|
|
|
|
2016-03-21 16:39:36 +00:00
|
|
|
|
2016-04-04 11:21:09 +00:00
|
|
|
if ($return_json) {
|
2016-03-20 16:01:50 +00:00
|
|
|
return response()->json([
|
2016-05-08 15:36:26 +00:00
|
|
|
'status' => 'success',
|
2016-03-20 16:01:50 +00:00
|
|
|
'redirectUrl' => route('showOrderDetails', [
|
2016-05-08 15:36:26 +00:00
|
|
|
'is_embedded' => $this->is_embedded,
|
2016-03-20 16:01:50 +00:00
|
|
|
'order_reference' => $order->order_reference,
|
|
|
|
|
]),
|
|
|
|
|
]);
|
|
|
|
|
}
|
2016-02-29 15:59:36 +00:00
|
|
|
|
2016-03-20 16:01:50 +00:00
|
|
|
return response()->redirectToRoute('showOrderDetails', [
|
2016-05-08 15:36:26 +00:00
|
|
|
'is_embedded' => $this->is_embedded,
|
2016-04-04 11:21:09 +00:00
|
|
|
'order_reference' => $order->order_reference,
|
|
|
|
|
]);
|
2016-03-20 16:01:50 +00:00
|
|
|
|
2016-05-28 08:28:53 +00:00
|
|
|
}
|
2016-03-20 16:01:50 +00:00
|
|
|
|
2016-02-29 15:59:36 +00:00
|
|
|
/**
|
2016-03-16 01:13:49 +00:00
|
|
|
* Show the order details page
|
2016-02-29 15:59:36 +00:00
|
|
|
*
|
2016-03-16 01:13:49 +00:00
|
|
|
* @param Request $request
|
|
|
|
|
* @param $order_reference
|
|
|
|
|
* @return \Illuminate\View\View
|
2016-02-29 15:59:36 +00:00
|
|
|
*/
|
2016-03-16 01:13:49 +00:00
|
|
|
public function showOrderDetails(Request $request, $order_reference)
|
2016-02-29 15:59:36 +00:00
|
|
|
{
|
|
|
|
|
$order = Order::where('order_reference', '=', $order_reference)->first();
|
|
|
|
|
|
|
|
|
|
if (!$order) {
|
2016-03-16 01:13:49 +00:00
|
|
|
abort(404);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
2020-01-08 11:28:44 +00:00
|
|
|
$orderService = new OrderService($order->amount, $order->booking_fee+$order->organiser_booking_fee, $order->event);
|
2018-07-10 10:19:20 +00:00
|
|
|
$orderService->calculateFinalCosts();
|
|
|
|
|
|
2016-02-29 15:59:36 +00:00
|
|
|
$data = [
|
2018-07-10 10:19:20 +00:00
|
|
|
'order' => $order,
|
|
|
|
|
'orderService' => $orderService,
|
|
|
|
|
'event' => $order->event,
|
|
|
|
|
'tickets' => $order->event->tickets,
|
|
|
|
|
'is_embedded' => $this->is_embedded,
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
|
|
if ($this->is_embedded) {
|
2016-03-16 01:13:49 +00:00
|
|
|
return view('Public.ViewEvent.Embedded.EventPageViewOrder', $data);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
2016-03-05 00:18:10 +00:00
|
|
|
|
2020-02-12 11:00:54 +00:00
|
|
|
return view('desktop.ViewEvent.ViewOrderPage', $data);
|
2019-10-11 16:26:24 +00:00
|
|
|
// return view('Public.ViewEvent.EventPageViewOrder', $data);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2016-03-16 01:13:49 +00:00
|
|
|
* Shows the tickets for an order - either HTML or PDF
|
2016-02-29 15:59:36 +00:00
|
|
|
*
|
2016-03-16 01:13:49 +00:00
|
|
|
* @param Request $request
|
|
|
|
|
* @param $order_reference
|
|
|
|
|
* @return \Illuminate\View\View
|
2016-02-29 15:59:36 +00:00
|
|
|
*/
|
2016-03-16 01:13:49 +00:00
|
|
|
public function showOrderTickets(Request $request, $order_reference)
|
2016-02-29 15:59:36 +00:00
|
|
|
{
|
|
|
|
|
$order = Order::where('order_reference', '=', $order_reference)->first();
|
|
|
|
|
|
|
|
|
|
if (!$order) {
|
2016-03-16 01:13:49 +00:00
|
|
|
abort(404);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
$images = [];
|
|
|
|
|
$imgs = $order->event->images;
|
|
|
|
|
foreach ($imgs as $img) {
|
|
|
|
|
$images[] = base64_encode(file_get_contents(public_path($img->image_path)));
|
|
|
|
|
}
|
2016-02-29 15:59:36 +00:00
|
|
|
|
|
|
|
|
$data = [
|
2016-05-08 15:36:26 +00:00
|
|
|
'order' => $order,
|
|
|
|
|
'event' => $order->event,
|
|
|
|
|
'tickets' => $order->event->tickets,
|
2016-03-05 00:18:10 +00:00
|
|
|
'attendees' => $order->attendees,
|
2016-05-20 23:09:34 +00:00
|
|
|
'css' => file_get_contents(public_path('assets/stylesheet/ticket.css')),
|
|
|
|
|
'image' => base64_encode(file_get_contents(public_path($order->event->organiser->full_logo_path))),
|
(localization) Several big changes:
1) Added localization components to the package. They allow usage of localized routes, like http://attendize.site/en/login
2) Added English and Polish localization files. They are ugly, repetitive, but mostly true to the original and relevant. It required rewriting several phrases, and certainly required editing most of the views and controllers.
3) Edited routes to accomodate point 1
4) Rewritten several rules regarding dates. In most cases using English notation (with English names for months) is bad in all other languages. I used environment wide date format that is used.
5) Updated installer. Haven't tested it yet, but should work. Rewrites .env.example file instead of creating it from scratch (by concatenating strings).
There are some minor changes that were simple fixes or other funky requirements from my employer that kinda make sense:
1) QR code reader wasn't working in firefox, fixed it. Works in chrome/firefox on mobile on https sites.
2) Added subscript text in some instances: below ticket registration, below ticket. It is kinda dumb, but in most cases is necessary to receive less complaints from clients.
3) Fixed geocoding api by adding api key in env file. At some point in 2016-2017 it was required by google to use API key from developer console and this requirement wasn't challenged in the code.
4) Ticket has been displaying either flyer or site logo on the side. Now displays both (which may affect 1d barcode - it might need some fixin). Regarding the same issue - description of an event contained the flyer image on the side, it was removed, cause it didn't fit in here.
5) Ticket style was updated, because of the above and because it didn't fit longer character strings. Now it's slightly uglier, but works in all cases.
and other.
There are also some inconveniences, like:
1) Unfinished translations. It was impossible for me to create translations based on strings located inside of a database, which I ignored (I think it's only at one place - surveys).
2) Ugly translation files. At some point I thought it is going to be easier to locate when I try translating vased by file name. Later I divided it by topics, and then I segmented it even more. It might require some serious clean-up.
3) Redundancy. In some cases there are several definitions for the same phrase in my localization files. I used it mostly to protect myself from different contexts for the phrase usage in different languages.
4) File division. There are several files that are placed in dedicated language directory (in /view/, like /view/pl/ or /view/en/). These files don't use language phrases, but they are translated as a whole. Mostly because using language phrases would make those view files unreadable.
5) Localzation helper marks some phrases as obsolete (in file "basic"), because they are used in app/Helpers folder (where this plugin doesn't reach)
2018-05-03 21:41:22 +00:00
|
|
|
'images' => $images,
|
2016-02-29 15:59:36 +00:00
|
|
|
];
|
|
|
|
|
|
2016-03-16 01:13:49 +00:00
|
|
|
if ($request->get('download') == '1') {
|
2016-12-01 22:11:34 +00:00
|
|
|
return PDF::html('Public.ViewEvent.Partials.PDFTicket', $data, 'Tickets');
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
2016-12-01 22:11:34 +00:00
|
|
|
return view('Public.ViewEvent.Partials.PDFTicket', $data);
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
2016-03-07 17:18:55 +00:00
|
|
|
|
2020-01-30 15:31:15 +00:00
|
|
|
private function mobileCompleteOrder($event_id,$transaction_id){
|
|
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
2020-02-01 13:51:21 +00:00
|
|
|
$order = Order::select('orders.id','order_status_id','is_payment_received','amount','booking_fee','created_at',
|
|
|
|
|
'organiser_booking_fee','event_id','session_id','account_id','first_name','last_name','email','order_reference')
|
|
|
|
|
->with(['event:id,sales_volume,organiser_fees_volume,organiser_id,title,post_order_display_message'])
|
2020-02-01 12:09:35 +00:00
|
|
|
->where('transaction_id',$transaction_id)
|
2020-01-30 15:31:15 +00:00
|
|
|
->where('event_id',$event_id)
|
|
|
|
|
->first();
|
|
|
|
|
|
|
|
|
|
$order->order_status_id = config('attendize.order_complete');
|
|
|
|
|
$order->is_payment_received = true;
|
2020-02-01 12:32:14 +00:00
|
|
|
$obf = $order->organiser_booking_fee;
|
|
|
|
|
$orderService = new OrderService($order->amount, $order->booking_fee + $obf, $order->event);
|
2020-01-31 12:13:22 +00:00
|
|
|
$orderService->calculateFinalCosts();
|
2020-01-30 15:31:15 +00:00
|
|
|
/*
|
|
|
|
|
* Update the event sales volume
|
|
|
|
|
*/
|
2020-02-01 12:09:35 +00:00
|
|
|
$event = $order->event;
|
|
|
|
|
$event->increment('sales_volume', $orderService->getGrandTotal());
|
2020-02-01 12:32:14 +00:00
|
|
|
$event->increment('organiser_fees_volume', $obf);
|
2020-01-30 15:31:15 +00:00
|
|
|
|
2020-02-01 12:09:35 +00:00
|
|
|
//todo join with order
|
2020-01-30 15:31:15 +00:00
|
|
|
$reserved_tickets = ReservedTickets::select('id', 'seat_no', 'ticket_id')
|
2020-02-01 13:16:32 +00:00
|
|
|
->with(['ticket:id,quantity_sold,sales_volume,organiser_fees_volume,price,title'])
|
2020-01-30 15:31:15 +00:00
|
|
|
->where('session_id', $order->session_id)
|
|
|
|
|
->where('event_id', $event_id)
|
|
|
|
|
->get();
|
|
|
|
|
/*
|
|
|
|
|
* Update the event stats
|
|
|
|
|
*/
|
|
|
|
|
$event_stats = EventStats::updateOrCreate([
|
|
|
|
|
'event_id' => $event_id,
|
|
|
|
|
'date' => DB::raw('CURRENT_DATE'),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
$event_stats->increment('tickets_sold', $reserved_tickets->count() ?? 0);
|
|
|
|
|
$event_stats->increment('sales_volume', $order->amount);
|
2020-02-01 12:32:14 +00:00
|
|
|
$event_stats->increment('organiser_fees_volume', $obf);
|
2020-01-30 15:31:15 +00:00
|
|
|
$attendee_increment = 1;
|
|
|
|
|
/*
|
|
|
|
|
* Add the attendees
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
foreach ($reserved_tickets as $reserved) {
|
|
|
|
|
|
|
|
|
|
$ticket = $reserved->ticket;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Update some ticket info
|
|
|
|
|
*/
|
2020-02-01 10:18:14 +00:00
|
|
|
$ticket->increment('quantity_sold', 1);
|
2020-01-30 15:31:15 +00:00
|
|
|
$ticket->increment('sales_volume', $ticket->price);
|
2020-02-01 12:32:14 +00:00
|
|
|
$ticket->increment('organiser_fees_volume', $obf);// * $reserved->quantity_reserved
|
2020-01-30 15:31:15 +00:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Insert order items (for use in generating invoices)
|
|
|
|
|
*/
|
|
|
|
|
$orderItem = new OrderItem();
|
|
|
|
|
$orderItem->title = $ticket->title;
|
|
|
|
|
$orderItem->quantity = 1;
|
|
|
|
|
$orderItem->order_id = $order->id;
|
|
|
|
|
$orderItem->unit_price = $ticket->price;
|
2020-02-01 12:32:14 +00:00
|
|
|
$orderItem->unit_booking_fee = $ticket->booking_fee + $obf;
|
2020-01-30 15:31:15 +00:00
|
|
|
$orderItem->save();
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Create the attendees
|
|
|
|
|
*/
|
|
|
|
|
$attendee = new Attendee();
|
|
|
|
|
$attendee->first_name = $order->first_name;
|
|
|
|
|
$attendee->last_name = $order->last_name;
|
|
|
|
|
$attendee->email = $order->email;
|
|
|
|
|
$attendee->event_id = $order->event_id;
|
|
|
|
|
$attendee->order_id = $order->id;
|
|
|
|
|
$attendee->ticket_id = $reserved->ticket_id;
|
2020-02-01 13:42:06 +00:00
|
|
|
$attendee->account_id = $order->account_id;
|
2020-01-30 15:31:15 +00:00
|
|
|
$attendee->reference_index = $attendee_increment;
|
|
|
|
|
$attendee->seat_no = $reserved->seat_no;
|
|
|
|
|
$attendee->save();
|
|
|
|
|
|
|
|
|
|
/* Keep track of total number of attendees */
|
|
|
|
|
$attendee_increment++;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-01 14:33:00 +00:00
|
|
|
$order->save();
|
2020-01-30 15:31:15 +00:00
|
|
|
DB::commit();
|
|
|
|
|
}
|
|
|
|
|
catch (\Exception $ex){
|
|
|
|
|
|
2020-02-01 13:31:46 +00:00
|
|
|
Log::error($ex);
|
2020-01-30 15:31:15 +00:00
|
|
|
DB::rollBack();
|
|
|
|
|
|
2020-02-12 11:00:54 +00:00
|
|
|
return view('mobile.CheckoutFailed',
|
2020-01-31 12:39:41 +00:00
|
|
|
['message' => $ex->getMessage()]
|
2020-01-31 12:13:22 +00:00
|
|
|
);
|
2020-01-30 15:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Remove any tickets the user has reserved after they have been ordered for the user
|
|
|
|
|
*/
|
|
|
|
|
ReservedTickets::where('session_id', $order->session_id)->delete();
|
|
|
|
|
|
|
|
|
|
Log::info('Firing the event');
|
|
|
|
|
event(new OrderCompletedEvent($order));
|
2020-01-31 12:13:22 +00:00
|
|
|
$data = [
|
|
|
|
|
'order' => $order,
|
|
|
|
|
'orderService' => $orderService,
|
|
|
|
|
'event' => $order->event,
|
|
|
|
|
'tickets' => $order->event->tickets,
|
|
|
|
|
'is_embedded' => $this->is_embedded,
|
|
|
|
|
];
|
2020-02-12 11:00:54 +00:00
|
|
|
return view('mobile.CheckoutSuccess', $data);
|
2020-01-30 15:31:15 +00:00
|
|
|
}
|
2016-02-29 15:59:36 +00:00
|
|
|
}
|
2019-08-29 19:23:05 +00:00
|
|
|
|