Version Notes
- Checkout transparente com API Bcash;
- Estorno/Cancelamento de pagamento diretamente no Bcash;
- Atualização automática de status do pagamento.
Download this release
Release Info
Developer | Bcash |
Extension | Bcash_Pagamento |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/community/Bcash/Pagamento/Block/Adminhtml/Dependentes.php +137 -0
- app/code/community/Bcash/Pagamento/Block/Adminhtml/Sales/Order/Grid.php +19 -0
- app/code/community/Bcash/Pagamento/Block/Adminhtml/Sales/Order/View.php +47 -0
- app/code/community/Bcash/Pagamento/Block/Form/Payment.php +194 -0
- app/code/community/Bcash/Pagamento/Block/Info/Payment.php +32 -0
- app/code/community/Bcash/Pagamento/Helper/Data.php +59 -0
- app/code/community/Bcash/Pagamento/Helper/PaymentMethod.php +140 -0
- app/code/community/Bcash/Pagamento/Helper/Transaction.php +518 -0
- app/code/community/Bcash/Pagamento/Model/Observer.php +112 -0
- app/code/community/Bcash/Pagamento/Model/Order.php +59 -0
- app/code/community/Bcash/Pagamento/Model/PaymentMethod.php +189 -0
- app/code/community/Bcash/Pagamento/Model/System/Config/Source/Installments.php +74 -0
- app/code/community/Bcash/Pagamento/controllers/Admin/Sales/OrderController.php +149 -0
- app/code/community/Bcash/Pagamento/controllers/NotificationController.php +223 -0
- app/code/community/Bcash/Pagamento/controllers/PaymentController.php +127 -0
- app/code/community/Bcash/Pagamento/etc/config.xml +204 -0
- app/code/community/Bcash/Pagamento/etc/system.xml +162 -0
- app/code/community/Bcash/Pagamento/sql/pagamento_setup/mysql4-install-0.1.0.php +134 -0
- app/design/frontend/base/default/layout/bcash/pagamento/layout.xml +18 -0
- app/design/frontend/base/default/template/pagamento/checkout/success.phtml +24 -0
- app/design/frontend/base/default/template/pagamento/form/payment.phtml +815 -0
- app/design/frontend/base/default/template/pagamento/sales/order/info/buttons/payment.phtml +17 -0
- app/etc/modules/Bcash_Pagamento.xml +13 -0
- lib/BcashApi/autoloader.php +4 -0
- lib/BcashApi/src/AutoLoader.php +55 -0
- lib/BcashApi/src/Config/Config.php +19 -0
- lib/BcashApi/src/Domain/Address.php +212 -0
- lib/BcashApi/src/Domain/CreditCard.php +141 -0
- lib/BcashApi/src/Domain/CurrencyEnum.php +10 -0
- lib/BcashApi/src/Domain/Customer.php +443 -0
- lib/BcashApi/src/Domain/DependentTransaction.php +56 -0
- lib/BcashApi/src/Domain/GenderEnum.php +12 -0
- lib/BcashApi/src/Domain/Model.php +28 -0
- lib/BcashApi/src/Domain/NotificationContent.php +51 -0
- lib/BcashApi/src/Domain/NotificationStatusEnum.php +21 -0
- lib/BcashApi/src/Domain/PaymentMethod.php +27 -0
- lib/BcashApi/src/Domain/PaymentMethodEnum.php +34 -0
- lib/BcashApi/src/Domain/Product.php +145 -0
- lib/BcashApi/src/Domain/ShippingTypeEnum.php +20 -0
- lib/BcashApi/src/Domain/StateEnum.php +62 -0
- lib/BcashApi/src/Domain/TransactionRequest.php +592 -0
- lib/BcashApi/src/Exception/BaseException.php +20 -0
- lib/BcashApi/src/Exception/ConnectionException.php +15 -0
- lib/BcashApi/src/Exception/ValidationException.php +15 -0
- lib/BcashApi/src/Helper/HttpHelper.php +17 -0
- lib/BcashApi/src/Http/Authentication/Basic.php +19 -0
- lib/BcashApi/src/Http/Authentication/OAuth.php +54 -0
- lib/BcashApi/src/Http/Connection.php +89 -0
- lib/BcashApi/src/Http/GetRequest.php +48 -0
- lib/BcashApi/src/Http/PostRequest.php +58 -0
- lib/BcashApi/src/Http/PutRequest.php +58 -0
- lib/BcashApi/src/Http/Response.php +43 -0
- lib/BcashApi/src/Service/Account.php +81 -0
- lib/BcashApi/src/Service/Cancellation.php +73 -0
- lib/BcashApi/src/Service/Consultation.php +90 -0
- lib/BcashApi/src/Service/IEnvironmentManager.php +15 -0
- lib/BcashApi/src/Service/Installments.php +90 -0
- lib/BcashApi/src/Service/Notification.php +93 -0
- lib/BcashApi/src/Service/Payment.php +72 -0
- lib/BcashApi/src/Test/NotificationSimulator.php +83 -0
- package.xml +20 -0
- skin/frontend/base/default/bcash/pagamento/css/application.css +648 -0
- skin/frontend/base/default/bcash/pagamento/images/application-sprite.png +0 -0
- skin/frontend/base/default/bcash/pagamento/js/payment.js +31 -0
app/code/community/Bcash/Pagamento/Block/Adminhtml/Dependentes.php
ADDED
@@ -0,0 +1,137 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bcash_Pagamento_Block_Adminhtml_Dependentes
|
5 |
+
*/
|
6 |
+
class Bcash_Pagamento_Block_Adminhtml_Dependentes extends Mage_Adminhtml_Block_System_Config_Form_Field
|
7 |
+
{
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @var array
|
11 |
+
*/
|
12 |
+
protected $_addRowButtonHtml = array();
|
13 |
+
/**
|
14 |
+
* @var array
|
15 |
+
*/
|
16 |
+
protected $_removeRowButtonHtml = array();
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Returns html part of the setting
|
20 |
+
*
|
21 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
22 |
+
* @return string
|
23 |
+
*/
|
24 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
25 |
+
{
|
26 |
+
$this->setElement($element);
|
27 |
+
|
28 |
+
$html = '<div id="email_dependentes_template" style="display:none">';
|
29 |
+
$html .= $this->_getRowTemplateHtml();
|
30 |
+
$html .= '</div>';
|
31 |
+
|
32 |
+
$html .= '<ul id="email_dependentes_container" style="width:100%;">';
|
33 |
+
if ($this->_getValue('dependente')) {
|
34 |
+
foreach ($this->_getValue('dependente') as $i => $f) {
|
35 |
+
if ($i) {
|
36 |
+
$html .= $this->_getRowTemplateHtml($i);
|
37 |
+
}
|
38 |
+
}
|
39 |
+
}
|
40 |
+
$html .= '</ul>';
|
41 |
+
$html .= $this->_getAddRowButtonHtml('email_dependentes_container', 'email_dependentes_template', $this->__('Adicionar nova Transação dependente'));
|
42 |
+
|
43 |
+
return $html;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Retrieve html template for setting
|
48 |
+
*
|
49 |
+
* @param int $rowIndex
|
50 |
+
* @return string
|
51 |
+
*/
|
52 |
+
protected function _getRowTemplateHtml($rowIndex = 0)
|
53 |
+
{
|
54 |
+
$html = '<li>';
|
55 |
+
|
56 |
+
$html .= '<div style="margin:5px 0 10px;width:100%;">';
|
57 |
+
$html .= '<label style="width:80px;float: left;">Email:</label>'
|
58 |
+
. '<input style="width:200px;" class="validate-email" name="' . $this->getElement()->getName() . '[dependente][]"'
|
59 |
+
.' value="' . $this->_getValue('dependente/' . $rowIndex) . '" ' . $this->_getDisabled() . '/> ';
|
60 |
+
$html .= '<label style="width:80px;float: left;">Percentual:</label>'
|
61 |
+
. '<input style="width:70px;" onblur="if (this.value.indexOf(\',\') > -1) { this.value = this.value.replace(\',\',\'.\') }" maxlength="4" name="'
|
62 |
+
. $this->getElement()->getName() . '[percentual][]" class="validate-number validate-number-range number-range-0-10" value="'
|
63 |
+
. $this->_getValue('percentual/' . $rowIndex) . '" ' . $this->_getDisabled() . '/> ';
|
64 |
+
$html .= $this->_getRemoveRowButtonHtml();
|
65 |
+
$html .= '</div>';
|
66 |
+
$html .= '</li>';
|
67 |
+
|
68 |
+
return $html;
|
69 |
+
}
|
70 |
+
|
71 |
+
/**
|
72 |
+
* @return string
|
73 |
+
*/
|
74 |
+
protected function _getDisabled()
|
75 |
+
{
|
76 |
+
return $this->getElement()->getDisabled() ? ' disabled' : '';
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @param $key
|
81 |
+
* @return mixed
|
82 |
+
*/
|
83 |
+
protected function _getValue($key)
|
84 |
+
{
|
85 |
+
return $this->getElement()->getData('value/' . $key);
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @param $key
|
90 |
+
* @param $value
|
91 |
+
* @return string
|
92 |
+
*/
|
93 |
+
protected function _getSelected($key, $value)
|
94 |
+
{
|
95 |
+
return $this->getElement()->getData('value/' . $key) == $value ? 'selected="selected"' : '';
|
96 |
+
}
|
97 |
+
|
98 |
+
/**
|
99 |
+
* @param $container
|
100 |
+
* @param $template
|
101 |
+
* @param string $title
|
102 |
+
* @return mixed
|
103 |
+
*/
|
104 |
+
protected function _getAddRowButtonHtml($container, $template, $title='Add')
|
105 |
+
{
|
106 |
+
if (!isset($this->_addRowButtonHtml[$container])) {
|
107 |
+
$this->_addRowButtonHtml[$container] = $this->getLayout()->createBlock('adminhtml/widget_button')
|
108 |
+
->setType('button')
|
109 |
+
->setClass('add ' . $this->_getDisabled())
|
110 |
+
->setLabel($this->__($title))
|
111 |
+
->setOnClick("Element.insert($('" . $container . "'), {bottom: $('" . $template . "').innerHTML})")
|
112 |
+
->setDisabled($this->_getDisabled())
|
113 |
+
// ->setStyle("float:left;clear:right;")
|
114 |
+
->toHtml();
|
115 |
+
}
|
116 |
+
return $this->_addRowButtonHtml[$container];
|
117 |
+
}
|
118 |
+
|
119 |
+
/**
|
120 |
+
* @param string $selector
|
121 |
+
* @param string $title
|
122 |
+
* @return array
|
123 |
+
*/
|
124 |
+
protected function _getRemoveRowButtonHtml($selector = 'li', $title = 'Delete')
|
125 |
+
{
|
126 |
+
if (!$this->_removeRowButtonHtml) {
|
127 |
+
$this->_removeRowButtonHtml = $this->getLayout()->createBlock('adminhtml/widget_button')
|
128 |
+
->setType('button')
|
129 |
+
->setClass('delete v-middle ' . $this->_getDisabled())
|
130 |
+
->setLabel($this->__($title))
|
131 |
+
->setOnClick("Element.remove($(this).up('" . $selector . "'))")
|
132 |
+
->setDisabled($this->_getDisabled())
|
133 |
+
->toHtml();
|
134 |
+
}
|
135 |
+
return $this->_removeRowButtonHtml;
|
136 |
+
}
|
137 |
+
}
|
app/code/community/Bcash/Pagamento/Block/Adminhtml/Sales/Order/Grid.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Classe para reescrita de funcionalidades no Block de listagem de pedidos
|
5 |
+
*/
|
6 |
+
class Bcash_Pagamento_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
|
7 |
+
{
|
8 |
+
protected function _prepareMassaction()
|
9 |
+
{
|
10 |
+
parent::_prepareMassaction();
|
11 |
+
|
12 |
+
if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/cancel')) {
|
13 |
+
$this->getMassactionBlock()->addItem('cancel_order_with_bcash', array(
|
14 |
+
'label' => $this->__('Cancelar com Bcash'),
|
15 |
+
'url' => $this->getUrl('pagamento/admin_sales_order/masscanceltransaction/')
|
16 |
+
));
|
17 |
+
}
|
18 |
+
}
|
19 |
+
}
|
app/code/community/Bcash/Pagamento/Block/Adminhtml/Sales/Order/View.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once(Mage::getBaseDir("lib") . "/BcashApi/autoloader.php");
|
4 |
+
|
5 |
+
use Bcash\Domain\NotificationStatusEnum;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Classe para reescrita de funcionalidades no Block de exibição de pedido
|
9 |
+
*/
|
10 |
+
class Bcash_Pagamento_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View
|
11 |
+
{
|
12 |
+
|
13 |
+
public function __construct()
|
14 |
+
{
|
15 |
+
parent::__construct();
|
16 |
+
|
17 |
+
$order = $this->getOrder();
|
18 |
+
|
19 |
+
// Consulta transaçao Bcash
|
20 |
+
$quoteId = $order->getQuoteId();
|
21 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
22 |
+
$transactionIdBcash = $quote->getTransactionIdBcash();
|
23 |
+
$transactionInfo = Mage::helper('pagamento')->getTransaction($transactionIdBcash);
|
24 |
+
|
25 |
+
// Checa se o status da transaçao Bcash permite cancelamento
|
26 |
+
if($transactionInfo->transacao->cod_status == NotificationStatusEnum::IN_PROGRESS || $transactionInfo->transacao->cod_status == NotificationStatusEnum::APPROVED) {
|
27 |
+
if ($order->canCancel() || $order->canCreditmemo()) {
|
28 |
+
$confirmationMessage = Mage::helper('core')->jsQuoteEscape(
|
29 |
+
Mage::helper('sales')->__('Deseja realmente cancelar o pedido ' . $order->getId() . '? \n\nA transação de pagamento também será cancelada.')
|
30 |
+
);
|
31 |
+
$this->_addButton('button_cancel_with_bcash', array(
|
32 |
+
'label' => 'Cancelar com Bcash',
|
33 |
+
'onclick' => 'deleteConfirm(\'' . $confirmationMessage . '\', \'' . $this->getUrl('pagamento/admin_sales_order/canceltransaction/') . '\')',
|
34 |
+
), 0, 100, 'header', 'header');
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
$payment_link = $quote->getPaymentLinkBcash();
|
39 |
+
if ($transactionInfo->transacao->cod_status == 1 && $payment_link) {
|
40 |
+
$this->_addButton('button_payment_link_bcash', array(
|
41 |
+
'label' => 'Link de Pagamento Bcash',
|
42 |
+
'onclick' => 'window.open(\'' . $payment_link . '\')',
|
43 |
+
), 0, 110, 'header', 'header');
|
44 |
+
}
|
45 |
+
|
46 |
+
}
|
47 |
+
}
|
app/code/community/Bcash/Pagamento/Block/Form/Payment.php
ADDED
@@ -0,0 +1,194 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once(Mage::getBaseDir("lib") . "/BcashApi/autoloader.php");
|
4 |
+
|
5 |
+
use Bcash\Service\Installments;
|
6 |
+
use Bcash\Exception\ValidationException;
|
7 |
+
use Bcash\Exception\ConnectionException;
|
8 |
+
use Bcash\Domain\PaymentMethodEnum;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Bcash_Pagamento_Block_Form_Payment
|
12 |
+
*/
|
13 |
+
class Bcash_Pagamento_Block_Form_Payment extends Mage_Payment_Block_Form
|
14 |
+
{
|
15 |
+
protected $_code = 'pagamento';
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var Mage_Core_Model_Abstract
|
19 |
+
*/
|
20 |
+
private $obj;
|
21 |
+
/**
|
22 |
+
* @var
|
23 |
+
*/
|
24 |
+
private $email;
|
25 |
+
/**
|
26 |
+
* @var
|
27 |
+
*/
|
28 |
+
private $token;
|
29 |
+
/**
|
30 |
+
* @var
|
31 |
+
*/
|
32 |
+
private $sandbox;
|
33 |
+
/**
|
34 |
+
* @var
|
35 |
+
*/
|
36 |
+
private $max_installments;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @var
|
40 |
+
*/
|
41 |
+
private $cards;
|
42 |
+
/**
|
43 |
+
* @var
|
44 |
+
*/
|
45 |
+
private $boleto;
|
46 |
+
/**
|
47 |
+
* @var
|
48 |
+
*/
|
49 |
+
private $tefs;
|
50 |
+
/**
|
51 |
+
* @var
|
52 |
+
*/
|
53 |
+
private $desconto_credito_1x;
|
54 |
+
/**
|
55 |
+
* @var
|
56 |
+
*/
|
57 |
+
private $quote;
|
58 |
+
/**
|
59 |
+
* @var
|
60 |
+
*/
|
61 |
+
private $cpf;
|
62 |
+
/**
|
63 |
+
* @var
|
64 |
+
*/
|
65 |
+
private $phone;
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Instancia o template referente ao método de pagamento
|
69 |
+
*/
|
70 |
+
public function __construct()
|
71 |
+
{
|
72 |
+
parent::__construct();
|
73 |
+
$this->setTemplate('pagamento/form/payment.phtml');
|
74 |
+
$this->obj = Mage::getSingleton('Bcash_Pagamento_Model_PaymentMethod');
|
75 |
+
$this->email = $this->obj->getConfigData('email');
|
76 |
+
$this->token = $this->obj->getConfigData('token');
|
77 |
+
$this->sandbox = $this->obj->getConfigData('sandbox');
|
78 |
+
$this->max_installments = $this->obj->getConfigData('max_installments');
|
79 |
+
$this->cpf = $this->obj->getConfigData('cpf');
|
80 |
+
$this->phone = $this->obj->getConfigData('phone');
|
81 |
+
$this->desconto_credito_1x = $this->obj->getConfigData('desconto_credito_1x');
|
82 |
+
$this->cards = array(PaymentMethodEnum::VISA, PaymentMethodEnum::MASTERCARD, PaymentMethodEnum::AMERICAN_EXPRESS, PaymentMethodEnum::AURA, PaymentMethodEnum::DINERS, PaymentMethodEnum::HIPERCARD, PaymentMethodEnum::ELO);
|
83 |
+
$this->boleto = PaymentMethodEnum::BANK_SLIP;
|
84 |
+
$this->tefs = array(PaymentMethodEnum::BB_ONLINE_TRANSFER, PaymentMethodEnum::BRADESCO_ONLINE_TRANSFER, PaymentMethodEnum::ITAU_ONLINE_TRANSFER, PaymentMethodEnum::BANRISUL_ONLINE_TRANSFER, PaymentMethodEnum::HSBC_ONLINE_TRANSFER);
|
85 |
+
}
|
86 |
+
|
87 |
+
public function getCpf()
|
88 |
+
{
|
89 |
+
return $this->cpf;
|
90 |
+
}
|
91 |
+
|
92 |
+
public function getPhone()
|
93 |
+
{
|
94 |
+
return $this->phone;
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Retorna os meios de pagamento disponíveis no módulo Bcash.
|
99 |
+
* @return mixed
|
100 |
+
*/
|
101 |
+
public function getPaymentMethods()
|
102 |
+
{
|
103 |
+
Mage::log("Bcash_Pagamento_Block_Form_Payment called getPaymentMethods");
|
104 |
+
// Find allowed payment methods
|
105 |
+
$listAllowed = $this->getAllowedPaymentMethods();
|
106 |
+
|
107 |
+
return Mage::helper('pagamento/paymentMethod')->getPaymentMethods($listAllowed);
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Retorna os parcelamentos possíveis via cartão de crédito.
|
112 |
+
* @return array
|
113 |
+
*/
|
114 |
+
public function getInstallments()
|
115 |
+
{
|
116 |
+
$installments = new Installments($this->email, $this->token);
|
117 |
+
try {
|
118 |
+
$sessionCheckout = Mage::getSingleton('checkout/session');
|
119 |
+
$quoteId = $sessionCheckout->getQuoteId();
|
120 |
+
$this->quote = Mage::getModel("sales/quote")->load($quoteId);
|
121 |
+
$grandTotal = floatval(number_format($this->quote->getData('grand_total'), 2, '.', ''));
|
122 |
+
$ignoreScheduledDiscount = false;
|
123 |
+
if($this->sandbox){
|
124 |
+
$installments->enableSandBox(true);
|
125 |
+
}
|
126 |
+
$response = $installments->calculate($grandTotal, $this->max_installments, $ignoreScheduledDiscount);
|
127 |
+
return array("ok" => true, "installments" => array(0 => $this->prepareInstallmentsCards($response)));
|
128 |
+
} catch (ValidationException $e) {
|
129 |
+
Mage::log("Erro Bcash ValidationException:" . $e->getMessage());
|
130 |
+
Mage::log($e->getErrors());
|
131 |
+
return array("ok" => false, "installments" => array("1" => $grandTotal));
|
132 |
+
} catch (ConnectionException $e) {
|
133 |
+
Mage::log("Erro Bcash ConnectionException:" . $e->getMessage());
|
134 |
+
Mage::log($e->getErrors());
|
135 |
+
return array("ok" => false, "installments" => array("1" => $grandTotal));
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
public function prepareInstallmentsCards($installments)
|
140 |
+
{
|
141 |
+
foreach ($installments->paymentTypes as $obj) {
|
142 |
+
if ('card' != $obj->name) {
|
143 |
+
unset($obj);
|
144 |
+
} else {
|
145 |
+
if ($this->desconto_credito_1x) {
|
146 |
+
$subTotal = floatval($this->quote->getSubtotal());
|
147 |
+
$desconto = ($this->desconto_credito_1x / 100) * $subTotal;
|
148 |
+
if ($desconto) {
|
149 |
+
foreach ($obj->paymentMethods as $type) {
|
150 |
+
foreach ($type->installments as &$installment) {
|
151 |
+
if ($installment->number == 1) {
|
152 |
+
$installment->installmentAmount -= $desconto;
|
153 |
+
$installment->installmentAmountDesc = " ({$this->desconto_credito_1x} % de desconto)";
|
154 |
+
break;
|
155 |
+
}
|
156 |
+
}
|
157 |
+
}
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
return $installments;
|
163 |
+
}
|
164 |
+
|
165 |
+
private function getAllowedPaymentMethods()
|
166 |
+
{
|
167 |
+
$methods = array();
|
168 |
+
$installments = new Installments($this->email, $this->token);
|
169 |
+
try {
|
170 |
+
$installments->enableSandBox($this->sandbox);
|
171 |
+
// Any param value just for check
|
172 |
+
$response = $installments->calculate(100.00, 1, false);
|
173 |
+
// list methods
|
174 |
+
foreach($response->paymentTypes as $types) {
|
175 |
+
foreach($types->paymentMethods as $method) {
|
176 |
+
$methods[] = $method->id;
|
177 |
+
}
|
178 |
+
}
|
179 |
+
} catch (ValidationException $e) {
|
180 |
+
Mage::log("Erro Bcash ValidationException:" . $e->getMessage());
|
181 |
+
Mage::log($e->getErrors());
|
182 |
+
} catch (ConnectionException $e) {
|
183 |
+
Mage::log("Erro Bcash ConnectionException:" . $e->getMessage());
|
184 |
+
Mage::log($e->getErrors());
|
185 |
+
}
|
186 |
+
|
187 |
+
return $methods;
|
188 |
+
}
|
189 |
+
|
190 |
+
|
191 |
+
|
192 |
+
}
|
193 |
+
|
194 |
+
|
app/code/community/Bcash/Pagamento/Block/Info/Payment.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bcash_Pagamento_Block_Info_Payment
|
5 |
+
*/
|
6 |
+
class Bcash_Pagamento_Block_Info_Payment extends Mage_Payment_Block_Info
|
7 |
+
{
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @param null $transport
|
11 |
+
* @return Varien_Object
|
12 |
+
*/
|
13 |
+
protected function _prepareSpecificInformation($transport = null)
|
14 |
+
{
|
15 |
+
if (null !== $this->_paymentSpecificInformation) {
|
16 |
+
return $this->_paymentSpecificInformation;
|
17 |
+
}
|
18 |
+
|
19 |
+
$data = array();
|
20 |
+
if ($this->getInfo()->getCustomFieldOne()) {
|
21 |
+
$data[Mage::helper('payment')->__('Custom Field One')] = $this->getInfo()->getCustomFieldOne();
|
22 |
+
}
|
23 |
+
|
24 |
+
if ($this->getInfo()->getCustomFieldTwo()) {
|
25 |
+
$data[Mage::helper('payment')->__('Custom Field Two')] = $this->getInfo()->getCustomFieldTwo();
|
26 |
+
}
|
27 |
+
|
28 |
+
$transport = parent::_prepareSpecificInformation($transport);
|
29 |
+
|
30 |
+
return $transport->setData(array_merge($data, $transport->getData()));
|
31 |
+
}
|
32 |
+
}
|
app/code/community/Bcash/Pagamento/Helper/Data.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once(Mage::getBaseDir("lib") . "/BcashApi/autoloader.php");
|
4 |
+
|
5 |
+
use Bcash\Service\Consultation;
|
6 |
+
use Bcash\Exception\ValidationException;
|
7 |
+
use Bcash\Exception\ConnectionException;
|
8 |
+
|
9 |
+
class Bcash_Pagamento_Helper_Data extends Mage_Payment_Helper_Data
|
10 |
+
{
|
11 |
+
|
12 |
+
private $email;
|
13 |
+
private $token;
|
14 |
+
private $obj;
|
15 |
+
private $sandbox;
|
16 |
+
|
17 |
+
public function __construct()
|
18 |
+
{
|
19 |
+
$this->obj = Mage::getSingleton('Bcash_Pagamento_Model_PaymentMethod');
|
20 |
+
$this->email = $this->obj->getConfigData('email');
|
21 |
+
$this->token = $this->obj->getConfigData('token');
|
22 |
+
$this->sandbox = $this->obj->getConfigData('sandbox');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function getTransaction($transactionId = null, $orderId = null)
|
26 |
+
{
|
27 |
+
$response = null;
|
28 |
+
$consultation = new Consultation($this->email, $this->token);
|
29 |
+
$consultation->enableSandBox($this->sandbox);
|
30 |
+
|
31 |
+
try {
|
32 |
+
if (!empty($transactionId) && !is_null($transactionId)) {
|
33 |
+
//Consulta pelo id da transação
|
34 |
+
$response = $consultation->searchByTransaction($transactionId);
|
35 |
+
} else if (!empty($orderId) && !is_null($orderId)) {
|
36 |
+
//Consulta pelo id do pedido
|
37 |
+
$response = $consultation->searchByOrder($orderId);
|
38 |
+
}
|
39 |
+
|
40 |
+
} catch (ValidationException $e) {
|
41 |
+
Mage::getSingleton('adminhtml/session')->addError('Error:' . $e->getMessage());
|
42 |
+
Mage::log($e->getMessage() . " :: " . $e->getErrors());
|
43 |
+
|
44 |
+
} catch (ConnectionException $e) {
|
45 |
+
Mage::getSingleton('adminhtml/session')->addError('Error:' . $e->getMessage());
|
46 |
+
Mage::log($e->getMessage() . " :: " . $e->getErrors());
|
47 |
+
}
|
48 |
+
|
49 |
+
return $response;
|
50 |
+
}
|
51 |
+
|
52 |
+
public function setTransaction()
|
53 |
+
{
|
54 |
+
//Create Transaction with Bcash
|
55 |
+
|
56 |
+
die('setTransaction');
|
57 |
+
|
58 |
+
}
|
59 |
+
}
|
app/code/community/Bcash/Pagamento/Helper/PaymentMethod.php
ADDED
@@ -0,0 +1,140 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bcash_Pagamento_Helper_PaymentMethod
|
4 |
+
{
|
5 |
+
|
6 |
+
const CARD_TYPE = "CARD";
|
7 |
+
const BANKSLIP_TYPE = "BANKSLIP";
|
8 |
+
const ONLINE_TRANSFER_TYPE = "ONLINE_TRANSFER";
|
9 |
+
|
10 |
+
private static $cards;
|
11 |
+
private static $onlineTransfer;
|
12 |
+
private static $bankSlip;
|
13 |
+
|
14 |
+
public function __construct()
|
15 |
+
{
|
16 |
+
self::$cards = array();
|
17 |
+
self::$bankSlip = array();
|
18 |
+
self::$onlineTransfer = array();
|
19 |
+
}
|
20 |
+
|
21 |
+
private function createPayment($id, $title, $type, $minimunValue, $maxInstallments)
|
22 |
+
{
|
23 |
+
$payment = new stdClass();
|
24 |
+
$payment->id = $id;
|
25 |
+
$payment->title = $title;
|
26 |
+
$payment->type = $type;
|
27 |
+
$payment->minimunValue = $minimunValue;
|
28 |
+
$payment->maxInstallments = $maxInstallments;
|
29 |
+
return $payment;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function getPaymentMethods($allowedMethods = null)
|
33 |
+
{
|
34 |
+
if(!is_null($allowedMethods)) {
|
35 |
+
$this->createAllowedPaymentMethods($allowedMethods);
|
36 |
+
}
|
37 |
+
else {
|
38 |
+
$this->createAllPaymentMethods();
|
39 |
+
}
|
40 |
+
|
41 |
+
return array(
|
42 |
+
self::CARD_TYPE => self::$cards,
|
43 |
+
self::BANKSLIP_TYPE => self::$bankSlip,
|
44 |
+
self::ONLINE_TRANSFER_TYPE => self::$onlineTransfer
|
45 |
+
);
|
46 |
+
}
|
47 |
+
|
48 |
+
public function getPaymentMethod($payment_method){
|
49 |
+
$methods = $this->getPaymentMethods();
|
50 |
+
foreach ($methods as $type => $methodsType) {
|
51 |
+
foreach ($methodsType as $PaymentObject) {
|
52 |
+
if($payment_method == $PaymentObject->id){
|
53 |
+
return $PaymentObject;
|
54 |
+
}
|
55 |
+
}
|
56 |
+
}
|
57 |
+
return null;
|
58 |
+
}
|
59 |
+
|
60 |
+
private function createAllowedPaymentMethods($listAllowed) {
|
61 |
+
// Card: Visa
|
62 |
+
if(in_array(1, $listAllowed)) {
|
63 |
+
self::$cards[] = $this->createPayment(1, 'Visa', self::CARD_TYPE, 1.0, 12);
|
64 |
+
}
|
65 |
+
// Card: Master
|
66 |
+
if(in_array(2, $listAllowed)) {
|
67 |
+
self::$cards[] = $this->createPayment(2, 'Master', self::CARD_TYPE, 1.0, 12);
|
68 |
+
}
|
69 |
+
// Card: American Express
|
70 |
+
if(in_array(37, $listAllowed)) {
|
71 |
+
self::$cards[] = $this->createPayment(37, 'American Express', self::CARD_TYPE, 1.0, 12);
|
72 |
+
}
|
73 |
+
// Card: Aura
|
74 |
+
if(in_array(45, $listAllowed)) {
|
75 |
+
self::$cards[] = $this->createPayment(45, 'Aura', self::CARD_TYPE, 1.0, 24);
|
76 |
+
}
|
77 |
+
// Card: Diners
|
78 |
+
if(in_array(55, $listAllowed)) {
|
79 |
+
self::$cards[] = $this->createPayment(55, 'Diners', self::CARD_TYPE, 1.0, 12);
|
80 |
+
}
|
81 |
+
// Card: Hipercard
|
82 |
+
if(in_array(56, $listAllowed)) {
|
83 |
+
self::$cards[] = $this->createPayment(56, 'HiperCard', self::CARD_TYPE, 1.0, 12);
|
84 |
+
}
|
85 |
+
// Card: Elo
|
86 |
+
if(in_array(63, $listAllowed)) {
|
87 |
+
self::$cards[] = $this->createPayment(63, 'Elo', self::CARD_TYPE, 1.0, 12);
|
88 |
+
}
|
89 |
+
|
90 |
+
// Boleto
|
91 |
+
if(in_array(10, $listAllowed)) {
|
92 |
+
self::$bankSlip[] = $this->createPayment(10, 'Boleto Bancário', self::BANKSLIP_TYPE, 0.01, 1);
|
93 |
+
}
|
94 |
+
|
95 |
+
// OnlineTransfer : BB
|
96 |
+
if(in_array(58, $listAllowed)) {
|
97 |
+
self::$onlineTransfer[] = $this->createPayment(58, 'BB', self::ONLINE_TRANSFER_TYPE, 0.01, 1);
|
98 |
+
}
|
99 |
+
// OnlineTransfer : Bradesco
|
100 |
+
if(in_array(59, $listAllowed)) {
|
101 |
+
self::$onlineTransfer[] = $this->createPayment(59, 'Bradesco', self::ONLINE_TRANSFER_TYPE, 0.01, 1);
|
102 |
+
}
|
103 |
+
// OnlineTransfer : Itaú
|
104 |
+
if(in_array(60, $listAllowed)) {
|
105 |
+
self::$onlineTransfer[] = $this->createPayment(60, 'Itaú', self::ONLINE_TRANSFER_TYPE, 0.01, 1);
|
106 |
+
}
|
107 |
+
// OnlineTransfer : Banrisul
|
108 |
+
if(in_array(61, $listAllowed)) {
|
109 |
+
self::$onlineTransfer[] = $this->createPayment(61, 'Banrisul', self::ONLINE_TRANSFER_TYPE, 0.01, 1);
|
110 |
+
}
|
111 |
+
// OnlineTransfer : HSBC
|
112 |
+
if(in_array(62, $listAllowed)) {
|
113 |
+
self::$onlineTransfer[] = $this->createPayment(62, 'HSBC', self::ONLINE_TRANSFER_TYPE, 0.01, 1);
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
private function createAllPaymentMethods() {
|
118 |
+
self::$cards = array(
|
119 |
+
$this->createPayment(1, 'Visa', self::CARD_TYPE, 1.0, 12),
|
120 |
+
$this->createPayment(2, 'Master', self::CARD_TYPE, 1.0, 12),
|
121 |
+
$this->createPayment(37, 'American Express', self::CARD_TYPE, 1.0, 12),
|
122 |
+
$this->createPayment(45, 'Aura', self::CARD_TYPE, 1.0, 24),
|
123 |
+
$this->createPayment(55, 'Diners', self::CARD_TYPE, 1.0, 12),
|
124 |
+
$this->createPayment(56, 'HiperCard', self::CARD_TYPE, 1.0, 12),
|
125 |
+
$this->createPayment(63, 'Elo', self::CARD_TYPE, 1.0, 12)
|
126 |
+
);
|
127 |
+
|
128 |
+
self::$bankSlip = array(
|
129 |
+
$this->createPayment(10, 'Boleto Bancário', self::BANKSLIP_TYPE, 0.01, 1)
|
130 |
+
);
|
131 |
+
|
132 |
+
self::$onlineTransfer = array(
|
133 |
+
$this->createPayment(58, 'BB', self::ONLINE_TRANSFER_TYPE, 0.01, 1),
|
134 |
+
$this->createPayment(59, 'Bradesco', self::ONLINE_TRANSFER_TYPE, 0.01, 1),
|
135 |
+
$this->createPayment(60, 'Itaú', self::ONLINE_TRANSFER_TYPE, 0.01, 1),
|
136 |
+
$this->createPayment(61, 'Banrisul', self::ONLINE_TRANSFER_TYPE, 0.01, 1),
|
137 |
+
$this->createPayment(62, 'HSBC', self::ONLINE_TRANSFER_TYPE, 0.01, 1)
|
138 |
+
);
|
139 |
+
}
|
140 |
+
}
|
app/code/community/Bcash/Pagamento/Helper/Transaction.php
ADDED
@@ -0,0 +1,518 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once(Mage::getBaseDir("lib") . "/BcashApi/autoloader.php");
|
4 |
+
|
5 |
+
use Bcash\Domain\PaymentMethodEnum;
|
6 |
+
use Bcash\Domain\CurrencyEnum;
|
7 |
+
use Bcash\Domain\StateEnum;
|
8 |
+
use Bcash\Domain\ShippingTypeEnum;
|
9 |
+
use Bcash\Domain\Model;
|
10 |
+
use Bcash\Domain\CreditCard;
|
11 |
+
use Bcash\Domain\Address;
|
12 |
+
use Bcash\Domain\Customer;
|
13 |
+
use Bcash\Domain\Product;
|
14 |
+
use Bcash\Domain\TransactionRequest;
|
15 |
+
use Bcash\Domain\PaymentMethod;
|
16 |
+
use Bcash\Service\Payment;
|
17 |
+
use Bcash\Domain\DependentTransaction;
|
18 |
+
use Bcash\Exception\ValidationException;
|
19 |
+
use Bcash\Exception\ConnectionException;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Class Bcash_Pagamento_Helper_Transaction
|
23 |
+
*/
|
24 |
+
class Bcash_Pagamento_Helper_Transaction extends Mage_Payment_Helper_Data
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* @var
|
28 |
+
*/
|
29 |
+
private $email;
|
30 |
+
/**
|
31 |
+
* @var
|
32 |
+
*/
|
33 |
+
private $token;
|
34 |
+
/**
|
35 |
+
* @var Mage_Core_Model_Abstract
|
36 |
+
*/
|
37 |
+
private $obj;
|
38 |
+
/**
|
39 |
+
* @var
|
40 |
+
*/
|
41 |
+
private $sandbox;
|
42 |
+
/**
|
43 |
+
* @var
|
44 |
+
*/
|
45 |
+
private $dependents;
|
46 |
+
/**
|
47 |
+
* @var
|
48 |
+
*/
|
49 |
+
private $consumer_key;
|
50 |
+
|
51 |
+
//Variaveis de Transação
|
52 |
+
/**
|
53 |
+
* @var
|
54 |
+
*/
|
55 |
+
private $itemsBcash;
|
56 |
+
/**
|
57 |
+
* @var
|
58 |
+
*/
|
59 |
+
private $billingDataBcash;
|
60 |
+
/**
|
61 |
+
* @var
|
62 |
+
*/
|
63 |
+
private $grandTotalBcash;
|
64 |
+
/**
|
65 |
+
* @var
|
66 |
+
*/
|
67 |
+
private $subTotalBcash;
|
68 |
+
/**
|
69 |
+
* @var
|
70 |
+
*/
|
71 |
+
private $transactionRequest;
|
72 |
+
/**
|
73 |
+
* @var
|
74 |
+
*/
|
75 |
+
private $quoteIdTransaction;
|
76 |
+
/**
|
77 |
+
* @var
|
78 |
+
*/
|
79 |
+
public $quoteBcash;
|
80 |
+
/**
|
81 |
+
* @var
|
82 |
+
*/
|
83 |
+
private $discountBcash;
|
84 |
+
/**
|
85 |
+
* @var
|
86 |
+
*/
|
87 |
+
private $discountPercentBcash;
|
88 |
+
|
89 |
+
/**
|
90 |
+
* @var
|
91 |
+
*/
|
92 |
+
private $deps = array();
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @var
|
96 |
+
*/
|
97 |
+
public $installments;
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @var
|
101 |
+
*/
|
102 |
+
public $payment_method;
|
103 |
+
/**
|
104 |
+
* @var
|
105 |
+
*/
|
106 |
+
public $cards;
|
107 |
+
/**
|
108 |
+
* @var
|
109 |
+
*/
|
110 |
+
public $tefs;
|
111 |
+
/**
|
112 |
+
* @var
|
113 |
+
*/
|
114 |
+
public $boleto;
|
115 |
+
/**
|
116 |
+
* @var
|
117 |
+
*/
|
118 |
+
private $cpf;
|
119 |
+
/**
|
120 |
+
* @var
|
121 |
+
*/
|
122 |
+
private $phone;
|
123 |
+
|
124 |
+
private $platformId;
|
125 |
+
|
126 |
+
public function __construct()
|
127 |
+
{
|
128 |
+
$this->obj = Mage::getSingleton('Bcash_Pagamento_Model_PaymentMethod');
|
129 |
+
$this->email = $this->obj->getConfigData('email');
|
130 |
+
$this->token = $this->obj->getConfigData('token');
|
131 |
+
$this->sandbox = $this->obj->getConfigData('sandbox');
|
132 |
+
$this->consumer_key = $this->obj->getConfigData('consumer_key');
|
133 |
+
$this->dependents = $this->obj->getConfigData('transacao_dependente');
|
134 |
+
$this->cpf = $this->obj->getConfigData('cpf');
|
135 |
+
$this->phone = $this->obj->getConfigData('phone');
|
136 |
+
$sessionCheckout = Mage::getSingleton('checkout/session');
|
137 |
+
$quoteId = $sessionCheckout->getQuoteId();
|
138 |
+
$sessionCheckout->setData('QuoteIdBcash', $quoteId);
|
139 |
+
$this->quoteBcash = Mage::getModel("sales/quote")->load($quoteId);
|
140 |
+
$this->grandTotalBcash = floatval($this->quoteBcash->getData('grand_total'));
|
141 |
+
$this->subTotalBcash = floatval($this->quoteBcash->getSubtotal());
|
142 |
+
//$shippingHandling = floatval($this->grandTotalBcash -$this->subTotalBcash);
|
143 |
+
$this->billingDataBcash = $this->quoteBcash->getBillingAddress()->getData();
|
144 |
+
$this->quoteIdTransaction = (str_pad($quoteId, 9, 0, STR_PAD_LEFT));
|
145 |
+
$this->itemsBcash = $this->quoteBcash->getItemsCollection()->getItems();
|
146 |
+
$this->cards = array(PaymentMethodEnum::VISA, PaymentMethodEnum::MASTERCARD, PaymentMethodEnum::AMERICAN_EXPRESS, PaymentMethodEnum::AURA, PaymentMethodEnum::DINERS, PaymentMethodEnum::HIPERCARD, PaymentMethodEnum::ELO);
|
147 |
+
$this->boleto = PaymentMethodEnum::BANK_SLIP;
|
148 |
+
$this->tefs = array(PaymentMethodEnum::BB_ONLINE_TRANSFER, PaymentMethodEnum::BRADESCO_ONLINE_TRANSFER, PaymentMethodEnum::ITAU_ONLINE_TRANSFER, PaymentMethodEnum::BANRISUL_ONLINE_TRANSFER, PaymentMethodEnum::HSBC_ONLINE_TRANSFER);
|
149 |
+
$this->payment_method = Mage::app()->getRequest()->getPost('payment-method');
|
150 |
+
$this->installments = Mage::app()->getRequest()->getPost('installments_bcash', 1);
|
151 |
+
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* @return array
|
156 |
+
* @throws Mage_Core_Exception
|
157 |
+
*/
|
158 |
+
public function startTransaction()
|
159 |
+
{
|
160 |
+
$this->transactionRequest = $this->createTransactionRequestBcash();
|
161 |
+
$this->setShippingBcash();
|
162 |
+
$this->setPaymentMethodBcash();
|
163 |
+
$payment = new Payment($this->consumer_key);
|
164 |
+
if ($this->sandbox) {
|
165 |
+
$payment->enableSandBox(true);
|
166 |
+
}
|
167 |
+
try {
|
168 |
+
$response = $payment->create($this->transactionRequest);
|
169 |
+
|
170 |
+
$arRet = array(
|
171 |
+
'response' => $response,
|
172 |
+
'payment_method' => $this->payment_method,
|
173 |
+
'discountPercent' => $this->discountPercentBcash,
|
174 |
+
'discount' => $this->discountBcash,
|
175 |
+
'deps' => $this->deps,
|
176 |
+
'installments' => $this->installments
|
177 |
+
);
|
178 |
+
if(isset($response->cancellationCode) && $response->cancellationCode){
|
179 |
+
if($response->cancellationCode == "700001"){
|
180 |
+
Mage::throwException("A transação não pode ser processada utilizando este cartão. Por favor, selecione outro meio de pagamento.");
|
181 |
+
}else{
|
182 |
+
Mage::throwException( Mage::helper('sales')->__(urldecode($arRet['response']->message)));
|
183 |
+
}
|
184 |
+
}else{
|
185 |
+
return $arRet;
|
186 |
+
}
|
187 |
+
} catch (ValidationException $e) {
|
188 |
+
Mage::log($e->getErrors());
|
189 |
+
$errorsArr = $e->getErrors();
|
190 |
+
$errorsList = $errorsArr->list;
|
191 |
+
$messages = $e->getMessage() . "\n";
|
192 |
+
foreach ($errorsList as $err) {
|
193 |
+
$messages .= "\n- " . urldecode($err->description) . " (" . $err->code . ")";
|
194 |
+
}
|
195 |
+
Mage::throwException($messages);
|
196 |
+
} catch (ConnectionException $e) {
|
197 |
+
Mage::log($e->getErrors());
|
198 |
+
$errorsArr = $e->getErrors();
|
199 |
+
$errorsList = $errorsArr->list;
|
200 |
+
$messages = $e->getMessage() . "\n";
|
201 |
+
foreach ($errorsList as $err) {
|
202 |
+
$messages .= "\n- " . urldecode($err->description) . " (" . $err->code . ")";
|
203 |
+
}
|
204 |
+
Mage::throwException($messages);
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Cria o objeto TransactionRequest via SDK Api Bcash.
|
210 |
+
* @return TransactionRequest
|
211 |
+
*/
|
212 |
+
public function createTransactionRequestBcash()
|
213 |
+
{
|
214 |
+
//Id:Plataforma => 565
|
215 |
+
$url = Mage::getUrl('pagamento/notification/request');
|
216 |
+
$transactionRequest = new TransactionRequest();
|
217 |
+
$transactionRequest->setSellerMail($this->email);
|
218 |
+
$transactionRequest->setOrderId($this->quoteBcash->getReservedOrderId());
|
219 |
+
$transactionRequest->setBuyer($this->createBuyerBcash());
|
220 |
+
$transactionRequest->setUrlNotification($url);
|
221 |
+
$transactionRequest->setProducts($this->createProductBcash());
|
222 |
+
$transactionRequest->setAcceptedContract("S");
|
223 |
+
$transactionRequest->setViewedContract("S");
|
224 |
+
$transactionRequest->setDependentTransactions($this->createDependentTransactionsBcash());
|
225 |
+
$transactionRequest->setPlatformId(565);
|
226 |
+
//var_dump($transactionRequest);
|
227 |
+
return $transactionRequest;
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Adiciona o método de pagamento a transação atual.
|
232 |
+
*/
|
233 |
+
public function setPaymentMethodBcash()
|
234 |
+
{
|
235 |
+
$this->transactionRequest->setPaymentMethod($this->payment_method);
|
236 |
+
if (in_array($this->payment_method, $this->cards)) {
|
237 |
+
$this->transactionRequest->setCreditCard($this->createCreditCardBcash());
|
238 |
+
$this->transactionRequest->setInstallments($this->installments);
|
239 |
+
}
|
240 |
+
|
241 |
+
if ($this->installments == 1) {
|
242 |
+
$discount = $this->calculateDiscount($this->payment_method);
|
243 |
+
$this->setDiscountBcash($discount);
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
/**
|
248 |
+
* @param $payment_method
|
249 |
+
* @return float|int
|
250 |
+
*/
|
251 |
+
public function calculateDiscount($payment_method)
|
252 |
+
{
|
253 |
+
$discount = 0;
|
254 |
+
if (in_array($payment_method, $this->cards)) {
|
255 |
+
$percent = $this->obj->getConfigData('desconto_credito_1x');
|
256 |
+
} elseif (in_array($payment_method, $this->tefs)) {
|
257 |
+
$percent = $this->obj->getConfigData('desconto_tef');
|
258 |
+
} else {
|
259 |
+
$percent = $this->obj->getConfigData('desconto_boleto');
|
260 |
+
}
|
261 |
+
if ($percent) {
|
262 |
+
//$discount = floatval(($this->subTotalBcash / 100) * $percent);
|
263 |
+
$discount = floatval(number_format(($this->subTotalBcash / 100) * $percent, 2, '.', ''));
|
264 |
+
$this->discountPercentBcash = $percent;
|
265 |
+
$this->discountBcash = $discount;
|
266 |
+
}
|
267 |
+
return $discount;
|
268 |
+
}
|
269 |
+
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Adiciona o endereço a transação atual.
|
273 |
+
* @return Address
|
274 |
+
*/
|
275 |
+
public function createAddressBcash()
|
276 |
+
{
|
277 |
+
$address = $this->quoteBcash->getShippingAddress();
|
278 |
+
$street = $address->getStreet(1);
|
279 |
+
$numero = $address->getStreet(2);
|
280 |
+
$complemento = $address->getStreet(3);
|
281 |
+
$bairro = $address->getStreet(4);
|
282 |
+
$addressObj = new Address();
|
283 |
+
$addressObj->setAddress($street);
|
284 |
+
$addressObj->setNumber($numero ? $numero : 'SN');
|
285 |
+
$addressObj->setComplement($complemento);
|
286 |
+
$addressObj->setNeighborhood($bairro);
|
287 |
+
$addressObj->setCity($address->getCity());
|
288 |
+
$addressObj->setState($this->parseRegionBcash($address->getRegion()));
|
289 |
+
$addressObj->setZipCode($address->getPostcode());
|
290 |
+
return $addressObj;
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* Adiciona o comprador a transação atual
|
295 |
+
* @return Customer
|
296 |
+
*/
|
297 |
+
public function createBuyerBcash()
|
298 |
+
{
|
299 |
+
$buyer = new Customer();
|
300 |
+
$customerData = null;
|
301 |
+
$prefix = "";
|
302 |
+
|
303 |
+
$customer_id = $this->quoteBcash->getCustomerId();
|
304 |
+
if(!is_null($customer_id)) {
|
305 |
+
$customer = Mage::getModel('customer/customer')->load($customer_id);
|
306 |
+
$customerData = $customer->getData();
|
307 |
+
}else {
|
308 |
+
$customerData = $this->quoteBcash->getData();
|
309 |
+
$prefix = "customer_";
|
310 |
+
}
|
311 |
+
|
312 |
+
if(!is_null($customerData)) {
|
313 |
+
$cpf_cnpj_bcash = isset($customerData[$prefix."taxvat"]) ? $customerData[$prefix."taxvat"] : null;
|
314 |
+
$cpf_cnpj_bcash = preg_replace('/[^0-9]+/', '', $cpf_cnpj_bcash);
|
315 |
+
|
316 |
+
if ($this->cpf) {
|
317 |
+
$cpf_cnpj_bcash = Mage::app()->getRequest()->getPost('cpf_cnpj_bcash');
|
318 |
+
$cpf_cnpj_bcash = preg_replace('/[^0-9]+/', '', $cpf_cnpj_bcash);
|
319 |
+
}
|
320 |
+
|
321 |
+
|
322 |
+
$buyer->setMail($customerData[$prefix.'email']);
|
323 |
+
$name = ($customerData[$prefix.'firstname']);
|
324 |
+
$name .= isset($customerData[$prefix.'middlename']) ? ' ' . $customerData[$prefix.'middlename'] : '';
|
325 |
+
$name .= isset($customerData[$prefix.'lastname']) ? ' ' . $customerData[$prefix.'lastname'] : '';
|
326 |
+
$buyer->setName($name);
|
327 |
+
if(strlen($cpf_cnpj_bcash) > 11) {
|
328 |
+
$buyer->setCnpj($cpf_cnpj_bcash);
|
329 |
+
$buyer->setCompanyName($name);
|
330 |
+
}else { $buyer->setCpf($cpf_cnpj_bcash); }
|
331 |
+
$buyer->setPhone($this->completePhoneBcash('telephone'));
|
332 |
+
$buyer->setCellPhone($this->completePhoneBcash('fax'));
|
333 |
+
$buyer->setAddress($this->createAddressBcash());
|
334 |
+
}
|
335 |
+
|
336 |
+
return $buyer;
|
337 |
+
}
|
338 |
+
|
339 |
+
/**
|
340 |
+
* Adiciona o telefone/celular na transação atual.
|
341 |
+
* @return string
|
342 |
+
*/
|
343 |
+
public function completePhoneBcash($attr = null)
|
344 |
+
{
|
345 |
+
if ($this->phone) {
|
346 |
+
$phone = Mage::app()->getRequest()->getPost('ddd_bcash') . Mage::app()->getRequest()->getPost('phone_bcash');
|
347 |
+
$phone = preg_replace('/[^0-9]+/', '', $phone);
|
348 |
+
return $this->parsePhone($phone);
|
349 |
+
}
|
350 |
+
$address = $this->quoteBcash->getBillingAddress()->getData();
|
351 |
+
if (!is_null($attr)) {
|
352 |
+
$phone = $this->parsePhone($address[$attr]);
|
353 |
+
return $phone;
|
354 |
+
}
|
355 |
+
return $this->parsePhone($address['telephone']);
|
356 |
+
}
|
357 |
+
|
358 |
+
/**
|
359 |
+
* Retorna somente 20 dígitos do telefone (limite da API).
|
360 |
+
* @param $phone
|
361 |
+
* @return string
|
362 |
+
*/
|
363 |
+
public function parsePhone($phone)
|
364 |
+
{
|
365 |
+
$phone = preg_replace('/[^0-9]+/', '', $phone);
|
366 |
+
if (strlen($phone) > 20) {
|
367 |
+
return substr($phone, -20);
|
368 |
+
}
|
369 |
+
return $phone;
|
370 |
+
}
|
371 |
+
|
372 |
+
/**
|
373 |
+
* Adiciona os produtos do carrinho de compras a transação atual.
|
374 |
+
* @return array
|
375 |
+
*/
|
376 |
+
public function createProductBcash()
|
377 |
+
{
|
378 |
+
$products = array();
|
379 |
+
foreach ($this->itemsBcash as $item) {
|
380 |
+
$price = $item->getPrice();
|
381 |
+
if ($price > 0) {
|
382 |
+
$product = new Product();
|
383 |
+
$cod = $item->getSku() ? $item->getSku() : $item->getId();
|
384 |
+
$product->setCode($cod);
|
385 |
+
$name = $item->getName();
|
386 |
+
$product->setDescription($name);
|
387 |
+
$qty = $item->getQty();
|
388 |
+
$product->setAmount(intval($qty));
|
389 |
+
$product->setValue(floatval($price));
|
390 |
+
array_push($products, $product);
|
391 |
+
}
|
392 |
+
}
|
393 |
+
return $products;
|
394 |
+
}
|
395 |
+
|
396 |
+
/**
|
397 |
+
* Adiciona valor adicional a transação atual.
|
398 |
+
* @param null $addition
|
399 |
+
* @param null $discount
|
400 |
+
*/
|
401 |
+
public function setAdditionBcash($addition = 0)
|
402 |
+
{
|
403 |
+
$this->transactionRequest->setAddition($addition);
|
404 |
+
}
|
405 |
+
|
406 |
+
/**
|
407 |
+
* Adiciona valor de desconto a transação atual caso o mesmo esteja definido no módulo.
|
408 |
+
* @param null $addition
|
409 |
+
* @param null $discount
|
410 |
+
*/
|
411 |
+
public function setDiscountBcash($discount)
|
412 |
+
{
|
413 |
+
$this->discountBcash = $discount;
|
414 |
+
$this->transactionRequest->setDiscount($discount);
|
415 |
+
}
|
416 |
+
|
417 |
+
/**
|
418 |
+
* Adiciona o tipo de Frete e valor definido para o mesmo a transação atual.
|
419 |
+
* @return void
|
420 |
+
*/
|
421 |
+
public function setShippingBcash()
|
422 |
+
{
|
423 |
+
$shipping = $this->quoteBcash->getShippingAddress()->getData();
|
424 |
+
$this->transactionRequest->setShipping(floatval($shipping['shipping_amount']));
|
425 |
+
$this->transactionRequest->setShippingType($shipping['shipping_description']);
|
426 |
+
}
|
427 |
+
|
428 |
+
/**
|
429 |
+
* Adiciona o cartão de crédito a transação atual quando solicitado a transação atual.
|
430 |
+
* @return CreditCard
|
431 |
+
*/
|
432 |
+
public function createCreditCardBcash()
|
433 |
+
{
|
434 |
+
$card_number_bcash = Mage::app()->getRequest()->getPost('card_number_bcash');
|
435 |
+
$month_bcash = Mage::app()->getRequest()->getPost('month_bcash');
|
436 |
+
$year_bcash = Mage::app()->getRequest()->getPost('year_bcash');
|
437 |
+
$name_card_bcash = Mage::app()->getRequest()->getPost('name_card_bcash');
|
438 |
+
$cvv_bcash = Mage::app()->getRequest()->getPost('cvv_bcash');
|
439 |
+
$creditCard = new CreditCard();
|
440 |
+
$creditCard->setHolder($name_card_bcash);
|
441 |
+
$creditCard->setNumber($card_number_bcash);
|
442 |
+
$creditCard->setSecurityCode($cvv_bcash);
|
443 |
+
$creditCard->setMaturityMonth($month_bcash);
|
444 |
+
$creditCard->setMaturityYear($year_bcash);
|
445 |
+
return $creditCard;
|
446 |
+
}
|
447 |
+
|
448 |
+
/**
|
449 |
+
* Adiciona as transações dependentes a transação atual.
|
450 |
+
* @return array
|
451 |
+
*/
|
452 |
+
public function createDependentTransactionsBcash()
|
453 |
+
{
|
454 |
+
$unserialezedDeps = unserialize($this->dependents);
|
455 |
+
foreach ($unserialezedDeps['dependente'] as $key => $obj) {
|
456 |
+
if ($obj && isset($unserialezedDeps['percentual'][$key]) && $unserialezedDeps['percentual'][$key] > 0) {
|
457 |
+
$dependent = new DependentTransaction();
|
458 |
+
$dependent->setEmail($obj);
|
459 |
+
$value = ($this->subTotalBcash / 100) * floatval($unserialezedDeps['percentual'][$key]);
|
460 |
+
$dependent->setValue(floatval(number_format($value, 2, '.', '')));
|
461 |
+
array_push($this->deps, $dependent);
|
462 |
+
}
|
463 |
+
}
|
464 |
+
return $this->deps;
|
465 |
+
}
|
466 |
+
|
467 |
+
/**
|
468 |
+
* Substitui os caracteres especificos da linguagem por caracteres ASCII equivalentes.
|
469 |
+
* @see http://stackoverflow.com/a/16427125/529403
|
470 |
+
* @param string $s
|
471 |
+
* @return string
|
472 |
+
*/
|
473 |
+
public static function normalizeChars($s)
|
474 |
+
{
|
475 |
+
$replace = array(
|
476 |
+
'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'Ae', 'Å'=>'A', 'Æ'=>'A', 'Ă'=>'A',
|
477 |
+
'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'ae', 'å'=>'a', 'ă'=>'a', 'æ'=>'ae',
|
478 |
+
'þ'=>'b', 'Þ'=>'B',
|
479 |
+
'Ç'=>'C', 'ç'=>'c',
|
480 |
+
'È'=>'E', 'É'=>'E', 'Ê'=>'E', 'Ë'=>'E',
|
481 |
+
'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e',
|
482 |
+
'Ğ'=>'G', 'ğ'=>'g',
|
483 |
+
'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'İ'=>'I', 'ı'=>'i', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i',
|
484 |
+
'Ñ'=>'N',
|
485 |
+
'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'Oe', 'Ø'=>'O', 'ö'=>'oe', 'ø'=>'o',
|
486 |
+
'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
|
487 |
+
'Š'=>'S', 'š'=>'s', 'Ş'=>'S', 'ș'=>'s', 'Ș'=>'S', 'ş'=>'s', 'ß'=>'ss',
|
488 |
+
'ț'=>'t', 'Ț'=>'T',
|
489 |
+
'Ù'=>'U', 'Ú'=>'U', 'Û'=>'U', 'Ü'=>'Ue',
|
490 |
+
'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ü'=>'ue',
|
491 |
+
'Ý'=>'Y',
|
492 |
+
'ý'=>'y', 'ý'=>'y', 'ÿ'=>'y',
|
493 |
+
'Ž'=>'Z', 'ž'=>'z'
|
494 |
+
);
|
495 |
+
return strtr($s, $replace);
|
496 |
+
}
|
497 |
+
|
498 |
+
/**
|
499 |
+
* Realiza a identificação do Estado preenchido pelo usuário.
|
500 |
+
* @param $state
|
501 |
+
* @return mixed|string
|
502 |
+
*/
|
503 |
+
public function parseRegionBcash($state)
|
504 |
+
{
|
505 |
+
if (strlen($state) == 2 && is_string($state)) {
|
506 |
+
return strtoupper($state);
|
507 |
+
} elseif (strlen($state) > 2 && is_string($state)) {
|
508 |
+
$state = $this->normalizeChars($state);
|
509 |
+
$state = trim($state);
|
510 |
+
$state = strtoupper($state);
|
511 |
+
$codes = array("AC" => "ACRE", "AL" => "ALAGOAS", "AM" => "AMAZONAS", "AP" => "AMAPA", "BA" => "BAHIA", "CE" => "CEARA", "DF" => "DISTRITO FEDERAL", "ES" => "ESPIRITO SANTO", "GO" => "GOIAS", "MA" => "MARANHAO", "MT" => "MATO GROSSO", "MS" => "MATO GROSSO DO SUL", "MG" => "MINAS GERAIS", "PA" => "PARA", "PB" => "PARAIBA", "PR" => "PARANA", "PE" => "PERNAMBUCO", "PI" => "PIAUI", "RJ" => "RIO DE JANEIRO", "RN" => "RIO GRANDE DO NORTE", "RO" => "RONDONIA", "RS" => "RIO GRANDE DO SUL", "RR" => "RORAIMA", "SC" => "SANTA CATARINA", "SE" => "SERGIPE", "SP" => "SAO PAULO", "TO" => "TOCANTINS");
|
512 |
+
if ($code = array_search($state, $codes)) {
|
513 |
+
return $code;
|
514 |
+
}
|
515 |
+
}
|
516 |
+
return $state;
|
517 |
+
}
|
518 |
+
}
|
app/code/community/Bcash/Pagamento/Model/Observer.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bcash_Pagamento_Model_Observer
|
5 |
+
*/
|
6 |
+
class Bcash_Pagamento_Model_Observer
|
7 |
+
{
|
8 |
+
/**
|
9 |
+
* Método para verificar alteração de status do pedido
|
10 |
+
*
|
11 |
+
* @param Varien_Event_Observer $observer
|
12 |
+
*/
|
13 |
+
public function checkOrderState(Varien_Event_Observer $observer)
|
14 |
+
{
|
15 |
+
$origOrderData = $observer->getEvent()->getData('data_object')->getOrigData();
|
16 |
+
$newOrderData = $observer->getEvent()->getData('data_object')->getData();
|
17 |
+
if (($origOrderData['state'] !== $newOrderData['state']) && ($newOrderData['state'] == Mage_Sales_Model_Order::STATE_CANCELED)) {
|
18 |
+
// Verifica se pedido possui transação Bcash relacionada
|
19 |
+
$order = $observer->getOrder()->getData();
|
20 |
+
if(!empty($order['transaction_id_bcash']) && !is_null($order['transaction_id_bcash'])) {
|
21 |
+
$orderId = $order['entity_id'];
|
22 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
23 |
+
$order->addStatusHistoryComment('Pedido não cancelado através do cancelamento Bcash. A transação ' . $order['transaction_id_bcash'] . ' não foi alterada.');
|
24 |
+
$order->save();
|
25 |
+
}
|
26 |
+
}
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Registra os dados do pedido na sessão.
|
31 |
+
* See etc/config.xml
|
32 |
+
* Triggered by: Mage::dispatchEvent('checkout_type_onepage_save_order_after', array('order'=>$order, 'quote'=>$this->getQuote()));
|
33 |
+
* @param Varien_Event_Observer $observer
|
34 |
+
*/
|
35 |
+
public function saveOrderQuoteToSession($observer)
|
36 |
+
{
|
37 |
+
/* @var $event Varien_Event */
|
38 |
+
$event = $observer->getEvent();
|
39 |
+
/* @var $order Mage_Sales_Model_Order */
|
40 |
+
$order = $event->getOrder();
|
41 |
+
/* @var $quote Mage_Sales_Model_Quote */
|
42 |
+
$quote = $event->getQuote();
|
43 |
+
$session = Mage::getSingleton('checkout/session');
|
44 |
+
$quoteId = $quote->getId();
|
45 |
+
$orderId = $order->getId();
|
46 |
+
$incrId = $order->getIncrementId();
|
47 |
+
Mage::log("Saving quote [$quoteId] and order [$incrId] to checkout/session");
|
48 |
+
$session->setData('OrderIdBcash', $orderId);
|
49 |
+
$session->setData('OrderIncrementIdBcash', $incrId);
|
50 |
+
$session->setData('QuoteIdBcash', $quoteId);
|
51 |
+
unset($event);
|
52 |
+
unset($order);
|
53 |
+
unset($quote);
|
54 |
+
unset($session);
|
55 |
+
return $this;
|
56 |
+
}
|
57 |
+
|
58 |
+
/*
|
59 |
+
<global>
|
60 |
+
- If you want your observer to listen no matter where the event is dispatched from, put it here. You can also put it in "frontend" or "adminhtml".
|
61 |
+
<events>
|
62 |
+
- This is the element that stores all of the events that are registered.
|
63 |
+
<checkout_submit_all_after>
|
64 |
+
- This is the "event" that you are listening to.
|
65 |
+
<observers>
|
66 |
+
- This is the type of event. I don't think there are others.
|
67 |
+
<awesome_example>
|
68 |
+
- This is a unique string that defines this configuration. It can be anything, and just needs to be unique.
|
69 |
+
<type>
|
70 |
+
- I have always used singleton, but other options can be "model" or "object". The "singleton" will create the object as Mage::getSingleton()
|
71 |
+
while both "object" and "model" will use Mage::getModel() when creating the observer object.
|
72 |
+
<class>
|
73 |
+
- This is the observer class.
|
74 |
+
<method>
|
75 |
+
- This is the function to be called in the observer class.
|
76 |
+
*/
|
77 |
+
|
78 |
+
/**
|
79 |
+
* Adiciona o Link do meio de pagamento a página de sucesso.
|
80 |
+
* @param $observer
|
81 |
+
*/
|
82 |
+
public function orderSuccessEvent($observer)
|
83 |
+
{
|
84 |
+
Mage::log("Bcash_Pagamento_Model_Observer::showPaymentLink");
|
85 |
+
try {
|
86 |
+
$order = new Mage_Sales_Model_Order();
|
87 |
+
$lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
88 |
+
$order->loadByIncrementId($lastOrderId);
|
89 |
+
$quoteId = $order->getQuoteId();
|
90 |
+
$quote = Mage::getModel("sales/quote")->loadByIdWithoutStore($quoteId);
|
91 |
+
$type = null;
|
92 |
+
$payment_method_bcash = $quote->getPaymentMethodBcash();
|
93 |
+
if ($payment_method_bcash) {
|
94 |
+
$helper = new Bcash_Pagamento_Helper_PaymentMethod();
|
95 |
+
$type = $helper->getPaymentMethod($payment_method_bcash);
|
96 |
+
}
|
97 |
+
$layout = Mage::app()->getLayout();
|
98 |
+
$block = $layout->createBlock(
|
99 |
+
'Mage_Core_Block_Template',
|
100 |
+
'link_pagamento_bcash',
|
101 |
+
array('template' => 'pagamento/checkout/success.phtml')
|
102 |
+
);
|
103 |
+
$block->setOrder($order);
|
104 |
+
$block->setQuote($quote);
|
105 |
+
$block->setType($type);
|
106 |
+
$layout->getBlock('content')->append($block);
|
107 |
+
} catch(Exception $e) {
|
108 |
+
Mage::log($e->getMessage());
|
109 |
+
}
|
110 |
+
}
|
111 |
+
|
112 |
+
}
|
app/code/community/Bcash/Pagamento/Model/Order.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once(Mage::getBaseDir("lib") . "/BcashApi/autoloader.php");
|
4 |
+
|
5 |
+
use Bcash_Pagamento_Helper_RegisterSdk;
|
6 |
+
use Bcash\Service\Cancellation;
|
7 |
+
use Bcash\Exception\ValidationException;
|
8 |
+
use Bcash\Exception\ConnectionException;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Class Bcash_Pagamento_Model_Order
|
12 |
+
*/
|
13 |
+
class Bcash_Pagamento_Model_Order extends Mage_Core_Model_Abstract
|
14 |
+
{
|
15 |
+
|
16 |
+
private $email;
|
17 |
+
private $token;
|
18 |
+
private $obj;
|
19 |
+
private $sandbox;
|
20 |
+
|
21 |
+
public function __construct()
|
22 |
+
{
|
23 |
+
$this->obj = Mage::getSingleton('Bcash_Pagamento_Model_PaymentMethod');
|
24 |
+
$this->email = $this->obj->getConfigData('email');
|
25 |
+
$this->token = $this->obj->getConfigData('token');
|
26 |
+
$this->sandbox = $this->obj->getConfigData('sandbox');
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Método para cancelamento de transação de pagamento
|
31 |
+
*
|
32 |
+
* @param $transactionId
|
33 |
+
* @return mixed
|
34 |
+
*/
|
35 |
+
public function cancellation($transactionId)
|
36 |
+
{
|
37 |
+
// Instância de classe de cancelamento
|
38 |
+
$cancellation = new Cancellation($this->email, $this->token);
|
39 |
+
$cancellation->enableSandBox($this->sandbox);
|
40 |
+
|
41 |
+
$response = null;
|
42 |
+
try {
|
43 |
+
if (!is_null($transactionId) && !empty($transactionId)) {
|
44 |
+
// Envia cancelamento da transação para API
|
45 |
+
$response = $cancellation->execute($transactionId);
|
46 |
+
}
|
47 |
+
} catch (ValidationException $e) {
|
48 |
+
Mage::getSingleton('adminhtml/session')->addError('Erro: ' . $e->getMessage());
|
49 |
+
Mage::log($e->getErrors());
|
50 |
+
|
51 |
+
} catch (ConnectionException $e) {
|
52 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage() . ' (Confirme se o serviço de cancelamento está habilitado para sua conta Bcash)');
|
53 |
+
Mage::log($e->getErrors());
|
54 |
+
}
|
55 |
+
|
56 |
+
return $response;
|
57 |
+
}
|
58 |
+
|
59 |
+
}
|
app/code/community/Bcash/Pagamento/Model/PaymentMethod.php
ADDED
@@ -0,0 +1,189 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
/**
|
5 |
+
* Class Bcash_Pagamento_Model_PaymentMethod
|
6 |
+
*/
|
7 |
+
class Bcash_Pagamento_Model_PaymentMethod extends Mage_Payment_Model_Method_Abstract
|
8 |
+
{
|
9 |
+
/**
|
10 |
+
* @var string
|
11 |
+
*/
|
12 |
+
protected $_code = 'pagamento';
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @var string
|
16 |
+
*/
|
17 |
+
protected $_formBlockType = 'pagamento/form_payment';
|
18 |
+
|
19 |
+
/** Flag executa o método initalize() com o checkout completo.
|
20 |
+
* @var bool
|
21 |
+
*/
|
22 |
+
protected $_isInitializeNeeded = true;
|
23 |
+
|
24 |
+
protected $_isGateway = true;
|
25 |
+
protected $_canAuthorize = true;
|
26 |
+
protected $_canUseCheckout = true;
|
27 |
+
//Disable multi-shipping for this payment module.
|
28 |
+
protected $_canUseForMultishipping = false;
|
29 |
+
|
30 |
+
protected $transaction;
|
31 |
+
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Inicializa o método de pagamento. Chamado quando a compra é completa.
|
35 |
+
* Objeto Order será criado após a chamada deste método.
|
36 |
+
*
|
37 |
+
* @param string $paymentAction
|
38 |
+
* @param Varien_Object $stateObject
|
39 |
+
* @return Mage_Payment_Model_Abstract
|
40 |
+
* @throws Mage_Payment_Model_Info_Exception
|
41 |
+
*/
|
42 |
+
public function initialize($paymentAction, $stateObject)
|
43 |
+
{
|
44 |
+
Mage::log('Called ' . __METHOD__ . ' with payment ' . $paymentAction);
|
45 |
+
Mage::log('Payment visitor: ' . Mage::helper('core/http')->getRemoteAddr());
|
46 |
+
parent::initialize($paymentAction, $stateObject);
|
47 |
+
|
48 |
+
if ($paymentAction != 'sale') {
|
49 |
+
return $this;
|
50 |
+
}
|
51 |
+
|
52 |
+
$state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
|
53 |
+
$stateObject->setState($state);
|
54 |
+
$stateObject->setStatus(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
|
55 |
+
$stateObject->setIsNotified(false);
|
56 |
+
|
57 |
+
try {
|
58 |
+
$result = $this->_customBeginPayment();
|
59 |
+
Mage::log(print_r($result, true));
|
60 |
+
$response = $result['response'];
|
61 |
+
$payment_method = $result['payment_method'];
|
62 |
+
$installments = $result['installments'];
|
63 |
+
|
64 |
+
/*
|
65 |
+
1 – Em andamento
|
66 |
+
3 – Aprovada
|
67 |
+
4 – Concluída
|
68 |
+
5 – Disputa
|
69 |
+
6 – Devolvida
|
70 |
+
7 – Cancelada
|
71 |
+
8 – Chargeback
|
72 |
+
*/
|
73 |
+
|
74 |
+
// Salvar o PEDIDO em caso de SUCESSO e adicionar os dados da Transação
|
75 |
+
if ($response->status != 1 && $response->status != 2) {
|
76 |
+
|
77 |
+
$setIsNotified = false;
|
78 |
+
switch($response->status)
|
79 |
+
{
|
80 |
+
case 3: //3 – Aprovada
|
81 |
+
case 4: //4 – Concluída
|
82 |
+
$state = Mage_Sales_Model_Order::STATE_PROCESSING;
|
83 |
+
$setIsNotified = true;
|
84 |
+
break;
|
85 |
+
case 6://6 – Devolvida
|
86 |
+
$state = Mage_Sales_Model_Order::STATE_HOLDED;
|
87 |
+
break;
|
88 |
+
case 7://7 – Cancelada
|
89 |
+
case 8://8 – Chargeback
|
90 |
+
$state = Mage_Sales_Model_Order::STATE_CANCELED;
|
91 |
+
break;
|
92 |
+
default:
|
93 |
+
$state = null;
|
94 |
+
break;
|
95 |
+
}
|
96 |
+
|
97 |
+
if(!is_null($state)){
|
98 |
+
$stateObject->setState($state);
|
99 |
+
$stateObject->setStatus($state);
|
100 |
+
$stateObject->setIsNotified($setIsNotified);
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
Mage::getSingleton('core/session')->setTransactionIdBcash($response->transactionId);
|
105 |
+
Mage::getSingleton('core/session')->setStatusBcash($response->status);
|
106 |
+
Mage::getSingleton('core/session')->setDescriptionStatusBcash(urldecode($response->descriptionStatus));
|
107 |
+
Mage::getSingleton('core/session')->setPaymentLinkBcash(isset($response->paymentLink) ? urldecode($response->paymentLink) : null);
|
108 |
+
Mage::getSingleton('core/session')->setPaymentMethodBcash($payment_method);
|
109 |
+
Mage::getSingleton('core/session')->setInstallmentsBcash($installments);
|
110 |
+
|
111 |
+
$cart = Mage::getSingleton('checkout/cart')->getQuote();
|
112 |
+
$cart->setTransactionIdBcash($response->transactionId)
|
113 |
+
->setStatusBcash($response->status)
|
114 |
+
->setDescriptionStatusBcash(urldecode($response->descriptionStatus))
|
115 |
+
->setPaymentLinkBcash(isset($response->paymentLink) ? urldecode($response->paymentLink) : null)
|
116 |
+
->setPaymentMethodBcash($payment_method)
|
117 |
+
->setInstallmentsBcash($installments);
|
118 |
+
$cart->save();
|
119 |
+
|
120 |
+
} catch (Exception $e) {
|
121 |
+
Mage::log($e->getMessage());
|
122 |
+
throw new Mage_Payment_Model_Info_Exception($e->getMessage());
|
123 |
+
}
|
124 |
+
|
125 |
+
return $this;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Inicializa a transação atual via SDK Api Bcash.
|
130 |
+
* Respond with token
|
131 |
+
* @throws SoapFault
|
132 |
+
* @throws Mage_Exception
|
133 |
+
* @throws Exception
|
134 |
+
*/
|
135 |
+
protected function _customBeginPayment()
|
136 |
+
{
|
137 |
+
$this->transaction = new Bcash_Pagamento_Helper_Transaction();
|
138 |
+
return $this->transaction->startTransaction();
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Assign data to info model instance
|
143 |
+
* @param mixed $data
|
144 |
+
* @return Mage_Payment_Model_Info
|
145 |
+
*/
|
146 |
+
public function assignData($data)
|
147 |
+
{
|
148 |
+
Mage::log('Assign Data with Bcash');
|
149 |
+
$result = parent::assignData($data);
|
150 |
+
$params = Mage::app()->getFrontController()->getRequest()->getParams();
|
151 |
+
$params['installments_bcash'] = isset($params['installments_bcash']) ?$params['installments_bcash']:1;
|
152 |
+
|
153 |
+
//Adiciona Desconto ao Pedido caso 1x Credito, Boleto ou TEF (configurados no Backend)
|
154 |
+
$discount = 0;
|
155 |
+
if ($params['installments_bcash'] == 1) {
|
156 |
+
$discount = $this->calculateDiscount($params['payment-method']);
|
157 |
+
}
|
158 |
+
$this->addDiscountToQuote($discount);
|
159 |
+
return $result;
|
160 |
+
}
|
161 |
+
|
162 |
+
public function calculateDiscount($payment_method)
|
163 |
+
{
|
164 |
+
$transaction = new Bcash_Pagamento_Helper_Transaction();
|
165 |
+
return $transaction->calculateDiscount($payment_method);
|
166 |
+
}
|
167 |
+
|
168 |
+
public function addDiscountToQuote($discountAmount = 0)
|
169 |
+
{
|
170 |
+
$cart = Mage::getSingleton('checkout/cart');
|
171 |
+
$objShippingAddress = $cart->getQuote()->getShippingAddress();
|
172 |
+
$objShippingAddress->setDiscountDescription('Meio de pagamento selecionado');
|
173 |
+
$objShippingAddress->addTotal(array(
|
174 |
+
'code' => 'discount',
|
175 |
+
'title' => "Desconto",
|
176 |
+
'value' => -$discountAmount,
|
177 |
+
));
|
178 |
+
$totalDiscountAmount = $discountAmount;
|
179 |
+
$subtotalWithDiscount = $discountAmount;
|
180 |
+
$baseTotalDiscountAmount = $discountAmount;
|
181 |
+
$baseSubtotalWithDiscount = $discountAmount;
|
182 |
+
$objShippingAddress->setDiscountAmount($totalDiscountAmount);
|
183 |
+
$objShippingAddress->setSubtotalWithDiscount($subtotalWithDiscount);
|
184 |
+
$objShippingAddress->setBaseDiscountAmount($baseTotalDiscountAmount);
|
185 |
+
$objShippingAddress->setBaseSubtotalWithDiscount($baseSubtotalWithDiscount);
|
186 |
+
$objShippingAddress->setGrandTotal($objShippingAddress->getGrandTotal() - $objShippingAddress->getDiscountAmount());
|
187 |
+
$objShippingAddress->setBaseGrandTotal($objShippingAddress->getBaseGrandTotal() - $objShippingAddress->getBaseDiscountAmount());
|
188 |
+
}
|
189 |
+
}
|
app/code/community/Bcash/Pagamento/Model/System/Config/Source/Installments.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bcash_Pagamento_Model_System_Config_Source_Installments
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Options getter
|
7 |
+
*
|
8 |
+
* @return array
|
9 |
+
*/
|
10 |
+
public function toOptionArray()
|
11 |
+
{
|
12 |
+
return array(
|
13 |
+
array('value' => 1, 'label' => Mage::helper('adminhtml')->__('1 parcela')),
|
14 |
+
array('value' => 2, 'label' => Mage::helper('adminhtml')->__('2 parcelas')),
|
15 |
+
array('value' => 3, 'label' => Mage::helper('adminhtml')->__('3 parcelas')),
|
16 |
+
array('value' => 4, 'label' => Mage::helper('adminhtml')->__('4 parcelas')),
|
17 |
+
array('value' => 5, 'label' => Mage::helper('adminhtml')->__('5 parcelas')),
|
18 |
+
array('value' => 6, 'label' => Mage::helper('adminhtml')->__('6 parcelas')),
|
19 |
+
array('value' => 7, 'label' => Mage::helper('adminhtml')->__('7 parcelas')),
|
20 |
+
array('value' => 8, 'label' => Mage::helper('adminhtml')->__('8 parcelas')),
|
21 |
+
array('value' => 9, 'label' => Mage::helper('adminhtml')->__('9 parcelas')),
|
22 |
+
array('value' => 10, 'label' => Mage::helper('adminhtml')->__('10 parcelas')),
|
23 |
+
array('value' => 11, 'label' => Mage::helper('adminhtml')->__('11 parcelas')),
|
24 |
+
array('value' => 12, 'label' => Mage::helper('adminhtml')->__('12 parcelas')),
|
25 |
+
array('value' => 13, 'label' => Mage::helper('adminhtml')->__('13 parcelas')),
|
26 |
+
array('value' => 14, 'label' => Mage::helper('adminhtml')->__('14 parcelas')),
|
27 |
+
array('value' => 15, 'label' => Mage::helper('adminhtml')->__('15 parcelas')),
|
28 |
+
array('value' => 16, 'label' => Mage::helper('adminhtml')->__('16 parcelas')),
|
29 |
+
array('value' => 17, 'label' => Mage::helper('adminhtml')->__('17 parcelas')),
|
30 |
+
array('value' => 18, 'label' => Mage::helper('adminhtml')->__('18 parcelas')),
|
31 |
+
array('value' => 19, 'label' => Mage::helper('adminhtml')->__('19 parcelas')),
|
32 |
+
array('value' => 20, 'label' => Mage::helper('adminhtml')->__('20 parcelas')),
|
33 |
+
array('value' => 21, 'label' => Mage::helper('adminhtml')->__('21 parcelas')),
|
34 |
+
array('value' => 22, 'label' => Mage::helper('adminhtml')->__('22 parcelas')),
|
35 |
+
array('value' => 23, 'label' => Mage::helper('adminhtml')->__('23 parcelas')),
|
36 |
+
array('value' => 24, 'label' => Mage::helper('adminhtml')->__('24 parcelas')),
|
37 |
+
);
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Get options in "key-value" format
|
42 |
+
*
|
43 |
+
* @return array
|
44 |
+
*/
|
45 |
+
public function toArray()
|
46 |
+
{
|
47 |
+
return array(
|
48 |
+
1 => Mage::helper('adminhtml')->__('1 parcela'),
|
49 |
+
2 => Mage::helper('adminhtml')->__('2 parcelas'),
|
50 |
+
3 => Mage::helper('adminhtml')->__('3 parcelas'),
|
51 |
+
4 => Mage::helper('adminhtml')->__('4 parcelas'),
|
52 |
+
5 => Mage::helper('adminhtml')->__('5 parcelas'),
|
53 |
+
6 => Mage::helper('adminhtml')->__('6 parcelas'),
|
54 |
+
7 => Mage::helper('adminhtml')->__('7 parcelas'),
|
55 |
+
8 => Mage::helper('adminhtml')->__('8 parcelas'),
|
56 |
+
9 => Mage::helper('adminhtml')->__('9 parcelas'),
|
57 |
+
10 => Mage::helper('adminhtml')->__('10 parcelas'),
|
58 |
+
11 => Mage::helper('adminhtml')->__('11 parcelas'),
|
59 |
+
12 => Mage::helper('adminhtml')->__('12 parcelas'),
|
60 |
+
13 => Mage::helper('adminhtml')->__('13 parcelas'),
|
61 |
+
14 => Mage::helper('adminhtml')->__('14 parcelas'),
|
62 |
+
15 => Mage::helper('adminhtml')->__('15 parcelas'),
|
63 |
+
16 => Mage::helper('adminhtml')->__('16 parcelas'),
|
64 |
+
17 => Mage::helper('adminhtml')->__('17 parcelas'),
|
65 |
+
18 => Mage::helper('adminhtml')->__('18 parcelas'),
|
66 |
+
19 => Mage::helper('adminhtml')->__('19 parcelas'),
|
67 |
+
20 => Mage::helper('adminhtml')->__('20 parcelas'),
|
68 |
+
21 => Mage::helper('adminhtml')->__('21 parcelas'),
|
69 |
+
22 => Mage::helper('adminhtml')->__('22 parcelas'),
|
70 |
+
23 => Mage::helper('adminhtml')->__('23 parcelas'),
|
71 |
+
24 => Mage::helper('adminhtml')->__('24 parcelas'),
|
72 |
+
);
|
73 |
+
}
|
74 |
+
}
|
app/code/community/Bcash/Pagamento/controllers/Admin/Sales/OrderController.php
ADDED
@@ -0,0 +1,149 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once(Mage::getBaseDir("lib") . "/BcashApi/autoloader.php");
|
4 |
+
|
5 |
+
use Bcash\Domain\NotificationStatusEnum;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Controller Bcash_Pagamento_Admin_Sales_OrderController
|
9 |
+
*/
|
10 |
+
class Bcash_Pagamento_Admin_Sales_OrderController extends Mage_Adminhtml_Controller_Action
|
11 |
+
{
|
12 |
+
/**
|
13 |
+
* Recebe requisição de cancelamento de um pedido
|
14 |
+
*/
|
15 |
+
public function canceltransactionAction()
|
16 |
+
{
|
17 |
+
$orderId = trim(stripslashes($this->getRequest()->getParam('order_id')));
|
18 |
+
|
19 |
+
if ($orderId) {
|
20 |
+
// Cancelamento da transação do pedido
|
21 |
+
if ($this->cancelBcashTransaction($orderId)) {
|
22 |
+
Mage::getSingleton('adminhtml/session')->addSuccess('Pedido cancelado com sucesso.');
|
23 |
+
} else {
|
24 |
+
Mage::getSingleton('adminhtml/session')->addError('Não foi possível cancelar o pedido.');
|
25 |
+
}
|
26 |
+
|
27 |
+
// Retorna para tela do pedido
|
28 |
+
$this->_redirect('adminhtml/sales_order/view', array('order_id' => $orderId));
|
29 |
+
}
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Recebe requisição de cancelamento de uma lista de pedidos
|
34 |
+
*/
|
35 |
+
public function masscanceltransactionAction()
|
36 |
+
{
|
37 |
+
$ordersIds = $this->getRequest()->getParam('order_ids');
|
38 |
+
|
39 |
+
if (!is_array($ordersIds)) {
|
40 |
+
Mage::getSingleton('adminhtml/session')->addError('Selecione pedidos para cancelamento.');
|
41 |
+
} else {
|
42 |
+
try {
|
43 |
+
// Counters
|
44 |
+
$cancelSuccess = 0;
|
45 |
+
$cancelFail = 0;
|
46 |
+
|
47 |
+
foreach ($ordersIds as $orderId) {
|
48 |
+
// Cancelamento da transação do pedido
|
49 |
+
if ($this->cancelBcashTransaction($orderId)) {
|
50 |
+
$cancelSuccess++;
|
51 |
+
} else {
|
52 |
+
$cancelFail++;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
if ($cancelSuccess > 0) {
|
57 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
58 |
+
Mage::helper('adminhtml')->__(
|
59 |
+
'Total de %d pedido(s) cancelados com sucesso.', $cancelSuccess
|
60 |
+
)
|
61 |
+
);
|
62 |
+
}
|
63 |
+
if ($cancelFail > 0) {
|
64 |
+
Mage::getSingleton('adminhtml/session')->addError(
|
65 |
+
Mage::helper('adminhtml')->__(
|
66 |
+
'Total de %d falha(s) no cancelamento.', $cancelFail
|
67 |
+
)
|
68 |
+
);
|
69 |
+
}
|
70 |
+
} catch (Exception $e) {
|
71 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
// Retorna para listagem de pedidos
|
76 |
+
$this->_redirect('adminhtml/sales_order');
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Método para cancelamento da transação de pagamento do pedido
|
81 |
+
*
|
82 |
+
* @param $orderId
|
83 |
+
* @return bool
|
84 |
+
*/
|
85 |
+
private function cancelBcashTransaction($orderId)
|
86 |
+
{
|
87 |
+
// Carrega pedido a partir de Id de entidade
|
88 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
89 |
+
|
90 |
+
if ($order->getId()) {
|
91 |
+
try {
|
92 |
+
// Consulta transação Bcash
|
93 |
+
$quoteId = $order->getQuoteId();
|
94 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
95 |
+
$orderTransactionBcash = $quote->getTransactionIdBcash();
|
96 |
+
$transactionInfo = Mage::helper('pagamento')->getTransaction($orderTransactionBcash);
|
97 |
+
|
98 |
+
// Checa se o status da transaçao Bcash permite cancelamento
|
99 |
+
if($transactionInfo->transacao->cod_status == NotificationStatusEnum::IN_PROGRESS || $transactionInfo->transacao->cod_status == NotificationStatusEnum::APPROVED) {
|
100 |
+
$pagamentoOrderModel = Mage::getModel('pagamento/order');
|
101 |
+
$responseCancellation = $pagamentoOrderModel->cancellation($orderTransactionBcash);
|
102 |
+
|
103 |
+
if ($responseCancellation != null) {
|
104 |
+
if ($responseCancellation->transactionStatusId == NotificationStatusEnum::CANCELLED) {
|
105 |
+
// Registro do cancelamento no pedido
|
106 |
+
$order->registerCancellation('Cancelamento efetivado no Bcash. ', TRUE)->save();
|
107 |
+
|
108 |
+
// Atualiza status na transação
|
109 |
+
$quote->setStatusBcash($responseCancellation->transactionStatusId)
|
110 |
+
->setDescriptionStatusBcash($responseCancellation->transactionStatusDescription);
|
111 |
+
$quote->save();
|
112 |
+
|
113 |
+
return true;
|
114 |
+
} else if ($responseCancellation->transactionStatusId == NotificationStatusEnum::REFUNDED) {
|
115 |
+
// Registro do estorno do pagamento
|
116 |
+
$payment = $order->getPayment();
|
117 |
+
$payment->setTransactionId($orderTransactionBcash)
|
118 |
+
->setPreparedMessage("Pagamento devolvido.")
|
119 |
+
->setIsTransactionClosed(1);
|
120 |
+
$payment->setRefundTransactionId($orderTransactionBcash);
|
121 |
+
$order->registerCancellation('Pagamento devolvido no Bcash. ', TRUE)->save();
|
122 |
+
|
123 |
+
// Atualiza status na transação
|
124 |
+
$quote->setStatusBcash($responseCancellation->transactionStatusId)
|
125 |
+
->setDescriptionStatusBcash($responseCancellation->transactionStatusDescription);
|
126 |
+
$quote->save();
|
127 |
+
|
128 |
+
return true;
|
129 |
+
} else {
|
130 |
+
// Registro em histórico do pedido: cancelamento não efetivado
|
131 |
+
$order->addStatusHistoryComment('Tentativa de cancelamento não efetivada no Bcash.');
|
132 |
+
$order->save();
|
133 |
+
|
134 |
+
return false;
|
135 |
+
}
|
136 |
+
}
|
137 |
+
}
|
138 |
+
|
139 |
+
} catch (Mage_Core_Exception $e) {
|
140 |
+
$this->_getSession()->addError($e->getMessage());
|
141 |
+
} catch (Exception $e) {
|
142 |
+
$this->_getSession()->addError($this->__('The order has not been cancelled.'));
|
143 |
+
Mage::log("Cancellation error: " . $e->getMessage());
|
144 |
+
}
|
145 |
+
}
|
146 |
+
|
147 |
+
return false;
|
148 |
+
}
|
149 |
+
}
|
app/code/community/Bcash/Pagamento/controllers/NotificationController.php
ADDED
@@ -0,0 +1,223 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once(Mage::getBaseDir("lib") . "/BcashApi/autoloader.php");
|
4 |
+
|
5 |
+
use Bcash\Service\Notification;
|
6 |
+
use Bcash\Domain\NotificationContent;
|
7 |
+
use Bcash\Domain\NotificationStatusEnum;
|
8 |
+
use Bcash\Exception\ValidationException;
|
9 |
+
use Bcash\Exception\ConnectionException;
|
10 |
+
use Bcash\Test\NotificationSimulator;
|
11 |
+
use Bcash\Config\Config;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Controller Bcash_Pagamento_NotificationController
|
15 |
+
*/
|
16 |
+
class Bcash_Pagamento_NotificationController extends Mage_Core_Controller_Front_Action
|
17 |
+
{
|
18 |
+
|
19 |
+
private $email;
|
20 |
+
private $token;
|
21 |
+
private $obj;
|
22 |
+
private $sandbox;
|
23 |
+
|
24 |
+
protected function _construct()
|
25 |
+
{
|
26 |
+
// access log (debug)
|
27 |
+
Mage::log('Notification visitor: ' . Mage::helper('core/http')->getRemoteAddr());
|
28 |
+
|
29 |
+
$this->obj = Mage::getSingleton('Bcash_Pagamento_Model_PaymentMethod');
|
30 |
+
$this->email = $this->obj->getConfigData('email');
|
31 |
+
$this->token = $this->obj->getConfigData('token');
|
32 |
+
$this->sandbox = $this->obj->getConfigData('sandbox');
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Index
|
37 |
+
*/
|
38 |
+
public function indexAction()
|
39 |
+
{
|
40 |
+
if($this->sandbox) {
|
41 |
+
// Get request
|
42 |
+
$transactionId = Mage::app()->getRequest()->getParam('transactionId');
|
43 |
+
$orderId = trim(stripslashes(Mage::app()->getRequest()->getParam('orderId')));
|
44 |
+
$statusId = (int)Mage::app()->getRequest()->getParam('statusId');
|
45 |
+
|
46 |
+
// Notification Simulator
|
47 |
+
$urlSubmit = Mage::getUrl('pagamento/notification/index');
|
48 |
+
echo "<h1>Bcash Notification Simulator</h1>
|
49 |
+
<form method='GET' action='" . $urlSubmit . "'>
|
50 |
+
<label>Nro. Pedido:</label>
|
51 |
+
<input type='text' name='orderId' placeholder='Nro. Pedido' value='" . $orderId . "'/>
|
52 |
+
<label>Nro. Transação:</label>
|
53 |
+
<input type='text' name='transactionId' placeholder='Nro. Transação' value='" . $transactionId . "'/>
|
54 |
+
<label>Status:</label>
|
55 |
+
<select name='statusId'>
|
56 |
+
<option value='1' " . ($statusId == 1 ? "selected" : "") . ">Em andamento</option>
|
57 |
+
<option value='3' " . ($statusId == 3 ? "selected" : "") . ">Aprovada</option>
|
58 |
+
<option value='4' " . ($statusId == 4 ? "selected" : "") . ">Concluída</option>
|
59 |
+
<option value='5' " . ($statusId == 5 ? "selected" : "") . ">Em disputa</option>
|
60 |
+
<option value='6' " . ($statusId == 6 ? "selected" : "") . ">Devolvida</option>
|
61 |
+
<option value='7' " . ($statusId == 7 ? "selected" : "") . ">Cancelada</option>
|
62 |
+
<option value='8' " . ($statusId == 8 ? "selected" : "") . ">Chargeback</option>
|
63 |
+
</select>
|
64 |
+
<input type='submit' value='Enviar'/>
|
65 |
+
</form>";
|
66 |
+
|
67 |
+
if(!empty($transactionId) && !empty($statusId) && !empty($orderId)) {
|
68 |
+
$urlSimulator = Mage::getUrl('pagamento/notification/request');
|
69 |
+
$returnSimulator = $this->notificationSimulator($urlSimulator, $transactionId, $orderId, $statusId);
|
70 |
+
echo "<h2>Retorno:</h2> <div style='clear:both;'></div><pre style='background-color: #EAEAEA; padding:20px;'>";
|
71 |
+
var_dump($returnSimulator);
|
72 |
+
echo "</pre>";
|
73 |
+
}
|
74 |
+
echo "<div style='clear:both;'><div style='float: right;margin-top: 20px; font-size: 12px;'>hostSandBox: " . Config::hostSandBox . "</div>";
|
75 |
+
}else {
|
76 |
+
echo "Habilite o Sandbox para simular notificações pelo Bcash.";
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Recebimento de notificações pela API
|
82 |
+
*/
|
83 |
+
public function requestAction()
|
84 |
+
{
|
85 |
+
// GET THIS URL -> Mage::getUrl('pagamento/notification/request')
|
86 |
+
|
87 |
+
// POST request
|
88 |
+
$transactionId = Mage::app()->getRequest()->getParam('transacao_id');
|
89 |
+
$orderId = trim(stripslashes(Mage::app()->getRequest()->getParam('pedido')));
|
90 |
+
$statusId = (int)Mage::app()->getRequest()->getParam('status_id');
|
91 |
+
$status = Mage::app()->getRequest()->getParam('status');
|
92 |
+
|
93 |
+
// Instância de classe de notificação
|
94 |
+
$notificationContent = new NotificationContent($transactionId, $orderId, $statusId);
|
95 |
+
$notification = new Notification($this->email, $this->token, $notificationContent);
|
96 |
+
$notification->enableSandBox($this->sandbox);
|
97 |
+
|
98 |
+
try {
|
99 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
100 |
+
if ($order->getData() != null) {
|
101 |
+
// Checa requisição válida através de valor total do pedido (valor dos produtos + frete + acréscimo - desconto)
|
102 |
+
$transactionValue = $order->getBaseGrandTotal();
|
103 |
+
$validNotification = $notification->verify($transactionValue);
|
104 |
+
|
105 |
+
if ($validNotification == true) {
|
106 |
+
// Registro de notificação recebida
|
107 |
+
$order->addStatusHistoryComment('Notificação da transação de pagamento recebida. Status: ' . $status);
|
108 |
+
$order->save();
|
109 |
+
|
110 |
+
// Processamento da notificação no pedido
|
111 |
+
$this->processNotification($transactionId, $orderId, $statusId);
|
112 |
+
}else {
|
113 |
+
Mage::log("Invalid bcash notification: Transaction: " . $transactionId . " - Status: " . $statusId);
|
114 |
+
}
|
115 |
+
} else {
|
116 |
+
Mage::log("Pedido " . $orderId . " não identificado. ");
|
117 |
+
}
|
118 |
+
} catch (ValidationException $e) {
|
119 |
+
Mage::log("Validation error: " . $e->getMessage());
|
120 |
+
Mage::log($e->getErrors());
|
121 |
+
|
122 |
+
} catch (ConnectionException $e) {
|
123 |
+
Mage::log("Connection error: " . $e->getMessage());
|
124 |
+
Mage::log($e->getErrors());
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Atualização de status do pedido conforme retorno da notificação
|
130 |
+
*
|
131 |
+
* @param $transactionId
|
132 |
+
* @param $orderId
|
133 |
+
* @param $statusId
|
134 |
+
* @throws Exception
|
135 |
+
*/
|
136 |
+
private function processNotification($transactionId, $orderId, $statusId)
|
137 |
+
{
|
138 |
+
// Carrega pedido a partir de código incremental
|
139 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
140 |
+
switch ($statusId) {
|
141 |
+
case NotificationStatusEnum::APPROVED:
|
142 |
+
case NotificationStatusEnum::COMPLETED:
|
143 |
+
$BaseGrandtotal = $order->getBaseGrandTotal();
|
144 |
+
$payment = $order->getPayment();
|
145 |
+
$payment->setTransactionId($transactionId)
|
146 |
+
->setCurrencyCode($order->getBaseCurrencyCode())
|
147 |
+
->setPreparedMessage("Pagamento aprovado.")
|
148 |
+
->setIsTransactionClosed(1)
|
149 |
+
->registerCaptureNotification($BaseGrandtotal);
|
150 |
+
$order->save();
|
151 |
+
|
152 |
+
// Atualiza status na transação
|
153 |
+
$quoteId = $order->getQuoteId();
|
154 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
155 |
+
$quote->setStatusBcash($statusId)
|
156 |
+
->setDescriptionStatusBcash("Aprovada");
|
157 |
+
$quote->save();
|
158 |
+
break;
|
159 |
+
case NotificationStatusEnum::IN_PROGRESS:
|
160 |
+
$payment = $order->getPayment();
|
161 |
+
$payment->setTransactionId($transactionId);
|
162 |
+
$payment->setIsTransactionClosed(0);
|
163 |
+
$payment->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, array('Status'=>'Em andamento'));
|
164 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true)->save();
|
165 |
+
break;
|
166 |
+
case NotificationStatusEnum::CANCELLED:
|
167 |
+
$order->registerCancellation('Pagamento cancelado.', TRUE)->save();
|
168 |
+
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true);
|
169 |
+
$order->save();
|
170 |
+
|
171 |
+
// Atualiza status na transação
|
172 |
+
$quoteId = $order->getQuoteId();
|
173 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
174 |
+
$quote->setStatusBcash($statusId)
|
175 |
+
->setDescriptionStatusBcash("Cancelada");
|
176 |
+
$quote->save();
|
177 |
+
break;
|
178 |
+
case NotificationStatusEnum::IN_DISPUTE:
|
179 |
+
$order->addStatusHistoryComment('A transação ' . $transactionId . ' está com status EM DISPUTA. Entre em contato com o Bcash.');
|
180 |
+
if($order->canHold()) {
|
181 |
+
$order->hold();
|
182 |
+
}else {
|
183 |
+
$order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true);
|
184 |
+
}
|
185 |
+
$order->save();
|
186 |
+
break;
|
187 |
+
case NotificationStatusEnum::CHARGEBACK:
|
188 |
+
$order->addStatusHistoryComment('A transação ' . $transactionId . ' está com status CHARGEBACK EM ANÁLISE. Entre em contato com o Bcash.');
|
189 |
+
if($order->canHold()) {
|
190 |
+
$order->hold();
|
191 |
+
}else {
|
192 |
+
$order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true);
|
193 |
+
}
|
194 |
+
$order->save();
|
195 |
+
break;
|
196 |
+
case NotificationStatusEnum::REFUNDED:
|
197 |
+
$order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true)->save();
|
198 |
+
break;
|
199 |
+
default:
|
200 |
+
$order->addStatusHistoryComment('Notificação da transação ' . $transactionId . ' sem ação identificada para o status ' . $statusId);
|
201 |
+
$order->save();
|
202 |
+
break;
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Simulação de notificação enviada pelo Bcash na URL de retorno
|
208 |
+
*
|
209 |
+
* @param $notificationUrl
|
210 |
+
* @param $transactionId
|
211 |
+
* @param $orderId
|
212 |
+
* @param $statusId
|
213 |
+
*/
|
214 |
+
private function notificationSimulator($notificationUrl, $transactionId, $orderId, $statusId)
|
215 |
+
{
|
216 |
+
try {
|
217 |
+
$result = NotificationSimulator::test($notificationUrl, $transactionId, $orderId, $statusId);
|
218 |
+
return $result;
|
219 |
+
} catch (ConnectionException $e) {
|
220 |
+
return $e->getMessage();
|
221 |
+
}
|
222 |
+
}
|
223 |
+
}
|
app/code/community/Bcash/Pagamento/controllers/PaymentController.php
ADDED
@@ -0,0 +1,127 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class Bcash_Pagamento_PaymentController
|
5 |
+
*/
|
6 |
+
class Bcash_Pagamento_PaymentController extends Mage_Core_Controller_Front_Action
|
7 |
+
{
|
8 |
+
|
9 |
+
/**
|
10 |
+
* Adiciona template.
|
11 |
+
*/
|
12 |
+
public function redirectAction()
|
13 |
+
{
|
14 |
+
$this->loadLayout();
|
15 |
+
$block = $this->getLayout()->createBlock('Mage_Core_Block_Template', 'paymentmethod', array('template' => 'pagamento/redirect.phtml'));
|
16 |
+
$this->getLayout()->getBlock('content')->append($block);
|
17 |
+
$this->renderLayout();
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Seta o redirecionamento da transação.
|
22 |
+
*/
|
23 |
+
public function responseAction()
|
24 |
+
{
|
25 |
+
if ($this->getRequest()->get("flag") == "1" && $this->getRequest()->get("orderId")) {
|
26 |
+
$orderId = $this->getRequest()->get("orderId");
|
27 |
+
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
28 |
+
$order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, true, 'Payment Success.');
|
29 |
+
$order->save();
|
30 |
+
|
31 |
+
Mage::getSingleton('checkout/session')->unsQuoteId();
|
32 |
+
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/success', array('_secure' => false));
|
33 |
+
} else {
|
34 |
+
Mage_Core_Controller_Varien_Action::_redirect('checkout/onepage/error', array('_secure' => false));
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
/**
|
39 |
+
* Salva dados da transação na Sessão.
|
40 |
+
*/
|
41 |
+
public function dadosAction()
|
42 |
+
{
|
43 |
+
$pid = Mage::app()->getRequest()->getPost('pid');
|
44 |
+
$input = Mage::app()->getRequest()->getPost('input');
|
45 |
+
$tipo = Mage::app()->getRequest()->getPost('tipo');
|
46 |
+
if ($input == "cartao") {
|
47 |
+
Mage::getSingleton('core/session')->setCardNumber($pid);
|
48 |
+
Mage::getSingleton('core/session')->setCardType($tipo);
|
49 |
+
Mage::getSingleton('core/session')->setBoleto("");
|
50 |
+
} elseif ($input == "cvv") {
|
51 |
+
Mage::getSingleton('core/session')->setCardCvv($pid);
|
52 |
+
} elseif ($input == "cpf") {
|
53 |
+
Mage::getSingleton('core/session')->setCPF($pid);
|
54 |
+
} elseif ($input == "parcelas") {
|
55 |
+
Mage::getSingleton('core/session')->setParcelas($pid);
|
56 |
+
} elseif ($input == "name") {
|
57 |
+
Mage::getSingleton('core/session')->setName($pid);
|
58 |
+
} elseif ($input == "mes") {
|
59 |
+
Mage::getSingleton('core/session')->setMes($pid);
|
60 |
+
} elseif ($input == "ano") {
|
61 |
+
Mage::getSingleton('core/session')->setAno($pid);
|
62 |
+
} elseif ($input == "ddd") {
|
63 |
+
Mage::getSingleton('core/session')->setDDD($pid);
|
64 |
+
} elseif ($input == "telefone") {
|
65 |
+
Mage::getSingleton('core/session')->setTelefone($pid);
|
66 |
+
} elseif ($input == "boleto") {
|
67 |
+
Mage::getSingleton('core/session')->setBoleto($tipo);
|
68 |
+
Mage::getSingleton('core/session')->setCardNumber("");
|
69 |
+
Mage::getSingleton('core/session')->setCardType("");
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
public function successAction()
|
74 |
+
{
|
75 |
+
|
76 |
+
$order = new Mage_Sales_Model_Order();
|
77 |
+
$lastOrderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
|
78 |
+
$order->loadByIncrementId($lastOrderId);
|
79 |
+
$quoteId = $order->getQuoteId();
|
80 |
+
$quote = Mage::getModel("sales/quote")->load($quoteId);
|
81 |
+
|
82 |
+
try
|
83 |
+
{
|
84 |
+
$order->setTransactionIdBcash($quote->getTransactionIdBcash())
|
85 |
+
->setStatusBcash($quote->getStatusBcash())
|
86 |
+
->setDescriptionStatusBcash($quote->getDescriptionStatusBcash())
|
87 |
+
->setPaymentLinkBcash($quote->getPaymentLinkBcash())
|
88 |
+
->setPaymentMethodBcash($quote->getPaymentMethodBcash())
|
89 |
+
->setInstallmentsBcash($quote->getInstallmentsBcash());
|
90 |
+
$order->save();
|
91 |
+
|
92 |
+
$order->sendNewOrderEmail();
|
93 |
+
}
|
94 |
+
catch (Exception $ex)
|
95 |
+
{
|
96 |
+
|
97 |
+
}
|
98 |
+
|
99 |
+
$type = null;
|
100 |
+
$payment_method_bcash = $order->getPaymentMethodBcash();
|
101 |
+
if($payment_method_bcash) {
|
102 |
+
$helper = new Bcash_Pagamento_Helper_PaymentMethod();
|
103 |
+
$type = $helper->getPaymentMethod($payment_method_bcash);
|
104 |
+
}
|
105 |
+
|
106 |
+
$this->loadLayout();
|
107 |
+
|
108 |
+
$this->getLayout()->getBlock('root')->setTemplate('page/2columns-right.phtml');
|
109 |
+
|
110 |
+
$block = $this->getLayout()->createBlock(
|
111 |
+
'Mage_Core_Block_Template',
|
112 |
+
'link_pagamento_bcash',
|
113 |
+
array('template' => 'pagamento/checkout/success.phtml')
|
114 |
+
);
|
115 |
+
|
116 |
+
$block->setOrder($order);
|
117 |
+
$block->setQuote($quote);
|
118 |
+
$block->setType($type);
|
119 |
+
|
120 |
+
$this->getLayout()->getBlock('content')->append($block);
|
121 |
+
|
122 |
+
$this->_initLayoutMessages('checkout/session');
|
123 |
+
Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId)));
|
124 |
+
|
125 |
+
$this->renderLayout();
|
126 |
+
}
|
127 |
+
}
|
app/code/community/Bcash/Pagamento/etc/config.xml
ADDED
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Bcash_Pagamento>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</Bcash_Pagamento>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<fieldsets>
|
10 |
+
<sales_convert_quote>
|
11 |
+
<transaction_id_bcash>
|
12 |
+
<to_order>*</to_order>
|
13 |
+
</transaction_id_bcash>
|
14 |
+
<status_bcash>
|
15 |
+
<to_order>*</to_order>
|
16 |
+
</status_bcash>
|
17 |
+
<description_status_bcash>
|
18 |
+
<to_order>*</to_order>
|
19 |
+
</description_status_bcash>
|
20 |
+
<payment_link_bcash>
|
21 |
+
<to_order>*</to_order>
|
22 |
+
</payment_link_bcash>
|
23 |
+
<payment_method_bcash>
|
24 |
+
<to_order>*</to_order>
|
25 |
+
</payment_method_bcash>
|
26 |
+
<installments_bcash>
|
27 |
+
<to_order>*</to_order>
|
28 |
+
</installments_bcash>
|
29 |
+
<cpf_cnpj_bcash>
|
30 |
+
<to_order>*</to_order>
|
31 |
+
</cpf_cnpj_bcash>
|
32 |
+
<ddd_bcash>
|
33 |
+
<to_order>*</to_order>
|
34 |
+
</ddd_bcash>
|
35 |
+
<phone_bcash>
|
36 |
+
<to_order>*</to_order>
|
37 |
+
</phone_bcash>
|
38 |
+
</sales_convert_quote>
|
39 |
+
<sales_convert_order>
|
40 |
+
<transaction_id_bcash>
|
41 |
+
<to_quote>*</to_quote>
|
42 |
+
</transaction_id_bcash>
|
43 |
+
<status_bcash>
|
44 |
+
<to_quote>*</to_quote>
|
45 |
+
</status_bcash>
|
46 |
+
<description_status_bcash>
|
47 |
+
<to_quote>*</to_quote>
|
48 |
+
</description_status_bcash>
|
49 |
+
<payment_link_bcash>
|
50 |
+
<to_quote>*</to_quote>
|
51 |
+
</payment_link_bcash>
|
52 |
+
<payment_method_bcash>
|
53 |
+
<to_quote>*</to_quote>
|
54 |
+
</payment_method_bcash>
|
55 |
+
<installments_bcash>
|
56 |
+
<to_quote>*</to_quote>
|
57 |
+
</installments_bcash>
|
58 |
+
<cpf_cnpj_bcash>
|
59 |
+
<to_quote>*</to_quote>
|
60 |
+
</cpf_cnpj_bcash>
|
61 |
+
<ddd_bcash>
|
62 |
+
<to_quote>*</to_quote>
|
63 |
+
</ddd_bcash>
|
64 |
+
<phone_bcash>
|
65 |
+
<to_quote>*</to_quote>
|
66 |
+
</phone_bcash>
|
67 |
+
</sales_convert_order>
|
68 |
+
</fieldsets>
|
69 |
+
<helpers>
|
70 |
+
<pagamento>
|
71 |
+
<class>Bcash_Pagamento_Helper</class>
|
72 |
+
</pagamento>
|
73 |
+
</helpers>
|
74 |
+
<blocks>
|
75 |
+
<pagamento>
|
76 |
+
<class>Bcash_Pagamento_Block</class>
|
77 |
+
</pagamento>
|
78 |
+
<pagamento_adminhtml>
|
79 |
+
<class>Bcash_Pagamento_Block_Adminhtml</class>
|
80 |
+
</pagamento_adminhtml>
|
81 |
+
<adminhtml>
|
82 |
+
<rewrite>
|
83 |
+
<sales_order_view>Bcash_Pagamento_Block_Adminhtml_Sales_Order_View</sales_order_view>
|
84 |
+
<sales_order_grid>Bcash_Pagamento_Block_Adminhtml_Sales_Order_Grid</sales_order_grid>
|
85 |
+
</rewrite>
|
86 |
+
</adminhtml>
|
87 |
+
</blocks>
|
88 |
+
<models>
|
89 |
+
<pagamento>
|
90 |
+
<class>Bcash_Pagamento_Model</class>
|
91 |
+
</pagamento>
|
92 |
+
</models>
|
93 |
+
<resources>
|
94 |
+
<pagamento_setup>
|
95 |
+
<setup>
|
96 |
+
<module>Bcash_Pagamento</module>
|
97 |
+
<class>Mage_Sales_Model_Mysql4_Setup</class>
|
98 |
+
</setup>
|
99 |
+
<connection>
|
100 |
+
<use>core_setup</use>
|
101 |
+
</connection>
|
102 |
+
</pagamento_setup>
|
103 |
+
<pagamento_write>
|
104 |
+
<use>core_write</use>
|
105 |
+
</pagamento_write>
|
106 |
+
<pagamento_read>
|
107 |
+
<use>core_read</use>
|
108 |
+
</pagamento_read>
|
109 |
+
<pagamento_setup>
|
110 |
+
<connection>
|
111 |
+
<use>core_setup</use>
|
112 |
+
</connection>
|
113 |
+
<setup>
|
114 |
+
<module>Bcash_Pagamento</module>
|
115 |
+
<class>Mage_Sales_Model_Mysql4_Setup</class>
|
116 |
+
</setup>
|
117 |
+
</pagamento_setup>
|
118 |
+
</resources>
|
119 |
+
<sales>
|
120 |
+
<order>
|
121 |
+
<states>
|
122 |
+
<pending_payment translate="label">
|
123 |
+
<visible_on_front>1</visible_on_front>
|
124 |
+
</pending_payment>
|
125 |
+
</states>
|
126 |
+
</order>
|
127 |
+
</sales>
|
128 |
+
</global>
|
129 |
+
<admin>
|
130 |
+
<routers>
|
131 |
+
<pagamento>
|
132 |
+
<use>admin</use>
|
133 |
+
<args>
|
134 |
+
<module>Bcash_Pagamento</module>
|
135 |
+
<frontName>pagamento</frontName>
|
136 |
+
</args>
|
137 |
+
</pagamento>
|
138 |
+
</routers>
|
139 |
+
</admin>
|
140 |
+
<adminhtml>
|
141 |
+
<events>
|
142 |
+
<sales_order_save_commit_after>
|
143 |
+
<observers>
|
144 |
+
<sales_order_save_commit_after_handler>
|
145 |
+
<type>model</type>
|
146 |
+
<class>pagamento/observer</class>
|
147 |
+
<method>checkOrderState</method>
|
148 |
+
<args></args>
|
149 |
+
</sales_order_save_commit_after_handler>
|
150 |
+
</observers>
|
151 |
+
</sales_order_save_commit_after>
|
152 |
+
</events>
|
153 |
+
</adminhtml>
|
154 |
+
<frontend>
|
155 |
+
<events>
|
156 |
+
<checkout_onepage_controller_success_action>
|
157 |
+
<observers>
|
158 |
+
<bcash_pagamento_observer_success>
|
159 |
+
<class>Bcash_Pagamento_Model_Observer</class>
|
160 |
+
<method>orderSuccessEvent</method>
|
161 |
+
</bcash_pagamento_observer_success>
|
162 |
+
</observers>
|
163 |
+
</checkout_onepage_controller_success_action>
|
164 |
+
<checkout_type_onepage_save_order_after>
|
165 |
+
<observers>
|
166 |
+
<bcash_pagamento_observer>
|
167 |
+
<class>Bcash_Pagamento_Model_Observer</class>
|
168 |
+
<method>saveOrderQuoteToSession</method>
|
169 |
+
</bcash_pagamento_observer>
|
170 |
+
</observers>
|
171 |
+
</checkout_type_onepage_save_order_after>
|
172 |
+
</events>
|
173 |
+
</frontend>
|
174 |
+
<default>
|
175 |
+
<payment>
|
176 |
+
<pagamento>
|
177 |
+
<title>Bcash</title>
|
178 |
+
<active>1</active>
|
179 |
+
<model>pagamento/paymentMethod</model>
|
180 |
+
<order_status>1</order_status>
|
181 |
+
<payment_action>sale</payment_action>
|
182 |
+
<allowspecific>0</allowspecific>
|
183 |
+
</pagamento>
|
184 |
+
</payment>
|
185 |
+
</default>
|
186 |
+
<frontend>
|
187 |
+
<routers>
|
188 |
+
<pagamento>
|
189 |
+
<use>standard</use>
|
190 |
+
<args>
|
191 |
+
<module>Bcash_Pagamento</module>
|
192 |
+
<frontName>pagamento</frontName>
|
193 |
+
</args>
|
194 |
+
</pagamento>
|
195 |
+
</routers>
|
196 |
+
<layout>
|
197 |
+
<updates>
|
198 |
+
<bcash_pagamento>
|
199 |
+
<file>bcash/pagamento/layout.xml</file>
|
200 |
+
</bcash_pagamento>
|
201 |
+
</updates>
|
202 |
+
</layout>
|
203 |
+
</frontend>
|
204 |
+
</config>
|
app/code/community/Bcash/Pagamento/etc/system.xml
ADDED
@@ -0,0 +1,162 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<payment>
|
5 |
+
<groups>
|
6 |
+
<pagamento translate="label" module="pagamento">
|
7 |
+
<label>Bcash - Pagamento Transparente</label>
|
8 |
+
<sort_order>1</sort_order>
|
9 |
+
<show_in_default>1</show_in_default>
|
10 |
+
<show_in_website>1</show_in_website>
|
11 |
+
<show_in_store>0</show_in_store>
|
12 |
+
|
13 |
+
<fields>
|
14 |
+
<active translate="label">
|
15 |
+
<label>Habilitar módulo</label>
|
16 |
+
<tooltip>Deseja habilitar o módulo?</tooltip>
|
17 |
+
<frontend_type>select</frontend_type>
|
18 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
19 |
+
<sort_order>1</sort_order>
|
20 |
+
<show_in_default>1</show_in_default>
|
21 |
+
<show_in_website>1</show_in_website>
|
22 |
+
<show_in_store>0</show_in_store>
|
23 |
+
</active>
|
24 |
+
|
25 |
+
<sandbox translate="label">
|
26 |
+
<label>Sandbox</label>
|
27 |
+
<tooltip>Deseja utilizar o módulo em ambiente de testes?</tooltip>
|
28 |
+
<frontend_type>select</frontend_type>
|
29 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
30 |
+
<sort_order>2</sort_order>
|
31 |
+
<show_in_default>2</show_in_default>
|
32 |
+
<show_in_website>2</show_in_website>
|
33 |
+
<show_in_store>0</show_in_store>
|
34 |
+
</sandbox>
|
35 |
+
|
36 |
+
<title translate="label">
|
37 |
+
<label>Titulo</label>
|
38 |
+
<tooltip>Informe o nome que deve ser apresentado para este meio de pagamento no checkout de sua loja.</tooltip>
|
39 |
+
<frontend_type>text</frontend_type>
|
40 |
+
<sort_order>3</sort_order>
|
41 |
+
<show_in_default>1</show_in_default>
|
42 |
+
<show_in_website>1</show_in_website>
|
43 |
+
<show_in_store>0</show_in_store>
|
44 |
+
</title>
|
45 |
+
|
46 |
+
<email translate="label">
|
47 |
+
<label>Email cadastrado no Bcash</label>
|
48 |
+
<comment>Clique <a href="https://www.bcash.com.br/criar-conta-comprador/" target="_blank">aqui</a> e cadastre-se.</comment>
|
49 |
+
<frontend_type>text</frontend_type>
|
50 |
+
<validate>validate-email</validate>
|
51 |
+
<sort_order>4</sort_order>
|
52 |
+
<show_in_default>1</show_in_default>
|
53 |
+
<show_in_website>1</show_in_website>
|
54 |
+
<show_in_store>0</show_in_store>
|
55 |
+
</email>
|
56 |
+
|
57 |
+
<token translate="label">
|
58 |
+
<label>Token</label>
|
59 |
+
<tooltip>Acesse a area de Gerenciamento de APIs no menu ferramentas do Bcash</tooltip>
|
60 |
+
<frontend_type>text</frontend_type>
|
61 |
+
<sort_order>5</sort_order>
|
62 |
+
<show_in_default>1</show_in_default>
|
63 |
+
<show_in_website>1</show_in_website>
|
64 |
+
<show_in_store>0</show_in_store>
|
65 |
+
</token>
|
66 |
+
|
67 |
+
<consumer_key translate="label">
|
68 |
+
<label>Consumer Key</label>
|
69 |
+
<tooltip>Solicite no atendimento do Bcash sua chave OAuth</tooltip>
|
70 |
+
<frontend_type>text</frontend_type>
|
71 |
+
<sort_order>5</sort_order>
|
72 |
+
<show_in_default>1</show_in_default>
|
73 |
+
<show_in_website>1</show_in_website>
|
74 |
+
<show_in_store>0</show_in_store>
|
75 |
+
</consumer_key>
|
76 |
+
|
77 |
+
<transacao_dependente>
|
78 |
+
<label>Transação dependente</label>
|
79 |
+
<tooltip>Adicione a comissão por transação dependente via Bcash, são válidos até 6 emails.</tooltip>
|
80 |
+
<frontend_model>pagamento/adminhtml_dependentes</frontend_model>
|
81 |
+
<backend_model>adminhtml/system_config_backend_serialized</backend_model>
|
82 |
+
<comment><![CDATA[Acesse seu painel no bcash.com.br e vá até "Ferramentas > Transação Dependente", o limite definido aqui não deve ultrapassar o valor definido no painel.]]></comment>
|
83 |
+
<sort_order>6</sort_order>
|
84 |
+
<show_in_default>1</show_in_default>
|
85 |
+
<show_in_website>0</show_in_website>
|
86 |
+
<show_in_store>0</show_in_store>
|
87 |
+
<can_be_empty>0</can_be_empty>
|
88 |
+
</transacao_dependente>
|
89 |
+
|
90 |
+
<desconto_boleto translate="label">
|
91 |
+
<label>Percentual Desconto Boleto</label>
|
92 |
+
<tooltip>Percentual de desconto em pagamentos via Boleto.</tooltip>
|
93 |
+
<frontend_type>text</frontend_type>
|
94 |
+
<sort_order>7</sort_order>
|
95 |
+
<validate>validate-number validate-number-range number-range-0-100</validate>
|
96 |
+
<show_in_default>1</show_in_default>
|
97 |
+
<show_in_website>1</show_in_website>
|
98 |
+
<show_in_store>0</show_in_store>
|
99 |
+
</desconto_boleto>
|
100 |
+
|
101 |
+
<desconto_tef translate="label">
|
102 |
+
<label>Percentual Desconto TEF</label>
|
103 |
+
<tooltip>Percentual de desconto em pagamentos via TEF.</tooltip>
|
104 |
+
<frontend_type>text</frontend_type>
|
105 |
+
<validate>validate-number validate-number-range number-range-0-100</validate>
|
106 |
+
<sort_order>8</sort_order>
|
107 |
+
<show_in_default>1</show_in_default>
|
108 |
+
<show_in_website>1</show_in_website>
|
109 |
+
<show_in_store>0</show_in_store>
|
110 |
+
</desconto_tef>
|
111 |
+
|
112 |
+
<desconto_credito_1x translate="label">
|
113 |
+
<label>Percentual Desconto Cartão de Crédito 1x</label>
|
114 |
+
<tooltip>Percentual de desconto em pagamentos via Cartão de crédito à vista.</tooltip>
|
115 |
+
<frontend_type>text</frontend_type>
|
116 |
+
<validate>validate-number validate-number-range number-range-0-100</validate>
|
117 |
+
<sort_order>9</sort_order>
|
118 |
+
<show_in_default>1</show_in_default>
|
119 |
+
<show_in_website>1</show_in_website>
|
120 |
+
<show_in_store>0</show_in_store>
|
121 |
+
</desconto_credito_1x>
|
122 |
+
|
123 |
+
<max_installments translate="label">
|
124 |
+
<label>Quantidade Máxima de Parcelas</label>
|
125 |
+
<tooltip>Define o limite do número de parcelas</tooltip>
|
126 |
+
<frontend_type>select</frontend_type>
|
127 |
+
<source_model>pagamento/system_config_source_installments</source_model>
|
128 |
+
<sort_order>10</sort_order>
|
129 |
+
<show_in_default>2</show_in_default>
|
130 |
+
<show_in_website>2</show_in_website>
|
131 |
+
<show_in_store>0</show_in_store>
|
132 |
+
</max_installments>
|
133 |
+
|
134 |
+
<cpf translate="label">
|
135 |
+
<label>Habilitar CPF</label>
|
136 |
+
<tooltip>Deseja exibir o campo CPF junto ao método de pagamento?</tooltip>
|
137 |
+
<frontend_type>select</frontend_type>
|
138 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
139 |
+
<sort_order>11</sort_order>
|
140 |
+
<show_in_default>1</show_in_default>
|
141 |
+
<show_in_website>1</show_in_website>
|
142 |
+
<show_in_store>0</show_in_store>
|
143 |
+
</cpf>
|
144 |
+
|
145 |
+
<phone translate="label">
|
146 |
+
<label>Habilitar Telefone</label>
|
147 |
+
<tooltip>Deseja exibir o campo Telefone junto ao método de pagamento?</tooltip>
|
148 |
+
<frontend_type>select</frontend_type>
|
149 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
150 |
+
<sort_order>12</sort_order>
|
151 |
+
<show_in_default>1</show_in_default>
|
152 |
+
<show_in_website>1</show_in_website>
|
153 |
+
<show_in_store>0</show_in_store>
|
154 |
+
</phone>
|
155 |
+
|
156 |
+
</fields>
|
157 |
+
|
158 |
+
</pagamento>
|
159 |
+
</groups>
|
160 |
+
</payment>
|
161 |
+
</sections>
|
162 |
+
</config>
|
app/code/community/Bcash/Pagamento/sql/pagamento_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
try {
|
4 |
+
|
5 |
+
$installer = $this;
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
$installer->addAttribute(
|
9 |
+
'quote', /* order, quote, order_item, quote_item */
|
10 |
+
'transaction_id_bcash',
|
11 |
+
array(
|
12 |
+
'type' => 'varchar', /* int, varchar, text, decimal, datetime */
|
13 |
+
'nullable' => true, /* default true */
|
14 |
+
'grid' => true, /* or true if you wan't use this attribute on orders grid page */
|
15 |
+
)
|
16 |
+
);
|
17 |
+
|
18 |
+
$installer->addAttribute(
|
19 |
+
'quote', /* order, quote, order_item, quote_item */
|
20 |
+
'status_bcash',
|
21 |
+
array(
|
22 |
+
'type' => 'varchar', /* int, varchar, text, decimal, datetime */
|
23 |
+
'nullable' => true, /* default true */
|
24 |
+
'grid' => false, /* or true if you wan't use this attribute on orders grid page */
|
25 |
+
)
|
26 |
+
);
|
27 |
+
|
28 |
+
$installer->addAttribute(
|
29 |
+
'quote', /* order, quote, order_item, quote_item */
|
30 |
+
'description_status_bcash',
|
31 |
+
array(
|
32 |
+
'type' => 'varchar', /* int, varchar, text, decimal, datetime */
|
33 |
+
'nullable' => true, /* default true */
|
34 |
+
'grid' => false, /* or true if you wan't use this attribute on orders grid page */
|
35 |
+
)
|
36 |
+
);
|
37 |
+
|
38 |
+
$installer->addAttribute(
|
39 |
+
'quote', /* order, quote, order_item, quote_item */
|
40 |
+
'payment_link_bcash',
|
41 |
+
array(
|
42 |
+
'type' => 'varchar', /* int, varchar, text, decimal, datetime */
|
43 |
+
'nullable' => true, /* default true */
|
44 |
+
'grid' => true, /* or true if you wan't use this attribute on orders grid page */
|
45 |
+
)
|
46 |
+
);
|
47 |
+
|
48 |
+
$installer->addAttribute(
|
49 |
+
'quote', /* order, quote, order_item, quote_item */
|
50 |
+
'installments_bcash',
|
51 |
+
array(
|
52 |
+
'type' => 'varchar', /* int, varchar, text, decimal, datetime */
|
53 |
+
'nullable' => true, /* default true */
|
54 |
+
'grid' => true, /* or true if you wan't use this attribute on orders grid page */
|
55 |
+
)
|
56 |
+
);
|
57 |
+
|
58 |
+
$installer->addAttribute(
|
59 |
+
'quote', /* order, quote, order_item, quote_item */
|
60 |
+
'payment_method_bcash',
|
61 |
+
array(
|
62 |
+
'type' => 'varchar', /* int, varchar, text, decimal, datetime */
|
63 |
+
'nullable' => true, /* default true */
|
64 |
+
'grid' => true, /* or true if you wan't use this attribute on orders grid page */
|
65 |
+
)
|
66 |
+
);
|
67 |
+
|
68 |
+
$installer->addAttribute(
|
69 |
+
'order', /* order, quote, order_item, quote_item */
|
70 |
+
'transaction_id_bcash',
|
71 |
+
array(
|
72 |
+
'type' => 'varchar', /* int, varchar, text, decimal, datetime */
|
73 |
+
'nullable' => true, /* default true */
|
74 |
+
'grid' => true, /* or true if you wan't use this attribute on orders grid page */
|
75 |
+
)
|
76 |
+
);
|
77 |
+
|
78 |
+
$installer->addAttribute(
|
79 |
+
'order', /* order, quote, order_item, quote_item */
|
80 |
+
'status_bcash',
|
81 |
+
array(
|
82 |
+
'type' => 'varchar', /* int, varchar, text, decimal, datetime */
|
83 |
+
'nullable' => true, /* default true */
|
84 |
+
'grid' => false, /* or true if you wan't use this attribute on orders grid page */
|
85 |
+
)
|
86 |
+
);
|
87 |
+
|
88 |
+
$installer->addAttribute(
|
89 |
+
'order', /* order, quote, order_item, quote_item */
|
90 |
+
'description_status_bcash',
|
91 |
+
array(
|
92 |
+
'type' => 'varchar', /* int, varchar, text, decimal, datetime */
|
93 |
+
'nullable' => true, /* default true */
|
94 |
+
'grid' => false, /* or true if you wan't use this attribute on orders grid page */
|
95 |
+
)
|
96 |
+
);
|
97 |
+
|
98 |
+
$installer->addAttribute(
|
99 |
+
'order', /* order, quote, order_item, quote_item */
|
100 |
+
'payment_link_bcash',
|
101 |
+
array(
|
102 |
+
'type' => 'varchar', /* int, varchar, text, decimal, datetime */
|
103 |
+
'nullable' => true, /* default true */
|
104 |
+
'grid' => true, /* or true if you wan't use this attribute on orders grid page */
|
105 |
+
)
|
106 |
+
);
|
107 |
+
|
108 |
+
$installer->addAttribute(
|
109 |
+
'order', /* order, quote, order_item, quote_item */
|
110 |
+
'installments_bcash',
|
111 |
+
array(
|
112 |
+
'type' => 'varchar', /* int, varchar, text, decimal, datetime */
|
113 |
+
'nullable' => true, /* default true */
|
114 |
+
'grid' => true, /* or true if you wan't use this attribute on orders grid page */
|
115 |
+
)
|
116 |
+
);
|
117 |
+
|
118 |
+
$installer->addAttribute(
|
119 |
+
'order', /* order, quote, order_item, quote_item */
|
120 |
+
'payment_method_bcash',
|
121 |
+
array(
|
122 |
+
'type' => 'varchar', /* int, varchar, text, decimal, datetime */
|
123 |
+
'nullable' => true, /* default true */
|
124 |
+
'grid' => true, /* or true if you wan't use this attribute on orders grid page */
|
125 |
+
)
|
126 |
+
);
|
127 |
+
|
128 |
+
$installer->endSetup();
|
129 |
+
|
130 |
+
} catch (Exception $e) {
|
131 |
+
|
132 |
+
Mage::log($e->getMessage());
|
133 |
+
|
134 |
+
}
|
app/design/frontend/base/default/layout/bcash/pagamento/layout.xml
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout>
|
3 |
+
<checkout_onepage_paymentmethod>
|
4 |
+
<reference name="head">
|
5 |
+
<action method="addJs">
|
6 |
+
<script>bcash/pagamento/js/payment.js</script>
|
7 |
+
</action>
|
8 |
+
</reference>
|
9 |
+
</checkout_onepage_paymentmethod>
|
10 |
+
<sales_order_view>
|
11 |
+
<reference name="sales.order.info.buttons">
|
12 |
+
<block type="sales/order_info_buttons" name="customer.order.payment.button" as="customer_order_payment_button" template="pagamento/sales/order/info/buttons/payment.phtml"></block>
|
13 |
+
</reference>
|
14 |
+
<reference name="sales.order.info">
|
15 |
+
<block type="sales/order_info" name="customer.order.payment" as="customer_order_payment" template="pagamento/sales/order/info/info.phtml"></block>
|
16 |
+
</reference>
|
17 |
+
</sales_order_view>
|
18 |
+
</layout>
|
app/design/frontend/base/default/template/pagamento/checkout/success.phtml
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- <h1>Bcash</h1> -->
|
2 |
+
<link rel="stylesheet" href="<?php echo $this->getSkinUrl('bcash/pagamento/css/application.css') ?>" type="text/css"/>
|
3 |
+
<div id="bcash_pagamento" style="float:left; width: 100%; padding: 10px;">
|
4 |
+
<?php
|
5 |
+
//$this->escapeHtml($this->getOrder()->getViewOrderUrl())
|
6 |
+
$url = Mage::getUrl() . 'sales/order/view/order_id/' . $this->getOrder()->getId();
|
7 |
+
$idPedido = $this->getQuote()->getReservedOrderId();
|
8 |
+
$type = $this->getType();
|
9 |
+
if ($type && $type->type == Bcash_Pagamento_Helper_PaymentMethod::CARD_TYPE): ?>
|
10 |
+
<!-- Compra realizada via Cartão de Crédito -->
|
11 |
+
<?php elseif ($type &&$type->type == Bcash_Pagamento_Helper_PaymentMethod::ONLINE_TRANSFER_TYPE): ?>
|
12 |
+
<!-- Compra realizada via Transferência -->
|
13 |
+
Clique no icone ao lado para acessar seu banco para realizar a transferência
|
14 |
+
<a href="<?php echo $this->getQuote()->getPaymentLinkBcash() ?>" >
|
15 |
+
<label class="bandeira band-<?php echo $type->id ?>" for="payment-method-<?php echo $type->id ?>"></label>
|
16 |
+
</a>
|
17 |
+
<?php elseif ($type && $type->type == Bcash_Pagamento_Helper_PaymentMethod::BANKSLIP_TYPE): ?>
|
18 |
+
<!-- Compra realizada via Boleto -->
|
19 |
+
Clique no icone ao lado para gerar o boleto para pagamento
|
20 |
+
<a href="<?php echo $this->getQuote()->getPaymentLinkBcash() ?>" >
|
21 |
+
<label class="bandeira band-<?php echo $type->id ?>" for="payment-method-<?php echo $type->id ?>"></label>
|
22 |
+
</a>
|
23 |
+
<?php endif; ?>
|
24 |
+
</div>
|
app/design/frontend/base/default/template/pagamento/form/payment.phtml
ADDED
@@ -0,0 +1,815 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- <h1>Bcash</h1> -->
|
2 |
+
<link rel="stylesheet" href="<?php echo $this->getSkinUrl('bcash/pagamento/css/application.css') ?>" type="text/css"/>
|
3 |
+
<!-- Script Start -->
|
4 |
+
<!--<script type="text/javascript" src="<?php echo $this->getSkinUrl('bcash/pagamento/js/payment.js'); ?>"></script>//-->
|
5 |
+
<!-- Script End -->
|
6 |
+
<?php
|
7 |
+
$code = $this->getCode();
|
8 |
+
$paymentMethods = $this->getPaymentMethods();
|
9 |
+
$paymentInstallments = $this->getInstallments();
|
10 |
+
$size = count($paymentMethods);
|
11 |
+
$paymentGroupName = array(
|
12 |
+
'CARD' => "Cartão de crédito",
|
13 |
+
'BANKSLIP' => "Boleto Bancário",
|
14 |
+
'ONLINE_TRANSFER' => "Transferência Bancária"
|
15 |
+
);
|
16 |
+
?>
|
17 |
+
<div id="payment-<?php echo $code; ?>">
|
18 |
+
|
19 |
+
<div class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
|
20 |
+
<div class="payment-group" >
|
21 |
+
|
22 |
+
<div class="b-row" style="padding-left:15px; margin-bottom:10px">
|
23 |
+
<?php if($this->getCpf()) : ?>
|
24 |
+
<div class="" style="float:left; width:40%; margin:2px">
|
25 |
+
<label>CPF/CNPJ do titular</label>
|
26 |
+
<input type="text" class="b-form-control validate-cpf-cnpj" id="cpf_cnpj_bcash"
|
27 |
+
name="cpf_cnpj_bcash" value=""
|
28 |
+
maxlength="18" autocomplete="off"/>
|
29 |
+
</div>
|
30 |
+
<?php endif; ?>
|
31 |
+
<?php if($this->getPhone()) : ?>
|
32 |
+
<div class="" style="float:left; width:53%; margin:3px; margin-left:10px">
|
33 |
+
<label>Telefone do titular</label><br />
|
34 |
+
|
35 |
+
<div style="width: 53px; float: left;">
|
36 |
+
<input type="text" class="b-form-control validate-ddd" maxlength="2" value=""
|
37 |
+
name="ddd_bcash"
|
38 |
+
id="ddd_bcash">
|
39 |
+
</div>
|
40 |
+
<div style="width: 123px; float: left; margin-left:3px">
|
41 |
+
<input type="text" class="b-form-control validate-phone" maxlength="9" value=""
|
42 |
+
name="phone_bcash"
|
43 |
+
id="phone_bcash">
|
44 |
+
</div>
|
45 |
+
|
46 |
+
</div>
|
47 |
+
<?php endif; ?>
|
48 |
+
</div>
|
49 |
+
</div>
|
50 |
+
</div>
|
51 |
+
|
52 |
+
<?php foreach ($paymentMethods as $paymentType => $payments): ?>
|
53 |
+
<?php
|
54 |
+
$totalPayments = count($payments);
|
55 |
+
if($totalPayments > 0):
|
56 |
+
?>
|
57 |
+
<div class="payment-group">
|
58 |
+
<div>
|
59 |
+
<h3><?php echo $paymentGroupName[$paymentType] ?></h3>
|
60 |
+
<ul>
|
61 |
+
<?php foreach ($payments as $payment): ?>
|
62 |
+
<li>
|
63 |
+
<input type="radio" class="payment-method-bcash validate-one-required-by-name"
|
64 |
+
id="payment-method-<?php echo $payment->id ?>" name="payment-method"
|
65 |
+
value="<?php echo $payment->id ?>" class/>
|
66 |
+
<label class="bandeira band-<?php echo $payment->id ?>"
|
67 |
+
for="payment-method-<?php echo $payment->id ?>"></label>
|
68 |
+
</li>
|
69 |
+
<?php endforeach; ?>
|
70 |
+
</ul>
|
71 |
+
</div>
|
72 |
+
|
73 |
+
<?php if ($paymentType == 'CARD'): ?>
|
74 |
+
|
75 |
+
<div id="card-conteiner" class="b-form-group b-hide">
|
76 |
+
<div class="b-n-row">
|
77 |
+
<div class="b-form-group b-col-xs-8">
|
78 |
+
<label>Número do cartão</label>
|
79 |
+
<input type="text" class="b-form-control validate-number-card" maxlength="20" value=""
|
80 |
+
id="card_number_bcash"
|
81 |
+
name="card_number_bcash"
|
82 |
+
autocomplete="off" style="width:100%">
|
83 |
+
</div>
|
84 |
+
<div class="b-form-group b-col-xs-4" style="padding:0px">
|
85 |
+
<div>
|
86 |
+
<label>CVV <span class="icon-tooltip" data-tooltip="Código de segurança do cartão de crédito.">?</span></label>
|
87 |
+
<input type="text" class="b-form-control validate-ccv-card" maxlength="3" value=""
|
88 |
+
name="cvv_bcash"
|
89 |
+
id="cvv_bcash">
|
90 |
+
</div>
|
91 |
+
</div>
|
92 |
+
</div>
|
93 |
+
<div class="b-n-row">
|
94 |
+
<div class="b-form-group b-col-xs-5" style="padding-right:0px">
|
95 |
+
<label class="">Validade</label>
|
96 |
+
|
97 |
+
<div class="b-form-group">
|
98 |
+
<div class="b-col-xs-5" style="padding:0px">
|
99 |
+
<select class="b-form-control validate-month-bcash" id="month_bcash"
|
100 |
+
name="month_bcash" style="padding: 2px;">
|
101 |
+
<option value=""></option>
|
102 |
+
<?php
|
103 |
+
for ($i = 1; $i < 13; $i++) :
|
104 |
+
$month = str_pad($i, 2, '0', STR_PAD_LEFT);
|
105 |
+
?>
|
106 |
+
<option value="<?php echo $month ?>"><?php echo $month ?></option>
|
107 |
+
<?php
|
108 |
+
endfor;
|
109 |
+
?>
|
110 |
+
</select>
|
111 |
+
</div>
|
112 |
+
<div class="b-col-xs-7" style="padding:0px; padding-left:4px">
|
113 |
+
<select class="b-form-control validate-year-bcash" id="year_bcash"
|
114 |
+
name="year_bcash" style="padding: 2px;">
|
115 |
+
<option value=""></option>
|
116 |
+
<?php
|
117 |
+
$year = date("Y");
|
118 |
+
$endYear = $year + 10;
|
119 |
+
for ($i = $year; $i < $endYear; $i++) :
|
120 |
+
$month = str_pad($i, 2, '0', STR_PAD_LEFT);
|
121 |
+
?>
|
122 |
+
<option value="<?php echo $month ?>"><?php echo $month ?></option>
|
123 |
+
<?php
|
124 |
+
endfor;
|
125 |
+
?>
|
126 |
+
</select>
|
127 |
+
</div>
|
128 |
+
</div>
|
129 |
+
</div>
|
130 |
+
<div class="b-form-group b-col-xs-7" style="padding-right:0px">
|
131 |
+
<label>Parcelas</label>
|
132 |
+
<select class="b-form-control validate-installments-bcash" name="installments_bcash" id="installments_bcash" style="max-width:100% !important">
|
133 |
+
<option value="" disabled> (Selecione o número de parcelas) </option>
|
134 |
+
<?php
|
135 |
+
$okInstallments = $paymentInstallments['ok'];
|
136 |
+
$installments = $paymentInstallments["installments"];
|
137 |
+
if (!$okInstallments) :
|
138 |
+
foreach ($installments as $times => $value) :
|
139 |
+
?>
|
140 |
+
<option value="<?php echo $times ?>"><?php echo $times ?>x - R$ <?php echo number_format($value,2,',','.')?></option>
|
141 |
+
<?php
|
142 |
+
endforeach;
|
143 |
+
endif;
|
144 |
+
?>
|
145 |
+
</select>
|
146 |
+
</div>
|
147 |
+
</div>
|
148 |
+
|
149 |
+
<div class="b-n-row">
|
150 |
+
<div class="b-form-group" style="padding-left:17px">
|
151 |
+
<label>Nome titular</label>
|
152 |
+
<input type="text" class="b-form-control validate-name-card" value="" name="name_card_bcash"
|
153 |
+
id="name_card_bcash" maxlength="100"
|
154 |
+
autocomplete="off" style="width:100%">
|
155 |
+
</div>
|
156 |
+
</div>
|
157 |
+
|
158 |
+
<div class="b-row">
|
159 |
+
|
160 |
+
</div>
|
161 |
+
|
162 |
+
|
163 |
+
</div> <!-- card-conteiner -->
|
164 |
+
|
165 |
+
<?php endif; ?>
|
166 |
+
|
167 |
+
<?php if ($size > 1): ?>
|
168 |
+
<hr>
|
169 |
+
<?php endif ?>
|
170 |
+
</div>
|
171 |
+
<?php endif; ?>
|
172 |
+
<!-- payment-group -->
|
173 |
+
<?php
|
174 |
+
$size--;
|
175 |
+
endforeach; ?>
|
176 |
+
</div>
|
177 |
+
<!-- div b-col-xs-4 -->
|
178 |
+
<script type="text/javascript">
|
179 |
+
//<![CDATA[
|
180 |
+
var requestUrl = '<?php echo Mage::getUrl('pagamento/payment/dados') ?>';
|
181 |
+
|
182 |
+
function in_array(needle, haystack, argStrict) {
|
183 |
+
var key = '',
|
184 |
+
strict = !!argStrict;
|
185 |
+
if (strict) {
|
186 |
+
for (key in haystack) {
|
187 |
+
if (haystack[key] === needle) {
|
188 |
+
return true;
|
189 |
+
}
|
190 |
+
}
|
191 |
+
} else {
|
192 |
+
for (key in haystack) {
|
193 |
+
if (haystack[key] == needle) {
|
194 |
+
return true;
|
195 |
+
}
|
196 |
+
}
|
197 |
+
}
|
198 |
+
return false;
|
199 |
+
}
|
200 |
+
|
201 |
+
/*Bandeiras*/
|
202 |
+
var visa = 1;
|
203 |
+
var master = 2;
|
204 |
+
var american_express = 37;
|
205 |
+
var aura = 45;
|
206 |
+
var dinners = 55;
|
207 |
+
var hipercard = 56;
|
208 |
+
var elo = 63;
|
209 |
+
var cards = [visa, master, american_express, aura, dinners, hipercard, elo];
|
210 |
+
var boleto = 10;
|
211 |
+
var banco_brasil = 58;
|
212 |
+
var banco_bradesco = 59;
|
213 |
+
var banco_itau = 60;
|
214 |
+
var banco_banrisul = 61;
|
215 |
+
var banco_hsbc = 62;
|
216 |
+
var tefs = [banco_brasil, banco_bradesco, banco_itau, banco_banrisul, banco_hsbc];
|
217 |
+
|
218 |
+
/*
|
219 |
+
* Parcelamentos
|
220 |
+
*/
|
221 |
+
<?php
|
222 |
+
echo "var installments_cc = [{ccId : 0, ccName : '', ccNumber : '', ccDescript : '(Selecione o número de parcelas)'}";
|
223 |
+
$okInstallments = $paymentInstallments['ok'];
|
224 |
+
if($okInstallments):
|
225 |
+
$installments = $paymentInstallments["installments"][0]->paymentTypes;
|
226 |
+
foreach ($installments as $type) :
|
227 |
+
if ($type->name == 'card') :
|
228 |
+
foreach ($type->paymentMethods as $typePayment) :
|
229 |
+
foreach ($typePayment->installments as $paymentInstallment) :
|
230 |
+
echo ",{ccId : " . $typePayment->id . ", ccName : '" . $typePayment->name . "', ccNumber : " . $paymentInstallment->number . ",
|
231 |
+
ccDescript : '" . $paymentInstallment->number . "x - R$ " . number_format($paymentInstallment->installmentAmount,2,',','.') .
|
232 |
+
($paymentInstallment->rate ? ' ('. number_format($paymentInstallment->rate,2,',','.') . '%)' : '') . (isset($paymentInstallment->installmentAmountDesc) ? $paymentInstallment->installmentAmountDesc : '') . "'}";
|
233 |
+
endforeach;
|
234 |
+
endforeach;
|
235 |
+
endif;
|
236 |
+
endforeach;
|
237 |
+
endif;
|
238 |
+
echo "];";
|
239 |
+
?>
|
240 |
+
|
241 |
+
var initBcashPagamento = function () {
|
242 |
+
checkPaymentOnLoad();
|
243 |
+
|
244 |
+
function showInstallmentsOnlyForMethod(method)
|
245 |
+
{
|
246 |
+
if (in_array(method, cards)) {
|
247 |
+
var select_id = 'installments_bcash';
|
248 |
+
var select = document.getElementById(select_id);
|
249 |
+
|
250 |
+
if(installments_cc.length > 1) {
|
251 |
+
// Remove options
|
252 |
+
var i; for(i=select.options.length-1; i>=0; i--) { select.remove(i); }
|
253 |
+
|
254 |
+
// Add options
|
255 |
+
var option = '';
|
256 |
+
for (i=0; i < installments_cc.length; i++) {
|
257 |
+
if(installments_cc[i].ccId == 0) {
|
258 |
+
option = document.createElement("option");
|
259 |
+
option.text = installments_cc[i].ccDescript;
|
260 |
+
option.value = '';
|
261 |
+
option.disabled = 'disabled';
|
262 |
+
select.add(option);
|
263 |
+
option = '';
|
264 |
+
}
|
265 |
+
if(installments_cc[i].ccId == method) {
|
266 |
+
option = document.createElement("option");
|
267 |
+
option.text = installments_cc[i].ccDescript;
|
268 |
+
option.value = installments_cc[i].ccNumber;
|
269 |
+
select.add(option);
|
270 |
+
option = '';
|
271 |
+
}
|
272 |
+
}
|
273 |
+
document.getElementById(select_id).value = "";
|
274 |
+
}
|
275 |
+
}
|
276 |
+
}
|
277 |
+
|
278 |
+
function ableCvv(card) {
|
279 |
+
cvvInput = document.getElementById("cvv_bcash");
|
280 |
+
cvvInput.value = '';
|
281 |
+
// Amex
|
282 |
+
if(card == american_express) {
|
283 |
+
cvvInput.maxLength = 4;
|
284 |
+
}else {
|
285 |
+
cvvInput.maxLength = 3;
|
286 |
+
}
|
287 |
+
|
288 |
+
if(cvvInput.hasClassName("validation-passed")) {
|
289 |
+
cvvInput.removeClassName("validation-passed");
|
290 |
+
}
|
291 |
+
|
292 |
+
// CVV não obrigatório
|
293 |
+
if(card == aura) {
|
294 |
+
if(cvvInput.hasClassName("validate-ccv-card")) {
|
295 |
+
cvvInput.removeClassName("validate-ccv-card");
|
296 |
+
}
|
297 |
+
}else {
|
298 |
+
if(!cvvInput.hasClassName("validate-ccv-card")) {
|
299 |
+
cvvInput.addClassName("validate-ccv-card");
|
300 |
+
}
|
301 |
+
}
|
302 |
+
}
|
303 |
+
|
304 |
+
function forceReloadOrderReviewOsc() {
|
305 |
+
if (typeof(OSCPayment) !== 'undefined') {
|
306 |
+
OSCPayment.forcesavePayment();
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
function checkPaymentOnLoad() {
|
311 |
+
document.body.select('input[type=radio][name="payment[method]"]').each(function (e) {
|
312 |
+
if(e.value == 'pagamento') {
|
313 |
+
e.checked = true;
|
314 |
+
//force order review reload
|
315 |
+
forceReloadOrderReviewOsc();
|
316 |
+
}
|
317 |
+
});
|
318 |
+
}
|
319 |
+
|
320 |
+
function checkIsCardSelected() {
|
321 |
+
var ElementPaymentMethod = [];
|
322 |
+
document.body.select('input[type=radio][name="payment-method"]:checked').each(function (element) {
|
323 |
+
if (element.checked) {
|
324 |
+
ElementPaymentMethod = element;
|
325 |
+
}
|
326 |
+
});
|
327 |
+
var $isCard = isCard(ElementPaymentMethod);
|
328 |
+
return $isCard;
|
329 |
+
}
|
330 |
+
|
331 |
+
Validation.add('validate-cpf-cnpj', 'Documento inválido.', function (v) {
|
332 |
+
return isCpfCnpj(v);
|
333 |
+
});
|
334 |
+
|
335 |
+
Validation.add('validate-ddd', 'Preencha o ddd.', function (v) {
|
336 |
+
return v.length == 2;
|
337 |
+
});
|
338 |
+
|
339 |
+
Validation.add('validate-phone', 'Preencha o telefone.', function (v) {
|
340 |
+
return v.length == 8 || v.length == 9;
|
341 |
+
});
|
342 |
+
|
343 |
+
Validation.add('validate-name-card', 'Preencha o nome do titular.', function (v) {
|
344 |
+
var iscard = checkIsCardSelected();
|
345 |
+
if (iscard) {
|
346 |
+
return v.length > 0;
|
347 |
+
}
|
348 |
+
return true;
|
349 |
+
});
|
350 |
+
|
351 |
+
Validation.add('validate-number-card', 'Preencha o número do cartão corretamente.', function (v) {
|
352 |
+
var iscard = checkIsCardSelected();
|
353 |
+
if (iscard) {
|
354 |
+
if (v.length > 0) {
|
355 |
+
return validateCardNumber();
|
356 |
+
}else {
|
357 |
+
return false;
|
358 |
+
}
|
359 |
+
}
|
360 |
+
return true;
|
361 |
+
});
|
362 |
+
|
363 |
+
Validation.add('validate-ccv-card', 'Preencha o código de segurança.', function (v) {
|
364 |
+
var iscard = checkIsCardSelected();
|
365 |
+
if (iscard) {
|
366 |
+
return v.length > 0;
|
367 |
+
}
|
368 |
+
return true;
|
369 |
+
});
|
370 |
+
|
371 |
+
Validation.add('validate-year-bcash', 'Preencha o ano de validade do cartão.', function (v) {
|
372 |
+
var iscard = checkIsCardSelected();
|
373 |
+
if (iscard) {
|
374 |
+
return v.length > 0;
|
375 |
+
}
|
376 |
+
return true;
|
377 |
+
});
|
378 |
+
|
379 |
+
Validation.add('validate-installments-bcash', 'Selecione o número de parcelas.', function (v) {
|
380 |
+
var iscard = checkIsCardSelected();
|
381 |
+
if (iscard) {
|
382 |
+
return v.length > 0;
|
383 |
+
}
|
384 |
+
return true;
|
385 |
+
});
|
386 |
+
|
387 |
+
Validation.add('validate-month-bcash', 'Preencha o mês de vencimento do cartão.', function (v) {
|
388 |
+
var iscard = checkIsCardSelected();
|
389 |
+
if (iscard) {
|
390 |
+
return v.length > 0;
|
391 |
+
}
|
392 |
+
return true;
|
393 |
+
});
|
394 |
+
|
395 |
+
var cards = ['1', '2', '37', '45', '55', '56', '63'];
|
396 |
+
|
397 |
+
function clickFlag(e) {
|
398 |
+
var elem, evt = e ? e : event;
|
399 |
+
if (evt.srcElement) {
|
400 |
+
elem = evt.srcElement;
|
401 |
+
} else if (evt.target) {
|
402 |
+
elem = evt.target;
|
403 |
+
}
|
404 |
+
|
405 |
+
var paymentMethodBcash = elem.attributes['for'].value;
|
406 |
+
var paymentRadio = document.getElementById(paymentMethodBcash);
|
407 |
+
document.getElementById(paymentMethodBcash).disabled = true;
|
408 |
+
document.getElementById(paymentMethodBcash).checked = true;
|
409 |
+
|
410 |
+
var cardConteiner = document.getElementById('card-conteiner');
|
411 |
+
if (isCard(paymentRadio) && hasClass(cardConteiner, 'b-hide')) {
|
412 |
+
cardConteiner.className = cardConteiner.className.replace(/\bb-hide\b/, '');
|
413 |
+
enableCardForm();
|
414 |
+
|
415 |
+
new Ajax.Request(requestUrl, {
|
416 |
+
method: 'POST',
|
417 |
+
parameters: 'input=cartao&tipo=' + paymentRadio.value
|
418 |
+
});
|
419 |
+
|
420 |
+
} else if (!isCard(paymentRadio) && !hasClass(cardConteiner, 'b-hide')) {
|
421 |
+
cardConteiner.className = cardConteiner.className + " b-hide";
|
422 |
+
disableCardForm();
|
423 |
+
|
424 |
+
new Ajax.Request(requestUrl, {
|
425 |
+
method: 'POST',
|
426 |
+
parameters: 'input=boleto&tipo=' + paymentRadio.value
|
427 |
+
});
|
428 |
+
} else {
|
429 |
+
var option = paymentRadio.value;
|
430 |
+
var typePayment = 'boleto';
|
431 |
+
if (!in_array(option, cards)) {
|
432 |
+
new Ajax.Request(requestUrl, {
|
433 |
+
method: 'POST',
|
434 |
+
parameters: 'input=' + typePayment + '&tipo=' + option
|
435 |
+
});
|
436 |
+
} else {
|
437 |
+
saveCardNumber();
|
438 |
+
}
|
439 |
+
}
|
440 |
+
disableUnunsed(paymentRadio);
|
441 |
+
showInstallmentsOnlyForMethod(paymentRadio.value);
|
442 |
+
ableCvv(paymentRadio.value);
|
443 |
+
checkPaymentOnLoad();
|
444 |
+
}
|
445 |
+
|
446 |
+
function enableCardForm() {
|
447 |
+
var formCardBcash = document.getElementsByClassName("b-form-control");
|
448 |
+
for (i in formCardBcash) {
|
449 |
+
formCardBcash[i].disabled = false;
|
450 |
+
}
|
451 |
+
}
|
452 |
+
|
453 |
+
function disableCardForm() {
|
454 |
+
var formCardBcash = document.getElementsByClassName("b-form-control");
|
455 |
+
for (i in formCardBcash) {
|
456 |
+
formCardBcash[i].disabled = true;
|
457 |
+
}
|
458 |
+
}
|
459 |
+
|
460 |
+
function disableUnunsed(paymentRadio) {
|
461 |
+
var paymentRadios = document.getElementsByClassName("payment-method-bcash");
|
462 |
+
for (var i = paymentRadios.length - 1; i >= 0; i--) {
|
463 |
+
paymentRadios[i].disabled = true;
|
464 |
+
}
|
465 |
+
;
|
466 |
+
paymentRadio.disabled = false;
|
467 |
+
}
|
468 |
+
|
469 |
+
function isCard(element) {
|
470 |
+
//console.log(element);
|
471 |
+
return cards.indexOf(element.value) > -1;
|
472 |
+
}
|
473 |
+
|
474 |
+
function hasClass(element, cls) {
|
475 |
+
return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
|
476 |
+
}
|
477 |
+
|
478 |
+
function mascaraCpfCnpj() {
|
479 |
+
var str = document.getElementById('cpf_cnpj_bcash');
|
480 |
+
var $value = str.value.replace(/\D/g, "");
|
481 |
+
/* Caso passe de 14 caracteres será formatado como CNPJ */
|
482 |
+
if ($value.length < 12)
|
483 |
+
str.value = cpf($value);
|
484 |
+
else if ($value.length >= 12 && $value.length < 15)
|
485 |
+
str.value = cnpj($value);
|
486 |
+
else
|
487 |
+
str.value = cnpj(cut($value));
|
488 |
+
}
|
489 |
+
|
490 |
+
function cut(str) {
|
491 |
+
return str.substring(0, 14);
|
492 |
+
}
|
493 |
+
|
494 |
+
/* Funcao de formatacao CPF */
|
495 |
+
function cpf(valor) {
|
496 |
+
/* Remove qualquer caracter digitado que não seja numero */
|
497 |
+
valor = valor.replace(/\D/g, "");
|
498 |
+
/* Adiciona um ponto entre o terceiro e o quarto digito */
|
499 |
+
valor = valor.replace(/(\d{3})(\d)/, "$1.$2");
|
500 |
+
/* Adiciona um ponto entre o terceiro e o quarto dígitos */
|
501 |
+
/* desta vez para o segundo bloco */
|
502 |
+
valor = valor.replace(/(\d{3})(\d)/, "$1.$2");
|
503 |
+
/* Adiciona um hifen entre o terceiro e o quarto dígitos */
|
504 |
+
valor = valor.replace(/(\d{3})(\d{1,2})$/, "$1-$2");
|
505 |
+
return valor;
|
506 |
+
}
|
507 |
+
|
508 |
+
/* Funcao de formatacao CNPJ */
|
509 |
+
function cnpj(valor) {
|
510 |
+
/* Remove qualquer caracter digitado que não seja numero */
|
511 |
+
valor = valor.replace(/\D/g, "");
|
512 |
+
/* Adiciona um ponto entre o segundo e o terceiro dígitos */
|
513 |
+
valor = valor.replace(/^(\d{2})(\d)/, "$1.$2");
|
514 |
+
/* Adiciona um ponto entre o quinto e o sexto dígitos */
|
515 |
+
valor = valor.replace(/^(\d{2})\.(\d{3})(\d)/, "$1.$2.$3");
|
516 |
+
/* Adiciona uma barra entre o oitavaloro e o nono dígitos */
|
517 |
+
valor = valor.replace(/\.(\d{3})(\d)/, ".$1/$2");
|
518 |
+
/* Adiciona um hífen depois do bloco de quatro dígitos */
|
519 |
+
valor = valor.replace(/(\d{4})(\d)/, "$1-$2");
|
520 |
+
return valor;
|
521 |
+
}
|
522 |
+
|
523 |
+
function onlyNumber(key) {
|
524 |
+
if (key == 8 || key == 46 || key == 37 || key == 39 || key == 9 || key == 35 || key == 36) {
|
525 |
+
return true;
|
526 |
+
}
|
527 |
+
else if ( key < 48 || key > 57 ) {
|
528 |
+
return false;
|
529 |
+
}
|
530 |
+
return true;
|
531 |
+
}
|
532 |
+
|
533 |
+
function unformatNumber(pNum) {
|
534 |
+
return String(pNum).replace(/\D/g, "").replace(/^0+/, "");
|
535 |
+
}
|
536 |
+
|
537 |
+
function isCpf(cpf) {
|
538 |
+
var soma;
|
539 |
+
var resto;
|
540 |
+
var i;
|
541 |
+
if ((cpf.length != 11) ||
|
542 |
+
(cpf == "00000000000") || (cpf == "11111111111") ||
|
543 |
+
(cpf == "22222222222") || (cpf == "33333333333") ||
|
544 |
+
(cpf == "44444444444") || (cpf == "55555555555") ||
|
545 |
+
(cpf == "66666666666") || (cpf == "77777777777") ||
|
546 |
+
(cpf == "88888888888") || (cpf == "99999999999")) {
|
547 |
+
return false;
|
548 |
+
}
|
549 |
+
soma = 0;
|
550 |
+
for (i = 1; i <= 9; i++) {
|
551 |
+
soma += Math.floor(cpf.charAt(i - 1)) * (11 - i);
|
552 |
+
}
|
553 |
+
resto = 11 - (soma - (Math.floor(soma / 11) * 11));
|
554 |
+
if ((resto == 10) || (resto == 11)) {
|
555 |
+
resto = 0;
|
556 |
+
}
|
557 |
+
if (resto != Math.floor(cpf.charAt(9))) {
|
558 |
+
return false;
|
559 |
+
}
|
560 |
+
soma = 0;
|
561 |
+
for (i = 1; i <= 10; i++) {
|
562 |
+
soma += cpf.charAt(i - 1) * (12 - i);
|
563 |
+
}
|
564 |
+
resto = 11 - (soma - (Math.floor(soma / 11) * 11));
|
565 |
+
if ((resto == 10) || (resto == 11)) {
|
566 |
+
resto = 0;
|
567 |
+
}
|
568 |
+
if (resto != Math.floor(cpf.charAt(10))) {
|
569 |
+
return false;
|
570 |
+
}
|
571 |
+
return true;
|
572 |
+
}
|
573 |
+
|
574 |
+
function isCnpj(s) {
|
575 |
+
var i;
|
576 |
+
var c = s.substr(0, 12);
|
577 |
+
var dv = s.substr(12, 2);
|
578 |
+
var d1 = 0;
|
579 |
+
for (i = 0; i < 12; i++) {
|
580 |
+
d1 += c.charAt(11 - i) * (2 + (i % 8));
|
581 |
+
}
|
582 |
+
if (d1 == 0) return false;
|
583 |
+
d1 = 11 - (d1 % 11);
|
584 |
+
if (d1 > 9) d1 = 0;
|
585 |
+
if (dv.charAt(0) != d1) {
|
586 |
+
return false;
|
587 |
+
}
|
588 |
+
d1 *= 2;
|
589 |
+
for (i = 0; i < 12; i++) {
|
590 |
+
d1 += c.charAt(11 - i) * (2 + ((i + 1) % 8));
|
591 |
+
}
|
592 |
+
d1 = 11 - (d1 % 11);
|
593 |
+
if (d1 > 9) d1 = 0;
|
594 |
+
if (dv.charAt(1) != d1) {
|
595 |
+
return false;
|
596 |
+
}
|
597 |
+
return true;
|
598 |
+
}
|
599 |
+
|
600 |
+
function isCpfCnpj(valor) {
|
601 |
+
var retorno = false;
|
602 |
+
var numero = valor;
|
603 |
+
numero = unformatNumber(numero);
|
604 |
+
if (numero.length > 11) {
|
605 |
+
if (isCnpj(numero)) {
|
606 |
+
retorno = true;
|
607 |
+
}
|
608 |
+
} else {
|
609 |
+
if (isCpf(numero)) {
|
610 |
+
retorno = true;
|
611 |
+
}
|
612 |
+
}
|
613 |
+
return retorno;
|
614 |
+
}
|
615 |
+
|
616 |
+
function validateNumber(event) {
|
617 |
+
var key = event.which || event.keyCode || event.charCode;
|
618 |
+
if (!onlyNumber(key)) {
|
619 |
+
return false;
|
620 |
+
}
|
621 |
+
}
|
622 |
+
|
623 |
+
var paymentsOptions = document.getElementsByClassName("bandeira");
|
624 |
+
for (var i = paymentsOptions.length - 1; i >= 0; i--) {
|
625 |
+
var paymentFlags = paymentsOptions[i];
|
626 |
+
paymentFlags.onclick = clickFlag;
|
627 |
+
}
|
628 |
+
<?php if($this->getCpf()) : ?>
|
629 |
+
document.getElementById("cpf_cnpj_bcash").onkeypress = function (event) {
|
630 |
+
var key = event.which || event.keyCode || event.charCode;
|
631 |
+
if (!onlyNumber(key)) {
|
632 |
+
return false;
|
633 |
+
}
|
634 |
+
mascaraCpfCnpj();
|
635 |
+
};
|
636 |
+
|
637 |
+
document.getElementById("cpf_cnpj_bcash").onblur = function (event) {
|
638 |
+
mascaraCpfCnpj();
|
639 |
+
};
|
640 |
+
<?php endif; ?>
|
641 |
+
<?php if($this->getPhone()) : ?>
|
642 |
+
document.getElementById("ddd_bcash").onkeypress = function (event) {
|
643 |
+
return validateNumber(event);
|
644 |
+
};
|
645 |
+
|
646 |
+
document.getElementById("phone_bcash").onkeypress = function (event) {
|
647 |
+
return validateNumber(event);
|
648 |
+
};
|
649 |
+
<?php endif; ?>
|
650 |
+
document.getElementById("card_number_bcash").onkeypress = function (event) {
|
651 |
+
return validateNumber(event);
|
652 |
+
};
|
653 |
+
|
654 |
+
function getCardSelected() {
|
655 |
+
var ElementPaymentMethod = [];
|
656 |
+
document.body.select('input[type=radio][name="payment-method"]:checked').each(function (element) {
|
657 |
+
if (element.checked) {
|
658 |
+
ElementPaymentMethod = element;
|
659 |
+
}
|
660 |
+
});
|
661 |
+
var $isCard = isCard(ElementPaymentMethod);
|
662 |
+
// console.log($isCard);
|
663 |
+
return {'element': ElementPaymentMethod, 'isCard': $isCard};
|
664 |
+
}
|
665 |
+
<?php if($this->getCpf()) : ?>
|
666 |
+
$('cpf_cnpj_bcash').observe('blur', function (e) {
|
667 |
+
var RegExp = /^[0-9]{11,14}$/;
|
668 |
+
var cpf_cnpj_bcash = document.getElementById("cpf_cnpj_bcash");
|
669 |
+
var valor = cpf_cnpj_bcash.value.replace(/\D/g, "");
|
670 |
+
if (RegExp.test(valor) == false && valor.length > 0) {
|
671 |
+
alert('Informe corretamente seu CPF/CNPJ ');
|
672 |
+
cpf_cnpj_bcash.value = '';
|
673 |
+
}
|
674 |
+
else if (valor.length > 0) {
|
675 |
+
var id = document.getElementById("cpf_cnpj_bcash").value;
|
676 |
+
new Ajax.Request(requestUrl, {
|
677 |
+
method: 'POST',
|
678 |
+
parameters: 'pid=' + id + '&input=cpf'
|
679 |
+
});
|
680 |
+
}
|
681 |
+
});
|
682 |
+
<?php endif; ?>
|
683 |
+
function saveCardNumber() {
|
684 |
+
var id = document.getElementById("card_number_bcash").value;
|
685 |
+
var $elem = getCardSelected();
|
686 |
+
var tipo = $elem.element.value;
|
687 |
+
new Ajax.Request(requestUrl, {
|
688 |
+
method: 'POST',
|
689 |
+
parameters: 'pid=' + id + '&input=cartao&tipo=' + tipo
|
690 |
+
});
|
691 |
+
}
|
692 |
+
|
693 |
+
$('card_number_bcash').observe('blur', function (e) {
|
694 |
+
saveCardNumber();
|
695 |
+
});
|
696 |
+
|
697 |
+
$('name_card_bcash').observe('blur', function (e) {
|
698 |
+
var id = document.getElementById("name_card_bcash").value;
|
699 |
+
new Ajax.Request(requestUrl, {
|
700 |
+
method: 'POST',
|
701 |
+
parameters: 'pid=' + id + '&input=name'
|
702 |
+
});
|
703 |
+
});
|
704 |
+
|
705 |
+
$('month_bcash').observe('blur', function (e) {
|
706 |
+
var id = document.getElementById("month_bcash").value;
|
707 |
+
new Ajax.Request(requestUrl, {
|
708 |
+
method: 'POST',
|
709 |
+
parameters: 'pid=' + id + '&input=mes'
|
710 |
+
});
|
711 |
+
});
|
712 |
+
|
713 |
+
$('year_bcash').observe('blur', function (e) {
|
714 |
+
var id = document.getElementById("year_bcash").value;
|
715 |
+
new Ajax.Request(requestUrl, {
|
716 |
+
method: 'POST',
|
717 |
+
parameters: 'pid=' + id + '&input=ano'
|
718 |
+
});
|
719 |
+
});
|
720 |
+
|
721 |
+
$('installments_bcash').observe('blur', function (e) {
|
722 |
+
var id = document.getElementById("installments_bcash").value;
|
723 |
+
new Ajax.Request(requestUrl, {
|
724 |
+
method: 'POST',
|
725 |
+
parameters: 'pid=' + id + '&input=parcelas'
|
726 |
+
});
|
727 |
+
forceReloadOrderReviewOsc();
|
728 |
+
});
|
729 |
+
|
730 |
+
$('cvv_bcash').observe('blur', function (e) {
|
731 |
+
var id = document.getElementById("cvv_bcash").value;
|
732 |
+
new Ajax.Request(requestUrl, {
|
733 |
+
method: 'POST',
|
734 |
+
parameters: 'pid=' + id + '&input=cvv'
|
735 |
+
});
|
736 |
+
});
|
737 |
+
<?php if($this->getPhone()) : ?>
|
738 |
+
$('ddd_bcash').observe('blur', function (e) {
|
739 |
+
var id = document.getElementById("ddd_bcash").value;
|
740 |
+
new Ajax.Request(requestUrl, {
|
741 |
+
method: 'POST',
|
742 |
+
parameters: 'pid=' + id + '&input=ddd'
|
743 |
+
});
|
744 |
+
});
|
745 |
+
|
746 |
+
$('phone_bcash').observe('blur', function (e) {
|
747 |
+
var id = document.getElementById("phone_bcash").value;
|
748 |
+
new Ajax.Request(requestUrl, {
|
749 |
+
method: 'POST',
|
750 |
+
parameters: 'pid=' + id + '&input=telefone'
|
751 |
+
});
|
752 |
+
});
|
753 |
+
<?php endif; ?>
|
754 |
+
|
755 |
+
function validateCardNumber()
|
756 |
+
{
|
757 |
+
var RegExpHipercard = /^(3841\d{10}(\d{3})?)|(3841\d{15})$/;
|
758 |
+
var RegExpElo = /^((((636368)|(438935)|(504175)|(451416)|(636297))\d{0,10})|((5067)|(4576)|(4011))\d{0,12})$/;
|
759 |
+
var RegExpElo2 = /^(636368|438935|504175|451416|636297)([0-9]{10})$/;
|
760 |
+
var RegExpDiners = /^3[0,6,8]\d{12}$/;
|
761 |
+
var RegExpAmex = /^3[47][0-9]{13}$/;
|
762 |
+
var RegExpVisa = /^4[0-9]{12}([0-9]{3})?$/;
|
763 |
+
var RegExpMaster = /^5[1-5][0-9]{14}$/;
|
764 |
+
var RegExpAura = /^(5078\d{2})(\d{2})(\d{11})$/;
|
765 |
+
var RegexFinal = '';
|
766 |
+
var paymentRadio = getCardSelected();
|
767 |
+
if (paymentRadio.isCard) {
|
768 |
+
var cardNumber = document.getElementById("card_number_bcash").value;
|
769 |
+
cardNumber = cardNumber.trim();
|
770 |
+
if(cardNumber.length <= 0) { return false; }
|
771 |
+
var codeCard = paymentRadio.element.value;
|
772 |
+
switch (parseInt(codeCard)) {
|
773 |
+
case visa:
|
774 |
+
RegexFinal = RegExpVisa;
|
775 |
+
break;
|
776 |
+
case master:
|
777 |
+
RegexFinal = RegExpMaster;
|
778 |
+
break;
|
779 |
+
case american_express:
|
780 |
+
RegexFinal = RegExpAmex;
|
781 |
+
break;
|
782 |
+
case elo:
|
783 |
+
if(cardNumber.length <= 16) { return true; }
|
784 |
+
RegexFinal = RegExpElo;
|
785 |
+
break;
|
786 |
+
case hipercard:
|
787 |
+
if(cardNumber.length >= 16 && cardNumber.length <= 19) { return true; }
|
788 |
+
RegexFinal = RegExpHipercard;
|
789 |
+
break;
|
790 |
+
case dinners:
|
791 |
+
if(cardNumber.length >= 14 && cardNumber.length <= 16) { return true; }
|
792 |
+
RegexFinal = RegExpDiners;
|
793 |
+
break;
|
794 |
+
case aura:
|
795 |
+
if(cardNumber.length == 19) { return true; }
|
796 |
+
RegexFinal = RegExpAura;
|
797 |
+
break;
|
798 |
+
}
|
799 |
+
if (RegexFinal == '') {
|
800 |
+
alert('Número do cartão não corresponde a bandeira selecionada ou está incorreto.');
|
801 |
+
cardNumber.value = '';
|
802 |
+
return false;
|
803 |
+
}
|
804 |
+
if (RegexFinal.test(cardNumber) == false) {
|
805 |
+
alert('Número do cartão não corresponde a bandeira selecionada ou está incorreto.');
|
806 |
+
cardNumber.value = '';
|
807 |
+
return false;
|
808 |
+
}
|
809 |
+
return true;
|
810 |
+
}
|
811 |
+
}
|
812 |
+
};
|
813 |
+
initBcashPagamento();
|
814 |
+
//]]>
|
815 |
+
</script>
|
app/design/frontend/base/default/template/pagamento/sales/order/info/buttons/payment.phtml
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
$_order = $this->getOrder();
|
3 |
+
|
4 |
+
$quoteId = $_order->getQuoteId();
|
5 |
+
|
6 |
+
$quote = Mage::getModel('sales/quote')->loadByIdWithoutStore($quoteId);
|
7 |
+
|
8 |
+
$payment_link = $quote->getPaymentLinkBcash();
|
9 |
+
?>
|
10 |
+
|
11 |
+
<?php if( strpos($payment_link, 'Boleto') !== FALSE ): ?>
|
12 |
+
<span class="separator">|</span>
|
13 |
+
<a href="<?php echo $payment_link ?>" class="link-reorder"><?php echo $this->__('2.a Via Boleto') ?></a>
|
14 |
+
<?php elseif( $payment_link && strpos($payment_link, 'Boleto') === FALSE ) : ?>
|
15 |
+
<span class="separator">|</span>
|
16 |
+
<a href="<?php echo $payment_link ?>" class="link-reorder"><?php echo $this->__('Pagar via TEF') ?></a>
|
17 |
+
<?php endif ?>
|
app/etc/modules/Bcash_Pagamento.xml
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Bcash_Pagamento>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>community</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Sales />
|
9 |
+
<Mage_Payment />
|
10 |
+
</depends>
|
11 |
+
</Bcash_Pagamento>
|
12 |
+
</modules>
|
13 |
+
</config>
|
lib/BcashApi/autoloader.php
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require_once __DIR__.'/src/AutoLoader.php';
|
4 |
+
Bcash\AutoLoader::register();
|
lib/BcashApi/src/AutoLoader.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
* This file is part of the Bcash Checkout package.
|
4 |
+
*
|
5 |
+
* (c) Raphael Negrisoli <raphael.batista@bcash.com.br>
|
6 |
+
* (c) Fabio Nowaki <fabio.nowaki@bcash.com.br>
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
namespace Bcash;
|
10 |
+
/**
|
11 |
+
* Implements a lightweight PSR-0 compliant autoloader.
|
12 |
+
*
|
13 |
+
* @author Raphael Negrisoli <raphael.batista@bcash.com.br>
|
14 |
+
* @author Fabio Nowaki <fabio.nowaki@bcash.com.br>
|
15 |
+
*/
|
16 |
+
class AutoLoader
|
17 |
+
{
|
18 |
+
private $directory;
|
19 |
+
private $prefix;
|
20 |
+
private $prefixLength;
|
21 |
+
/**
|
22 |
+
* @param string $baseDirectory Base directory where the source files are located.
|
23 |
+
*/
|
24 |
+
public function __construct($baseDirectory = __DIR__)
|
25 |
+
{
|
26 |
+
$this->directory = $baseDirectory;
|
27 |
+
$this->prefix = __NAMESPACE__ . '\\';
|
28 |
+
$this->prefixLength = strlen($this->prefix);
|
29 |
+
}
|
30 |
+
/**
|
31 |
+
* Registers the autoloader class with the PHP SPL autoloader.
|
32 |
+
*
|
33 |
+
* @param boolean $prepend Prepend the autoloader on the stack instead of appending it.
|
34 |
+
*/
|
35 |
+
public static function register($prepend = false)
|
36 |
+
{
|
37 |
+
spl_autoload_register(array(new self, 'autoload'), true, $prepend);
|
38 |
+
}
|
39 |
+
/**
|
40 |
+
* Loads a class from a file using its fully qualified name.
|
41 |
+
*
|
42 |
+
* @param string $className Fully qualified name of a class.
|
43 |
+
*/
|
44 |
+
public function autoload($className)
|
45 |
+
{
|
46 |
+
if (0 === strpos($className, $this->prefix)) {
|
47 |
+
$parts = explode('\\', substr($className, $this->prefixLength));
|
48 |
+
$filepath = $this->directory.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts).'.php';
|
49 |
+
if (is_file($filepath)) {
|
50 |
+
require($filepath);
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
|
55 |
+
}
|
lib/BcashApi/src/Config/Config.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Config;
|
4 |
+
/**
|
5 |
+
* Classe de configuração responsável por armazenar as informações de conexão do cliente com a API </br>
|
6 |
+
* Responsável também por armazenar as configurações de utilização da API desejadas, como por exemplo a versão.
|
7 |
+
*
|
8 |
+
*/
|
9 |
+
class Config
|
10 |
+
{
|
11 |
+
const host = "https://api.bcash.com.br/service";
|
12 |
+
const hostSandBox = "https://sandbox-api.bcash.com.br/service";
|
13 |
+
|
14 |
+
const siteHost = "https://www.bcash.com.br";
|
15 |
+
const siteHostSandBox = "https://sandbox.bcash.com.br";
|
16 |
+
|
17 |
+
const charset = "UTF-8"; // UTF-8 or ISO-8859-1
|
18 |
+
const timeout = 20;
|
19 |
+
}
|
lib/BcashApi/src/Domain/Address.php
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Domain;
|
4 |
+
|
5 |
+
class Address extends Model
|
6 |
+
{
|
7 |
+
|
8 |
+
protected $address;
|
9 |
+
|
10 |
+
protected $number;
|
11 |
+
|
12 |
+
protected $complement;
|
13 |
+
|
14 |
+
protected $neighborhood;
|
15 |
+
|
16 |
+
protected $city;
|
17 |
+
|
18 |
+
protected $state;
|
19 |
+
|
20 |
+
protected $zipCode;
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Endereço do comprador<br>
|
26 |
+
* <i>Tamanho máximo: 100 caracteres</i><br>
|
27 |
+
*
|
28 |
+
* @return address
|
29 |
+
* , ex.: Av. Tiradentes
|
30 |
+
*/
|
31 |
+
public function getAddress()
|
32 |
+
{
|
33 |
+
return $this->address;
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
+
* Endereço do comprador<br>
|
38 |
+
* <i>Tamanho máximo: 100 caracteres</i><br>
|
39 |
+
* <b>Campo obrigatório</b>
|
40 |
+
*
|
41 |
+
* @param address
|
42 |
+
* , ex.: Av. Tiradentes
|
43 |
+
*/
|
44 |
+
public function setAddress($address)
|
45 |
+
{
|
46 |
+
$this->address = $address;
|
47 |
+
}
|
48 |
+
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Número do endereço<br>
|
52 |
+
* <i>Tamanho máximo: 10 caracteres</i><br>
|
53 |
+
*
|
54 |
+
* @return number
|
55 |
+
* , ex.: 1254
|
56 |
+
*/
|
57 |
+
public function getNumber()
|
58 |
+
{
|
59 |
+
return $this->number;
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Número do endereço<br>
|
65 |
+
* <i>Tamanho máximo: 10 caracteres</i><br>
|
66 |
+
* <b>Campo obrigatório</b>
|
67 |
+
*
|
68 |
+
* @param number
|
69 |
+
* , ex.: 1254
|
70 |
+
*/
|
71 |
+
public function setNumber($number)
|
72 |
+
{
|
73 |
+
$this->number = $number;
|
74 |
+
}
|
75 |
+
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Complemento do endereço do comprador<br>
|
79 |
+
* <i>Tamanho máximo: 80 caracteres</i><br>
|
80 |
+
*
|
81 |
+
* @return complement
|
82 |
+
* , ex.: Apartamento 10
|
83 |
+
*/
|
84 |
+
public function getComplement()
|
85 |
+
{
|
86 |
+
return $this->complement;
|
87 |
+
}
|
88 |
+
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Complemento do endereço do comprador<br>
|
92 |
+
* <i>Tamanho máximo: 80 caracteres</i><br>
|
93 |
+
*
|
94 |
+
* @param complement
|
95 |
+
* , ex.: Apartamento 10
|
96 |
+
*/
|
97 |
+
public function setComplement($complement)
|
98 |
+
{
|
99 |
+
$this->complement = $complement;
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
/**
|
104 |
+
* Bairro do comprador<br>
|
105 |
+
* <i>Tamanho máximo: 50 caracteres</i><br>
|
106 |
+
*
|
107 |
+
* @return neighborhood
|
108 |
+
* , ex.: Centro
|
109 |
+
*/
|
110 |
+
public function getNeighborhood()
|
111 |
+
{
|
112 |
+
return $this->neighborhood;
|
113 |
+
}
|
114 |
+
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Bairro do comprador<br>
|
118 |
+
* <i>Tamanho máximo: 50 caracteres</i><br>
|
119 |
+
* <b>Campo obrigatório</b>
|
120 |
+
*
|
121 |
+
* @param neighborhood
|
122 |
+
* , ex.: Centro
|
123 |
+
*/
|
124 |
+
public function setNeighborhood($neighborhood)
|
125 |
+
{
|
126 |
+
$this->neighborhood = $neighborhood;
|
127 |
+
}
|
128 |
+
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Cidade do comprador<br>
|
132 |
+
* <i>Tamanho máximo: 255 caracteres</i><br>
|
133 |
+
*
|
134 |
+
* @return city
|
135 |
+
* , ex.: São Paulo
|
136 |
+
*/
|
137 |
+
public function getCity()
|
138 |
+
{
|
139 |
+
return $this->city;
|
140 |
+
}
|
141 |
+
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Cidade do comprador<br>
|
145 |
+
* <i>Tamanho máximo: 255 caracteres</i><br>
|
146 |
+
* <b>Campo obrigatório</b>
|
147 |
+
*
|
148 |
+
* @param city
|
149 |
+
* , ex.: São Paulo
|
150 |
+
*/
|
151 |
+
public function setCity($city)
|
152 |
+
{
|
153 |
+
$this->city = $city;
|
154 |
+
}
|
155 |
+
|
156 |
+
|
157 |
+
/**
|
158 |
+
* Estado do comprador<br>
|
159 |
+
* <i>Tamanho máximo: 2 caracteres</i><br>
|
160 |
+
* <br>
|
161 |
+
* *Vide enum: {@link StateEnum}
|
162 |
+
*
|
163 |
+
* @return state
|
164 |
+
*/
|
165 |
+
public function getState()
|
166 |
+
{
|
167 |
+
return $this->state;
|
168 |
+
}
|
169 |
+
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Estado do comprador<br>
|
173 |
+
* <i>Tamanho máximo: 2 caracteres</i><br>
|
174 |
+
* <b>Campo obrigatório</b><br>
|
175 |
+
* <br>
|
176 |
+
* *Vide enum: {@link StateEnum}
|
177 |
+
*
|
178 |
+
* @param state
|
179 |
+
*/
|
180 |
+
public function setState($state)
|
181 |
+
{
|
182 |
+
$this->state = $state;
|
183 |
+
}
|
184 |
+
|
185 |
+
|
186 |
+
/**
|
187 |
+
* CEP do comprador<br>
|
188 |
+
* <i>Tamanho máximo: 9 caracteres</i><br>
|
189 |
+
*
|
190 |
+
* @return zipCode
|
191 |
+
* , ex.: 17500000
|
192 |
+
*/
|
193 |
+
public function getZipCode()
|
194 |
+
{
|
195 |
+
return $this->zipCode;
|
196 |
+
}
|
197 |
+
|
198 |
+
|
199 |
+
/**
|
200 |
+
* CEP do comprador<br>
|
201 |
+
* <i>Tamanho máximo: 9 caracteres</i><br>
|
202 |
+
* <b>Campo obrigatório</b>
|
203 |
+
*
|
204 |
+
* @param zipCode
|
205 |
+
* , ex.: 17500000
|
206 |
+
*/
|
207 |
+
public function setZipCode($zipCode)
|
208 |
+
{
|
209 |
+
$this->zipCode = $zipCode;
|
210 |
+
}
|
211 |
+
|
212 |
+
}
|
lib/BcashApi/src/Domain/CreditCard.php
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Domain;
|
4 |
+
|
5 |
+
class CreditCard extends Model
|
6 |
+
{
|
7 |
+
|
8 |
+
protected $holder;
|
9 |
+
|
10 |
+
protected $number;
|
11 |
+
|
12 |
+
protected $securityCode;
|
13 |
+
|
14 |
+
protected $maturityMonth;
|
15 |
+
|
16 |
+
protected $maturityYear;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Nome do titular do cartão de crédito<br>
|
20 |
+
* <i>Tamanho máximo: 100 caracteres</i><br>
|
21 |
+
*
|
22 |
+
* @return holder
|
23 |
+
* , ex.: João D. F. Silva
|
24 |
+
*/
|
25 |
+
public function getHolder()
|
26 |
+
{
|
27 |
+
return $this->holder;
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Nome do titular do cartão de crédito<br>
|
33 |
+
* <i>Tamanho máximo: 100 caracteres</i><br>
|
34 |
+
* <b>Campo obrigatório</b>
|
35 |
+
*
|
36 |
+
* @param holder
|
37 |
+
* , ex.: João D. F. Silva
|
38 |
+
*/
|
39 |
+
public function setHolder($holder)
|
40 |
+
{
|
41 |
+
$this->holder = $holder;
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Número do cartão de crédito do cliente<br>
|
47 |
+
* <i>Tamanho máximo: 30 caracteres</i><br>
|
48 |
+
*
|
49 |
+
* @return number
|
50 |
+
* , ex.: 4111111111111110
|
51 |
+
*/
|
52 |
+
public function getNumber()
|
53 |
+
{
|
54 |
+
return $this->number;
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Número do cartão de crédito do cliente<br>
|
60 |
+
* <i>Tamanho máximo: 30 caracteres</i><br>
|
61 |
+
* <b>Campo obrigatório</b>
|
62 |
+
*
|
63 |
+
* @param number
|
64 |
+
* , ex.: 4111111111111110
|
65 |
+
*/
|
66 |
+
public function setNumber($number)
|
67 |
+
{
|
68 |
+
$this->number = $number;
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Código de segurança do cartão de crédito, geralmente encontra-se no verso
|
74 |
+
* do cartão<br>
|
75 |
+
*
|
76 |
+
* @return securityCode
|
77 |
+
*/
|
78 |
+
public function getSecurityCode()
|
79 |
+
{
|
80 |
+
return $this->securityCode;
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Código de segurança do cartão de crédito, geralmente encontra-se no verso
|
86 |
+
* do cartão<br>
|
87 |
+
* <b>Campo obrigatório</b>
|
88 |
+
*
|
89 |
+
* @param securityCode
|
90 |
+
*/
|
91 |
+
public function setSecurityCode($securityCode)
|
92 |
+
{
|
93 |
+
$this->securityCode = $securityCode;
|
94 |
+
}
|
95 |
+
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Mês de vencimento do cartão de crédito<br>
|
99 |
+
*
|
100 |
+
* @return maturityMonth
|
101 |
+
*/
|
102 |
+
public function getMaturityMonth()
|
103 |
+
{
|
104 |
+
return $this->maturityMonth;
|
105 |
+
}
|
106 |
+
|
107 |
+
|
108 |
+
/**
|
109 |
+
* Mês de vencimento do cartão de crédito<br>
|
110 |
+
* <b>Campo obrigatório</b>
|
111 |
+
*
|
112 |
+
* @param maturityMonth
|
113 |
+
*/
|
114 |
+
public function setMaturityMonth($maturityMonth)
|
115 |
+
{
|
116 |
+
$this->maturityMonth = $maturityMonth;
|
117 |
+
}
|
118 |
+
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Ano de vencimento do cartão de crédito <b>Campo obrigatório</b>
|
122 |
+
*
|
123 |
+
* @return maturityYear
|
124 |
+
*/
|
125 |
+
public function getMaturityYear()
|
126 |
+
{
|
127 |
+
return $this->maturityYear;
|
128 |
+
}
|
129 |
+
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Ano de vencimento do cartão de crédito <b>Campo obrigatório</b>
|
133 |
+
*
|
134 |
+
* @param maturityYear
|
135 |
+
*/
|
136 |
+
public function setMaturityYear($maturityYear)
|
137 |
+
{
|
138 |
+
$this->maturityYear = $maturityYear;
|
139 |
+
}
|
140 |
+
|
141 |
+
}
|
lib/BcashApi/src/Domain/CurrencyEnum.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Domain;
|
4 |
+
|
5 |
+
class CurrencyEnum
|
6 |
+
{
|
7 |
+
|
8 |
+
const REAL = "BRL";
|
9 |
+
|
10 |
+
}
|
lib/BcashApi/src/Domain/Customer.php
ADDED
@@ -0,0 +1,443 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Domain;
|
4 |
+
|
5 |
+
class Customer extends Model
|
6 |
+
{
|
7 |
+
|
8 |
+
protected $mail;
|
9 |
+
|
10 |
+
protected $name;
|
11 |
+
|
12 |
+
protected $cpf;
|
13 |
+
|
14 |
+
protected $phone;
|
15 |
+
|
16 |
+
protected $cellPhone;
|
17 |
+
|
18 |
+
protected $address;
|
19 |
+
|
20 |
+
protected $gender;
|
21 |
+
|
22 |
+
protected $birthDate;
|
23 |
+
|
24 |
+
protected $rg;
|
25 |
+
|
26 |
+
protected $issueRgDate;
|
27 |
+
|
28 |
+
protected $organConsignorRg;
|
29 |
+
|
30 |
+
protected $stateConsignorRg;
|
31 |
+
|
32 |
+
protected $companyName;
|
33 |
+
|
34 |
+
protected $cnpj;
|
35 |
+
|
36 |
+
protected $searchToken;
|
37 |
+
|
38 |
+
|
39 |
+
|
40 |
+
/**
|
41 |
+
* E-mail do comprador<br>
|
42 |
+
* <i>Tamanho máximo: 80 caracteres</i><br>
|
43 |
+
*
|
44 |
+
* @return mail
|
45 |
+
* , ex.: cliente@provedor.com
|
46 |
+
*/
|
47 |
+
public function getMail()
|
48 |
+
{
|
49 |
+
return $this->mail;
|
50 |
+
}
|
51 |
+
|
52 |
+
|
53 |
+
/**
|
54 |
+
* E-mail do comprador<br>
|
55 |
+
* <i>Tamanho máximo: 80 caracteres</i><br>
|
56 |
+
* <b>Campo obrigatório</b>
|
57 |
+
*
|
58 |
+
* @param mail
|
59 |
+
* , ex.: cliente@provedor.com
|
60 |
+
*/
|
61 |
+
public function setMail($mail)
|
62 |
+
{
|
63 |
+
$this->mail = $mail;
|
64 |
+
}
|
65 |
+
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Nome do comprador<br>
|
69 |
+
* <i>Tamanho máximo: 80 caracteres</i><br>
|
70 |
+
*
|
71 |
+
* @return name
|
72 |
+
* , ex.: Antonio Junior
|
73 |
+
*/
|
74 |
+
public function getName()
|
75 |
+
{
|
76 |
+
return $this->name;
|
77 |
+
}
|
78 |
+
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Nome do comprador<br>
|
82 |
+
* <i>Tamanho máximo: 80 caracteres</i><br>
|
83 |
+
* <b>Campo obrigatório</b>
|
84 |
+
*
|
85 |
+
* @param name
|
86 |
+
* , ex.: Antonio Junior
|
87 |
+
*/
|
88 |
+
public function setName($name)
|
89 |
+
{
|
90 |
+
$this->name = $name;
|
91 |
+
}
|
92 |
+
|
93 |
+
|
94 |
+
/**
|
95 |
+
* CPF do comprador<br>
|
96 |
+
* <i>Tamanho máximo: 17 caracteres</i><br>
|
97 |
+
*
|
98 |
+
* @return cpf
|
99 |
+
* , ex.: 99999999999
|
100 |
+
*/
|
101 |
+
public function getCpf()
|
102 |
+
{
|
103 |
+
return $this->cpf;
|
104 |
+
}
|
105 |
+
|
106 |
+
|
107 |
+
/**
|
108 |
+
* CPF do comprador<br>
|
109 |
+
* <i>Tamanho máximo: 17 caracteres</i><br>
|
110 |
+
* <b>Campo obrigatório</b>
|
111 |
+
*
|
112 |
+
* @param cpf
|
113 |
+
* , ex.: 99999999999
|
114 |
+
*/
|
115 |
+
public function setCpf($cpf)
|
116 |
+
{
|
117 |
+
$this->cpf = $cpf;
|
118 |
+
}
|
119 |
+
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Telefone do comprador: DDD + número telefônico<br>
|
123 |
+
* <i>Tamanho máximo: 20 caracteres</i><br>
|
124 |
+
*
|
125 |
+
* @return phone
|
126 |
+
* , ex.: 1126267469
|
127 |
+
*/
|
128 |
+
public function getPhone()
|
129 |
+
{
|
130 |
+
return $this->phone;
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Telefone do comprador: DDD + número telefônico<br>
|
136 |
+
* <i>Tamanho máximo: 20 caracteres</i><br>
|
137 |
+
* <b>Campo obrigatório, caso não seja informado o campo cellPhone</b>
|
138 |
+
*
|
139 |
+
* @param phone
|
140 |
+
* , ex.: 1126267469
|
141 |
+
*/
|
142 |
+
public function setPhone($phone)
|
143 |
+
{
|
144 |
+
$this->phone = $phone;
|
145 |
+
}
|
146 |
+
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Celular do comprador: DDD + número telefônico<br>
|
150 |
+
* <i>Tamanho máximo: 20 caracteres</i><br>
|
151 |
+
*
|
152 |
+
* @return cellPhone
|
153 |
+
* , ex.: 1199990000
|
154 |
+
*/
|
155 |
+
public function getCellPhone()
|
156 |
+
{
|
157 |
+
return $this->cellPhone;
|
158 |
+
}
|
159 |
+
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Celular do comprador: DDD + número telefônico<br>
|
163 |
+
* <i>Tamanho máximo: 20 caracteres</i><br>
|
164 |
+
* <b>Campo obrigatório, caso não seja informado o campo phone</b>
|
165 |
+
*
|
166 |
+
* @param cellPhone
|
167 |
+
* , ex.: 1199990000
|
168 |
+
*/
|
169 |
+
public function setCellPhone($cellPhone)
|
170 |
+
{
|
171 |
+
$this->cellPhone = $cellPhone;
|
172 |
+
}
|
173 |
+
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Sexo do comprador<br>
|
177 |
+
* <i>Tamanho máximo: 1 caracteres</i><br>
|
178 |
+
* <br>
|
179 |
+
* *Vide enum: {@link GenderEnum}
|
180 |
+
*
|
181 |
+
* @return gender
|
182 |
+
* , ex.: GenderEnum::MALE
|
183 |
+
*/
|
184 |
+
public function getGender()
|
185 |
+
{
|
186 |
+
return $this->gender;
|
187 |
+
}
|
188 |
+
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Sexo do comprador<br>
|
192 |
+
* <i>Tamanho máximo: 1 caracteres</i><br>
|
193 |
+
* <b>Campo obrigatório</b><br>
|
194 |
+
* <br>
|
195 |
+
* *Vide enum: {@link GenderEnum}
|
196 |
+
*
|
197 |
+
* @param gender
|
198 |
+
* , ex.: GenderEnum::MALE
|
199 |
+
*/
|
200 |
+
public function setGender($gender)
|
201 |
+
{
|
202 |
+
$this->gender = $gender;
|
203 |
+
}
|
204 |
+
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Data de Nascimento do comprador<br>
|
208 |
+
*
|
209 |
+
*
|
210 |
+
* @return birthDate
|
211 |
+
* , ex.: date("d/m/Y");
|
212 |
+
*/
|
213 |
+
public function getBirthDate()
|
214 |
+
{
|
215 |
+
return $this->birthDate;
|
216 |
+
}
|
217 |
+
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Data de Nascimento do comprador<br>
|
221 |
+
*
|
222 |
+
*
|
223 |
+
* @param birthDate
|
224 |
+
* , ex.: date("d/m/Y");
|
225 |
+
*/
|
226 |
+
public function setBirthDate($birthDate)
|
227 |
+
{
|
228 |
+
$this->birthDate = $birthDate;
|
229 |
+
}
|
230 |
+
|
231 |
+
|
232 |
+
/**
|
233 |
+
* RG do comprador<br>
|
234 |
+
* <i>Tamanho máximo: 17 caracteres</i><br>
|
235 |
+
*
|
236 |
+
* @return rg
|
237 |
+
* , ex.: 999999999
|
238 |
+
*/
|
239 |
+
public function getRg()
|
240 |
+
{
|
241 |
+
return $this->rg;
|
242 |
+
}
|
243 |
+
|
244 |
+
|
245 |
+
/**
|
246 |
+
* RG do comprador<br>
|
247 |
+
* <i>Tamanho máximo: 17 caracteres</i><br>
|
248 |
+
*
|
249 |
+
* @param rg
|
250 |
+
* , ex.: 999999999
|
251 |
+
*/
|
252 |
+
public function setRg($rg)
|
253 |
+
{
|
254 |
+
$this->rg = $rg;
|
255 |
+
}
|
256 |
+
|
257 |
+
|
258 |
+
/**
|
259 |
+
* Data da emissão do RG do comprador<br>
|
260 |
+
*
|
261 |
+
* @return issueRgDate
|
262 |
+
* , ex.: date("d/m/Y");
|
263 |
+
*/
|
264 |
+
public function getIssueRgDate()
|
265 |
+
{
|
266 |
+
return $this->issueRgDate;
|
267 |
+
}
|
268 |
+
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Data da emissão do RG do comprador<br>
|
272 |
+
*
|
273 |
+
* @param issueRgDate
|
274 |
+
* , ex.: date("d/m/Y");
|
275 |
+
*/
|
276 |
+
public function setIssueRgDate($issueRgDate)
|
277 |
+
{
|
278 |
+
$this->issueRgDate = $issueRgDate;
|
279 |
+
}
|
280 |
+
|
281 |
+
|
282 |
+
/**
|
283 |
+
* Orgão Emissor do RG do comprador<br>
|
284 |
+
* <i>Tamanho máximo: 15 caracteres</i><br>
|
285 |
+
*
|
286 |
+
* @return organConsignorRg
|
287 |
+
* , ex.: SSP
|
288 |
+
*/
|
289 |
+
public function getOrganConsignorRg()
|
290 |
+
{
|
291 |
+
return $this->organConsignorRg;
|
292 |
+
}
|
293 |
+
|
294 |
+
|
295 |
+
/**
|
296 |
+
* Orgão Emissor do RG do comprador<br>
|
297 |
+
* <i>Tamanho máximo: 15 caracteres</i><br>
|
298 |
+
*
|
299 |
+
* @param organConsignorRg
|
300 |
+
* , ex.: SSP
|
301 |
+
*/
|
302 |
+
public function setOrganConsignorRg($organConsignorRg)
|
303 |
+
{
|
304 |
+
$this->organConsignorRg = $organConsignorRg;
|
305 |
+
}
|
306 |
+
|
307 |
+
|
308 |
+
/**
|
309 |
+
* Estado emissor do RG do comprador<br>
|
310 |
+
* <i>Tamanho máximo: 2 caracteres</i><br>
|
311 |
+
* <br>
|
312 |
+
* *Vide enum: {@link StateEnum}
|
313 |
+
*
|
314 |
+
* @return stateConsignorRg
|
315 |
+
* , ex.: StateEnum::MINAS_GERAIS
|
316 |
+
*/
|
317 |
+
public function getStateConsignorRg()
|
318 |
+
{
|
319 |
+
return $this->stateConsignorRg;
|
320 |
+
}
|
321 |
+
|
322 |
+
|
323 |
+
/**
|
324 |
+
* Estado emissor do RG do comprador<br>
|
325 |
+
* <i>Tamanho máximo: 2 caracteres</i><br>
|
326 |
+
* <br>
|
327 |
+
* *Vide enum: {@link StateEnum}
|
328 |
+
*
|
329 |
+
* @param stateConsignorRg
|
330 |
+
* , ex.: StateEnum::MINAS_GERAIS
|
331 |
+
*/
|
332 |
+
public function setStateConsignorRg($stateConsignorRg)
|
333 |
+
{
|
334 |
+
$this->stateConsignorRg = $stateConsignorRg;
|
335 |
+
}
|
336 |
+
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Razão social do comprador. Enviado somente quando a conta do cliente for
|
340 |
+
* conta Jurídica<br>
|
341 |
+
* <i>Tamanho máximo: 255 caracteres</i>
|
342 |
+
*
|
343 |
+
* @return companyName
|
344 |
+
* , ex.: Razão Social da minha empresa
|
345 |
+
*/
|
346 |
+
public function getCompanyName()
|
347 |
+
{
|
348 |
+
return $this->companyName;
|
349 |
+
}
|
350 |
+
|
351 |
+
|
352 |
+
/**
|
353 |
+
* Razão social do comprador. Enviado somente quando a conta do cliente for
|
354 |
+
* conta Jurídica<br>
|
355 |
+
* <i>Tamanho máximo: 255 caracteres</i>
|
356 |
+
*
|
357 |
+
* @param companyName
|
358 |
+
* , ex.: Razão Social da minha empresa
|
359 |
+
*/
|
360 |
+
public function setCompanyName($companyName)
|
361 |
+
{
|
362 |
+
$this->companyName = $companyName;
|
363 |
+
}
|
364 |
+
|
365 |
+
|
366 |
+
/**
|
367 |
+
* CNPJ do comprador. Enviado somente quando a conta do cliente for conta
|
368 |
+
* Jurídica<br>
|
369 |
+
* <i>Tamanho máximo: 30 caracteres</i>
|
370 |
+
*
|
371 |
+
* @return cnpj
|
372 |
+
* , ex.: 99999999999999
|
373 |
+
*/
|
374 |
+
public function getCnpj()
|
375 |
+
{
|
376 |
+
return $this->cnpj;
|
377 |
+
}
|
378 |
+
|
379 |
+
|
380 |
+
/**
|
381 |
+
* CNPJ do comprador. Enviado somente quando a conta do cliente for conta
|
382 |
+
* Jurídica<br>
|
383 |
+
* <i>Tamanho máximo: 30 caracteres</i>
|
384 |
+
*
|
385 |
+
* @param cnpj
|
386 |
+
* , ex.: 99999999999999
|
387 |
+
*/
|
388 |
+
public function setCnpj($cnpj)
|
389 |
+
{
|
390 |
+
$this->cnpj = $cnpj;
|
391 |
+
}
|
392 |
+
|
393 |
+
|
394 |
+
/**
|
395 |
+
* Objeto {@link Address}<br>
|
396 |
+
* <b>Campo obrigatório</b>
|
397 |
+
*
|
398 |
+
* @return address
|
399 |
+
*/
|
400 |
+
public function getAddress()
|
401 |
+
{
|
402 |
+
return $this->address;
|
403 |
+
}
|
404 |
+
|
405 |
+
|
406 |
+
/**
|
407 |
+
* Objeto {@link Address}<br>
|
408 |
+
* <b>Campo obrigatório</b>
|
409 |
+
*
|
410 |
+
* @param address
|
411 |
+
*/
|
412 |
+
public function setAddress(Address $address)
|
413 |
+
{
|
414 |
+
$this->address = $address;
|
415 |
+
}
|
416 |
+
|
417 |
+
|
418 |
+
/**
|
419 |
+
* Token gerado apartir do serviço de consulta de conta<br>
|
420 |
+
* <br>
|
421 |
+
* *Vide {@link AccountService}
|
422 |
+
*
|
423 |
+
* @return searchToken
|
424 |
+
*/
|
425 |
+
public function getSearchToken()
|
426 |
+
{
|
427 |
+
return $this->searchToken;
|
428 |
+
}
|
429 |
+
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Token gerado apartir do serviço de consulta de conta<br>
|
433 |
+
* <br>
|
434 |
+
* *Vide {@link AccountService}
|
435 |
+
*
|
436 |
+
* @param searchToken
|
437 |
+
*/
|
438 |
+
public function setSearchToken($searchToken)
|
439 |
+
{
|
440 |
+
$this->searchToken = $searchToken;
|
441 |
+
}
|
442 |
+
|
443 |
+
}
|
lib/BcashApi/src/Domain/DependentTransaction.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Domain;
|
4 |
+
|
5 |
+
class DependentTransaction extends Model
|
6 |
+
{
|
7 |
+
|
8 |
+
protected $email;
|
9 |
+
|
10 |
+
protected $value;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Email da conta dependente<br>
|
14 |
+
* <i>Tamanho máximo: 80 caracteres</i><br>
|
15 |
+
*
|
16 |
+
* @return email
|
17 |
+
*/
|
18 |
+
public function getEmail()
|
19 |
+
{
|
20 |
+
return $this->email;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Email da conta dependente<br>
|
25 |
+
* <i>Tamanho máximo: 80 caracteres</i><br>
|
26 |
+
*
|
27 |
+
* @param email
|
28 |
+
*/
|
29 |
+
public function setEmail($email)
|
30 |
+
{
|
31 |
+
$this->email = $email;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Valor monetário da transação dependente.<br>
|
36 |
+
*
|
37 |
+
* @return value
|
38 |
+
* , ex.: 10.95
|
39 |
+
*/
|
40 |
+
public function getValue()
|
41 |
+
{
|
42 |
+
return $this->value;
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Valor monetário da transação dependente.<br>
|
47 |
+
*
|
48 |
+
* @param value
|
49 |
+
* , ex.: 10.95
|
50 |
+
*/
|
51 |
+
public function setValue($value)
|
52 |
+
{
|
53 |
+
$this->value = $value;
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
lib/BcashApi/src/Domain/GenderEnum.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Domain;
|
4 |
+
|
5 |
+
class GenderEnum
|
6 |
+
{
|
7 |
+
|
8 |
+
const MALE = "M";
|
9 |
+
|
10 |
+
const FEMALE = "F";
|
11 |
+
|
12 |
+
}
|
lib/BcashApi/src/Domain/Model.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Domain;
|
4 |
+
|
5 |
+
abstract class Model
|
6 |
+
{
|
7 |
+
|
8 |
+
public function toArray()
|
9 |
+
{
|
10 |
+
return $this->processArray(get_object_vars($this));
|
11 |
+
}
|
12 |
+
|
13 |
+
private function processArray($array)
|
14 |
+
{
|
15 |
+
foreach ($array as $key => $value) {
|
16 |
+
if (is_object($value)) {
|
17 |
+
$array[$key] = $value->toArray();
|
18 |
+
}
|
19 |
+
if (is_array($value)) {
|
20 |
+
$array[$key] = $this->processArray($value);
|
21 |
+
}
|
22 |
+
}
|
23 |
+
|
24 |
+
// If the property isn't an object or array, leave it untouched
|
25 |
+
return $array;
|
26 |
+
}
|
27 |
+
|
28 |
+
}
|
lib/BcashApi/src/Domain/NotificationContent.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Domain;
|
4 |
+
|
5 |
+
class NotificationContent
|
6 |
+
{
|
7 |
+
protected $idTransaction;
|
8 |
+
|
9 |
+
protected $pedido;
|
10 |
+
|
11 |
+
protected $status;
|
12 |
+
|
13 |
+
|
14 |
+
public function __construct($idTransaction, $pedido, $status)
|
15 |
+
{
|
16 |
+
$this->idTransaction = $idTransaction;
|
17 |
+
$this->pedido = $pedido;
|
18 |
+
$this->status = $status;
|
19 |
+
}
|
20 |
+
|
21 |
+
public function getIdTransaction()
|
22 |
+
{
|
23 |
+
return $this->idTransaction;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function setIdTransaction($idTransaction)
|
27 |
+
{
|
28 |
+
$this->idTransaction = $idTransaction;
|
29 |
+
}
|
30 |
+
|
31 |
+
public function getPedido()
|
32 |
+
{
|
33 |
+
return $this->pedido;
|
34 |
+
}
|
35 |
+
|
36 |
+
public function setPedido($pedido)
|
37 |
+
{
|
38 |
+
$this->pedido = $pedido;
|
39 |
+
}
|
40 |
+
|
41 |
+
public function getStatus()
|
42 |
+
{
|
43 |
+
return $this->status;
|
44 |
+
}
|
45 |
+
|
46 |
+
public function setStatus($status)
|
47 |
+
{
|
48 |
+
$this->status = $status;
|
49 |
+
}
|
50 |
+
|
51 |
+
}
|
lib/BcashApi/src/Domain/NotificationStatusEnum.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Domain;
|
4 |
+
|
5 |
+
class NotificationStatusEnum {
|
6 |
+
|
7 |
+
const IN_PROGRESS = 1;
|
8 |
+
|
9 |
+
const APPROVED = 3;
|
10 |
+
|
11 |
+
const COMPLETED = 4;
|
12 |
+
|
13 |
+
const IN_DISPUTE = 5;
|
14 |
+
|
15 |
+
const REFUNDED = 6;
|
16 |
+
|
17 |
+
const CANCELLED = 7;
|
18 |
+
|
19 |
+
const CHARGEBACK = 8;
|
20 |
+
|
21 |
+
}
|
lib/BcashApi/src/Domain/PaymentMethod.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Domain;
|
4 |
+
|
5 |
+
class PaymentMethod extends Model
|
6 |
+
{
|
7 |
+
|
8 |
+
protected $code;
|
9 |
+
|
10 |
+
public function __construct($code)
|
11 |
+
{
|
12 |
+
$this->code = $code;
|
13 |
+
}
|
14 |
+
|
15 |
+
/**
|
16 |
+
* Meio de Pagamento utilizado para processar a transação<br>
|
17 |
+
* *Vide enum: {@link PaymentMethodEnum}
|
18 |
+
*
|
19 |
+
* @return code
|
20 |
+
* , ex.: PaymentMethodEnum::VISA
|
21 |
+
*/
|
22 |
+
public function getCode()
|
23 |
+
{
|
24 |
+
return $this->code;
|
25 |
+
}
|
26 |
+
|
27 |
+
}
|
lib/BcashApi/src/Domain/PaymentMethodEnum.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Domain;
|
4 |
+
|
5 |
+
class PaymentMethodEnum
|
6 |
+
{
|
7 |
+
|
8 |
+
const VISA = "1";
|
9 |
+
|
10 |
+
const MASTERCARD = "2";
|
11 |
+
|
12 |
+
const BANK_SLIP = "10";
|
13 |
+
|
14 |
+
const AMERICAN_EXPRESS = "37";
|
15 |
+
|
16 |
+
const AURA = "45";
|
17 |
+
|
18 |
+
const DINERS = "55";
|
19 |
+
|
20 |
+
const HIPERCARD = "56";
|
21 |
+
|
22 |
+
const BB_ONLINE_TRANSFER = "58";
|
23 |
+
|
24 |
+
const BRADESCO_ONLINE_TRANSFER = "59";
|
25 |
+
|
26 |
+
const ITAU_ONLINE_TRANSFER = "60";
|
27 |
+
|
28 |
+
const BANRISUL_ONLINE_TRANSFER = "61";
|
29 |
+
|
30 |
+
const HSBC_ONLINE_TRANSFER = "62";
|
31 |
+
|
32 |
+
const ELO = "63";
|
33 |
+
|
34 |
+
}
|
lib/BcashApi/src/Domain/Product.php
ADDED
@@ -0,0 +1,145 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Domain;
|
4 |
+
|
5 |
+
class Product extends Model
|
6 |
+
{
|
7 |
+
|
8 |
+
protected $code;
|
9 |
+
|
10 |
+
protected $description;
|
11 |
+
|
12 |
+
protected $amount;
|
13 |
+
|
14 |
+
protected $value;
|
15 |
+
|
16 |
+
protected $extraDescription;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Código que identifica o produto em sua loja<br>
|
20 |
+
* <i>Tamanho máximo: 50 caracteres</i><br>
|
21 |
+
*
|
22 |
+
* @return code
|
23 |
+
* , ex.: 446
|
24 |
+
*/
|
25 |
+
public function getCode()
|
26 |
+
{
|
27 |
+
return $this->code;
|
28 |
+
}
|
29 |
+
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Código que identifica o produto em sua loja<br>
|
33 |
+
* <i>Tamanho máximo: 50 caracteres</i><br>
|
34 |
+
* <b>Campo obrigatório</b>
|
35 |
+
*
|
36 |
+
* @param code
|
37 |
+
* , ex.: 446
|
38 |
+
*/
|
39 |
+
public function setCode($code)
|
40 |
+
{
|
41 |
+
$this->code = $code;
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Descrição ou nome do(s) produto comprado. Será visualizada pelo cliente<br>
|
47 |
+
* <i>Tamanho máximo: 255 caracteres</i><br>
|
48 |
+
*
|
49 |
+
* @return description
|
50 |
+
* , ex.: Camiseta da seleção brasileira
|
51 |
+
*/
|
52 |
+
public function getDescription()
|
53 |
+
{
|
54 |
+
return $this->description;
|
55 |
+
}
|
56 |
+
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Descrição ou nome do(s) produto comprado. Será visualizada pelo cliente<br>
|
60 |
+
* <i>Tamanho máximo: 255 caracteres</i><br>
|
61 |
+
* <b>Campo obrigatório</b>
|
62 |
+
*
|
63 |
+
* @param description
|
64 |
+
* , ex.: Camiseta da seleção brasileira
|
65 |
+
*/
|
66 |
+
public function setDescription($description)
|
67 |
+
{
|
68 |
+
$this->description = $description;
|
69 |
+
}
|
70 |
+
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Quantidade comprada deste produto<br>
|
74 |
+
*
|
75 |
+
* @return amount
|
76 |
+
* , ex.: 2
|
77 |
+
*/
|
78 |
+
public function getAmount()
|
79 |
+
{
|
80 |
+
return $this->amount;
|
81 |
+
}
|
82 |
+
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Quantidade comprada deste produto<br>
|
86 |
+
* <b>Campo obrigatório</b>
|
87 |
+
*
|
88 |
+
* @param amount
|
89 |
+
* , ex.: 2
|
90 |
+
*/
|
91 |
+
public function setAmount($amount)
|
92 |
+
{
|
93 |
+
$this->amount = $amount;
|
94 |
+
}
|
95 |
+
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Valor unitário do produto<br>
|
99 |
+
*
|
100 |
+
* @return value
|
101 |
+
* , ex.: 10.95
|
102 |
+
*/
|
103 |
+
public function getValue()
|
104 |
+
{
|
105 |
+
return $this->value;
|
106 |
+
}
|
107 |
+
|
108 |
+
|
109 |
+
/**
|
110 |
+
* Valor unitário do produto<br>
|
111 |
+
* <b>Campo obrigatório</b>
|
112 |
+
*
|
113 |
+
* @param value
|
114 |
+
* , ex.: 10.95
|
115 |
+
*/
|
116 |
+
public function setValue($value)
|
117 |
+
{
|
118 |
+
$this->value = $value;
|
119 |
+
}
|
120 |
+
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Descrição adicional do produto<br>
|
124 |
+
* <i>Tamanho máximo: 255 caracteres</i>
|
125 |
+
*
|
126 |
+
* @return extraDescription
|
127 |
+
*/
|
128 |
+
public function getExtraDescription()
|
129 |
+
{
|
130 |
+
return $this->extraDescription;
|
131 |
+
}
|
132 |
+
|
133 |
+
|
134 |
+
/**
|
135 |
+
* Descrição adicional do produto<br>
|
136 |
+
* <i>Tamanho máximo: 255 caracteres</i>
|
137 |
+
*
|
138 |
+
* @param extraDescription
|
139 |
+
*/
|
140 |
+
public function setExtraDescription($extraDescription)
|
141 |
+
{
|
142 |
+
$this->extraDescription = $extraDescription;
|
143 |
+
}
|
144 |
+
|
145 |
+
}
|
lib/BcashApi/src/Domain/ShippingTypeEnum.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Domain;
|
4 |
+
|
5 |
+
class ShippingTypeEnum
|
6 |
+
{
|
7 |
+
|
8 |
+
const E_SEDEX = "E_SEDEX";
|
9 |
+
|
10 |
+
const SEDEX = "SEDEX";
|
11 |
+
|
12 |
+
const PAC = "PAC";
|
13 |
+
|
14 |
+
const ENCOMENDA = "ENCOMENDA";
|
15 |
+
|
16 |
+
const CARTA_REGISTRADA = "CARTA_REGISTRADA";
|
17 |
+
|
18 |
+
const TRANSPORTADORA = "TRANSPORTADORA";
|
19 |
+
|
20 |
+
}
|
lib/BcashApi/src/Domain/StateEnum.php
ADDED
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Domain;
|
4 |
+
|
5 |
+
class StateEnum
|
6 |
+
{
|
7 |
+
|
8 |
+
const ACRE = "AC";
|
9 |
+
|
10 |
+
const ALAGOAS = "AL";
|
11 |
+
|
12 |
+
const AMAPA = "AP";
|
13 |
+
|
14 |
+
const AMAZONAS = "AM";
|
15 |
+
|
16 |
+
const BAHIA = "BA";
|
17 |
+
|
18 |
+
const CEARA = "CE";
|
19 |
+
|
20 |
+
const DISTRITO_FEDERAL = "DF";
|
21 |
+
|
22 |
+
const ESPIRITO_SANTO = "ES";
|
23 |
+
|
24 |
+
const GOIAS = "GO";
|
25 |
+
|
26 |
+
const MARANHAO = "MA";
|
27 |
+
|
28 |
+
const MATO_GROSSO = "MT";
|
29 |
+
|
30 |
+
const MATO_GROSSO_DO_SUL = "MS";
|
31 |
+
|
32 |
+
const MINAS_GERAIS = "MG";
|
33 |
+
|
34 |
+
const PARA = "PA";
|
35 |
+
|
36 |
+
const PARAIBA = "PB";
|
37 |
+
|
38 |
+
const PARANA = "PR";
|
39 |
+
|
40 |
+
const PERNAMBUCO = "PE";
|
41 |
+
|
42 |
+
const PIAUI = "PI";
|
43 |
+
|
44 |
+
const RIO_DE_JANEIRO = "RJ";
|
45 |
+
|
46 |
+
const RIO_GRANDE_DO_NORTE = "RN";
|
47 |
+
|
48 |
+
const RIO_GRANDE_DO_SUL = "RS";
|
49 |
+
|
50 |
+
const RONDONIA = "RO";
|
51 |
+
|
52 |
+
const RORAIMA = "RR";
|
53 |
+
|
54 |
+
const SANTA_CATARINA = "SC";
|
55 |
+
|
56 |
+
const SAO_PAULO = "SP";
|
57 |
+
|
58 |
+
const SERGIPE = "SE";
|
59 |
+
|
60 |
+
const TOCANTINS = "TO";
|
61 |
+
|
62 |
+
}
|
lib/BcashApi/src/Domain/TransactionRequest.php
ADDED
@@ -0,0 +1,592 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Domain;
|
4 |
+
|
5 |
+
use Bcash\Domain\PaymentMethod;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Objeto de requisição para serviços de transação.
|
9 |
+
*/
|
10 |
+
class TransactionRequest extends Model
|
11 |
+
{
|
12 |
+
|
13 |
+
protected $sellerMail;
|
14 |
+
|
15 |
+
protected $ipSeller;
|
16 |
+
|
17 |
+
protected $orderId;
|
18 |
+
|
19 |
+
protected $buyer;
|
20 |
+
|
21 |
+
protected $free;
|
22 |
+
|
23 |
+
protected $freight;
|
24 |
+
|
25 |
+
protected $freightType;
|
26 |
+
|
27 |
+
protected $discount;
|
28 |
+
|
29 |
+
protected $addition;
|
30 |
+
|
31 |
+
protected $paymentMethod;
|
32 |
+
|
33 |
+
protected $urlReturn;
|
34 |
+
|
35 |
+
protected $urlNotification;
|
36 |
+
|
37 |
+
protected $products;
|
38 |
+
|
39 |
+
protected $dependentTransactions;
|
40 |
+
|
41 |
+
protected $installments;
|
42 |
+
|
43 |
+
protected $creditCard;
|
44 |
+
|
45 |
+
protected $currency;
|
46 |
+
|
47 |
+
protected $acceptedContract;
|
48 |
+
|
49 |
+
protected $viewedContract;
|
50 |
+
|
51 |
+
protected $campaignId;
|
52 |
+
|
53 |
+
protected $platformId;
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Recupera o e-mail da loja cadastrada no Pagamento Digital.
|
57 |
+
*
|
58 |
+
* @return sellerMail
|
59 |
+
*/
|
60 |
+
public function getSellerMail()
|
61 |
+
{
|
62 |
+
return $this->sellerMail;
|
63 |
+
}
|
64 |
+
|
65 |
+
|
66 |
+
/**
|
67 |
+
* E-mail da loja cadastrada no Pagamento Digital<br>
|
68 |
+
* <i>Tamanho máximo: 80 caracteres</i><br>
|
69 |
+
* <b>Campo obrigatório</b>
|
70 |
+
*
|
71 |
+
* @param sellerMail
|
72 |
+
* , ex.: empresa@provedor.com
|
73 |
+
*/
|
74 |
+
public function setSellerMail($sellerMail)
|
75 |
+
{
|
76 |
+
$this->sellerMail = $sellerMail;
|
77 |
+
}
|
78 |
+
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Código do pedido atribuído pela loja<br>
|
82 |
+
* <i>Tamanho máximo: 50 caracteres</i>
|
83 |
+
*
|
84 |
+
* @return orderId
|
85 |
+
* , ex.: 123
|
86 |
+
*/
|
87 |
+
public function getOrderId()
|
88 |
+
{
|
89 |
+
return $this->orderId;
|
90 |
+
}
|
91 |
+
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Código do pedido atribuído pela loja<br>
|
95 |
+
* <i>Tamanho máximo: 50 caracteres</i>
|
96 |
+
*
|
97 |
+
* @param orderId
|
98 |
+
* , ex.: 123
|
99 |
+
*/
|
100 |
+
public function setOrderId($orderId)
|
101 |
+
{
|
102 |
+
$this->orderId = $orderId;
|
103 |
+
}
|
104 |
+
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Objeto {@link Customer}<br>
|
108 |
+
*
|
109 |
+
* @return buyer
|
110 |
+
*/
|
111 |
+
public function getBuyer()
|
112 |
+
{
|
113 |
+
return $this->buyer;
|
114 |
+
}
|
115 |
+
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Objeto {@link Customer}<br>
|
119 |
+
* <b>Campo obrigatório</b>
|
120 |
+
*
|
121 |
+
* @param buyer
|
122 |
+
*/
|
123 |
+
public function setBuyer(Customer $buyer) {
|
124 |
+
$this->buyer = $buyer;
|
125 |
+
}
|
126 |
+
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Campo de Livre Digitação. Pode ser utilizado para algum parâmetro
|
130 |
+
* adicional de identificação da venda<br>
|
131 |
+
* <i>Tamanho máximo: 255 caracteres</i>
|
132 |
+
*
|
133 |
+
* @return free
|
134 |
+
* , ex.: compra teste
|
135 |
+
*/
|
136 |
+
public function getFree() {
|
137 |
+
return $this->free;
|
138 |
+
}
|
139 |
+
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Campo de Livre Digitação. Pode ser utilizado para algum parâmetro
|
143 |
+
* adicional de identificação da venda<br>
|
144 |
+
* <i>Tamanho máximo: 255 caracteres</i>
|
145 |
+
*
|
146 |
+
* @param free
|
147 |
+
* , ex.: compra teste
|
148 |
+
*/
|
149 |
+
public function setFree($free)
|
150 |
+
{
|
151 |
+
$this->free = $free;
|
152 |
+
}
|
153 |
+
|
154 |
+
|
155 |
+
/**
|
156 |
+
* Valor do frete<br>
|
157 |
+
*
|
158 |
+
* @return shipping
|
159 |
+
* , ex.: 10.95
|
160 |
+
*/
|
161 |
+
public function getShipping()
|
162 |
+
{
|
163 |
+
return $this->freight;
|
164 |
+
}
|
165 |
+
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Valor do frete<br>
|
169 |
+
*
|
170 |
+
* @param shipping
|
171 |
+
* , ex.: 10.95
|
172 |
+
*/
|
173 |
+
public function setShipping($value)
|
174 |
+
{
|
175 |
+
$this->freight = $value;
|
176 |
+
}
|
177 |
+
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Tipo do frete<br>
|
181 |
+
* <br>
|
182 |
+
* *Vide enum: {@link ShippingTypeEnum}
|
183 |
+
*
|
184 |
+
* @return shippingType
|
185 |
+
* , ex.: ShippingTypeEnum::SEDEX
|
186 |
+
*/
|
187 |
+
public function getShippingType()
|
188 |
+
{
|
189 |
+
return $this->freightType;
|
190 |
+
}
|
191 |
+
|
192 |
+
|
193 |
+
/**
|
194 |
+
* Tipo do frete<br>
|
195 |
+
* <br>
|
196 |
+
* *Vide enum: {@link ShippingTypeEnum}
|
197 |
+
*
|
198 |
+
* @param shippingType
|
199 |
+
* , ex.: ShippingTypeEnum::SEDEX
|
200 |
+
*/
|
201 |
+
public function setShippingType($type)
|
202 |
+
{
|
203 |
+
$this->freightType = $type;
|
204 |
+
}
|
205 |
+
|
206 |
+
|
207 |
+
/**
|
208 |
+
* Valor total do desconto atribuído pela loja<br>
|
209 |
+
*
|
210 |
+
*
|
211 |
+
* @return discount
|
212 |
+
* , ex.: 2.25
|
213 |
+
*/
|
214 |
+
public function getDiscount()
|
215 |
+
{
|
216 |
+
return $this->discount;
|
217 |
+
}
|
218 |
+
|
219 |
+
|
220 |
+
/**
|
221 |
+
* Valor total do desconto atribuído pela loja<br>
|
222 |
+
*
|
223 |
+
*
|
224 |
+
* @param discount
|
225 |
+
* , ex.: 2.25
|
226 |
+
*/
|
227 |
+
public function setDiscount($discount)
|
228 |
+
{
|
229 |
+
$this->discount = $discount;
|
230 |
+
}
|
231 |
+
|
232 |
+
|
233 |
+
/**
|
234 |
+
* Valor total do acréscimo feito pela loja
|
235 |
+
*
|
236 |
+
* @return addition
|
237 |
+
* , ex.: 2.25
|
238 |
+
*/
|
239 |
+
public function getAddition()
|
240 |
+
{
|
241 |
+
return $this->addition;
|
242 |
+
}
|
243 |
+
|
244 |
+
|
245 |
+
/**
|
246 |
+
* Valor total do acréscimo feito pela loja
|
247 |
+
*
|
248 |
+
* @param addition
|
249 |
+
* , ex.: 2.25
|
250 |
+
*/
|
251 |
+
public function setAddition($addition)
|
252 |
+
{
|
253 |
+
$this->addition = $addition;
|
254 |
+
}
|
255 |
+
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Forma de pagamento<br>
|
259 |
+
* <br>
|
260 |
+
* *Vide enum: {@link PaymentMethodEnum}
|
261 |
+
*
|
262 |
+
* @return paymentMethod
|
263 |
+
* , ex.: PaymentMethodEnum::VISA
|
264 |
+
*/
|
265 |
+
public function getPaymentMethod()
|
266 |
+
{
|
267 |
+
return $this->paymentMethod;
|
268 |
+
}
|
269 |
+
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Forma de pagamento<br>
|
273 |
+
* <br>
|
274 |
+
* *Vide enum: {@link PaymentMethodEnum}
|
275 |
+
*
|
276 |
+
* @param paymentMethod
|
277 |
+
* , ex.: PaymentMethodEnum::VISA
|
278 |
+
*/
|
279 |
+
public function setPaymentMethod($paymentMethod)
|
280 |
+
{
|
281 |
+
$this->paymentMethod = new PaymentMethod($paymentMethod);
|
282 |
+
}
|
283 |
+
|
284 |
+
|
285 |
+
/**
|
286 |
+
* URL que direciona o usuário para a loja<br>
|
287 |
+
* <i>Tamanho máximo: 255 caracteres</i>
|
288 |
+
*
|
289 |
+
* @return urlreturn
|
290 |
+
* , ex.: https://www.bcash.com.br/loja/retorno.php
|
291 |
+
*/
|
292 |
+
public function getUrlReturn()
|
293 |
+
{
|
294 |
+
return $this->urlReturn;
|
295 |
+
}
|
296 |
+
|
297 |
+
|
298 |
+
/**
|
299 |
+
* URL que direciona o usuário para a loja<br>
|
300 |
+
* <i>Tamanho máximo: 255 caracteres</i>
|
301 |
+
*
|
302 |
+
* @param urlreturn
|
303 |
+
* , ex.: https://www.bcash.com.br/loja/retorno.php
|
304 |
+
*/
|
305 |
+
public function setUrlReturn($urlReturn)
|
306 |
+
{
|
307 |
+
$this->urlReturn = $urlReturn;
|
308 |
+
}
|
309 |
+
|
310 |
+
|
311 |
+
/**
|
312 |
+
* URL que a loja ir receber as informações de alteração de status da
|
313 |
+
* transação<br>
|
314 |
+
* <i>Tamanho máximo: 255 caracteres</i>
|
315 |
+
*
|
316 |
+
*
|
317 |
+
* @return urlNotification
|
318 |
+
* , https://www.bcash.com.br/loja/aviso.php
|
319 |
+
*/
|
320 |
+
public function getUrlNotification()
|
321 |
+
{
|
322 |
+
return $this->urlNotification;
|
323 |
+
}
|
324 |
+
|
325 |
+
|
326 |
+
/**
|
327 |
+
* URL que a loja ir receber as informações de alteração de status da
|
328 |
+
* transação<br>
|
329 |
+
* <i>Tamanho máximo: 255 caracteres</i>
|
330 |
+
*
|
331 |
+
*
|
332 |
+
* @param urlNotification
|
333 |
+
* , https://www.bcash.com.br/loja/aviso.php
|
334 |
+
*/
|
335 |
+
public function setUrlNotification($urlNotification)
|
336 |
+
{
|
337 |
+
$this->urlNotification = $urlNotification;
|
338 |
+
}
|
339 |
+
|
340 |
+
|
341 |
+
/**
|
342 |
+
* Lista de produtos.<br>
|
343 |
+
*
|
344 |
+
* *Obs.: Preencher a lista com o objeto {@link Product}
|
345 |
+
*
|
346 |
+
* @return products
|
347 |
+
*/
|
348 |
+
public function getProducts()
|
349 |
+
{
|
350 |
+
return $this->products;
|
351 |
+
}
|
352 |
+
|
353 |
+
|
354 |
+
/**
|
355 |
+
* Lista de produtos.<br>
|
356 |
+
* <b>Campo obrigatório</b><br>
|
357 |
+
*
|
358 |
+
* *Obs.: Preencher a lista com o objeto {@link Product}
|
359 |
+
*
|
360 |
+
* @param products
|
361 |
+
*/
|
362 |
+
public function setProducts(Array $products)
|
363 |
+
{
|
364 |
+
$this->products = $products;
|
365 |
+
}
|
366 |
+
|
367 |
+
/**
|
368 |
+
* Lista de transacoes dependentes.<br>
|
369 |
+
*
|
370 |
+
* *Obs.: Preencher a lista com o objeto {@link DependentTransaction}
|
371 |
+
*
|
372 |
+
* @return dependentTransactions
|
373 |
+
*/
|
374 |
+
public function getDependentTransactions()
|
375 |
+
{
|
376 |
+
return $this->dependentTransactions;
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Lista de transacoes dependentes.<br>
|
381 |
+
*
|
382 |
+
* *Obs.: Preencher a lista com o objeto {@link DependentTransaction}
|
383 |
+
*
|
384 |
+
* @param DependentTransaction
|
385 |
+
*/
|
386 |
+
public function setDependentTransactions(Array $dependentTransactions)
|
387 |
+
{
|
388 |
+
$this->dependentTransactions = $dependentTransactions;
|
389 |
+
}
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Quantidade de Parcelas que a compra será processada<br>
|
393 |
+
*
|
394 |
+
*
|
395 |
+
* @return installments
|
396 |
+
* , ex.: 5
|
397 |
+
*/
|
398 |
+
public function getInstallments()
|
399 |
+
{
|
400 |
+
return $this->installments;
|
401 |
+
}
|
402 |
+
|
403 |
+
/**
|
404 |
+
* Quantidade de Parcelas que a compra será processada<br>
|
405 |
+
*
|
406 |
+
*
|
407 |
+
* @param installments
|
408 |
+
* , ex.: 5
|
409 |
+
*/
|
410 |
+
public function setInstallments($installments)
|
411 |
+
{
|
412 |
+
$this->installments = $installments;
|
413 |
+
}
|
414 |
+
|
415 |
+
|
416 |
+
/**
|
417 |
+
* Objeto {@link CreditCard}
|
418 |
+
*
|
419 |
+
* @return creditCard
|
420 |
+
*/
|
421 |
+
public function getCreditCard()
|
422 |
+
{
|
423 |
+
return $this->creditCard;
|
424 |
+
}
|
425 |
+
|
426 |
+
|
427 |
+
/**
|
428 |
+
* Objeto {@link CreditCard}
|
429 |
+
*
|
430 |
+
* @param creditCard
|
431 |
+
*/
|
432 |
+
public function setCreditCard(CreditCard $creditCard)
|
433 |
+
{
|
434 |
+
$this->creditCard = $creditCard;
|
435 |
+
}
|
436 |
+
|
437 |
+
|
438 |
+
/**
|
439 |
+
* Moeda utilizada para a transação<br>
|
440 |
+
* <i>Tamanho máximo: 3 caracteres</i><br>
|
441 |
+
* <br>
|
442 |
+
*
|
443 |
+
* *Vide enum: {@link CurrencyEnum}
|
444 |
+
*
|
445 |
+
* @return currency
|
446 |
+
* , ex.: CurrencyEnum.REAL
|
447 |
+
*/
|
448 |
+
public function getCurrency()
|
449 |
+
{
|
450 |
+
return $this->currency;
|
451 |
+
}
|
452 |
+
|
453 |
+
|
454 |
+
/**
|
455 |
+
* Moeda utilizada para a transação<br>
|
456 |
+
* <i>Tamanho máximo: 3 caracteres</i><br>
|
457 |
+
* <br>
|
458 |
+
*
|
459 |
+
* *Vide enum: {@link CurrencyEnum}
|
460 |
+
*
|
461 |
+
* @param currency
|
462 |
+
* , ex.: CurrencyEnum.REAL
|
463 |
+
*/
|
464 |
+
public function setCurrency($currency)
|
465 |
+
{
|
466 |
+
$this->currency = $currency;
|
467 |
+
}
|
468 |
+
|
469 |
+
|
470 |
+
/**
|
471 |
+
* Loja informa se o comprador aceitou os termos do contrato<br>
|
472 |
+
*
|
473 |
+
* @return acceptedContract
|
474 |
+
* , ex.: "S"
|
475 |
+
*/
|
476 |
+
public function getAcceptedContract()
|
477 |
+
{
|
478 |
+
return $this->acceptedContract;
|
479 |
+
}
|
480 |
+
|
481 |
+
|
482 |
+
/**
|
483 |
+
* Loja informa se o comprador aceitou os termos do contrato<br>
|
484 |
+
*
|
485 |
+
* @param acceptedContract
|
486 |
+
* , ex.: "S"
|
487 |
+
*/
|
488 |
+
public function setAcceptedContract($acceptedContract)
|
489 |
+
{
|
490 |
+
$this->acceptedContract = $acceptedContract;
|
491 |
+
}
|
492 |
+
|
493 |
+
|
494 |
+
/**
|
495 |
+
* Loja informa se o comprador visualizou os termos do contrato<br>
|
496 |
+
*
|
497 |
+
* @return viewedContract
|
498 |
+
* , ex.: "S"
|
499 |
+
*/
|
500 |
+
public function getViewedContract()
|
501 |
+
{
|
502 |
+
return $this->viewedContract;
|
503 |
+
}
|
504 |
+
|
505 |
+
|
506 |
+
/**
|
507 |
+
* Loja informa se o comprador visualizou os termos do contrato<br>
|
508 |
+
*
|
509 |
+
* @param viewedContract
|
510 |
+
* , ex.: "S"
|
511 |
+
*/
|
512 |
+
public function setViewedContract($viewedContract)
|
513 |
+
{
|
514 |
+
$this->viewedContract = $viewedContract;
|
515 |
+
}
|
516 |
+
|
517 |
+
|
518 |
+
/**
|
519 |
+
* Identificador da campanha da loja no Pagamento Digital
|
520 |
+
*
|
521 |
+
* @return campaignId
|
522 |
+
* , ex.: 123
|
523 |
+
*/
|
524 |
+
public function getCampaignId()
|
525 |
+
{
|
526 |
+
return $this->campaignId;
|
527 |
+
}
|
528 |
+
|
529 |
+
|
530 |
+
/**
|
531 |
+
* Identificador da campanha da loja no Pagamento Digital
|
532 |
+
*
|
533 |
+
* @param campaignId
|
534 |
+
* , ex.: 123
|
535 |
+
*/
|
536 |
+
public function setCampaignId($campaignId)
|
537 |
+
{
|
538 |
+
$this->campaignId = $campaignId;
|
539 |
+
}
|
540 |
+
|
541 |
+
|
542 |
+
/**
|
543 |
+
* Endereço de IP da loja<br>
|
544 |
+
* <i>Tamanho máximo: 40 caracteres</i><br>
|
545 |
+
*
|
546 |
+
* @return ipSeller
|
547 |
+
* , ex.: 169.254.57.175
|
548 |
+
*/
|
549 |
+
public function getIpSeller()
|
550 |
+
{
|
551 |
+
return $this->ipSeller;
|
552 |
+
}
|
553 |
+
|
554 |
+
|
555 |
+
/**
|
556 |
+
* Endereço de IP da loja<br>
|
557 |
+
* <i>Tamanho máximo: 40 caracteres</i><br>
|
558 |
+
* <b>Campo obrigatório</b>
|
559 |
+
*
|
560 |
+
* @param ipSeller
|
561 |
+
* , ex.: 169.254.57.175
|
562 |
+
*/
|
563 |
+
public function setIpSeller($ipSeller)
|
564 |
+
{
|
565 |
+
$this->ipSeller = $ipSeller;
|
566 |
+
}
|
567 |
+
|
568 |
+
|
569 |
+
/**
|
570 |
+
* Recupera identificador da plataforma cadastrada no Bcash<br>
|
571 |
+
*
|
572 |
+
* @return platformId
|
573 |
+
* , ex.: 999
|
574 |
+
*/
|
575 |
+
public function getPlatformId()
|
576 |
+
{
|
577 |
+
return $this->platformId;
|
578 |
+
}
|
579 |
+
|
580 |
+
|
581 |
+
/**
|
582 |
+
* Atribui identificador da plataforma cadastrada no Bcash<br>
|
583 |
+
*
|
584 |
+
* @param platformId
|
585 |
+
* , ex.: 999
|
586 |
+
*/
|
587 |
+
public function setPlatformId($platformId)
|
588 |
+
{
|
589 |
+
$this->platformId = $platformId;
|
590 |
+
}
|
591 |
+
|
592 |
+
}
|
lib/BcashApi/src/Exception/BaseException.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Exception;
|
4 |
+
|
5 |
+
class BaseException extends \Exception
|
6 |
+
{
|
7 |
+
private $errors;
|
8 |
+
|
9 |
+
public function __construct($errors, $message = "")
|
10 |
+
{
|
11 |
+
parent::__construct($message);
|
12 |
+
$this->errors = $errors;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getErrors()
|
16 |
+
{
|
17 |
+
return $this->errors;
|
18 |
+
}
|
19 |
+
|
20 |
+
}
|
lib/BcashApi/src/Exception/ConnectionException.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Exception;
|
4 |
+
|
5 |
+
class ConnectionException extends BaseException
|
6 |
+
{
|
7 |
+
const MESSAGE = "Erro de conexão: ";
|
8 |
+
|
9 |
+
public function __construct($errors, $message)
|
10 |
+
{
|
11 |
+
parent::__construct($errors, self::MESSAGE . $message);
|
12 |
+
$this->errors = $errors;
|
13 |
+
}
|
14 |
+
|
15 |
+
}
|
lib/BcashApi/src/Exception/ValidationException.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Exception;
|
4 |
+
|
5 |
+
class ValidationException extends BaseException
|
6 |
+
{
|
7 |
+
const MESSAGE = "Solicitação Inválida";
|
8 |
+
|
9 |
+
public function __construct($errors)
|
10 |
+
{
|
11 |
+
parent::__construct($errors, self::MESSAGE);
|
12 |
+
$this->errors = $errors;
|
13 |
+
}
|
14 |
+
|
15 |
+
}
|
lib/BcashApi/src/Helper/HttpHelper.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Helper;
|
4 |
+
|
5 |
+
class HttpHelper
|
6 |
+
{
|
7 |
+
public static function toQueryString($parameters)
|
8 |
+
{
|
9 |
+
return http_build_query($parameters, '', '&');
|
10 |
+
}
|
11 |
+
|
12 |
+
public static function fromJson($json)
|
13 |
+
{
|
14 |
+
return json_decode($json);
|
15 |
+
}
|
16 |
+
|
17 |
+
}
|
lib/BcashApi/src/Http/Authentication/Basic.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Http\Authentication;
|
4 |
+
|
5 |
+
class Basic
|
6 |
+
{
|
7 |
+
private $email;
|
8 |
+
private $token;
|
9 |
+
|
10 |
+
public function generateHeader($email, $token)
|
11 |
+
{
|
12 |
+
|
13 |
+
$this->email = $email;
|
14 |
+
$this->token = $token;
|
15 |
+
|
16 |
+
return "Authorization: Basic " . base64_encode($this->email . ":" . $this->token);
|
17 |
+
}
|
18 |
+
|
19 |
+
}
|
lib/BcashApi/src/Http/Authentication/OAuth.php
ADDED
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Http\Authentication;
|
4 |
+
|
5 |
+
use Bcash\Config\Config;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Classe de Autorization padrão OAtuh 1.0
|
9 |
+
*
|
10 |
+
* @author bcash
|
11 |
+
*/
|
12 |
+
class OAuth {
|
13 |
+
|
14 |
+
private $consumer_key;
|
15 |
+
private $nonce;
|
16 |
+
private $timestamp;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Função para gerar o header
|
20 |
+
* @access public
|
21 |
+
* @return string
|
22 |
+
*/
|
23 |
+
public function generateHeader($consumer_key) {
|
24 |
+
|
25 |
+
$this->consumer_key = $consumer_key;
|
26 |
+
$this->nonce = md5( microtime() . mt_rand() );
|
27 |
+
$this->timestamp = urlencode(time()*1000);
|
28 |
+
|
29 |
+
$header = "Authorization: OAuth realm=https://api.bcash.com.br," .
|
30 |
+
"oauth_consumer_key=" .$this->consumer_key . "," .
|
31 |
+
"oauth_nonce=" . $this->nonce . "," .
|
32 |
+
"oauth_signature=" . $this->generateSignature() . "," .
|
33 |
+
"oauth_signature_method=PLAINTEXT," .
|
34 |
+
"oauth_timestamp=" . $this->timestamp . "," .
|
35 |
+
"oauth_version=1.0" ;
|
36 |
+
return $header;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Função para gerar o campo oauth_signature
|
41 |
+
* @access private
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
private function generateSignature() {
|
45 |
+
$oauth_signature = "oauth_consumer_key=" . urlencode($this->consumer_key) . "&" .
|
46 |
+
"oauth_nonce=" . urlencode($this->nonce) . "&" .
|
47 |
+
"oauth_signature_method=" . urlencode("PLAINTEXT") . "&" .
|
48 |
+
"oauth_timestamp=" . urlencode($this->timestamp) . "&" .
|
49 |
+
"oauth_version=" . urlencode("1.0");
|
50 |
+
|
51 |
+
$oauth_signature = base64_encode($oauth_signature);
|
52 |
+
return $oauth_signature;
|
53 |
+
}
|
54 |
+
}
|
lib/BcashApi/src/Http/Connection.php
ADDED
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Http;
|
4 |
+
|
5 |
+
use Bcash\Http\PostRequest;
|
6 |
+
use Bcash\Http\Response;
|
7 |
+
use Bcash\Helper\HttpHelper;
|
8 |
+
use Bcash\Exception\ValidationException;
|
9 |
+
use Bcash\Exception\ConnectionException;
|
10 |
+
|
11 |
+
class Connection
|
12 |
+
{
|
13 |
+
|
14 |
+
const USER_AGENT = "bcash-php-sdk-2.0.0";
|
15 |
+
private $timeout;
|
16 |
+
|
17 |
+
public function __construct($timeout = 60)
|
18 |
+
{
|
19 |
+
if (!function_exists('curl_init')) {
|
20 |
+
throw new Exception('BcashLibrary: cURL library is required.');
|
21 |
+
}
|
22 |
+
|
23 |
+
$this->timeout = $timeout;
|
24 |
+
}
|
25 |
+
|
26 |
+
public function post(PostRequest $request)
|
27 |
+
{
|
28 |
+
$ch = curl_init();
|
29 |
+
|
30 |
+
curl_setopt($ch, CURLOPT_URL, $request->getUrl());
|
31 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $request->getHeaders());
|
32 |
+
curl_setopt($ch, CURLOPT_POST, count($request->getContent()));
|
33 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $request->getContent());
|
34 |
+
|
35 |
+
return $this->send($ch);
|
36 |
+
}
|
37 |
+
|
38 |
+
public function get(GetRequest $request)
|
39 |
+
{
|
40 |
+
$ch = curl_init();
|
41 |
+
|
42 |
+
curl_setopt($ch, CURLOPT_URL, $request->getUrl());
|
43 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $request->getHeaders());
|
44 |
+
|
45 |
+
return $this->send($ch);
|
46 |
+
}
|
47 |
+
|
48 |
+
public function put(PutRequest $request)
|
49 |
+
{
|
50 |
+
$ch = curl_init();
|
51 |
+
|
52 |
+
curl_setopt($ch, CURLOPT_URL, $request->getUrl());
|
53 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $request->getHeaders());
|
54 |
+
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
|
55 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $request->getContent());
|
56 |
+
|
57 |
+
return $this->send($ch);
|
58 |
+
}
|
59 |
+
|
60 |
+
|
61 |
+
private function send($ch)
|
62 |
+
{
|
63 |
+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->timeout);
|
64 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
65 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
66 |
+
curl_setopt($ch, CURLOPT_USERAGENT, self::USER_AGENT);
|
67 |
+
|
68 |
+
$response = new Response(curl_exec($ch), curl_getinfo($ch, CURLINFO_HTTP_CODE));
|
69 |
+
$response = $this->responseResolver($response, $ch);
|
70 |
+
|
71 |
+
curl_close($ch);
|
72 |
+
|
73 |
+
return $response;
|
74 |
+
}
|
75 |
+
|
76 |
+
private function responseResolver(Response $response, $ch)
|
77 |
+
{
|
78 |
+
if ($response->isOK()) {
|
79 |
+
return $response;
|
80 |
+
}
|
81 |
+
|
82 |
+
if ($response->isBadRequest()) {
|
83 |
+
throw new ValidationException(HttpHelper::fromJson($response->getContent()));
|
84 |
+
}
|
85 |
+
|
86 |
+
throw new ConnectionException(HttpHelper::fromJson($response->getContent()), curl_error($ch));
|
87 |
+
}
|
88 |
+
|
89 |
+
}
|
lib/BcashApi/src/Http/GetRequest.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Http;
|
4 |
+
|
5 |
+
class GetRequest
|
6 |
+
{
|
7 |
+
private $url;
|
8 |
+
private $headers;
|
9 |
+
private $params;
|
10 |
+
|
11 |
+
public function __construct($url)
|
12 |
+
{
|
13 |
+
$this->headers = Array();
|
14 |
+
$this->params = Array();
|
15 |
+
$this->url = $url;
|
16 |
+
}
|
17 |
+
|
18 |
+
public function setUrl($url)
|
19 |
+
{
|
20 |
+
$this->url = $url;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function getUrl()
|
24 |
+
{
|
25 |
+
return $this->url;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function addHeader($header)
|
29 |
+
{
|
30 |
+
array_push($this->headers, $header);
|
31 |
+
}
|
32 |
+
|
33 |
+
public function getHeaders()
|
34 |
+
{
|
35 |
+
return $this->headers;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function addParam($name, $value)
|
39 |
+
{
|
40 |
+
$this->params[$name] = $value;
|
41 |
+
}
|
42 |
+
|
43 |
+
public function getParams()
|
44 |
+
{
|
45 |
+
return $this->params;
|
46 |
+
}
|
47 |
+
|
48 |
+
}
|
lib/BcashApi/src/Http/PostRequest.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Http;
|
4 |
+
|
5 |
+
class PostRequest
|
6 |
+
{
|
7 |
+
private $url;
|
8 |
+
private $headers;
|
9 |
+
private $params;
|
10 |
+
private $content;
|
11 |
+
|
12 |
+
public function __construct($url)
|
13 |
+
{
|
14 |
+
$this->headers = Array();
|
15 |
+
$this->params = Array();
|
16 |
+
$this->url = $url;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function setUrl($url)
|
20 |
+
{
|
21 |
+
$this->url = $url;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getUrl()
|
25 |
+
{
|
26 |
+
return $this->url;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function addHeader($header)
|
30 |
+
{
|
31 |
+
array_push($this->headers, $header);
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getHeaders()
|
35 |
+
{
|
36 |
+
return $this->headers;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function addParam($name, $value)
|
40 |
+
{
|
41 |
+
$this->params[$name] = $value;
|
42 |
+
}
|
43 |
+
|
44 |
+
public function getParams()
|
45 |
+
{
|
46 |
+
return $this->params;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function setContent($content)
|
50 |
+
{
|
51 |
+
$this->content = $content;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getContent()
|
55 |
+
{
|
56 |
+
return $this->content;
|
57 |
+
}
|
58 |
+
}
|
lib/BcashApi/src/Http/PutRequest.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Http;
|
4 |
+
|
5 |
+
class PutRequest
|
6 |
+
{
|
7 |
+
private $url;
|
8 |
+
private $headers;
|
9 |
+
private $params;
|
10 |
+
private $content;
|
11 |
+
|
12 |
+
public function __construct($url)
|
13 |
+
{
|
14 |
+
$this->headers = Array();
|
15 |
+
$this->params = Array();
|
16 |
+
$this->url = $url;
|
17 |
+
}
|
18 |
+
|
19 |
+
public function setUrl($url)
|
20 |
+
{
|
21 |
+
$this->url = $url;
|
22 |
+
}
|
23 |
+
|
24 |
+
public function getUrl()
|
25 |
+
{
|
26 |
+
return $this->url;
|
27 |
+
}
|
28 |
+
|
29 |
+
public function addHeader($header)
|
30 |
+
{
|
31 |
+
array_push($this->headers, $header);
|
32 |
+
}
|
33 |
+
|
34 |
+
public function getHeaders()
|
35 |
+
{
|
36 |
+
return $this->headers;
|
37 |
+
}
|
38 |
+
|
39 |
+
public function addParam($name, $value)
|
40 |
+
{
|
41 |
+
$this->params[$name] = $value;
|
42 |
+
}
|
43 |
+
|
44 |
+
public function getParams()
|
45 |
+
{
|
46 |
+
return $this->params;
|
47 |
+
}
|
48 |
+
|
49 |
+
public function setContent($content)
|
50 |
+
{
|
51 |
+
$this->content = $content;
|
52 |
+
}
|
53 |
+
|
54 |
+
public function getContent()
|
55 |
+
{
|
56 |
+
return $this->content;
|
57 |
+
}
|
58 |
+
}
|
lib/BcashApi/src/Http/Response.php
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Http;
|
4 |
+
|
5 |
+
class Response
|
6 |
+
{
|
7 |
+
private static $OK = 200;
|
8 |
+
private static $BAD_REQUEST = 400;
|
9 |
+
private $code;
|
10 |
+
private $content;
|
11 |
+
|
12 |
+
public function __construct($content, $code)
|
13 |
+
{
|
14 |
+
$this->content = $content;
|
15 |
+
$this->code = $code;
|
16 |
+
}
|
17 |
+
|
18 |
+
public function getCode()
|
19 |
+
{
|
20 |
+
return $this->code;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function getContent()
|
24 |
+
{
|
25 |
+
return $this->content;
|
26 |
+
}
|
27 |
+
|
28 |
+
public function isOK()
|
29 |
+
{
|
30 |
+
return isset($this->code) && ($this->code == self::$OK);
|
31 |
+
}
|
32 |
+
|
33 |
+
public function isFail()
|
34 |
+
{
|
35 |
+
return $this->content === false;
|
36 |
+
}
|
37 |
+
|
38 |
+
public function isBadRequest()
|
39 |
+
{
|
40 |
+
return isset($this->code) && ($this->code == self::$BAD_REQUEST);
|
41 |
+
}
|
42 |
+
|
43 |
+
}
|
lib/BcashApi/src/Service/Account.php
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Service;
|
4 |
+
|
5 |
+
use Bcash\Service\IEnvironmentManager;
|
6 |
+
use Bcash\Http\PostRequest;
|
7 |
+
use Bcash\Config\Config;
|
8 |
+
use Bcash\Http\Authentication\Basic;
|
9 |
+
use Bcash\Helper\HttpHelper;
|
10 |
+
use Bcash\Http\Connection;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Cliente para busca de contas
|
14 |
+
*
|
15 |
+
*/
|
16 |
+
class Account implements IEnvironmentManager
|
17 |
+
{
|
18 |
+
const route = "/searchAccount/json";
|
19 |
+
private $email;
|
20 |
+
private $token;
|
21 |
+
private $url;
|
22 |
+
|
23 |
+
public function __construct($email, $token)
|
24 |
+
{
|
25 |
+
$this->email = $email;
|
26 |
+
$this->token = $token;
|
27 |
+
$this->url = Config::host . self::route;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Busca todas a contas vinculadas com o CPF informado.
|
32 |
+
*
|
33 |
+
* @param cpf
|
34 |
+
* CPF utilizado para a busca.
|
35 |
+
* @return Objeto que contém informações da busca e uma lista de contas
|
36 |
+
* @throws AccountException
|
37 |
+
* exceção em caso de de erro na busca da conta.
|
38 |
+
*/
|
39 |
+
public function searchBy($cpf)
|
40 |
+
{
|
41 |
+
$request = $this->generateRequest($cpf);
|
42 |
+
$response = $this->send($request);
|
43 |
+
|
44 |
+
return HttpHelper::fromJson($response->getContent());
|
45 |
+
}
|
46 |
+
|
47 |
+
private function generateRequest($cpf)
|
48 |
+
{
|
49 |
+
$request = new PostRequest($this->url);
|
50 |
+
|
51 |
+
$basic = new Basic();
|
52 |
+
$request->addHeader($basic->generateHeader($this->email, $this->token));
|
53 |
+
$request->addHeader("Content-Type:application/x-www-form-urlencoded;charset=" . Config::charset);
|
54 |
+
|
55 |
+
$obj = new \stdClass;
|
56 |
+
$obj->cpf = $cpf;
|
57 |
+
|
58 |
+
$parameters = array("data"=> json_encode($obj), "version" => "1.0");
|
59 |
+
$request->setContent(HttpHelper::toQueryString($parameters));
|
60 |
+
|
61 |
+
return $request;
|
62 |
+
}
|
63 |
+
|
64 |
+
private function send($request)
|
65 |
+
{
|
66 |
+
$connection = new Connection(Config::timeout);
|
67 |
+
$response = $connection->post($request);
|
68 |
+
|
69 |
+
return $response;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function enableSandBox($bool)
|
73 |
+
{
|
74 |
+
$this->url = Config::host . self::route;
|
75 |
+
|
76 |
+
if ($bool) {
|
77 |
+
$this->url = Config::hostSandBox . self::route;
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
}
|
lib/BcashApi/src/Service/Cancellation.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Service;
|
4 |
+
|
5 |
+
use Bcash\Service\IEnvironmentManager;
|
6 |
+
use Bcash\Http\Authentication\Basic;
|
7 |
+
use Bcash\Http\PostRequest;
|
8 |
+
use Bcash\Helper\HttpHelper;
|
9 |
+
use Bcash\Http\Connection;
|
10 |
+
use Bcash\Config\Config;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Cliente para o serviço de cancelamento de transação.
|
14 |
+
*
|
15 |
+
*/
|
16 |
+
class Cancellation implements IEnvironmentManager
|
17 |
+
{
|
18 |
+
const route = "/transactions/%s/cancel";
|
19 |
+
private $email;
|
20 |
+
private $token;
|
21 |
+
private $url;
|
22 |
+
|
23 |
+
public function __construct($email, $token)
|
24 |
+
{
|
25 |
+
$this->email = $email;
|
26 |
+
$this->token = $token;
|
27 |
+
$this->url = Config::host . self::route;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Cancela a transação informada.
|
32 |
+
*
|
33 |
+
* @param id_transacao
|
34 |
+
* Id da transação no Bcash a ser cancelada.
|
35 |
+
*/
|
36 |
+
public function execute($transactionId)
|
37 |
+
{
|
38 |
+
$request = $this->generateRequest($transactionId);
|
39 |
+
$response = $this->send($request);
|
40 |
+
|
41 |
+
return HttpHelper::fromJson($response->getContent());
|
42 |
+
}
|
43 |
+
|
44 |
+
private function generateRequest($transactionId)
|
45 |
+
{
|
46 |
+
$request = new PostRequest($this->url);
|
47 |
+
|
48 |
+
$basic = new Basic();
|
49 |
+
$request->addHeader($basic->generateHeader($this->email, $this->token));
|
50 |
+
$request->addHeader("Content-Type:application/json;charset=".Config::charset);
|
51 |
+
|
52 |
+
$request->setUrl(vsprintf($this->url, $transactionId));
|
53 |
+
|
54 |
+
return $request;
|
55 |
+
}
|
56 |
+
|
57 |
+
private function send($request)
|
58 |
+
{
|
59 |
+
$connection = new Connection(Config::timeout);
|
60 |
+
$response = $connection->post($request);
|
61 |
+
|
62 |
+
return $response;
|
63 |
+
}
|
64 |
+
|
65 |
+
public function enableSandBox($bool)
|
66 |
+
{
|
67 |
+
$this->url = Config::host . self::route;
|
68 |
+
|
69 |
+
if ($bool) {
|
70 |
+
$this->url = Config::hostSandBox . self::route;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
lib/BcashApi/src/Service/Consultation.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Service;
|
4 |
+
|
5 |
+
use Bcash\Service\IEnvironmentManager;
|
6 |
+
use Bcash\Http\PostRequest;
|
7 |
+
use Bcash\Config\Config;
|
8 |
+
use Bcash\Http\Authentication\Basic;
|
9 |
+
use Bcash\Helper\HttpHelper;
|
10 |
+
use Bcash\Http\Connection;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Cliente para consulta de transações.
|
14 |
+
*
|
15 |
+
*/
|
16 |
+
class Consultation implements IEnvironmentManager
|
17 |
+
{
|
18 |
+
const route = "/transacao/consulta";
|
19 |
+
private $email;
|
20 |
+
private $token;
|
21 |
+
private $url;
|
22 |
+
|
23 |
+
public function __construct($email, $token)
|
24 |
+
{
|
25 |
+
$this->email = $email;
|
26 |
+
$this->token = $token;
|
27 |
+
$this->url = Config::siteHost . self::route;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Busca os dados da transação pelo id da transação no Bcash.
|
32 |
+
*
|
33 |
+
* @param id_transacao
|
34 |
+
* Id da transação no Bcash a ser consultada.
|
35 |
+
* @return Objeto que contém informações da busca
|
36 |
+
*/
|
37 |
+
public function searchByTransaction($id_transacao)
|
38 |
+
{
|
39 |
+
$request = $this->generateRequest("id_transacao", $id_transacao);
|
40 |
+
$response = $this->send($request);
|
41 |
+
|
42 |
+
return HttpHelper::fromJson($response->getContent());
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Busca os dados da transação pelo id do pedido.
|
47 |
+
*
|
48 |
+
* @param id_pedido
|
49 |
+
* Id do pedido a ser consultado.
|
50 |
+
* @return Objeto que contém informações da busca
|
51 |
+
*/
|
52 |
+
public function searchByOrder($id_pedido)
|
53 |
+
{
|
54 |
+
$request = $this->generateRequest("id_pedido", $id_pedido);
|
55 |
+
$response = $this->send($request);
|
56 |
+
|
57 |
+
return HttpHelper::fromJson($response->getContent());
|
58 |
+
}
|
59 |
+
|
60 |
+
private function generateRequest($param, $value)
|
61 |
+
{
|
62 |
+
$request = new PostRequest($this->url);
|
63 |
+
|
64 |
+
$basic = new Basic();
|
65 |
+
$request->addHeader($basic->generateHeader($this->email, $this->token));
|
66 |
+
|
67 |
+
$parameters = array($param => $value, "codificacao" => Config::charset, "tipo_retorno" => 2);
|
68 |
+
$request->setContent(HttpHelper::toQueryString($parameters));
|
69 |
+
|
70 |
+
return $request;
|
71 |
+
}
|
72 |
+
|
73 |
+
private function send($request)
|
74 |
+
{
|
75 |
+
$connection = new Connection(Config::timeout);
|
76 |
+
$response = $connection->post($request);
|
77 |
+
|
78 |
+
return $response;
|
79 |
+
}
|
80 |
+
|
81 |
+
public function enableSandBox($bool)
|
82 |
+
{
|
83 |
+
$this->url = Config::siteHost . self::route;
|
84 |
+
|
85 |
+
if ($bool) {
|
86 |
+
$this->url = Config::siteHostSandBox . self::route;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
}
|
lib/BcashApi/src/Service/IEnvironmentManager.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Service;
|
4 |
+
|
5 |
+
/**
|
6 |
+
*
|
7 |
+
* Interface para gerenciar o ambiente de execução dos serviços
|
8 |
+
*
|
9 |
+
* @author Leonardo Tonin Neto
|
10 |
+
*
|
11 |
+
*/
|
12 |
+
interface IEnvironmentManager
|
13 |
+
{
|
14 |
+
public function enableSandBox($bool);
|
15 |
+
}
|
lib/BcashApi/src/Service/Installments.php
ADDED
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Service;
|
4 |
+
|
5 |
+
use Bcash\Service\IEnvironmentManager;
|
6 |
+
use Bcash\Http\GetRequest;
|
7 |
+
use Bcash\Config\Config;
|
8 |
+
use Bcash\Http\Authentication\Basic;
|
9 |
+
use Bcash\Helper\HttpHelper;
|
10 |
+
use Bcash\Http\Connection;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Cliente para consulta de parcelamento
|
14 |
+
*
|
15 |
+
*/
|
16 |
+
class Installments implements IEnvironmentManager
|
17 |
+
{
|
18 |
+
const route = "/installments";
|
19 |
+
private $email;
|
20 |
+
private $token;
|
21 |
+
private $url;
|
22 |
+
|
23 |
+
public function __construct($email, $token)
|
24 |
+
{
|
25 |
+
$this->email = $email;
|
26 |
+
$this->token = $token;
|
27 |
+
$this->url = Config::host . self::route;
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Chama o serviço de cálculo de parcelas.
|
32 |
+
*
|
33 |
+
* @param amount
|
34 |
+
* Valor para o cálculo.
|
35 |
+
* @param max
|
36 |
+
* Máximo de parcelas aceito.
|
37 |
+
* @return Objeto que contém as formas de parcelamento calculadas
|
38 |
+
* @throws InstallmentException
|
39 |
+
* exceção em caso de na consulta.
|
40 |
+
*/
|
41 |
+
public function calculate($amount, $max = null, $ignoreScheduledDiscount = null)
|
42 |
+
{
|
43 |
+
$request = $this->generateRequest($amount, $max, $ignoreScheduledDiscount);
|
44 |
+
$response = $this->send($request);
|
45 |
+
|
46 |
+
return HttpHelper::fromJson($response->getContent());
|
47 |
+
}
|
48 |
+
|
49 |
+
private function generateRequest($amount, $max, $ignoreScheduledDiscount)
|
50 |
+
{
|
51 |
+
$request = new GetRequest($this->url);
|
52 |
+
|
53 |
+
$basic = new Basic();
|
54 |
+
$request->addHeader($basic->generateHeader($this->email, $this->token));
|
55 |
+
$request->addHeader("Content-Type:application/x-www-form-urlencoded;charset=" . Config::charset);
|
56 |
+
$request->addParam("amount", $amount);
|
57 |
+
|
58 |
+
if ($max != null) {
|
59 |
+
$request->addParam("maxInstallments", $max);
|
60 |
+
}
|
61 |
+
|
62 |
+
$request->addParam("ignoreScheduledDiscount", 0);
|
63 |
+
|
64 |
+
if ($ignoreScheduledDiscount === true){
|
65 |
+
$request->addParam("ignoreScheduledDiscount", 1);
|
66 |
+
}
|
67 |
+
|
68 |
+
$request->setUrl($this->url . "?" . http_build_query($request->getParams(), '', '&'));
|
69 |
+
|
70 |
+
return $request;
|
71 |
+
}
|
72 |
+
|
73 |
+
private function send($request)
|
74 |
+
{
|
75 |
+
$connection = new Connection(Config::timeout);
|
76 |
+
$response = $connection->get($request);
|
77 |
+
|
78 |
+
return $response;
|
79 |
+
}
|
80 |
+
|
81 |
+
public function enableSandBox($bool)
|
82 |
+
{
|
83 |
+
$this->url = Config::host . self::route;
|
84 |
+
|
85 |
+
if ($bool) {
|
86 |
+
$this->url = Config::hostSandBox . self::route;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
|
90 |
+
}
|
lib/BcashApi/src/Service/Notification.php
ADDED
@@ -0,0 +1,93 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Service;
|
4 |
+
|
5 |
+
use Bcash\Service\Consultation;
|
6 |
+
use Bcash\Domain\NotificationContent;
|
7 |
+
|
8 |
+
class Notification implements IEnvironmentManager
|
9 |
+
{
|
10 |
+
private $email;
|
11 |
+
private $token;
|
12 |
+
private $notificationContent;
|
13 |
+
private $transaction;
|
14 |
+
private $sandBox;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @param email
|
18 |
+
* Email da conta do lojista no bcash para autenticação.
|
19 |
+
* @param token
|
20 |
+
* Token da conta do lojista no bcash para autenticação.
|
21 |
+
* @param Array notificationContent
|
22 |
+
* Conteúdo recebido na notificação
|
23 |
+
*/
|
24 |
+
public function __construct($email, $token, NotificationContent $notificationContent)
|
25 |
+
{
|
26 |
+
$this->email = $email;
|
27 |
+
$this->token = $token;
|
28 |
+
|
29 |
+
if (empty($notificationContent)) {
|
30 |
+
$notificationContent = $_POST;
|
31 |
+
}
|
32 |
+
|
33 |
+
$this->sandBox = false;
|
34 |
+
$this->notificationContent = $notificationContent;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Valida a notificação recebida
|
39 |
+
* @param transactionValue
|
40 |
+
* Soma de todos os produtos + frete + acrescimos - descontos.
|
41 |
+
* @return boolean indicando se a notificação é ou não válida.
|
42 |
+
*/
|
43 |
+
public function verify($transactionValue)
|
44 |
+
{
|
45 |
+
$this->getTransaction();
|
46 |
+
|
47 |
+
if (!$this->compareStatus() || !$this->compareValue($transactionValue) || !$this->compareOrder()) {
|
48 |
+
return false;
|
49 |
+
}
|
50 |
+
|
51 |
+
return true;
|
52 |
+
}
|
53 |
+
|
54 |
+
private function compareValue($value)
|
55 |
+
{
|
56 |
+
$consultado = $this->transaction->valor_original;
|
57 |
+
return $consultado == $value;
|
58 |
+
}
|
59 |
+
|
60 |
+
private function compareStatus()
|
61 |
+
{
|
62 |
+
$consultado = $this->transaction->cod_status;
|
63 |
+
$recebido = $this->notificationContent->getStatus();
|
64 |
+
return $consultado == $recebido;
|
65 |
+
}
|
66 |
+
|
67 |
+
private function compareOrder()
|
68 |
+
{
|
69 |
+
$consultado = $this->transaction->id_pedido;
|
70 |
+
$recebido = $this->notificationContent->getPedido();
|
71 |
+
return $consultado == $recebido;
|
72 |
+
}
|
73 |
+
|
74 |
+
private function getTransaction()
|
75 |
+
{
|
76 |
+
if (!empty($transaction)) {
|
77 |
+
return;
|
78 |
+
}
|
79 |
+
|
80 |
+
$consultation = new Consultation($this->email, $this->token);
|
81 |
+
$consultation->enableSandBox($this->sandBox);
|
82 |
+
$this->transaction = $consultation->searchByTransaction($this->notificationContent->getIdTransaction());
|
83 |
+
$this->transaction = $this->transaction->transacao;
|
84 |
+
}
|
85 |
+
|
86 |
+
public function enableSandBox($bool)
|
87 |
+
{
|
88 |
+
if ($bool) {
|
89 |
+
$this->sandBox = true;
|
90 |
+
}
|
91 |
+
}
|
92 |
+
|
93 |
+
}
|
lib/BcashApi/src/Service/Payment.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Service;
|
4 |
+
|
5 |
+
use Bcash\Service\IEnvironmentManager;
|
6 |
+
use Bcash\Http\Authentication\OAuth;
|
7 |
+
use Bcash\Http\PostRequest;
|
8 |
+
use Bcash\Helper\HttpHelper;
|
9 |
+
use Bcash\Http\Connection;
|
10 |
+
use Bcash\Domain\TransactionRequest;
|
11 |
+
use Bcash\Config\Config;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Cliente para serviços de criação de transação.
|
15 |
+
*
|
16 |
+
*/
|
17 |
+
class Payment implements IEnvironmentManager
|
18 |
+
{
|
19 |
+
const route = "/createTransaction/json";
|
20 |
+
private $consumer_key;
|
21 |
+
private $url;
|
22 |
+
|
23 |
+
public function __construct($consumer_key)
|
24 |
+
{
|
25 |
+
$this->consumer_key = $consumer_key;
|
26 |
+
$this->url = Config::host . self::route;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Cria uma transação a partir dos dados informados.
|
31 |
+
*
|
32 |
+
* @param request
|
33 |
+
* Objeto que contém informações para a criação da transação
|
34 |
+
*/
|
35 |
+
public function create(TransactionRequest $transactionRequest)
|
36 |
+
{
|
37 |
+
$request = $this->generateRequest($transactionRequest);
|
38 |
+
$response = $this->send($request);
|
39 |
+
|
40 |
+
return HttpHelper::fromJson($response->getContent());
|
41 |
+
}
|
42 |
+
|
43 |
+
private function generateRequest(TransactionRequest $transactionRequest)
|
44 |
+
{
|
45 |
+
$request = new PostRequest($this->url);
|
46 |
+
|
47 |
+
$oAuth = new OAuth();
|
48 |
+
$request->addHeader($oAuth->generateHeader($this->consumer_key));
|
49 |
+
$request->addHeader("Content-Type:application/x-www-form-urlencoded;charset=".Config::charset);
|
50 |
+
$parameters = array("data"=> json_encode($transactionRequest->toArray()), "version" => "1.0");
|
51 |
+
$request->setContent(HttpHelper::toQueryString($parameters));
|
52 |
+
|
53 |
+
return $request;
|
54 |
+
}
|
55 |
+
|
56 |
+
private function send($request)
|
57 |
+
{
|
58 |
+
$connection = new Connection(Config::timeout);
|
59 |
+
$response = $connection->post($request);
|
60 |
+
|
61 |
+
return $response;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function enableSandBox($bool)
|
65 |
+
{
|
66 |
+
$this->url = Config::host . self::route;
|
67 |
+
|
68 |
+
if ($bool) {
|
69 |
+
$this->url = Config::hostSandBox . self::route;
|
70 |
+
}
|
71 |
+
}
|
72 |
+
}
|
lib/BcashApi/src/Test/NotificationSimulator.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace Bcash\Test;
|
4 |
+
|
5 |
+
use Bcash\Http\PostRequest;
|
6 |
+
use Bcash\Http\Connection;
|
7 |
+
use Bcash\Helper\HttpHelper;
|
8 |
+
use Bcash\Config\Config;
|
9 |
+
use Bcash\Domain\NotificationStatusEnum;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Classe para simular a notificação do bcash.
|
13 |
+
*
|
14 |
+
*/
|
15 |
+
class NotificationSimulator
|
16 |
+
{
|
17 |
+
|
18 |
+
public static $STATUS_DESCRIPTION = array(
|
19 |
+
1 => "Em andamento",
|
20 |
+
3 => "Aprovada",
|
21 |
+
4 => "Concluída",
|
22 |
+
5 => "Disputa",
|
23 |
+
6 => "Devolvida",
|
24 |
+
7 => "Cancelada",
|
25 |
+
8 => "Chargeback"
|
26 |
+
);
|
27 |
+
|
28 |
+
public static function test($urlAviso, $id_transacao, $id_pedido, $id_status)
|
29 |
+
{
|
30 |
+
$request = new PostRequest($urlAviso);
|
31 |
+
$parameters = array(
|
32 |
+
"transacao_id" => $id_transacao,
|
33 |
+
"pedido" => $id_pedido,
|
34 |
+
"status_id" => $id_status,
|
35 |
+
"status" => self::$STATUS_DESCRIPTION[$id_status]
|
36 |
+
);
|
37 |
+
|
38 |
+
$request->setContent(HttpHelper::toQueryString($parameters));
|
39 |
+
|
40 |
+
$response = self::send($request);
|
41 |
+
return $response;
|
42 |
+
}
|
43 |
+
|
44 |
+
private static function send($request)
|
45 |
+
{
|
46 |
+
$ch = curl_init();
|
47 |
+
|
48 |
+
curl_setopt($ch, CURLOPT_URL, $request->getUrl());
|
49 |
+
curl_setopt($ch, CURLOPT_POST, count($request->getContent()));
|
50 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $request->getContent());
|
51 |
+
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, Config::timeout);
|
52 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
53 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
|
54 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
55 |
+
|
56 |
+
$result = curl_exec($ch);
|
57 |
+
|
58 |
+
$response = new \StdClass;
|
59 |
+
|
60 |
+
if ($result === false) {
|
61 |
+
$response->message = 'Curl error: ' . curl_error($ch);
|
62 |
+
return $response;
|
63 |
+
}
|
64 |
+
|
65 |
+
$response->code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
66 |
+
|
67 |
+
curl_close($ch);
|
68 |
+
|
69 |
+
if ($response->code == 200) {
|
70 |
+
$response->message = "Request successfully delivered: " . $request->getContent() . " for URL " . $request->getUrl();
|
71 |
+
return $response;
|
72 |
+
}
|
73 |
+
|
74 |
+
if ($response->code == 404) {
|
75 |
+
$response->message = "Url not found: " . $request->getUrl();
|
76 |
+
return $response;
|
77 |
+
}
|
78 |
+
|
79 |
+
return $response;
|
80 |
+
}
|
81 |
+
|
82 |
+
}
|
83 |
+
|
package.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Bcash_Pagamento</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>GNU General Public License (GPL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Módulo para Magento Bcash Transparente (API)</summary>
|
10 |
+
<description>Módulo para Magento Bcash Transparente (API)</description>
|
11 |
+
<notes>- Checkout transparente com API Bcash;
|
12 |
+
- Estorno/Cancelamento de pagamento diretamente no Bcash;
|
13 |
+
- Atualização automática de status do pagamento.</notes>
|
14 |
+
<authors><author><name>Bcash</name><user>Bcash</user><email>danilo.benedetti@bcash.com.br</email></author></authors>
|
15 |
+
<date>2015-10-08</date>
|
16 |
+
<time>20:40:14</time>
|
17 |
+
<contents><target name="magecommunity"><dir name="Bcash"><dir name="Pagamento"><dir name="Block"><dir name="Adminhtml"><file name="Dependentes.php" hash="817d7116d5ab890b5525a7185100ab37"/><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="ce5a4c048d7579d00640a06635c68790"/><file name="View.php" hash="ec2e6d2af5eb75cd727cb8923ee7d06a"/></dir></dir></dir><dir name="Form"><file name="Payment.php" hash="6e4147ecf10be00f598601160a27ce2c"/></dir><dir name="Info"><file name="Payment.php" hash="7df027e4d1c5819454778ebe535828cf"/></dir></dir><dir name="Helper"><file name="Data.php" hash="720a98734461aebde16b0753b48e699b"/><file name="PaymentMethod.php" hash="1fe0aa7851a9ba7f4f195869841defc3"/><file name="Transaction.php" hash="9bbfdd2dc9d982a22aeb917702dc0c69"/></dir><dir name="Model"><file name="Observer.php" hash="51a6c9bf70be31f406213d5f58e0812e"/><file name="Order.php" hash="e82596b3ad50673719e88d65597995d9"/><file name="PaymentMethod.php" hash="2365de778dc2187456a19ca71a45badb"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Installments.php" hash="5fae970a6cb83b5be079c5762b8e214d"/></dir></dir></dir></dir><dir name="controllers"><dir name="Admin"><dir name="Sales"><file name="OrderController.php" hash="f5e28688b10de3a386632ffe9db53dec"/></dir></dir><file name="NotificationController.php" hash="ade9f612e7b4fb55575a4eb7c3f26274"/><file name="PaymentController.php" hash="f1a7cb9ad8a36c035843fca0932a2959"/></dir><dir name="etc"><file name="config.xml" hash="a47ffcb9c303eb0fcb72b6d38cff23ea"/><file name="system.xml" hash="445170483c052ee95127df17723ca561"/></dir><dir name="sql"><dir name="pagamento_setup"><file name="mysql4-install-0.1.0.php" hash="51ff3e257bb67b19c92f05793617b225"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="bcash"><dir name="pagamento"><file name="layout.xml" hash="5e15451eac5922ec1fc48f0b703bf09c"/></dir></dir></dir><dir name="template"><dir name="pagamento"><dir name="checkout"><file name="success.phtml" hash="b05ea8293726da56f3e5007740d2872f"/></dir><dir name="form"><file name="payment.phtml" hash="0cd4c6a5cda187622931867e083f6405"/></dir><dir name="sales"><dir name="order"><dir name="info"><dir name="buttons"><file name="payment.phtml" hash="218fcb385c5c7c643967a69b23b62896"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Bcash_Pagamento.xml" hash="3dd07f527dbcd104762897d392acb31b"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="bcash"><dir name="pagamento"><dir name="css"><file name="application.css" hash="34b84ab770c9d29b95ab2244256a63e7"/></dir><dir name="images"><file name="application-sprite.png" hash="2c6c670b3ca8f7eb783f874bd387527e"/></dir><dir name="js"><file name="payment.js" hash="c0124aabf6a91849c0aa7db6cea6a471"/></dir></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="BcashApi"><dir name="src"><file name="AutoLoader.php" hash="d661e36286a54d06a36cc13ed62379d1"/><dir name="Config"><file name="Config.php" hash="027627d0781a1a6842ab2b6f7cb13512"/></dir><dir name="Domain"><file name="Address.php" hash="ebc176d33ba79ac46cf59561f479919f"/><file name="CreditCard.php" hash="bcf12a466ab99f25da348a93c2e7f995"/><file name="CurrencyEnum.php" hash="c2097c3796e8ab354a9b61ce1bb9c70e"/><file name="Customer.php" hash="68f056140a92bfb9a7534ced54939d44"/><file name="DependentTransaction.php" hash="2553d6ed93f39cb96ef185cbc886311c"/><file name="GenderEnum.php" hash="11377e531d5914b232b99f8cee61e61c"/><file name="Model.php" hash="f1b7fe3fb7384852f16f4b6931fc8545"/><file name="NotificationContent.php" hash="52b6ad7894c455dd4f4c199fdaf1fad3"/><file name="NotificationStatusEnum.php" hash="1635e03b18f7de30fd6bd80a7ff4f4d4"/><file name="PaymentMethod.php" hash="86fbfc29bc8671a4617f51a36031eba4"/><file name="PaymentMethodEnum.php" hash="d0deaeac659f54826bb38aa94d7f5c34"/><file name="Product.php" hash="674e7475e0555e9f2f592c7931098144"/><file name="ShippingTypeEnum.php" hash="4849b2ff3bf4294285e1d2e51d5226ea"/><file name="StateEnum.php" hash="75080122c0eb3807dcca92e064ff5d1d"/><file name="TransactionRequest.php" hash="f1e29973341750cca57dfac7f1496355"/></dir><dir name="Exception"><file name="BaseException.php" hash="e4d5637be15c9939cedb80b6aa54418e"/><file name="ConnectionException.php" hash="421fb7fbab02fe882a00765cc9cff569"/><file name="ValidationException.php" hash="03379f9626fcb19694a3662395da755f"/></dir><dir name="Helper"><file name="HttpHelper.php" hash="3ee5690f7eb45974cf888128643b2700"/></dir><dir name="Http"><dir name="Authentication"><file name="Basic.php" hash="b9ca27226db5535b70edea699d6d2e55"/><file name="OAuth.php" hash="92e6d135821380337561ace5572b8f9a"/></dir><file name="Connection.php" hash="381b6f242da04ef4c68691e70a3118b5"/><file name="GetRequest.php" hash="bbb366a1fb1396cd53e7976740880351"/><file name="PostRequest.php" hash="9e425ddf0278e72ffbb3b7369e18359d"/><file name="PutRequest.php" hash="7da14392d43109682f7373e8d4b12660"/><file name="Response.php" hash="f941571206e14c8251373168b08e297f"/></dir><dir name="Service"><file name="Account.php" hash="1e62bbf14e84348bb4b08a37ca843dfb"/><file name="Cancellation.php" hash="e1931a4e0bc1e66006670645336d93f4"/><file name="Consultation.php" hash="8c4fb3a25d9ffa418aad36cce99cab12"/><file name="IEnvironmentManager.php" hash="05668b184b91a5895f8308e5dc02d422"/><file name="Installments.php" hash="101e7aa5aace7e618156c3152aa894c8"/><file name="Notification.php" hash="550b7ee0fea57d7ac30c4648c9896c39"/><file name="Payment.php" hash="87a8184a928e04f56b6b9d796a6e9806"/></dir><dir name="Test"><file name="NotificationSimulator.php" hash="de77ea4d3c4c656a1dafd77f944aafbe"/></dir></dir><file name="autoloader.php" hash="9d6567ac5239179a52d4fa8c1d3542f0"/></dir></target></contents>
|
18 |
+
<compatible/>
|
19 |
+
<dependencies><required><php><min>5.3.0</min><max>5.6.14</max></php></required></dependencies>
|
20 |
+
</package>
|
skin/frontend/base/default/bcash/pagamento/css/application.css
ADDED
@@ -0,0 +1,648 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.payment-group *,
|
2 |
+
.payment-group *:before,
|
3 |
+
.payment-group *:after {
|
4 |
+
box-sizing: border-box;
|
5 |
+
}
|
6 |
+
|
7 |
+
.payment-group {
|
8 |
+
font: 14px Arial, Helvetica, sans-serif;
|
9 |
+
}
|
10 |
+
|
11 |
+
.payment-group ul {
|
12 |
+
list-style: none;
|
13 |
+
padding-left: 0px;
|
14 |
+
margin-left: -5px;
|
15 |
+
}
|
16 |
+
|
17 |
+
.payment-group li {
|
18 |
+
display: inline-block;
|
19 |
+
height: 42px;
|
20 |
+
padding: 10px 5px;
|
21 |
+
}
|
22 |
+
|
23 |
+
.payment-group input[type='radio'] {
|
24 |
+
position: absolute;
|
25 |
+
top: 0px;
|
26 |
+
left: 0px;
|
27 |
+
z-index: -1 !important;
|
28 |
+
float: left !important;
|
29 |
+
clear: both !important;
|
30 |
+
margin: 0px !important;
|
31 |
+
padding: 0px !important;
|
32 |
+
width: 0px !important;
|
33 |
+
height: 0px !important;
|
34 |
+
opacity: 0;
|
35 |
+
}
|
36 |
+
|
37 |
+
.bandeira {
|
38 |
+
display: inline-block;
|
39 |
+
background: url(../images/application-sprite.png) no-repeat;
|
40 |
+
width: 70px;
|
41 |
+
height: 46px;
|
42 |
+
text-indent: -9999px;
|
43 |
+
cursor: pointer;
|
44 |
+
}
|
45 |
+
|
46 |
+
|
47 |
+
/* visa */
|
48 |
+
|
49 |
+
.band-1 {
|
50 |
+
background-position: 0 -177px
|
51 |
+
}
|
52 |
+
|
53 |
+
.band-1:hover {
|
54 |
+
border: none;
|
55 |
+
background-position: -74px -177px
|
56 |
+
}
|
57 |
+
|
58 |
+
.payment-group input[type='radio']:checked + .band-1 {
|
59 |
+
background-position: -150px -177px;
|
60 |
+
}
|
61 |
+
|
62 |
+
|
63 |
+
/* master */
|
64 |
+
|
65 |
+
.band-2 {
|
66 |
+
background-position: 0 -226px
|
67 |
+
}
|
68 |
+
|
69 |
+
.band-2:hover {
|
70 |
+
border: none;
|
71 |
+
background-position: -74px -226px
|
72 |
+
}
|
73 |
+
|
74 |
+
.payment-group input[type='radio']:checked + .band-2 {
|
75 |
+
background-position: -150px -226px;
|
76 |
+
}
|
77 |
+
|
78 |
+
|
79 |
+
/* amex */
|
80 |
+
|
81 |
+
.band-37 {
|
82 |
+
background-position: 0 -274px
|
83 |
+
}
|
84 |
+
|
85 |
+
.band-37:hover {
|
86 |
+
border: none;
|
87 |
+
background-position: -74px -274px
|
88 |
+
}
|
89 |
+
|
90 |
+
.payment-group input[type='radio']:checked + .band-37 {
|
91 |
+
background-position: -150px -274px
|
92 |
+
}
|
93 |
+
|
94 |
+
|
95 |
+
/* aura */
|
96 |
+
|
97 |
+
.band-45 {
|
98 |
+
background-position: 0 -323px
|
99 |
+
}
|
100 |
+
|
101 |
+
.band-45:hover {
|
102 |
+
border: none;
|
103 |
+
background-position: -74px -323px
|
104 |
+
}
|
105 |
+
|
106 |
+
.payment-group input[type='radio']:checked + .band-45 {
|
107 |
+
background-position: -150px -323px
|
108 |
+
}
|
109 |
+
|
110 |
+
|
111 |
+
/* diners */
|
112 |
+
|
113 |
+
.band-55 {
|
114 |
+
background-position: 0 -371px
|
115 |
+
}
|
116 |
+
|
117 |
+
.band-55:hover {
|
118 |
+
border: none;
|
119 |
+
background-position: -74px -371px
|
120 |
+
}
|
121 |
+
|
122 |
+
.payment-group input[type='radio']:checked + .band-55 {
|
123 |
+
background-position: -150px -371px
|
124 |
+
}
|
125 |
+
|
126 |
+
|
127 |
+
/* hiper */
|
128 |
+
|
129 |
+
.band-56 {
|
130 |
+
background-position: 0 -420px
|
131 |
+
}
|
132 |
+
|
133 |
+
.band-56:hover {
|
134 |
+
border: none;
|
135 |
+
background-position: -74px -420px
|
136 |
+
}
|
137 |
+
|
138 |
+
.payment-group input[type='radio']:checked + .band-56 {
|
139 |
+
background-position: -150px -420px
|
140 |
+
}
|
141 |
+
|
142 |
+
|
143 |
+
/* elo */
|
144 |
+
|
145 |
+
.band-63 {
|
146 |
+
background-position: 0 -468px
|
147 |
+
}
|
148 |
+
|
149 |
+
.band-63:hover {
|
150 |
+
border: none;
|
151 |
+
background-position: -74px -468px
|
152 |
+
}
|
153 |
+
|
154 |
+
.payment-group input[type='radio']:checked + .band-63 {
|
155 |
+
background-position: -150px -468px
|
156 |
+
}
|
157 |
+
|
158 |
+
|
159 |
+
/* boleto */
|
160 |
+
|
161 |
+
.band-10 {
|
162 |
+
background-position: 0 -517px
|
163 |
+
}
|
164 |
+
|
165 |
+
.band-10:hover {
|
166 |
+
border: none;
|
167 |
+
background-position: -74px -517px
|
168 |
+
}
|
169 |
+
|
170 |
+
.payment-group input[type='radio']:checked + .band-10 {
|
171 |
+
background-position: -150px -517px
|
172 |
+
}
|
173 |
+
|
174 |
+
|
175 |
+
/* bb */
|
176 |
+
|
177 |
+
.band-58 {
|
178 |
+
background-position: 0 -565px
|
179 |
+
}
|
180 |
+
|
181 |
+
.band-58:hover {
|
182 |
+
border: none;
|
183 |
+
background-position: -74px -565px
|
184 |
+
}
|
185 |
+
|
186 |
+
.payment-group input[type='radio']:checked + .band-58 {
|
187 |
+
background-position: -150px -565px
|
188 |
+
}
|
189 |
+
|
190 |
+
|
191 |
+
/* bradesco */
|
192 |
+
|
193 |
+
.band-59 {
|
194 |
+
background-position: 0 -614px
|
195 |
+
}
|
196 |
+
|
197 |
+
.band-59:hover {
|
198 |
+
border: none;
|
199 |
+
background-position: -74px -614px
|
200 |
+
}
|
201 |
+
|
202 |
+
.payment-group input[type='radio']:checked + .band-59 {
|
203 |
+
background-position: -150px -614px
|
204 |
+
}
|
205 |
+
|
206 |
+
|
207 |
+
/* itau */
|
208 |
+
|
209 |
+
.band-60 {
|
210 |
+
background-position: 0 -662px
|
211 |
+
}
|
212 |
+
|
213 |
+
.band-60:hover {
|
214 |
+
border: none;
|
215 |
+
background-position: -74px -662px
|
216 |
+
}
|
217 |
+
|
218 |
+
.payment-group input[type='radio']:checked + .band-60 {
|
219 |
+
background-position: -150px -662px
|
220 |
+
}
|
221 |
+
|
222 |
+
|
223 |
+
/* hsbc */
|
224 |
+
|
225 |
+
.band-62 {
|
226 |
+
background-position: 0 -759px
|
227 |
+
}
|
228 |
+
|
229 |
+
.band-62:hover {
|
230 |
+
border: none;
|
231 |
+
background-position: -74px -759px
|
232 |
+
}
|
233 |
+
|
234 |
+
.payment-group input[type='radio']:checked + .band-62 {
|
235 |
+
background-position: -150px -759px
|
236 |
+
}
|
237 |
+
|
238 |
+
|
239 |
+
/* banrisul*/
|
240 |
+
|
241 |
+
.band-61 {
|
242 |
+
background-position: 0 -711px
|
243 |
+
}
|
244 |
+
|
245 |
+
.band-61:hover {
|
246 |
+
border: none;
|
247 |
+
background-position: -74px -711px
|
248 |
+
}
|
249 |
+
|
250 |
+
.payment-group input[type='radio']:checked + .band-61 {
|
251 |
+
background-position: -150px -711px
|
252 |
+
}
|
253 |
+
|
254 |
+
|
255 |
+
/* bootstrap */
|
256 |
+
|
257 |
+
.b-col-xs-1,
|
258 |
+
.b-col-xs-2,
|
259 |
+
.b-col-xs-3,
|
260 |
+
.b-col-xs-4,
|
261 |
+
.b-col-xs-5,
|
262 |
+
.b-col-xs-6,
|
263 |
+
.b-col-xs-7,
|
264 |
+
.b-col-xs-8,
|
265 |
+
.b-col-xs-9,
|
266 |
+
.b-col-xs-10,
|
267 |
+
.b-col-xs-11,
|
268 |
+
.b-col-xs-12 {
|
269 |
+
float: left;
|
270 |
+
}
|
271 |
+
|
272 |
+
.b-col-xs-1,
|
273 |
+
.b-col-sm-1,
|
274 |
+
.b-col-md-1,
|
275 |
+
.b-col-lg-1,
|
276 |
+
.b-col-xs-2,
|
277 |
+
.b-col-sm-2,
|
278 |
+
.b-col-md-2,
|
279 |
+
.b-col-lg-2,
|
280 |
+
.b-col-xs-3,
|
281 |
+
.b-col-sm-3,
|
282 |
+
.b-col-md-3,
|
283 |
+
.b-col-lg-3,
|
284 |
+
.b-col-xs-4,
|
285 |
+
.b-col-sm-4,
|
286 |
+
.b-col-md-4,
|
287 |
+
.b-col-lg-4,
|
288 |
+
.b-col-xs-5,
|
289 |
+
.b-col-sm-5,
|
290 |
+
.b-col-md-5,
|
291 |
+
.b-col-lg-5,
|
292 |
+
.b-col-xs-6,
|
293 |
+
.b-col-sm-6,
|
294 |
+
.b-col-md-6,
|
295 |
+
.b-col-lg-6,
|
296 |
+
.b-col-xs-7,
|
297 |
+
.b-col-sm-7,
|
298 |
+
.b-col-md-7,
|
299 |
+
.b-col-lg-7,
|
300 |
+
.b-col-xs-8,
|
301 |
+
.b-col-sm-8,
|
302 |
+
.b-col-md-8,
|
303 |
+
.b-col-lg-8,
|
304 |
+
.b-col-xs-9,
|
305 |
+
.b-col-sm-9,
|
306 |
+
.b-col-md-9,
|
307 |
+
.b-col-lg-9,
|
308 |
+
.b-col-xs-10,
|
309 |
+
.b-col-sm-10,
|
310 |
+
.b-col-md-10,
|
311 |
+
.b-col-lg-10,
|
312 |
+
.b-col-xs-11,
|
313 |
+
.b-col-sm-11,
|
314 |
+
.b-col-md-11,
|
315 |
+
.b-col-lg-11,
|
316 |
+
.b-col-xs-12,
|
317 |
+
.b-col-sm-12,
|
318 |
+
.b-col-md-12,
|
319 |
+
.b-col-lg-12 {
|
320 |
+
position: relative;
|
321 |
+
min-height: 1px;
|
322 |
+
padding-right: 15px;
|
323 |
+
padding-left: 15px;
|
324 |
+
}
|
325 |
+
|
326 |
+
.b-col-xs-10 {
|
327 |
+
width: 83.33333333%;
|
328 |
+
}
|
329 |
+
|
330 |
+
.b-col-xs-8 {
|
331 |
+
width: 66.66666667%;
|
332 |
+
}
|
333 |
+
|
334 |
+
.b-col-xs-7 {
|
335 |
+
width: 58.33333333%;
|
336 |
+
}
|
337 |
+
|
338 |
+
.b-col-xs-6 {
|
339 |
+
width: 50%;
|
340 |
+
}
|
341 |
+
|
342 |
+
.b-col-xs-5 {
|
343 |
+
width: 41.66666667%;
|
344 |
+
}
|
345 |
+
|
346 |
+
.b-col-xs-4 {
|
347 |
+
width: 33.33333333%;
|
348 |
+
}
|
349 |
+
|
350 |
+
.b-col-xs-3 {
|
351 |
+
width: 25%;
|
352 |
+
}
|
353 |
+
|
354 |
+
.b-col-xs-2 {
|
355 |
+
width: 16.66666667%;
|
356 |
+
}
|
357 |
+
|
358 |
+
.b-col-xs-1 {
|
359 |
+
width: 8.33333333%;
|
360 |
+
}
|
361 |
+
|
362 |
+
.b-input-sm {
|
363 |
+
height: 30px;
|
364 |
+
padding: 5px 10px;
|
365 |
+
font-size: 12px;
|
366 |
+
line-height: 1.5;
|
367 |
+
border-radius: 3px;
|
368 |
+
}
|
369 |
+
|
370 |
+
.b-form-control {
|
371 |
+
display: block;
|
372 |
+
width: 100%;
|
373 |
+
/*height: 24px;*/
|
374 |
+
/*padding: 6px 12px;*/
|
375 |
+
/*font-size: 14px;*/
|
376 |
+
/*line-height: 1.42857;*/
|
377 |
+
/*color: #555;*/
|
378 |
+
/*background-color: #FFF;*/
|
379 |
+
/*background-image: none;*/
|
380 |
+
/*border: 1px solid #CCC;*/
|
381 |
+
/*border-radius: 4px;*/
|
382 |
+
/*box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.075) inset;*/
|
383 |
+
/*transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;*/
|
384 |
+
}
|
385 |
+
|
386 |
+
.b-form-control .error {
|
387 |
+
border-color: red;
|
388 |
+
}
|
389 |
+
|
390 |
+
.b-form-control:focus {
|
391 |
+
border: 1px solid #39C;
|
392 |
+
}
|
393 |
+
|
394 |
+
.b-form-control::-moz-placeholder {
|
395 |
+
color: #999;
|
396 |
+
opacity: 1;
|
397 |
+
}
|
398 |
+
|
399 |
+
.b-form-control:-ms-input-placeholder {
|
400 |
+
color: #999;
|
401 |
+
}
|
402 |
+
|
403 |
+
.b-form-control::-webkit-input-placeholder {
|
404 |
+
color: #999;
|
405 |
+
}
|
406 |
+
|
407 |
+
.b-form-control[disabled],
|
408 |
+
.b-form-control[readonly],
|
409 |
+
fieldset[disabled] .b-form-control {
|
410 |
+
background-color: #eee;
|
411 |
+
opacity: 1;
|
412 |
+
}
|
413 |
+
|
414 |
+
.b-form-control[disabled],
|
415 |
+
fieldset[disabled] .b-form-control {
|
416 |
+
cursor: not-allowed;
|
417 |
+
}
|
418 |
+
|
419 |
+
select.b-form-control {
|
420 |
+
border-radius: 2px;
|
421 |
+
border: 1px solid silver;
|
422 |
+
background: #FFFFFF;
|
423 |
+
font-size: 15px;
|
424 |
+
width: 100%;
|
425 |
+
padding: 0 8px;
|
426 |
+
height: 30px;
|
427 |
+
margin-top: 0px;
|
428 |
+
}
|
429 |
+
|
430 |
+
.b-btn {
|
431 |
+
display: inline-block;
|
432 |
+
padding: 6px 12px;
|
433 |
+
margin-bottom: 0;
|
434 |
+
font-size: 14px;
|
435 |
+
font-weight: 400;
|
436 |
+
line-height: 1.42857143;
|
437 |
+
text-align: center;
|
438 |
+
white-space: nowrap;
|
439 |
+
vertical-align: middle;
|
440 |
+
-ms-touch-action: manipulation;
|
441 |
+
touch-action: manipulation;
|
442 |
+
cursor: pointer;
|
443 |
+
-webkit-user-select: none;
|
444 |
+
-moz-user-select: none;
|
445 |
+
-ms-user-select: none;
|
446 |
+
user-select: none;
|
447 |
+
background-image: none;
|
448 |
+
border: 1px solid transparent;
|
449 |
+
border-radius: 4px;
|
450 |
+
}
|
451 |
+
|
452 |
+
.b-btn-success {
|
453 |
+
color: #fff;
|
454 |
+
background-color: #5cb85c;
|
455 |
+
border-color: #4cae4c;
|
456 |
+
}
|
457 |
+
|
458 |
+
.b-btn-success.focus,
|
459 |
+
.b-btn-success:focus {
|
460 |
+
color: #fff;
|
461 |
+
background-color: #449d44;
|
462 |
+
border-color: #255625;
|
463 |
+
}
|
464 |
+
|
465 |
+
.b-btn-success:hover {
|
466 |
+
color: #fff;
|
467 |
+
background-color: #449d44;
|
468 |
+
border-color: #398439;
|
469 |
+
}
|
470 |
+
|
471 |
+
.b-field-card-date {
|
472 |
+
width: 21.5px;
|
473 |
+
display: inline-block;
|
474 |
+
}
|
475 |
+
|
476 |
+
.b-form-inline .b-form-group {
|
477 |
+
display: inline-block;
|
478 |
+
margin-bottom: 0;
|
479 |
+
vertical-align: middle;
|
480 |
+
}
|
481 |
+
|
482 |
+
.b-form-group:before,
|
483 |
+
.b-row:after,
|
484 |
+
.b-row:before {
|
485 |
+
display: table;
|
486 |
+
content: " ";
|
487 |
+
}
|
488 |
+
|
489 |
+
.b-row:after,
|
490 |
+
.b-form-group:after {
|
491 |
+
clear: both;
|
492 |
+
}
|
493 |
+
|
494 |
+
.b-row {
|
495 |
+
margin-right: -15px;
|
496 |
+
margin-left: -15px;
|
497 |
+
}
|
498 |
+
|
499 |
+
.b-no-margin {
|
500 |
+
margin-right: 0px;
|
501 |
+
margin-left: 0px;
|
502 |
+
}
|
503 |
+
|
504 |
+
.b-l-margin {
|
505 |
+
margin-left: 15px;
|
506 |
+
}
|
507 |
+
|
508 |
+
.b-r-margin {
|
509 |
+
margin-right: 15px;
|
510 |
+
}
|
511 |
+
|
512 |
+
.b-form-group {
|
513 |
+
margin-bottom: 15px;
|
514 |
+
}
|
515 |
+
|
516 |
+
.b-form-inline .b-form-group {
|
517 |
+
display: inline-block;
|
518 |
+
margin-bottom: 0;
|
519 |
+
vertical-align: middle;
|
520 |
+
}
|
521 |
+
|
522 |
+
label {
|
523 |
+
display: inline-block;
|
524 |
+
max-width: 100%;
|
525 |
+
margin-bottom: 5px;
|
526 |
+
font-weight: 700;
|
527 |
+
}
|
528 |
+
|
529 |
+
input[type="number"]::-webkit-outer-spin-button,
|
530 |
+
input[type="number"]::-webkit-inner-spin-button {
|
531 |
+
-webkit-appearance: none;
|
532 |
+
margin: 0;
|
533 |
+
}
|
534 |
+
|
535 |
+
input[type="number"] {
|
536 |
+
-moz-appearance: textfield;
|
537 |
+
}
|
538 |
+
|
539 |
+
.b-form-group select.b-form-control {
|
540 |
+
height: 30px;
|
541 |
+
line-height: 30px;
|
542 |
+
}
|
543 |
+
|
544 |
+
hr {
|
545 |
+
margin-top: 20px;
|
546 |
+
margin-bottom: 20px;
|
547 |
+
border: 0;
|
548 |
+
border-top: 1px solid #eee;
|
549 |
+
}
|
550 |
+
|
551 |
+
.b-hide {
|
552 |
+
display: none;
|
553 |
+
}
|
554 |
+
|
555 |
+
.b-n-row {
|
556 |
+
float: left;
|
557 |
+
width: 95%;
|
558 |
+
padding: 2px;
|
559 |
+
}
|
560 |
+
|
561 |
+
|
562 |
+
/**
|
563 |
+
* Tooltip Styles
|
564 |
+
*/
|
565 |
+
|
566 |
+
.icon-tooltip {
|
567 |
+
display: inline-block;
|
568 |
+
margin-left: 3px;
|
569 |
+
padding: 1px 4px;
|
570 |
+
vertical-align: middle;
|
571 |
+
color: #fff;
|
572 |
+
font-size: 8px;
|
573 |
+
background-color: #2E8AB8;
|
574 |
+
border-radius: 40px;
|
575 |
+
}
|
576 |
+
|
577 |
+
|
578 |
+
/* Add this attribute to the element that needs a tooltip */
|
579 |
+
|
580 |
+
[data-tooltip] {
|
581 |
+
position: relative;
|
582 |
+
z-index: 2;
|
583 |
+
cursor: pointer;
|
584 |
+
}
|
585 |
+
|
586 |
+
|
587 |
+
/* Hide the tooltip content by default */
|
588 |
+
|
589 |
+
[data-tooltip]:before,
|
590 |
+
[data-tooltip]:after {
|
591 |
+
visibility: hidden;
|
592 |
+
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
593 |
+
filter: progid: DXImageTransform.Microsoft.Alpha(Opacity=0);
|
594 |
+
opacity: 0;
|
595 |
+
pointer-events: none;
|
596 |
+
}
|
597 |
+
|
598 |
+
|
599 |
+
/* Position tooltip above the element */
|
600 |
+
|
601 |
+
[data-tooltip]:before {
|
602 |
+
position: absolute;
|
603 |
+
bottom: 150%;
|
604 |
+
left: 50%;
|
605 |
+
margin-bottom: 5px;
|
606 |
+
margin-left: -80px;
|
607 |
+
padding: 7px;
|
608 |
+
width: 160px;
|
609 |
+
-webkit-border-radius: 3px;
|
610 |
+
-moz-border-radius: 3px;
|
611 |
+
border-radius: 3px;
|
612 |
+
background-color: #000;
|
613 |
+
background-color: rgba(45, 133, 198, 1);
|
614 |
+
color: #fff;
|
615 |
+
content: attr(data-tooltip);
|
616 |
+
text-align: center;
|
617 |
+
font-size: 14px;
|
618 |
+
line-height: 1.2;
|
619 |
+
}
|
620 |
+
|
621 |
+
|
622 |
+
/* Triangle hack to make tooltip look like a speech bubble */
|
623 |
+
|
624 |
+
[data-tooltip]:after {
|
625 |
+
position: absolute;
|
626 |
+
bottom: 150%;
|
627 |
+
left: 50%;
|
628 |
+
margin-left: -5px;
|
629 |
+
width: 0;
|
630 |
+
border-top: 5px solid #000;
|
631 |
+
border-top: 5px solid rgba(45, 133, 198, 1);
|
632 |
+
border-right: 5px solid transparent;
|
633 |
+
border-left: 5px solid transparent;
|
634 |
+
content: " ";
|
635 |
+
font-size: 0;
|
636 |
+
line-height: 0;
|
637 |
+
}
|
638 |
+
|
639 |
+
|
640 |
+
/* Show tooltip content on hover */
|
641 |
+
|
642 |
+
[data-tooltip]:hover:before,
|
643 |
+
[data-tooltip]:hover:after {
|
644 |
+
visibility: visible;
|
645 |
+
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
|
646 |
+
filter: progid: DXImageTransform.Microsoft.Alpha(Opacity=100);
|
647 |
+
opacity: 1;
|
648 |
+
}
|
skin/frontend/base/default/bcash/pagamento/images/application-sprite.png
ADDED
Binary file
|
skin/frontend/base/default/bcash/pagamento/js/payment.js
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function () {
|
2 |
+
var cards = [ '1', '2', '37', '45', '55', '56', '63'];
|
3 |
+
|
4 |
+
function clickFlag(e) {
|
5 |
+
alert('clickFlag');
|
6 |
+
cardConteiner = document.getElementById('card-conteiner');
|
7 |
+
if (isCard(this) && hasClass(cardConteiner, 'b-hide')) {
|
8 |
+
cardConteiner.className = cardConteiner.className.replace(/\bb-hide\b/,'');
|
9 |
+
} else if (!isCard(this) && !hasClass(cardConteiner, 'b-hide')) {
|
10 |
+
cardConteiner.className = cardConteiner.className + " b-hide";
|
11 |
+
}
|
12 |
+
}
|
13 |
+
|
14 |
+
function isCard(element) {
|
15 |
+
return cards.indexOf(element.value) > -1;
|
16 |
+
}
|
17 |
+
|
18 |
+
function hasClass(element, cls) {
|
19 |
+
return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
|
20 |
+
}
|
21 |
+
|
22 |
+
function initBcashPagamento() {
|
23 |
+
var paymentsOptions = document.getElementsByClassName("bandeira");
|
24 |
+
for (var i = paymentsOptions.length - 1; i >= 0; i--) {
|
25 |
+
var paymentFlags = payments[i];
|
26 |
+
paymentFlags.onclick = clickFlag;
|
27 |
+
};
|
28 |
+
}
|
29 |
+
|
30 |
+
initBcashPagamento();
|
31 |
+
});
|