Skip to content

Commit

Permalink
Merge pull request #91 from caiquecastro/allow-cache-routes
Browse files Browse the repository at this point in the history
Thanks
  • Loading branch information
fernandobandeira authored Feb 5, 2018
2 parents 014e3ae + 47ee434 commit db3bb87
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
40 changes: 40 additions & 0 deletions src/Artistas/PagSeguroController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Artistas\PagSeguro;

class PagSeguroController
{
/** @var \Artistas\PagSeguro\PagSeguroClient */
private $pagseguro;

/**
* Instancia as dependências.
*/
public function __construct()
{
$this->pagseguro = app('pagseguro');
}

/**
* Gera um token de sessão para realizar transações.
*
* @return string
*/
public function session()
{
return $this->pagseguro->startSession();
}

/**
* Inclui o arquivo javascript necessário para gerar o token no browser.
*
* @return \Illuminate\Http\Response
*/
public function javascript()
{
$scriptContent = file_get_contents($this->pagseguro->getUrl()['javascript']);

return response()->make($scriptContent, '200')
->header('Content-Type', 'text/javascript');
}
}
8 changes: 2 additions & 6 deletions src/Artistas/routes.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?php

Route::get('/pagseguro/session', function () {
return \PagSeguro::startSession();
});
Route::get('/pagseguro/session', '\Artisas\PagSeguro\PagseguroController@session');

Route::get('/pagseguro/javascript', function () {
return response()->make(file_get_contents(\PagSeguro::getUrl()['javascript']), '200')->header('Content-Type', 'text/javascript');
});
Route::get('/pagseguro/javascript', '\Artistas\PagSeguro\PagseguroController@javascript');

0 comments on commit db3bb87

Please sign in to comment.