@@ -5,46 +5,46 @@ |
||
| 5 | 5 | public function __construct(); |
| 6 | 6 | |
| 7 | 7 | /** |
| 8 | - * @return void |
|
| 9 | - * @param String $token |
|
| 10 | - **/ |
|
| 8 | + * @return void |
|
| 9 | + * @param String $token |
|
| 10 | + **/ |
|
| 11 | 11 | public function setToken($token); |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * @return void |
|
| 15 | - * @param String $email |
|
| 16 | - **/ |
|
| 14 | + * @return void |
|
| 15 | + * @param String $email |
|
| 16 | + **/ |
|
| 17 | 17 | public function setEmail($email); |
| 18 | 18 | |
| 19 | 19 | /** |
| 20 | - * @return String $token |
|
| 21 | - **/ |
|
| 20 | + * @return String $token |
|
| 21 | + **/ |
|
| 22 | 22 | public function getToken(); |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * @return String $email |
|
| 26 | - **/ |
|
| 25 | + * @return String $email |
|
| 26 | + **/ |
|
| 27 | 27 | public function getEmail(); |
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | - * @return void |
|
| 31 | - * @param Array $produtos |
|
| 32 | - **/ |
|
| 30 | + * @return void |
|
| 31 | + * @param Array $produtos |
|
| 32 | + **/ |
|
| 33 | 33 | public function setProdutos($produtos); |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | - * @return Array $produto |
|
| 37 | - **/ |
|
| 36 | + * @return Array $produto |
|
| 37 | + **/ |
|
| 38 | 38 | public function getProdutos(); |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | - * @param Array Produtos a serem adicionados |
|
| 42 | - **/ |
|
| 41 | + * @param Array Produtos a serem adicionados |
|
| 42 | + **/ |
|
| 43 | 43 | public function adicionarProdutosGateway(); |
| 44 | 44 | |
| 45 | 45 | /** |
| 46 | - * @param Array Andress/Endeço do cliente |
|
| 47 | - **/ |
|
| 46 | + * @param Array Andress/Endeço do cliente |
|
| 47 | + **/ |
|
| 48 | 48 | public function setEnderecoClienteGateway(); |
| 49 | 49 | |
| 50 | 50 | public function setCliente($cliente); |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -interface GatewayInterface{ |
|
| 3 | +interface GatewayInterface { |
|
| 4 | 4 | |
| 5 | 5 | public function __construct(); |
| 6 | 6 | |
@@ -30,10 +30,10 @@ |
||
| 30 | 30 | |
| 31 | 31 | if ($this->Hieraquia->save($dados)) { |
| 32 | 32 | $this->Session->setFlash('Hieraquia salva com sucesso!'); |
| 33 | - return $this->redirect('/hieraquia/listar_cadastros'); |
|
| 33 | + return $this->redirect('/hieraquia/listar_cadastros'); |
|
| 34 | 34 | } else { |
| 35 | 35 | $this->Session->setFlash('Ocorreu um erro ao salva o produto!'); |
| 36 | - return $this->redirect('/hieraquia/listar_cadastros'); |
|
| 36 | + return $this->redirect('/hieraquia/listar_cadastros'); |
|
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
@@ -26,10 +26,10 @@ |
||
| 26 | 26 | |
| 27 | 27 | if ($this->Newsletter->save($dados)) { |
| 28 | 28 | $this->Session->setFlash('Cadastro de newsletter excluido com sucesso!'); |
| 29 | - return $this->redirect('/newsletter/listar_cadastros'); |
|
| 29 | + return $this->redirect('/newsletter/listar_cadastros'); |
|
| 30 | 30 | } else { |
| 31 | 31 | $this->Session->setFlash('Ocorreu algum erro ao excluir o cadastro de newsletter!'); |
| 32 | - return $this->redirect('/newsletter/listar_cadastros'); |
|
| 32 | + return $this->redirect('/newsletter/listar_cadastros'); |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | |
| 19 | 19 | if ($_FILES['nota']['type'] != "text/xml") { |
| 20 | 20 | $this->Session->setFlash('O arquivo deve ser do tipo xml! ', 'default'); |
| 21 | - return $this->redirect('/nfe/gerar_danfe'); |
|
| 21 | + return $this->redirect('/nfe/gerar_danfe'); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | $arq = $_FILES["nota"]["tmp_name"]; |
@@ -52,13 +52,13 @@ discard block |
||
| 52 | 52 | debug($nfe->autoriza($sNFe, $lote, $aResp)); |
| 53 | 53 | //enviar o lote |
| 54 | 54 | if ($resp = $nfe->autoriza($sNFe, $lote, $aResp)) { |
| 55 | - if ($aResp['bStat']) { |
|
| 56 | - echo "Numero do Recibo : " . $aResp['nRec'] .", use este numero para obter o protocolo ou informações de erro no xml com testaRecibo.php."; |
|
| 57 | - } else { |
|
| 58 | - echo "Houve erro !! $nfe->errMsg"; |
|
| 59 | - } |
|
| 55 | + if ($aResp['bStat']) { |
|
| 56 | + echo "Numero do Recibo : " . $aResp['nRec'] .", use este numero para obter o protocolo ou informações de erro no xml com testaRecibo.php."; |
|
| 57 | + } else { |
|
| 58 | + echo "Houve erro !! $nfe->errMsg"; |
|
| 59 | + } |
|
| 60 | 60 | } else { |
| 61 | - echo "houve erro !! $nfe->errMsg"; |
|
| 61 | + echo "houve erro !! $nfe->errMsg"; |
|
| 62 | 62 | } |
| 63 | 63 | debug($nfe); |
| 64 | 64 | echo '<BR><BR><h1>DEBUG DA COMUNICAÇÕO SOAP</h1><BR><BR>'; |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | class NfeController extends AppController { |
| 4 | 4 | |
| 5 | - public function beforeFilter(){ |
|
| 5 | + public function beforeFilter() { |
|
| 6 | 6 | return true; |
| 7 | 7 | } |
| 8 | 8 | |
@@ -23,11 +23,11 @@ discard block |
||
| 23 | 23 | |
| 24 | 24 | $arq = $_FILES["nota"]["tmp_name"]; |
| 25 | 25 | |
| 26 | - if ( is_file($arq) ){ |
|
| 26 | + if (is_file($arq)) { |
|
| 27 | 27 | $docxml = file_get_contents($arq); |
| 28 | - $danfe = new DanfeNFePHP($docxml, 'P', 'A4','../images/logo.jpg','I',''); |
|
| 28 | + $danfe = new DanfeNFePHP($docxml, 'P', 'A4', '../images/logo.jpg', 'I', ''); |
|
| 29 | 29 | $id = $danfe->montaDANFE(); |
| 30 | - $imprime_danfe = $danfe->printDANFE($id . '.pdf','I'); |
|
| 30 | + $imprime_danfe = $danfe->printDANFE($id.'.pdf', 'I'); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | unlink($arq); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | //use isso, este é o modo manual voce tem mais controle sobre o que acontece |
| 45 | 45 | $filename = 'nfephp/exemplos/xml/11101284613439000180550010000004881093997017-nfe.xml'; |
| 46 | 46 | //obter um numero de lote |
| 47 | - $lote = substr(str_replace(',', '', number_format(microtime(true)*1000000, 0)), 0, 15); |
|
| 47 | + $lote = substr(str_replace(',', '', number_format(microtime(true) * 1000000, 0)), 0, 15); |
|
| 48 | 48 | // montar o array com a NFe |
| 49 | 49 | $sNFe = file_get_contents($filename); |
| 50 | 50 | //array vazio passado como referencia |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | //enviar o lote |
| 54 | 54 | if ($resp = $nfe->autoriza($sNFe, $lote, $aResp)) { |
| 55 | 55 | if ($aResp['bStat']) { |
| 56 | - echo "Numero do Recibo : " . $aResp['nRec'] .", use este numero para obter o protocolo ou informações de erro no xml com testaRecibo.php."; |
|
| 56 | + echo "Numero do Recibo : ".$aResp['nRec'].", use este numero para obter o protocolo ou informações de erro no xml com testaRecibo.php."; |
|
| 57 | 57 | } else { |
| 58 | 58 | echo "Houve erro !! $nfe->errMsg"; |
| 59 | 59 | } |
@@ -13,51 +13,51 @@ |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * @return void |
|
| 17 | - * @param String $token |
|
| 18 | - **/ |
|
| 16 | + * @return void |
|
| 17 | + * @param String $token |
|
| 18 | + **/ |
|
| 19 | 19 | public function setToken($token) |
| 20 | 20 | { |
| 21 | 21 | $this->gateway->setToken($token); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * @return void |
|
| 26 | - * @param String $email |
|
| 27 | - **/ |
|
| 25 | + * @return void |
|
| 26 | + * @param String $email |
|
| 27 | + **/ |
|
| 28 | 28 | public function setEmail($email) |
| 29 | 29 | { |
| 30 | 30 | $this->gateway->setEmail($email); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | - * @return String $token |
|
| 35 | - **/ |
|
| 34 | + * @return String $token |
|
| 35 | + **/ |
|
| 36 | 36 | public function getToken() |
| 37 | 37 | { |
| 38 | 38 | return $this->gateway->getToken(); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * @return String $email |
|
| 43 | - **/ |
|
| 42 | + * @return String $email |
|
| 43 | + **/ |
|
| 44 | 44 | public function getEmail() |
| 45 | 45 | { |
| 46 | 46 | return $this->gateway->getEmail(); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | - * @return void |
|
| 51 | - * @param Array $produtos |
|
| 52 | - **/ |
|
| 50 | + * @return void |
|
| 51 | + * @param Array $produtos |
|
| 52 | + **/ |
|
| 53 | 53 | public function setProdutos($produto) |
| 54 | 54 | { |
| 55 | 55 | $this->gateway->setProdutos($produto); |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | - * @return Array $produto |
|
| 60 | - **/ |
|
| 59 | + * @return Array $produto |
|
| 60 | + **/ |
|
| 61 | 61 | public function getProdutos() |
| 62 | 62 | { |
| 63 | 63 | return $this->gateway->getProdutos(); |
@@ -7,6 +7,9 @@ discard block |
||
| 7 | 7 | |
| 8 | 8 | private $gateway = ''; |
| 9 | 9 | |
| 10 | + /** |
|
| 11 | + * @param string $gateway |
|
| 12 | + */ |
|
| 10 | 13 | public function __construct($gateway) |
| 11 | 14 | { |
| 12 | 15 | $this->gateway = new $gateway(); |
@@ -48,7 +51,7 @@ discard block |
||
| 48 | 51 | |
| 49 | 52 | /** |
| 50 | 53 | * @return void |
| 51 | - * @param Array $produtos |
|
| 54 | + * @param Array $produto |
|
| 52 | 55 | **/ |
| 53 | 56 | public function setProdutos($produto) |
| 54 | 57 | { |
@@ -83,6 +86,9 @@ discard block |
||
| 83 | 86 | return $this->gateway->setEnderecoClienteGateway(); |
| 84 | 87 | } |
| 85 | 88 | |
| 89 | + /** |
|
| 90 | + * @param string $reference |
|
| 91 | + */ |
|
| 86 | 92 | public function setReference($reference) |
| 87 | 93 | { |
| 88 | 94 | $this->gateway->setReference($reference); |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | require 'GatewayInterface.php'; |
| 4 | -include(APP . 'Vendor/PagSeguro/source/PagSeguroLibrary/PagSeguroLibrary.php'); |
|
| 4 | +include(APP.'Vendor/PagSeguro/source/PagSeguroLibrary/PagSeguroLibrary.php'); |
|
| 5 | 5 | |
| 6 | 6 | class PagseguroController extends AppController implements GatewayInterface |
| 7 | 7 | { |
@@ -124,8 +124,8 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | foreach ($this->getProdutos() as $i => $item) { |
| 126 | 126 | $this->paymentRequest->addItem( |
| 127 | - '000' . $item['Produto']['id'], |
|
| 128 | - $item['Produto']['nome'] . ' Tamanho: '. $item['Produto']['variacao'], |
|
| 127 | + '000'.$item['Produto']['id'], |
|
| 128 | + $item['Produto']['nome'].' Tamanho: '.$item['Produto']['variacao'], |
|
| 129 | 129 | $item['Produto']['quantidade'], |
| 130 | 130 | number_format($item['Produto']['preco'], 2, '.', '') |
| 131 | 131 | ); |
@@ -6,216 +6,216 @@ |
||
| 6 | 6 | class PagseguroController extends AppController implements GatewayInterface |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - private $paymentRequest; |
|
| 10 | - private $email; |
|
| 11 | - private $token; |
|
| 12 | - private $produtos = array(); |
|
| 13 | - private $client = array(); |
|
| 14 | - private $reference; |
|
| 15 | - private $valor_frete; |
|
| 16 | - |
|
| 17 | - public function __construct() |
|
| 18 | - { |
|
| 19 | - $this->paymentRequest = new PagSeguroPaymentRequest(); |
|
| 20 | - // Set the currency |
|
| 21 | - $this->paymentRequest->setCurrency("BRL"); |
|
| 22 | - } |
|
| 9 | + private $paymentRequest; |
|
| 10 | + private $email; |
|
| 11 | + private $token; |
|
| 12 | + private $produtos = array(); |
|
| 13 | + private $client = array(); |
|
| 14 | + private $reference; |
|
| 15 | + private $valor_frete; |
|
| 16 | + |
|
| 17 | + public function __construct() |
|
| 18 | + { |
|
| 19 | + $this->paymentRequest = new PagSeguroPaymentRequest(); |
|
| 20 | + // Set the currency |
|
| 21 | + $this->paymentRequest->setCurrency("BRL"); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - // $products, $andress, $client, $total, $valor_frete, $id_venda |
|
| 25 | - public function finalizarPedido() |
|
| 26 | - { |
|
| 27 | - $this->paymentRequest->setReference($this->reference); |
|
| 28 | - $this->paymentRequest->setShippingCost($this->valor_frete); |
|
| 24 | + // $products, $andress, $client, $total, $valor_frete, $id_venda |
|
| 25 | + public function finalizarPedido() |
|
| 26 | + { |
|
| 27 | + $this->paymentRequest->setReference($this->reference); |
|
| 28 | + $this->paymentRequest->setShippingCost($this->valor_frete); |
|
| 29 | 29 | |
| 30 | 30 | |
| 31 | - // Set the url used by PagSeguro to redirect user after checkout process ends |
|
| 32 | - $this->paymentRequest->setRedirectUrl("http://www.lojamodelo.com.br"); |
|
| 31 | + // Set the url used by PagSeguro to redirect user after checkout process ends |
|
| 32 | + $this->paymentRequest->setRedirectUrl("http://www.lojamodelo.com.br"); |
|
| 33 | 33 | |
| 34 | - try { |
|
| 34 | + try { |
|
| 35 | 35 | |
| 36 | - /* |
|
| 36 | + /* |
|
| 37 | 37 | * #### Credentials ##### |
| 38 | 38 | * Replace the parameters below with your credentials |
| 39 | 39 | * You can also get your credentials from a config file. See an example: |
| 40 | 40 | * $credentials = PagSeguroConfig::getAccountCredentials(); |
| 41 | 41 | // */ |
| 42 | 42 | |
| 43 | - // seller authentication |
|
| 44 | - $credentials = new PagSeguroAccountCredentials($this->email, $this->token); |
|
| 43 | + // seller authentication |
|
| 44 | + $credentials = new PagSeguroAccountCredentials($this->email, $this->token); |
|
| 45 | 45 | |
| 46 | - // application authentication |
|
| 47 | - //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
| 46 | + // application authentication |
|
| 47 | + //$credentials = PagSeguroConfig::getApplicationCredentials(); |
|
| 48 | 48 | |
| 49 | - //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
| 49 | + //$credentials->setAuthorizationCode("E231B2C9BCC8474DA2E260B6C8CF60D3"); |
|
| 50 | 50 | |
| 51 | - // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. |
|
| 52 | - $url = $this->paymentRequest->register($credentials); |
|
| 51 | + // Register this payment request in PagSeguro to obtain the payment URL to redirect your customer. |
|
| 52 | + $url = $this->paymentRequest->register($credentials); |
|
| 53 | 53 | |
| 54 | - return $url; |
|
| 55 | - |
|
| 56 | - } catch (PagSeguroServiceException $e) { |
|
| 57 | - |
|
| 58 | - die($e->getMessage()); |
|
| 59 | - |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * @return void |
|
| 65 | - * @param String $token |
|
| 66 | - **/ |
|
| 67 | - public function setToken($token) |
|
| 68 | - { |
|
| 69 | - $this->token = $token; |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * @return String $token |
|
| 74 | - **/ |
|
| 75 | - public function getToken() |
|
| 76 | - { |
|
| 77 | - return $this->token; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - /** |
|
| 81 | - * @return void |
|
| 82 | - * @param String $email |
|
| 83 | - **/ |
|
| 84 | - public function setEmail($email) |
|
| 85 | - { |
|
| 86 | - $this->email = $email; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @return String $email |
|
| 91 | - **/ |
|
| 92 | - public function getEmail() |
|
| 93 | - { |
|
| 94 | - return $this->email; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * @return void |
|
| 99 | - * @param Array $produtos |
|
| 100 | - **/ |
|
| 101 | - public function setProdutos($produtos) |
|
| 102 | - { |
|
| 103 | - $this->produtos = $produtos; |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - /** |
|
| 107 | - * @return Array $produtos |
|
| 108 | - **/ |
|
| 109 | - public function getProdutos() |
|
| 110 | - { |
|
| 111 | - return $this->produtos; |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * @param Array Produtos |
|
| 116 | - * @return Array Produtos |
|
| 117 | - **/ |
|
| 118 | - public function adicionarProdutosGateway() |
|
| 119 | - { |
|
| 120 | - if (empty($this->getProdutos())) |
|
| 121 | - { |
|
| 122 | - throw new Exception("Você precisa usar a função setar os dados do produto!", 1); |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - foreach ($this->getProdutos() as $i => $item) { |
|
| 126 | - $this->paymentRequest->addItem( |
|
| 127 | - '000' . $item['Produto']['id'], |
|
| 128 | - $item['Produto']['nome'] . ' Tamanho: '. $item['Produto']['variacao'], |
|
| 129 | - $item['Produto']['quantidade'], |
|
| 130 | - number_format($item['Produto']['preco'], 2, '.', '') |
|
| 131 | - ); |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - return $this->getProdutos(); |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - public function setEndereco($endereco) |
|
| 138 | - { |
|
| 139 | - $this->endereco = $endereco; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - public function getEndereco() |
|
| 143 | - { |
|
| 144 | - return $this->endereco; |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - public function setEnderecoClienteGateway() |
|
| 148 | - { |
|
| 149 | - if (empty($this->endereco)) |
|
| 150 | - { |
|
| 151 | - throw new Exception("Você precisa usar a função setar os dados do cliente!", 1); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - $sedexCode = PagSeguroShippingType::getCodeByType('PAC'); |
|
| 155 | - $paymentRequest->setShippingType($sedexCode); |
|
| 156 | - |
|
| 157 | - $paymentRequest->setShippingAddress( |
|
| 158 | - $this->endereco['cep'], |
|
| 159 | - $this->endereco['endereco'], |
|
| 160 | - $this->endereco['numero'], |
|
| 161 | - $this->endereco['complemento'], |
|
| 162 | - $this->endereco['bairro'], |
|
| 163 | - $this->endereco['cidade'], |
|
| 164 | - $this->endereco['estado'], |
|
| 165 | - 'BRA' |
|
| 166 | - ); |
|
| 167 | - |
|
| 168 | - return $this->getEndereco(); |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - public function setReference($reference) |
|
| 172 | - { |
|
| 173 | - $this->reference = $reference; |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - public function getReference() |
|
| 177 | - { |
|
| 178 | - return $this->reference; |
|
| 179 | - } |
|
| 180 | - |
|
| 181 | - public function setValorFrete($valor_frete) |
|
| 182 | - { |
|
| 183 | - $this->valor_frete = $valor_frete; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - public function getValorFrete() |
|
| 187 | - { |
|
| 188 | - return $this->valor_frete; |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - public function setClienteGateway() |
|
| 192 | - { |
|
| 193 | - if (empty($this->cliente)) |
|
| 194 | - { |
|
| 195 | - throw new Exception("Você precisa usar a função setar os dados do cliente!", 1); |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - // Set your customer information. |
|
| 199 | - $this->paymentRequest->setSender( |
|
| 200 | - $this->cliente['nome'], |
|
| 201 | - $this->cliente['email'], |
|
| 202 | - $this->cliente['ddd'], |
|
| 203 | - $this->cliente['telefone'], |
|
| 204 | - 'CPF', |
|
| 205 | - $this->cliente['cpf'] |
|
| 206 | - ); |
|
| 207 | - |
|
| 208 | - return $this->getCliente(); |
|
| 209 | - } |
|
| 210 | - |
|
| 211 | - public function setCliente($cliente) |
|
| 212 | - { |
|
| 213 | - $this->cliente = $cliente; |
|
| 214 | - } |
|
| 215 | - |
|
| 216 | - public function getCliente() |
|
| 217 | - { |
|
| 218 | - return $this->cliente; |
|
| 219 | - } |
|
| 54 | + return $url; |
|
| 55 | + |
|
| 56 | + } catch (PagSeguroServiceException $e) { |
|
| 57 | + |
|
| 58 | + die($e->getMessage()); |
|
| 59 | + |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * @return void |
|
| 65 | + * @param String $token |
|
| 66 | + **/ |
|
| 67 | + public function setToken($token) |
|
| 68 | + { |
|
| 69 | + $this->token = $token; |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * @return String $token |
|
| 74 | + **/ |
|
| 75 | + public function getToken() |
|
| 76 | + { |
|
| 77 | + return $this->token; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + /** |
|
| 81 | + * @return void |
|
| 82 | + * @param String $email |
|
| 83 | + **/ |
|
| 84 | + public function setEmail($email) |
|
| 85 | + { |
|
| 86 | + $this->email = $email; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @return String $email |
|
| 91 | + **/ |
|
| 92 | + public function getEmail() |
|
| 93 | + { |
|
| 94 | + return $this->email; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * @return void |
|
| 99 | + * @param Array $produtos |
|
| 100 | + **/ |
|
| 101 | + public function setProdutos($produtos) |
|
| 102 | + { |
|
| 103 | + $this->produtos = $produtos; |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + /** |
|
| 107 | + * @return Array $produtos |
|
| 108 | + **/ |
|
| 109 | + public function getProdutos() |
|
| 110 | + { |
|
| 111 | + return $this->produtos; |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * @param Array Produtos |
|
| 116 | + * @return Array Produtos |
|
| 117 | + **/ |
|
| 118 | + public function adicionarProdutosGateway() |
|
| 119 | + { |
|
| 120 | + if (empty($this->getProdutos())) |
|
| 121 | + { |
|
| 122 | + throw new Exception("Você precisa usar a função setar os dados do produto!", 1); |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + foreach ($this->getProdutos() as $i => $item) { |
|
| 126 | + $this->paymentRequest->addItem( |
|
| 127 | + '000' . $item['Produto']['id'], |
|
| 128 | + $item['Produto']['nome'] . ' Tamanho: '. $item['Produto']['variacao'], |
|
| 129 | + $item['Produto']['quantidade'], |
|
| 130 | + number_format($item['Produto']['preco'], 2, '.', '') |
|
| 131 | + ); |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + return $this->getProdutos(); |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + public function setEndereco($endereco) |
|
| 138 | + { |
|
| 139 | + $this->endereco = $endereco; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + public function getEndereco() |
|
| 143 | + { |
|
| 144 | + return $this->endereco; |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + public function setEnderecoClienteGateway() |
|
| 148 | + { |
|
| 149 | + if (empty($this->endereco)) |
|
| 150 | + { |
|
| 151 | + throw new Exception("Você precisa usar a função setar os dados do cliente!", 1); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + $sedexCode = PagSeguroShippingType::getCodeByType('PAC'); |
|
| 155 | + $paymentRequest->setShippingType($sedexCode); |
|
| 156 | + |
|
| 157 | + $paymentRequest->setShippingAddress( |
|
| 158 | + $this->endereco['cep'], |
|
| 159 | + $this->endereco['endereco'], |
|
| 160 | + $this->endereco['numero'], |
|
| 161 | + $this->endereco['complemento'], |
|
| 162 | + $this->endereco['bairro'], |
|
| 163 | + $this->endereco['cidade'], |
|
| 164 | + $this->endereco['estado'], |
|
| 165 | + 'BRA' |
|
| 166 | + ); |
|
| 167 | + |
|
| 168 | + return $this->getEndereco(); |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + public function setReference($reference) |
|
| 172 | + { |
|
| 173 | + $this->reference = $reference; |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + public function getReference() |
|
| 177 | + { |
|
| 178 | + return $this->reference; |
|
| 179 | + } |
|
| 180 | + |
|
| 181 | + public function setValorFrete($valor_frete) |
|
| 182 | + { |
|
| 183 | + $this->valor_frete = $valor_frete; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + public function getValorFrete() |
|
| 187 | + { |
|
| 188 | + return $this->valor_frete; |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + public function setClienteGateway() |
|
| 192 | + { |
|
| 193 | + if (empty($this->cliente)) |
|
| 194 | + { |
|
| 195 | + throw new Exception("Você precisa usar a função setar os dados do cliente!", 1); |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + // Set your customer information. |
|
| 199 | + $this->paymentRequest->setSender( |
|
| 200 | + $this->cliente['nome'], |
|
| 201 | + $this->cliente['email'], |
|
| 202 | + $this->cliente['ddd'], |
|
| 203 | + $this->cliente['telefone'], |
|
| 204 | + 'CPF', |
|
| 205 | + $this->cliente['cpf'] |
|
| 206 | + ); |
|
| 207 | + |
|
| 208 | + return $this->getCliente(); |
|
| 209 | + } |
|
| 210 | + |
|
| 211 | + public function setCliente($cliente) |
|
| 212 | + { |
|
| 213 | + $this->cliente = $cliente; |
|
| 214 | + } |
|
| 215 | + |
|
| 216 | + public function getCliente() |
|
| 217 | + { |
|
| 218 | + return $this->cliente; |
|
| 219 | + } |
|
| 220 | 220 | |
| 221 | 221 | } |
| 222 | 222 | \ No newline at end of file |
@@ -168,6 +168,9 @@ discard block |
||
| 168 | 168 | return $this->getEndereco(); |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | + /** |
|
| 172 | + * @param string $reference |
|
| 173 | + */ |
|
| 171 | 174 | public function setReference($reference) |
| 172 | 175 | { |
| 173 | 176 | $this->reference = $reference; |
@@ -178,6 +181,9 @@ discard block |
||
| 178 | 181 | return $this->reference; |
| 179 | 182 | } |
| 180 | 183 | |
| 184 | + /** |
|
| 185 | + * @param double $valor_frete |
|
| 186 | + */ |
|
| 181 | 187 | public function setValorFrete($valor_frete) |
| 182 | 188 | { |
| 183 | 189 | $this->valor_frete = $valor_frete; |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | class SiteController extends AppController { |
| 4 | 4 | |
| 5 | - public function beforeFilter(){ |
|
| 5 | + public function beforeFilter() { |
|
| 6 | 6 | $this->Session->write('Usuario', $_SESSION['information']); |
| 7 | 7 | |
| 8 | 8 | return true; |
@@ -7,9 +7,9 @@ |
||
| 7 | 7 | class AviseMe extends AppModel |
| 8 | 8 | { |
| 9 | 9 | public $belongsTo = array ( |
| 10 | - 'Produto' => array ( |
|
| 11 | - 'className' => 'Produto' , |
|
| 12 | - 'foreignKey' => 'produto_id' |
|
| 13 | - ), |
|
| 14 | - ); |
|
| 10 | + 'Produto' => array ( |
|
| 11 | + 'className' => 'Produto' , |
|
| 12 | + 'foreignKey' => 'produto_id' |
|
| 13 | + ), |
|
| 14 | + ); |
|
| 15 | 15 | } |
| 16 | 16 | \ No newline at end of file |
@@ -6,9 +6,9 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | class AviseMe extends AppModel |
| 8 | 8 | { |
| 9 | - public $belongsTo = array ( |
|
| 10 | - 'Produto' => array ( |
|
| 11 | - 'className' => 'Produto' , |
|
| 9 | + public $belongsTo = array( |
|
| 10 | + 'Produto' => array( |
|
| 11 | + 'className' => 'Produto', |
|
| 12 | 12 | 'foreignKey' => 'produto_id' |
| 13 | 13 | ), |
| 14 | 14 | ); |
@@ -2,13 +2,13 @@ |
||
| 2 | 2 | |
| 3 | 3 | class Banner extends AppModel { |
| 4 | 4 | public $belongsTo = array ( |
| 5 | - 'Usuario' => array ( |
|
| 6 | - 'className' => 'Usuario' , |
|
| 7 | - 'foreignKey' => 'usuario_id' |
|
| 8 | - ), |
|
| 9 | - 'CategoriaBanner' => array ( |
|
| 10 | - 'className' => 'CategoriaBanner' , |
|
| 11 | - 'foreignKey' => 'categoria_banner_id' |
|
| 12 | - ), |
|
| 13 | - ); |
|
| 5 | + 'Usuario' => array ( |
|
| 6 | + 'className' => 'Usuario' , |
|
| 7 | + 'foreignKey' => 'usuario_id' |
|
| 8 | + ), |
|
| 9 | + 'CategoriaBanner' => array ( |
|
| 10 | + 'className' => 'CategoriaBanner' , |
|
| 11 | + 'foreignKey' => 'categoria_banner_id' |
|
| 12 | + ), |
|
| 13 | + ); |
|
| 14 | 14 | } |
| 15 | 15 | \ No newline at end of file |
@@ -1,13 +1,13 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | class Banner extends AppModel { |
| 4 | - public $belongsTo = array ( |
|
| 5 | - 'Usuario' => array ( |
|
| 6 | - 'className' => 'Usuario' , |
|
| 4 | + public $belongsTo = array( |
|
| 5 | + 'Usuario' => array( |
|
| 6 | + 'className' => 'Usuario', |
|
| 7 | 7 | 'foreignKey' => 'usuario_id' |
| 8 | 8 | ), |
| 9 | - 'CategoriaBanner' => array ( |
|
| 10 | - 'className' => 'CategoriaBanner' , |
|
| 9 | + 'CategoriaBanner' => array( |
|
| 10 | + 'className' => 'CategoriaBanner', |
|
| 11 | 11 | 'foreignKey' => 'categoria_banner_id' |
| 12 | 12 | ), |
| 13 | 13 | ); |