Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: cria layout base para o boleto
- Loading branch information
1 parent
80d4767
commit c9a3c04
Showing
4 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
upload/catalog/controller/extension/payment/pagseguro_boleto.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
class ControllerExtensionPaymentPagSeguroBoleto extends Controller | ||
{ | ||
const EXTENSION_PREFIX = 'payment_pagseguro_'; | ||
|
||
public function index() | ||
{ | ||
$data = $this->language->load('extension/payment/pagseguro_boleto'); | ||
|
||
$this->load->model('extension/payment/pagseguro'); | ||
|
||
$data['session'] = $this->model_extension_payment_pagseguro->generateSession(); | ||
|
||
if ($this->config->get(self::EXTENSION_PREFIX . 'sandbox')) { | ||
$data['javascript_src'] = 'https://stc.pagseguro.uol.com.br/pagseguro/api/v2/checkout/pagseguro.directpayment.js'; | ||
} else { | ||
$data['javascript_src'] = 'https://stc.sandbox.pagseguro.uol.com.br/pagseguro/api/v2/checkout/pagseguro.directpayment.js'; | ||
} | ||
|
||
return $this->load->view('extension/payment/pagseguro_boleto', $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,36 @@ | ||
<?php | ||
|
||
require_once DIR_SYSTEM . 'library/PagSeguro/vendor/autoload.php'; | ||
|
||
use ValdeirPsr\PagSeguro\Domains\Environment; | ||
use ValdeirPsr\PagSeguro\Request\Session; | ||
|
||
class ModelExtensionPaymentPagSeguro extends Model | ||
{ | ||
const EXTENSION_PREFIX = 'payment_pagseguro_'; | ||
|
||
public function getMethod($address, $total) | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* Gera uma nova sessão para o pedido | ||
*/ | ||
public function generateSession(): string | ||
{ | ||
|
||
} | ||
|
||
private function factoryEnvironment(): Environment | ||
{ | ||
$email = $this->config->get(self::EXTENSION_PREFIX . 'email'); | ||
$token = $this->config->get(self::EXTENSION_PREFIX . 'token'); | ||
|
||
if ($this->config->get(self::EXTENSION_PREFIX . 'sandbox')) { | ||
return Environment::sandbox($email, $token); | ||
} | ||
|
||
return Environment::production($email, $token); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
upload/catalog/view/theme/default/template/extension/payment/pagseguro_boleto.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{% if warning %} | ||
<div class="alert alert-danger" id="warning" role="alert">{{ warning }}</div> | ||
{% else %} | ||
<div id="warning" class="alert alert-danger" role="alert" style="display:none"></div> | ||
<div id="info" class="alert alert-info" role="alert" style="display:none">{{ text_wait }}.</div> | ||
|
||
<div class="col-sm-5 col-md-offset-3"> | ||
<div class="form-group col-md-12"> | ||
<label for="cpf">{{ entry_cpf }}</label> | ||
<input type="text" name="cpf" id="cpf" value="" placeholder="{{ entry_cpf }}" class="form-control"> | ||
</div> | ||
|
||
<div class="form-group col-md-12"> | ||
<button type="button" id="button-print" data-loading-text="{{ text_wait }}" class="btn btn-primary pull-left"> | ||
<i class="fa fa-barcode"></i> | ||
{{ btn_print }} | ||
</button> | ||
|
||
<button type="button" id="button-download" data-loading-text="{{ text_wait }}" class="btn btn-link pull-right"> | ||
<i class="fa fa-download"></i> | ||
{{ btn_download }} | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.colorbox/1.6.4/jquery.colorbox-min.js" integrity="sha512-DAVSi/Ovew9ZRpBgHs6hJ+EMdj1fVKE+csL7mdf9v7tMbzM1i4c/jAvHE8AhcKYazlFl7M8guWuO3lDNzIA48A==" crossorigin="anonymous"></script> | ||
|
||
<script type="text/javascript"> | ||
(function (src) { | ||
const script = document.createElement('script') | ||
script.async = true | ||
script.src = src | ||
script.addEventListener('load', loadedScriptSuccess) | ||
script.addEventListener('error', loadedScriptFailed) | ||
document.head.appendChild(script) | ||
})('{{ javascript_src }}') | ||
function loadedScriptSuccess() { | ||
alert('Sucesso') | ||
PagSeguroDirectPayment.setSessionId('{{ session }}'); | ||
document.querySelector('#cpf').addEventListener('input', formatCpf) | ||
} | ||
function loadedScriptFailed() { | ||
alert('Error loaded script') | ||
} | ||
/** | ||
* Formata o número do CPF | ||
*/ | ||
function formatCpf(e) { | ||
e.target.value = e.target | ||
.value | ||
.replace(/\D/g, '') | ||
.replace(/(\d{3})(\d{3})?(\d{3})?(\d{2})?/g, '$1.$2.$3-$4') | ||
} | ||
</script> | ||
{% endif %} |