/** * Test Create Event * * @return event */ public function testCreateEvent() { $eventData = ['user_id' => '1', 'title' => 'Unit test event ' . time(), 'address1' => '123 st', 'zipcode' => '89017', 'tags' => 'concerts', 'is_published' => 1, 'meta' => '{"schedules": [{"timeZoneId": 6, "daysOfWeek": null, "start": {"date": "2020-10-31", "time": "12:00:00"}, "end": {"date": "2020-10-31", "time": "17:00:00"}, "repeat": null}]}']; $api = new \App\Helpers\ApiHelper(); $event = $api->store('events', $eventData); $event = $event['data']['event']; return $event; }
public function postRsvp($slug) { // Grab rsvp data $data = Request::all(); // Instantiate the APIHelper $api = new \App\Helpers\ApiHelper(); $url = 'attendees'; if (\Auth::check()) { $url .= '?auth_user_id=' . \Auth::user()->id; } // Post your rsvp $rsvpStatus = $api->store($url, $data); return $rsvpStatus; }
/** * Create test tickets * * @depends testCreateEvent * @return $eventsTicketsUserData */ public function testCreateTickets($event) { // Instanciate apihelper $api = new \App\Helpers\ApiHelper(); $ticketsToMake = 6; for ($ticket = 0; $ticket < $ticketsToMake; $ticket++) { switch (true) { case $ticket < 3: // Grab a user from $user = $api->store('ticketsinventories', ['name' => 'Test ticket' . time(), 'amount' => 1.6, 'inventory' => 9999, 'user_id' => $event['user_id'], 'event_id' => $event['id'], 'is_enabled' => 1]); break; default: // Grab a user from $user = $api->store('ticketsinventories', ['name' => 'Test ticket' . time(), 'amount' => 6 * 45, 'inventory' => 9999, 'user_id' => $event['user_id'], 'event_id' => $event['id'], 'is_enabled' => 1]); break; } } $eventsTicketsUserData = $api->index('events/' . $event['slug'] . '?with[]=ticketsInventory&with[]=nextEvent'); echo 'Creating events schedule...'; sleep(15); // Refresh event data $eventsTicketsUserData = $api->index('events/' . $event['slug'] . '?with[]=ticketsInventory&with[]=nextEvent'); return $eventsTicketsUserData; }
public function doCharge($slug) { // Set the error array as empty array $errorMessage = []; // Request all input $data = \Input::all(); \Input::flash(); if (!isset($data['userId'])) { $data['userId'] = 0; } // Explode purchaseId $purchasedId = explode(',', $data['purchasedId']); // Explode quantity $ticketQuantity = explode(',', $data['qty']); // For each purchaseId set the tickets array for ($i = 0; $i <= count($purchasedId); $i++) { if (isset($purchasedId[$i])) { $tickets[] = ['id' => $purchasedId[$i], 'quantity' => $ticketQuantity[$i]]; } } // Set TicketsInventories $data['ticketInventories'] = $tickets; // Instanciate ApiHelper $api = new ApiHelper(); // Set quantity $quantity = $data['totalQuantity']; $chargeUrl = 'ticketsorders/purchase'; if (\Auth::check()) { $chargeUrl .= '?auth_user_id=' . \Auth::user()->id; } // Charge the user $charge = $api->store($chargeUrl, $data); // if the charge is successful if ($charge['success'] === false) { // If error is string if (!is_array($charge['error'])) { // Redirect back with fail message and input return Redirect::back()->with(['fail_message' => $charge['error']])->withInput(); } else { // Set all errors to one level array foreach ($charge['error'] as $key => $error) { for ($i = 0; $i < count($charge['error']); $i++) { if (isset($error[$i])) { $errors[] = $error[$i]; } } } // Redirect back with fail message and input return Redirect::back()->with(['updateErrors' => $errors])->withInput(); } } else { // Redirect to the ticket confirmation page with accompanying data return \Redirect::route('tickets.confirmation', $slug)->with(['quantity' => $quantity]); } }
public function oathCallback(Request $request, $provider) { // Check if user is signed in if (!\Auth::check()) { // Return fail message return Redirect::route('home')->with('fail_message', 'You must be signed in to make this request'); } // Check if code is set if (!isset($request::all()['code'])) { return Redirect::route('payment')->with('fail_message', 'There was a problem creating your account. Please try again later'); } // Define userId $userId = \Auth::user()->id; // Define connected user data with return authorization $connectedUser = Socialize::driver($provider)->user(); // Define create data $acctId = $connectedUser->id; $meta = json_encode($connectedUser); // Insanciate the APIHelper $api = new \App\Helpers\ApiHelper(); // Save managed account to API $stripeManagedAccount = $api->store('users/createManaged', ['user_id' => $userId, 'acct_id' => $acctId, 'meta' => $meta]); // Check success if ($stripeManagedAccount['success'] !== true) { return Redirect::route('payment')->with(['fail_message' => $stripeManagedAccount['error']]); } // Return success return Redirect::route('payment')->with(['success_message' => 'Account connected successfully!']); }