Because this is highly under construction, if you decide to use this boilerplate, please signup on our mailing list so we can let you know if anything significant changes http:https://eepurl.com/hLEE1D
This is meant as starter package for start making applications related to Openticket.tech, probaly also known as Eventix. This package include all OAuth2 logic to get you up to speed, all token handling is taken care of.
Run the following commands:
git clone [email protected]:opentickettech/laravel-starter.git
cd laravel-starter
cp .env.example .env
composer install
bash vendor/bin/sail up -d
bash vendor/bin/sail artisan key:generate
bash vendor/bin/sail artisan migrate
Note: If the migrate commands fails, wait a moment (mysql takes some time to boot), application then should be running at http:https://localhost/.
Set the following env values:
OPENTICKETTECH_CLIENT_ID=
OPENTICKETTECH_CLIENT_SECRET=
OPENTICKETTECH_REDIRECT_URI=
Retrieve the CLIENT_ID
and CLIENT_SECRET
from dashboard https://dashboard.eventix.io/company/client.
Note: that you should set the exact same redirect value in the dashboard and the OPENTICKETTECH_REDIRECT_URI
value, make sure to add /redirect
at end of route.
For local testing you can install https://ngrok.com/, to expose your local instance. When running ngrok http 80
you get a public url:
set the env value OPENTICKETTECH_REDIRECT_URI
and the redirect url of your Client in dashboard appropriately, make sure to add /redirect
at end of route.
API docs - https://docs.openticket.tech/
Domain | Method | URI | Name | Action | Middleware |
---|---|---|---|---|---|
GET,HEAD | / | Closure | web | ||
POST | api/webhook/{company_id} | Closure | api | ||
GET,HEAD | company/{company_id} | Closure | web | ||
GET,HEAD | connect | Closure | web | ||
GET,HEAD | dashboard | Closure | web | ||
GET,HEAD | logout | Closure | web | ||
GET,HEAD | public/{company_id} | Closure | web | ||
GET,HEAD | public_encrypted/{encrypted_company_id} | Closure | web | ||
GET,HEAD | redirect | Closure | web |
Route::get('/company/{company_id}', function ($company_id) {
$userId = Cookie::get('user_id');
if (is_null($userId)) {
return redirect('/');
}
$userObj = \App\Models\User::find($userId);
$user = (object) Socialite::driver('opentickettech')->userFromToken($userObj->companyAccessToken->access_token);
if(is_null($companyAccessToken = $userObj->allCompanyAccessTokens()->find($company_id))){
abort(404, 'Company not found');
}
$client = new \Misc\Openticket\OTApi($companyAccessToken);
$upcomingEvents = $client->get('/event/upcoming');
return view('company', ['user' => $user, 'company' => $companyAccessToken, 'upcoming_events' => $upcomingEvents]);
});
Route::any('/webhook/{company_id}', function (Request $request, $company_id) {
$companyAccessToken = CompanyAccessToken::find($company_id);
if(is_null($companyAccessToken)){
abort(404, 'Company not found');
}
$orderId = $guid = $request->get('guid');
$client = new OTApi($companyAccessToken);
$order = $client->get("/order/$orderId");
Log::info("New order: $order->email ($order->guid)");
// Do stuff with order or something else
// Signal success, any content will do, but retrying is stopped after status code 200
return response('' , 200);
});