Permalink
Browse files

Implementação do módulo que contém os boletos Bradesco, Itaú, Real e …

…Banco do Brasil. O módulo se chama Cushy Mage e foi criado por Renan Gonçalves (http://blog.renangoncalves.com)
  • Loading branch information...
Ludy Amano
Ludy Amano committed Mar 16, 2009
1 parent 20e9bb0 commit 149e2d10fd4a02abb6adbd3ecb40c947d4434e6e
Showing with 15,446 additions and 1 deletion.
  1. +19 −0 app/code/community/Cushy/Boleto/Helper/Data.php
  2. +49 −0 app/code/community/Cushy/Boleto/Model/Bb.php
  3. +47 −0 app/code/community/Cushy/Boleto/Model/Bradesco.php
  4. +45 −0 app/code/community/Cushy/Boleto/Model/Itau.php
  5. +45 −0 app/code/community/Cushy/Boleto/Model/Real.php
  6. +82 −0 app/code/community/Cushy/Boleto/Model/Standard.php
  7. +96 −0 app/code/community/Cushy/Boleto/controllers/StandardController.php
  8. +79 −0 app/code/community/Cushy/Boleto/etc/config.xml
  9. +474 −0 app/code/community/Cushy/Boleto/etc/system.xml
  10. +14 −1 app/design/frontend/default/default/template/checkout/success.phtml
  11. +9 −0 app/etc/modules/Cushy_Boleto.xml
  12. +4 −0 skin/boletophp/BUGS.txt
  13. +340 −0 skin/boletophp/COPYING
  14. +26 −0 skin/boletophp/COPYRIGHT
  15. +20 −0 skin/boletophp/CREDITOS.txt
  16. +30 −0 skin/boletophp/LEIAME.txt
  17. +97 −0 skin/boletophp/boleto_bancoob.php
  18. +89 −0 skin/boletophp/boleto_banespa.php
  19. +93 −0 skin/boletophp/boleto_banestes.php
  20. +118 −0 skin/boletophp/boleto_bb.php
  21. +89 −0 skin/boletophp/boleto_besc.php
  22. +94 −0 skin/boletophp/boleto_bradesco.php
  23. +96 −0 skin/boletophp/boleto_cef.php
  24. +101 −0 skin/boletophp/boleto_cef_sigcb.php
  25. +97 −0 skin/boletophp/boleto_cef_sinco.php
  26. +86 −0 skin/boletophp/boleto_hsbc.php
  27. +91 −0 skin/boletophp/boleto_itau.php
  28. +96 −0 skin/boletophp/boleto_nossacaixa.php
  29. +88 −0 skin/boletophp/boleto_real.php
  30. +89 −0 skin/boletophp/boleto_santander_banespa.php
  31. +101 −0 skin/boletophp/boleto_sicredi.php
  32. +115 −0 skin/boletophp/boleto_sudameris.php
  33. +92 −0 skin/boletophp/boleto_unibanco.php
  34. BIN skin/boletophp/imagens/1.png
  35. BIN skin/boletophp/imagens/2.png
  36. BIN skin/boletophp/imagens/3.png
  37. BIN skin/boletophp/imagens/6.png
  38. BIN skin/boletophp/imagens/b.png
  39. BIN skin/boletophp/imagens/imgbrrazu.png
  40. BIN skin/boletophp/imagens/imgbrrlrj.png
  41. BIN skin/boletophp/imagens/imgpxlazu.png
  42. BIN skin/boletophp/imagens/logo_empresa.png
  43. BIN skin/boletophp/imagens/logobancoob.jpg
  44. BIN skin/boletophp/imagens/logobanespa.jpg
  45. BIN skin/boletophp/imagens/logobanestes.jpg
  46. BIN skin/boletophp/imagens/logobb.jpg
  47. BIN skin/boletophp/imagens/logobesc.jpg
  48. BIN skin/boletophp/imagens/logobradesco.jpg
  49. BIN skin/boletophp/imagens/logocaixa.jpg
  50. BIN skin/boletophp/imagens/logohsbc.jpg
  51. BIN skin/boletophp/imagens/logoitau.jpg
  52. BIN skin/boletophp/imagens/logonossacaixa.jpg
  53. BIN skin/boletophp/imagens/logoreal.jpg
  54. BIN skin/boletophp/imagens/logosantander.jpg
  55. BIN skin/boletophp/imagens/logosicredi.jpg
  56. BIN skin/boletophp/imagens/logosudameris.jpg
  57. BIN skin/boletophp/imagens/logounibanco.jpg
  58. BIN skin/boletophp/imagens/p.png
  59. +381 −0 skin/boletophp/include/funcoes_bancoob.php
  60. +506 −0 skin/boletophp/include/funcoes_banespa.php
  61. +374 −0 skin/boletophp/include/funcoes_banestes.php
  62. +413 −0 skin/boletophp/include/funcoes_bb.php
  63. +487 −0 skin/boletophp/include/funcoes_besc.php
  64. +387 −0 skin/boletophp/include/funcoes_bradesco.php
  65. +388 −0 skin/boletophp/include/funcoes_cef.php
  66. +390 −0 skin/boletophp/include/funcoes_cef_sigcb.php
  67. +387 −0 skin/boletophp/include/funcoes_cef_sinco.php
  68. +402 −0 skin/boletophp/include/funcoes_hsbc.php
  69. +344 −0 skin/boletophp/include/funcoes_itau.php
  70. +503 −0 skin/boletophp/include/funcoes_nossacaixa.php
  71. +368 −0 skin/boletophp/include/funcoes_real.php
  72. +412 −0 skin/boletophp/include/funcoes_santander_banespa.php
  73. +419 −0 skin/boletophp/include/funcoes_sicredi.php
  74. +325 −0 skin/boletophp/include/funcoes_sudameris.php
  75. +352 −0 skin/boletophp/include/funcoes_unibanco.php
  76. +850 −0 skin/boletophp/include/layout_bancoob.php
  77. +269 −0 skin/boletophp/include/layout_banespa.php
  78. +286 −0 skin/boletophp/include/layout_banestes.php
  79. +848 −0 skin/boletophp/include/layout_bb.php
  80. +269 −0 skin/boletophp/include/layout_besc.php
  81. +269 −0 skin/boletophp/include/layout_bradesco.php
  82. +269 −0 skin/boletophp/include/layout_cef.php
  83. +269 −0 skin/boletophp/include/layout_cef_sinco.php
  84. +269 −0 skin/boletophp/include/layout_hsbc.php
  85. +269 −0 skin/boletophp/include/layout_itau.php
  86. +269 −0 skin/boletophp/include/layout_nossacaixa.php
  87. +269 −0 skin/boletophp/include/layout_real.php
  88. +278 −0 skin/boletophp/include/layout_santander_banespa.php
  89. +272 −0 skin/boletophp/include/layout_sicredi.php
  90. +373 −0 skin/boletophp/include/layout_sudameris.php
  91. +269 −0 skin/boletophp/include/layout_unibanco.php
@@ -0,0 +1,19 @@
+<?php
+/**
+ * Short description
+ *
+ * Long description
+ *
+ *
+ * Copyright 2008, Renan Gonçalves <renan.saddam@gmail.com>
+ * Licensed under The MIT License
+ * Redistributions of files must retain the copyright notice.
+ *
+ * @copyright Copyright 2008, Renan Gonçalves
+ * @category Cushy
+ * @package Cushy_Boleto
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+class Cushy_Boleto_Helper_Data extends Mage_Core_Helper_Abstract {
+ //
+}
@@ -0,0 +1,49 @@
+<?php
+/**
+ * Short description
+ *
+ * Long description
+ *
+ *
+ * Copyright 2008, Renan Gonçalves <renan.saddam@gmail.com>
+ * Licensed under The MIT License
+ * Redistributions of files must retain the copyright notice.
+ *
+ * @copyright Copyright 2008, Renan Gonçalves
+ * @category Cushy
+ * @package Cushy_Boleto
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+class Cushy_Boleto_Model_Bb extends Cushy_Boleto_Model_Standard {
+ /**
+ * _code property
+ *
+ * @var string
+ */
+ protected $_code = 'boleto_bb';
+
+ /**
+ * Prepare the values to show in the bill
+ *
+ * @see Cushy_Boleto_Model_Standard::prepareValues
+ * @param Mage_Sales_Model_Order $order
+ * @param array $values
+ * @return array Values to Display
+ */
+ protected function _prepareValues(Mage_Sales_Model_Order $order, $values) {
+ $values = array_merge($values, array(
+ 'quantidade' => '1',
+ 'valor_unitario' => $values['valor_boleto'],
+ 'aceite' => 'N',
+ 'especie' => 'R$',
+ 'especie_doc' => 'DM',
+ 'carteira' => '18',
+ 'convenio' => Mage::getStoreConfig('payment/' . $this->_code . '/agreement_number'),
+ 'contrato' => Mage::getStoreConfig('payment/' . $this->_code . '/contract_number')
+ ));
+ $values['formatacao_convenio'] = strlen($values['convenio']);
+ $values['formatacao_nosso_numero'] = strlen($values['nosso_numero']) <= 5 ? '1' : '2';
+
+ return $values;
+ }
+}
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Short description
+ *
+ * Long description
+ *
+ *
+ * Copyright 2008, Renan Gonçalves <renan.saddam@gmail.com>
+ * Licensed under The MIT License
+ * Redistributions of files must retain the copyright notice.
+ *
+ * @copyright Copyright 2008, Renan Gonçalves
+ * @category Cushy
+ * @package Cushy_Boleto
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+class Cushy_Boleto_Model_Bradesco extends Cushy_Boleto_Model_Standard {
+ /**
+ * _code property
+ *
+ * @var string
+ */
+ protected $_code = 'boleto_bradesco';
+
+ /**
+ * Prepare the values to show in the bill
+ *
+ * @see Cushy_Boleto_Model_Standard::prepareValues
+ * @param Mage_Sales_Model_Order $order
+ * @param array $values
+ * @return array Values to Display
+ */
+ protected function _prepareValues(Mage_Sales_Model_Order $order, $values) {
+ $values = array_merge($values, array(
+ 'quantidade' => '001',
+ 'valor_unitario' => $values['valor_boleto'],
+ 'aceite' => '',
+ 'especie' => 'R$',
+ 'especie_doc' => 'DS',
+ 'conta_cedente' => $values['conta'],
+ 'conta_cedente_dv' => $values['conta_dv'],
+ 'carteira' => '06'
+ ));
+
+ return $values;
+ }
+}
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Short description
+ *
+ * Long description
+ *
+ *
+ * Copyright 2008, Renan Gonçalves <renan.saddam@gmail.com>
+ * Licensed under The MIT License
+ * Redistributions of files must retain the copyright notice.
+ *
+ * @copyright Copyright 2008, Renan Gonçalves
+ * @category Cushy
+ * @package Cushy_Boleto
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+class Cushy_Boleto_Model_Itau extends Cushy_Boleto_Model_Standard {
+ /**
+ * _code property
+ *
+ * @var string
+ */
+ protected $_code = 'boleto_itau';
+
+ /**
+ * Prepare the values to show in the bill
+ *
+ * @see Cushy_Boleto_Model_Standard::prepareValues
+ * @param Mage_Sales_Model_Order $order
+ * @param array $values
+ * @return array Values to Display
+ */
+ protected function _prepareValues(Mage_Sales_Model_Order $order, $values) {
+ $values = array_merge($values, array(
+ 'quantidade' => '001',
+ 'valor_unitario' => $values['valor_boleto'],
+ 'aceite' => '',
+ 'especie' => 'R$',
+ 'especie_doc' => '',
+ 'carteira' => Mage::getStoreConfig('payment/' . $this->_code . '/carteira')
+ ));
+
+ return $values;
+ }
+}
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Short description
+ *
+ * Long description
+ *
+ *
+ * Copyright 2008, Renan Gonçalves <renan.saddam@gmail.com>
+ * Licensed under The MIT License
+ * Redistributions of files must retain the copyright notice.
+ *
+ * @copyright Copyright 2008, Renan Gonçalves
+ * @category Cushy
+ * @package Cushy_Boleto
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+class Cushy_Boleto_Model_Real extends Cushy_Boleto_Model_Standard {
+ /**
+ * _code property
+ *
+ * @var string
+ */
+ protected $_code = 'boleto_real';
+
+ /**
+ * Prepare the values to show in the bill
+ *
+ * @see Cushy_Boleto_Model_Standard::prepareValues
+ * @param Mage_Sales_Model_Order $order
+ * @param array $values
+ * @return array Values to Display
+ */
+ protected function _prepareValues(Mage_Sales_Model_Order $order, $values) {
+ $values = array_merge($values, array(
+ 'quantidade' => '001',
+ 'valor_unitario' => $values['valor_boleto'],
+ 'aceite' => 'N',
+ 'especie' => 'R$',
+ 'especie_doc' => '',
+ 'carteira' => '57'
+ ));
+
+ return $values;
+ }
+}
@@ -0,0 +1,82 @@
+<?php
+/**
+ * Short description
+ *
+ * Long description
+ *
+ *
+ * Copyright 2008, Renan Gonçalves <renan.saddam@gmail.com>
+ * Licensed under The MIT License
+ * Redistributions of files must retain the copyright notice.
+ *
+ * @copyright Copyright 2008, Renan Gonçalves
+ * @category Cushy
+ * @package Cushy_Boleto
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+abstract class Cushy_Boleto_Model_Standard extends Mage_Payment_Model_Method_Abstract {
+ /**
+ * Prepare the values to show the bill
+ *
+ * @return array Values to display
+ */
+ public function prepareValues() {
+ $order = Mage::registry('current_order');
+ $address = $order->getBillingAddress();
+
+ // Default Values
+ $default = array(
+ 'nosso_numero' => $order->getIncrementId(),
+ 'numero_documento' => $order->getIncrementId(),
+ 'data_vencimento' => date('d/m/Y', time() + (Mage::getStoreConfig('payment/' . $this->_code . '/due_date') * 86400)),
+ 'data_documento' => date('d/m/Y'),
+ 'data_processamento' => date('d/m/Y'),
+ 'valor_boleto' => number_format($order->getGrandTotal(), 2, ',', ''),
+ 'sacado' => $address->getFirstname() . ' ' . $address->getLastname(),
+ 'endereco1' => implode(' ', $address->getStreet()),
+ 'endereco2' => $address->getCity() . ' - ' . $address->getRegion() . ' - CEP: ' . $address->getPostcode(),
+ 'identificacao' => Mage::getStoreConfig('payment/' . $this->_code . '/identification'),
+ 'cpf_cnpj' => Mage::getStoreConfig('payment/' . $this->_code . '/cpf_cnpj'),
+ 'endereco' => Mage::getStoreConfig('payment/' . $this->_code . '/address'),
+ 'cidade_uf' => Mage::getStoreConfig('payment/' . $this->_code . '/city_region'),
+ 'cedente' => Mage::getStoreConfig('payment/' . $this->_code . '/transferor')
+ );
+
+ // Instructions sentences
+ $instructions = explode("\n", Mage::getStoreConfig('payment/' . $this->_code . '/instructions'));
+ for ($i = 0; $i < 4; $i++) {
+ $instruction = isset($instructions[$i]) ? $instructions[$i] : '';
+ $default['instrucoes' . ($i + 1)] = $instruction;
+ }
+
+ // Extra Informations
+ $informations = explode("\n", Mage::getStoreConfig('payment/' . $this->_code . '/informations'));
+ for ($i = 0; $i < 3; $i++) {
+ $information = isset($informations[$i]) ? $informations[$i] : '';
+ $default['demonstrativo' . ($i + 1)] = $information;
+ }
+
+ // Agency
+ $agency = Mage::getStoreConfig('payment/' . $this->_code . '/agency');
+ $default['agencia'] = substr($agency, 0, -1);
+ $default['agencia_dv'] = substr($agency, -1);
+
+ // Account
+ $account = Mage::getStoreConfig('payment/' . $this->_code . '/account');
+ $default['conta'] = substr($account, 0, -1);
+ $default['conta_dv'] = substr($account, -1);
+
+ return $this->_prepareValues($order, $default);
+ }
+
+ /**
+ * If the method needs specific data, that is the place
+ *
+ * @param Mage_Sales_Model_Order $order
+ * @param array $values
+ * @return array Values to Display
+ */
+ protected function _prepareValues(Mage_Sales_Model_Order $order, $values) {
+ return $values;
+ }
+}
@@ -0,0 +1,96 @@
+<?php
+/**
+ * Short description
+ *
+ * Long description
+ *
+ *
+ * Copyright 2008, Renan Gonçalves <renan.saddam@gmail.com>
+ * Licensed under The MIT License
+ * Redistributions of files must retain the copyright notice.
+ *
+ * @copyright Copyright 2008, Renan Gonçalves
+ * @category Cushy
+ * @package Cushy_Boleto
+ * @license http://www.opensource.org/licenses/mit-license.php The MIT License
+ */
+class Cushy_Boleto_StandardController extends Mage_Core_Controller_Front_Action {
+ /**
+ * The name of the Boleto
+ *
+ * @see Cushy_Boleto_StandardController::_canViewOrder
+ * @var string
+ */
+ protected $_method;
+
+ /**
+ * Generate the bill
+ *
+ * @return void
+ */
+ public function viewAction() {
+ if (!$this->_loadValidOrder()) {
+ return false;
+ }
+
+ $dadosboleto = Mage::getModel('boleto/' . $this->_method)->prepareValues();
+ foreach ($dadosboleto as $key => $value) {
+ $dadosboleto[$key] = utf8_decode($value);
+ }
+
+ $path = BP . DS . 'skin' . DS . 'boletophp' . DS . 'include' . DS;
+ ob_start();
+ include $path . 'funcoes_' . $this->_method . '.php';
+ include $path . 'layout_' . $this->_method . '.php';
+ $content = ob_get_clean();
+
+ $url = preg_replace('/index\.php\/$/', '', Mage::getUrl('/')) . 'skin/boletophp/';
+ $content = str_ireplace(array('src=imagens', 'src="imagens'), array('src=' . $url . 'imagens', 'src="' . $url . 'imagens'), $content);
+ $content = str_ireplace('<body', '<body onload="window.print();"', $content);
+
+ echo $content;
+ exit;
+ }
+
+ /**
+ * Gets the order_id parameter passed by url and put order on Registry
+ *
+ * @param mixed $orderId
+ * @return boolean
+ */
+ protected function _loadValidOrder($orderId = null) {
+ if ($orderId == null) {
+ $orderId = (int) $this->getRequest()->getParam('order_id');
+ }
+ if (!$orderId) {
+ $this->_forward('noRoute');
+ return false;
+ }
+
+ $order = Mage::getModel('sales/order')->load($orderId);
+ if ($this->_canViewOrder($order)) {
+ Mage::register('current_order', $order);
+ return true;
+ } else {
+ $this->_redirect('sales/order/history');
+ return false;
+ }
+ }
+
+ /**
+ * Check if the current user made the given order
+ *
+ * @param Mage_Sales_Model_Order $order
+ * @return boolean
+ */
+ protected function _canViewOrder($order) {
+ $customerId = Mage::getSingleton('customer/session')->getCustomerId();
+ $availableStates = Mage::getSingleton('sales/order_config')->getVisibleOnFrontStates();
+ $method = $order->getPayment()->getMethod();
+ if ($order->getCustomerId() == $customerId && in_array($order->getState(), $availableStates, true) && strpos($method, 'boleto_') !== false) {
+ $this->_method = substr($method, 7);
+ return true;
+ }
+ return false;
+ }
+}
Oops, something went wrong.

0 comments on commit 149e2d1

Please sign in to comment.