Skip to content

Commit

Permalink
First version of the External Service demo.
Browse files Browse the repository at this point in the history
  • Loading branch information
Menno committed May 25, 2015
0 parents commit 44f9dfb
Show file tree
Hide file tree
Showing 103 changed files with 6,604 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString

DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto
*.css linguist-vendored
*.less linguist-vendored
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/vendor
/node_modules
.env
.idea
Empty file added .npmignore
Empty file.
7 changes: 7 additions & 0 deletions app/Commands/Command.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php namespace App\Commands;

abstract class Command {

//

}
32 changes: 32 additions & 0 deletions app/Console/Commands/Inspire.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Foundation\Inspiring;

class Inspire extends Command {

/**
* The console command name.
*
* @var string
*/
protected $name = 'inspire';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Display an inspiring quote';

/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$this->comment(PHP_EOL.Inspiring::quote().PHP_EOL);
}

}
29 changes: 29 additions & 0 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel {

/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
'App\Console\Commands\Inspire',
];

/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
$schedule->command('inspire')
->hourly();
}

}
7 changes: 7 additions & 0 deletions app/Events/Event.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php namespace App\Events;

abstract class Event {

//

}
42 changes: 42 additions & 0 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php namespace App\Exceptions;

use Exception;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler {

/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
'Symfony\Component\HttpKernel\Exception\HttpException'
];

/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
return parent::report($e);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
return parent::render($request, $e);
}

}
Empty file added app/Handlers/Commands/.gitkeep
Empty file.
Empty file added app/Handlers/Events/.gitkeep
Empty file.
36 changes: 36 additions & 0 deletions app/Helpers/Code.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php namespace App\Helpers;

class Code
{
/**
* Fetch a payload example
*
* @param $file
* @return string
*/
public static function payload($file)
{
if (preg_match('/^([a-zA-Z0-9\_]+)$/', $file))
{
return file_get_contents(base_path().'/resources/json/'.$file.'_payload.json');
}

return 'Incorrect filename';
}

/**
* Fetch a response example
*
* @param $file
* @return string
*/
public static function response($file)
{
if (preg_match('/^([a-zA-Z0-9\_]+)$/', $file))
{
return file_get_contents(base_path().'/resources/json/'.$file.'_response.json');
}

return 'Incorrect filename';
}
}
51 changes: 51 additions & 0 deletions app/Http/Controllers/AppController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php namespace App\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use Illuminate\Http\Request;

class AppController extends Controller {

/**
* The homepage of the application to explain its purpose
*
* @return \Illuminate\View\View
*/
public function home()
{
return view('app/home');
}

/**
* This url is called when a SEOshop customer installs this application
*
* @return \Illuminate\View\View
*/
public function install()
{
return view('app/install');
}

/**
* This url is called when a SEOshop customer uninstalls the application
*
* @return \Illuminate\View\View
*/
public function uninstall()
{
return view('app/uninstall');
}

/**
* This url is called when a SEOshop customer cancels the application, this does not yet uninstall the app
* Uninstalling will only happen at the end of the billing cycle (once a month)
*
* @return \Illuminate\View\View
*/
public function cancel()
{
return view('app/cancel');
}

}
11 changes: 11 additions & 0 deletions app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php namespace App\Http\Controllers;

use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;

abstract class Controller extends BaseController {

use DispatchesCommands, ValidatesRequests;

}
65 changes: 65 additions & 0 deletions app/Http/Controllers/PaymentsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php namespace App\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use App\Payment;
use App\Transaction;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Input;

class PaymentsController extends Controller {

public function index()
{
return response()->json(['payment_methods' => Payment::all()]);
}

public function create(Request $request)
{
$order = $request->input('order');

$transaction = Transaction::create([
'status' => 'unpaid',
'order_id' => array_get($order, 'id'),
'price_incl' => array_get($order, 'price_incl'),
'price_excl' => array_get($order, 'price_excl'),
'redirect_url' => Input::get('redirect_url')
]);

return response()->json(['payment_url' => url('pay/'.$transaction->id)]);
}

public function show($id)
{
if ($transaction = Transaction::find($id))
{
return view('payments.show', ['transaction' => $transaction]);
}

return redirect('/');
}

public function one($id)
{
if ($transaction = Transaction::where(['order_id' => $id])->orderBy('updated_at', 'desc')->first())
{
return response()->json(['status' => $transaction->status]);
}

return false;
}

public function update($id, $status)
{
if ($transaction = Transaction::find($id))
{
$transaction->status = $status;
$transaction->save();
}

// Redirect back to the checkout
return redirect($transaction->redirect_url);
}

}
21 changes: 21 additions & 0 deletions app/Http/Controllers/ShipmentsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php namespace App\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use App\Shipment;
use Illuminate\Http\Request;

class ShipmentsController extends Controller {

public function index()
{
return response()->json(['shipment_methods' => Shipment::all()]);
}

public function create()
{
return response()->json(['redirect_url' => 'http://google.nl/']);
}

}
32 changes: 32 additions & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel {

/**
* The application's global HTTP middleware stack.
*
* @var array
*/
protected $middleware = [
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
'Illuminate\Cookie\Middleware\EncryptCookies',
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
'Illuminate\Session\Middleware\StartSession',
'Illuminate\View\Middleware\ShareErrorsFromSession',
// 'App\Http\Middleware\VerifyCsrfToken',
];

/**
* The application's route middleware.
*
* @var array
*/
protected $routeMiddleware = [
'auth' => 'App\Http\Middleware\Authenticate',
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
];

}
Loading

0 comments on commit 44f9dfb

Please sign in to comment.