Tray_CheckoutApi - Version 0.1.0

Version Notes

Primeira versão liberada no Magento Connect

Download this release

Release Info

Developer TrayCheckout
Extension Tray_CheckoutApi
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (54) hide show
  1. app/code/community/Tray/CheckoutApi/Block/Adminhtml/System/Config/Fieldset/Label.php +43 -0
  2. app/code/community/Tray/CheckoutApi/Block/Error.php +27 -0
  3. app/code/community/Tray/CheckoutApi/Block/Form/Standard.php +91 -0
  4. app/code/community/Tray/CheckoutApi/Block/Info/Standard.php +61 -0
  5. app/code/community/Tray/CheckoutApi/Block/Link.php +23 -0
  6. app/code/community/Tray/CheckoutApi/Block/Payment.php +76 -0
  7. app/code/community/Tray/CheckoutApi/Block/Redirect_D.php +78 -0
  8. app/code/community/Tray/CheckoutApi/Block/Return.php +28 -0
  9. app/code/community/Tray/CheckoutApi/Helper/Adress.php +142 -0
  10. app/code/community/Tray/CheckoutApi/Helper/Data.php +131 -0
  11. app/code/community/Tray/CheckoutApi/Model/Config.php +56 -0
  12. app/code/community/Tray/CheckoutApi/Model/Geral_D.php +34 -0
  13. app/code/community/Tray/CheckoutApi/Model/Mysql4/Setup.php +23 -0
  14. app/code/community/Tray/CheckoutApi/Model/Observer.php +37 -0
  15. app/code/community/Tray/CheckoutApi/Model/Source/Country.php +28 -0
  16. app/code/community/Tray/CheckoutApi/Model/Source/Paymentmethods.php +40 -0
  17. app/code/community/Tray/CheckoutApi/Model/Source/Qtdsplit.php +39 -0
  18. app/code/community/Tray/CheckoutApi/Model/Source/Specificcountries.php +28 -0
  19. app/code/community/Tray/CheckoutApi/Model/Standard.php +653 -0
  20. app/code/community/Tray/CheckoutApi/controllers/StandardController.php +357 -0
  21. app/code/community/Tray/CheckoutApi/etc/adminhtml.xml +45 -0
  22. app/code/community/Tray/CheckoutApi/etc/config.xml +181 -0
  23. app/code/community/Tray/CheckoutApi/etc/system.xml +174 -0
  24. app/code/community/Tray/CheckoutApi/sql/checkoutapi_setup/mysql4-install-0.1.0.php +60 -0
  25. app/design/adminhtml/default/default/layout/tray_checkoutapi.xml +36 -0
  26. app/design/adminhtml/default/default/template/tray/checkoutredir/form/standard.phtml +30 -0
  27. app/design/adminhtml/default/default/template/tray/checkoutredir/getbaseurl.phtml +30 -0
  28. app/design/adminhtml/default/default/template/tray/checkoutredir/info/standard.phtml +25 -0
  29. app/design/frontend/base/default/layout/tray_checkoutapi.xml +56 -0
  30. app/design/frontend/base/default/template/tray/checkoutapi/error.phtml +56 -0
  31. app/design/frontend/base/default/template/tray/checkoutapi/form/images/overlay.png +0 -0
  32. app/design/frontend/base/default/template/tray/checkoutapi/form/standard.phtml +190 -0
  33. app/design/frontend/base/default/template/tray/checkoutapi/head.phtml +36 -0
  34. app/design/frontend/base/default/template/tray/checkoutapi/info/standard.phtml +36 -0
  35. app/design/frontend/base/default/template/tray/checkoutapi/overlay.phtml +28 -0
  36. app/design/frontend/base/default/template/tray/checkoutapi/payment.phtml +84 -0
  37. app/design/frontend/base/default/template/tray/checkoutapi/return.phtml +23 -0
  38. app/etc/modules/Tray_CheckoutApi.xml +32 -0
  39. package.xml +18 -0
  40. skin/adminhtml/default/default/tray/checkoutapi/css/magentomodal.css +194 -0
  41. skin/adminhtml/default/default/tray/checkoutapi/images/btn_bg.gif +0 -0
  42. skin/adminhtml/default/default/tray/checkoutapi/images/content_bg.gif +0 -0
  43. skin/adminhtml/default/default/tray/checkoutapi/images/top_bg.gif +0 -0
  44. skin/adminhtml/default/default/tray/checkoutapi/images/window_close.png +0 -0
  45. skin/adminhtml/default/default/tray/checkoutapi/js/exibitionsettingswebcheckout.js +26 -0
  46. skin/frontend/base/default/tray/checkoutapi/css/styles.css +10 -0
  47. skin/frontend/base/default/tray/checkoutapi/images/BannerTrayCheckout890px.png +0 -0
  48. skin/frontend/base/default/tray/checkoutapi/images/banner_comlogo_formas.jpg +0 -0
  49. skin/frontend/base/default/tray/checkoutapi/images/banner_semlogo_formas.jpg +0 -0
  50. skin/frontend/base/default/tray/checkoutapi/images/banner_semlogo_formas.png +0 -0
  51. skin/frontend/base/default/tray/checkoutapi/images/close.png +0 -0
  52. skin/frontend/base/default/tray/checkoutapi/images/overlay.png +0 -0
  53. skin/frontend/base/default/tray/checkoutapi/images/paymentFlags1.png +0 -0
  54. skin/frontend/base/default/tray/checkoutapi/images/paymentFlagsTc.png +0 -0
app/code/community/Tray/CheckoutApi/Block/Adminhtml/System/Config/Fieldset/Label.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Block_Adminhtml_System_Config_Fieldset_Label extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
21
+ {
22
+ public function render(Varien_Data_Form_Element_Abstract $element)
23
+ {
24
+ $id = $element->getHtmlId();
25
+ $html = sprintf('
26
+ <tr class="system-fieldset-sub-head" id="row_%s">
27
+ <td colspan="5">
28
+ <h4 id="%s">%s</h4>
29
+ <p class="note">
30
+ <span>%s</span>
31
+ </p>
32
+ </td>
33
+ </tr>',
34
+ $element->getHtmlId(), $element->getHtmlId(), $element->getLabel(), $element->getComment()
35
+ );
36
+
37
+ $html .= <<<HTML
38
+
39
+ HTML;
40
+
41
+ return $html;
42
+ }
43
+ }
app/code/community/Tray/CheckoutApi/Block/Error.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Block_Error extends Mage_Core_Block_Template
21
+ {
22
+
23
+ protected function getError()
24
+ {
25
+
26
+ }
27
+ }
app/code/community/Tray/CheckoutApi/Block/Form/Standard.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Block_Form_Standard extends Mage_Payment_Block_Form
21
+ {
22
+ protected function _construct()
23
+ {
24
+ $this->setTemplate('tray/checkoutapi/form/standard.phtml');
25
+ parent::_construct();
26
+ }
27
+ protected function _getConfig()
28
+ {
29
+ return Mage::getSingleton('payment/config');
30
+ }
31
+ public function getCcMonths()
32
+ {
33
+ $months = $this->getData('cc_months');
34
+ if (is_null($months)) {
35
+ $months[0] = $this->__('Month');
36
+ $months = array_merge($months, $this->_getConfig()->getMonths());
37
+ $this->setData('cc_months', $months);
38
+ }
39
+ return $months;
40
+ }
41
+
42
+ public function getCcYears()
43
+ {
44
+ $years = $this->getData('cc_years');
45
+ if (is_null($years)) {
46
+ $years = $this->_getConfig()->getYears();
47
+ $years = array(0=>$this->__('Year'))+$years;
48
+ $this->setData('cc_years', $years);
49
+ }
50
+ return $years;
51
+ }
52
+
53
+ public function getSplitSimulate($totalValue = "0")
54
+ {
55
+ $tcStandard = Mage::getModel('checkoutapi/standard');
56
+ $tcNoSplitTaxRate = $tcStandard->getConfigData('tcNoSplitTaxRate');
57
+
58
+ $tcNoSplitTaxRate = explode(",",$tcNoSplitTaxRate);
59
+
60
+ $params = array(
61
+ "token_account" => $tcStandard->getConfigData('token'),
62
+ "payment_method_id" => "3",
63
+ "price" => $totalValue
64
+ );
65
+
66
+
67
+ if(sizeof($tcNoSplitTaxRate) > 1){
68
+ for($itc = 0; $itc < sizeof($tcNoSplitTaxRate);$itc++){
69
+ $params["splits[$itc][split_transaction]"] = $tcNoSplitTaxRate[$itc];
70
+ $params["splits[$itc][percentage]"] = $tcStandard->getConfigData('splitTax');
71
+ }
72
+ }else{
73
+ $params["splits[][split_transaction]"] = "1";
74
+ $params["splits[][percentage]"] = $tcStandard->getConfigData('splitTax');
75
+ }
76
+
77
+ $params = preg_replace("/splits\%5B\d+\%5D/","splits%5B%5D", http_build_query($params));
78
+
79
+ $tcResponse = simplexml_load_string($tcStandard->getTrayCheckoutRequest("/api/seller_splits/simulate_split",$params));
80
+ $splitSimulate = array(""=>'Parcela(s)');
81
+
82
+ for($iTc = 0; $iTc < (int)$tcStandard->getConfigData('tcQtdSplit'); $iTc++){
83
+ $splittings = $tcResponse->data_response->splittings->splitting[$iTc];
84
+ $splitSimulate[(int)$splittings->split] = (string)$splittings->split . " x de R$" . number_format((float)$splittings->value_split, 2, ',','');
85
+ }
86
+
87
+ $this->setData('splitSimulate', $splitSimulate);
88
+
89
+ return $splitSimulate;
90
+ }
91
+ }
app/code/community/Tray/CheckoutApi/Block/Info/Standard.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Block_Info_Standard extends Mage_Payment_Block_Info
21
+ {
22
+ protected function _construct()
23
+ {
24
+ parent::_construct();
25
+ $this->setTemplate('tray/checkoutapi/info/standard.phtml');
26
+ }
27
+
28
+ public function getLinkPayment($order)
29
+ {
30
+ if ($this->getRequest()->getRouteName() != 'checkout') {
31
+ $_order = $order;
32
+ $incrementid = $_order->getData('increment_id');
33
+ $quoteid = $_order->getData('quote_id');
34
+
35
+ $hash = Mage::getModel('core/encryption')->encrypt($incrementid . ":" . $quoteid);
36
+ $method = $_order->getPayment()->getMethod();
37
+ switch ($method) {
38
+ case 'traycheckoutapi':
39
+ return '<span>Para efetuar o pagamento, <a href="' . Mage::getBaseUrl() . 'checkoutapi/standard/paymentbackend/order/' . $hash . '">clique aqui</a>.</span>';
40
+ break;
41
+ }
42
+ }
43
+ }
44
+
45
+ protected function _prepareSpecificInformation($transport = null)
46
+ {
47
+ if (null !== $this->_paymentSpecificInformation) {
48
+ return $this->_paymentSpecificInformation;
49
+ }
50
+ $info = $this->getInfo();
51
+ $transport = new Varien_Object();
52
+ $transport = parent::_prepareSpecificInformation($transport);
53
+ $transport->addData(array(
54
+ Mage::helper('payment')->__('Payment Method ID') => $info->getTraycheckoutTransactionId(),
55
+ Mage::helper('payment')->__('Split Number') => $info->getTraycheckoutSplitNumber(),
56
+ Mage::helper('payment')->__('Split Value') => $info->getTraycheckoutSplitValue()
57
+ ));
58
+ return $transport;
59
+ }
60
+
61
+ }
app/code/community/Tray/CheckoutApi/Block/Link.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Block_Link extends Mage_Core_Block_Template
21
+ {
22
+
23
+ }
app/code/community/Tray/CheckoutApi/Block/Payment.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Block_Payment extends Mage_Core_Block_Template
21
+ {
22
+ protected $order_number;
23
+ protected $transaction_id;
24
+ protected $url_payment;
25
+ protected $typeful_line;
26
+ protected $status_id;
27
+ protected $status_name;
28
+ protected $payment_method_id;
29
+ protected $payment_method_name;
30
+
31
+ public function getOrderNumber() {
32
+ return $this->order_number;
33
+ }
34
+ public function getTransactionId() {
35
+ return $this->transaction_id;
36
+ }
37
+ public function getUrlPayment() {
38
+ return $this->url_payment;
39
+ }
40
+ public function getTypefulLine() {
41
+ return $this->typeful_line;
42
+ }
43
+ public function getStatusId() {
44
+ return $this->status_id;
45
+ }
46
+ public function getStatusName() {
47
+ return $this->status_name;
48
+ }
49
+ public function getPaymentMethodId() {
50
+ return $this->payment_method_id;
51
+ }
52
+ public function getPaymentMethodName() {
53
+ return $this->payment_method_name;
54
+ }
55
+
56
+ protected function getPayment()
57
+ {
58
+ $standard = Mage::getModel('checkoutapi/'.$this->getRequest()->getParam("type"));
59
+
60
+ $response = $standard->getTrayCheckoutRequest("/v2/transactions/pay_complete",$standard->getCheckoutFormFields());
61
+
62
+ $xml = simplexml_load_string($response);
63
+ $this->order_number = $xml->data_response->transaction->order_number;
64
+ $this->transaction_id = $xml->data_response->transaction->transaction_id;
65
+ $this->url_payment = $xml->data_response->transaction->payment->url_payment;
66
+ $this->typeful_line = $xml->data_response->transaction->payment->linha_digitavel;
67
+ $this->status_id = $xml->data_response->transaction->status_id;
68
+ $this->status_name = $xml->data_response->transaction->status_name;
69
+ $this->payment_method_name = $xml->data_response->transaction->payment->payment_method_name;
70
+ $this->payment_method_id = $xml->data_response->transaction->payment->payment_method_id;
71
+
72
+ $standard->updateTransactionTrayCheckout($xml->data_response->transaction);
73
+
74
+ echo "";
75
+ }
76
+ }
app/code/community/Tray/CheckoutApi/Block/Redirect_D.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Block_Redirect extends Mage_Core_Block_Abstract
21
+ {
22
+
23
+ protected function _toHtml()
24
+ {
25
+ $standard = Mage::getModel('checkoutapi/'.$this->getRequest()->getParam("type"));
26
+
27
+ $form = new Varien_Data_Form();
28
+
29
+ $form->setAction($standard->getCheckoutApiUrl())
30
+ ->setId('checkoutapi_payment_checkout')
31
+ ->setName('checkoutapi_payment_checkout')
32
+ ->setMethod('POST')
33
+ ->setUseContainer(true);
34
+
35
+ $xx= 0;
36
+ foreach ($standard->getCheckoutFormFields() as $field => $value)
37
+ {
38
+ if($field =="transaction_products"){
39
+ $xx= $value;
40
+ }
41
+ $form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
42
+ }
43
+
44
+ $xhtml = $form->toHtml();
45
+ for($yy=0; $yy< $xx; $yy++){
46
+ $xhtml = str_replace("transaction_product[$yy]", "transaction_product[]", $xhtml);
47
+ }
48
+
49
+ $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
50
+ $html .= '<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="pt-BR">';
51
+ $html .= '<head>';
52
+ $html .= '<meta http-equiv="Content-Language" content="pt-br" />';
53
+ $html .= '<meta name="language" content="pt-br" />';
54
+ $html .= '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /></head>';
55
+ $html .= '<body>';
56
+ $html .= '<div align="center">';
57
+ $html .= '<font size="4">Sua compra está em processo de finalização.<br /><br />';
58
+ $html .= ''.$this->__('Aguarde ... você será redirecionado para o TrayCheckout em <span id="tempo">5</span> segundos.</font>');
59
+ $html .= '<div>';
60
+ $html .=$xhtml;
61
+ $html .= '<script type="text/javascript">
62
+ function setTempo(){
63
+ var tempo = eval(document.getElementById("tempo").innerHTML);
64
+ if (tempo - 1 < 0){
65
+ document.getElementById("checkoutapi_payment_checkout").submit();
66
+ }else{
67
+ document.getElementById("tempo").innerHTML = tempo - 1;
68
+ setTimeout("setTempo()",1000);
69
+ }
70
+
71
+ }
72
+ setTimeout("setTempo()",1000);
73
+ </script>';
74
+ $html .= '</body></html>';
75
+
76
+ return utf8_decode($html);
77
+ }
78
+ }
app/code/community/Tray/CheckoutApi/Block/Return.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Block_Return extends Mage_Core_Block_Template
21
+ {
22
+
23
+ protected function getReturn()
24
+ {
25
+
26
+ }
27
+
28
+ }
app/code/community/Tray/CheckoutApi/Helper/Adress.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Helper_Adress extends Mage_Core_Helper_Data
21
+ {
22
+
23
+ private $completion = array("casa", "ap", "apto", "apart", "frente", "fundos", "sala", "cj");
24
+ private $df = array("bloco", "setor", "quadra", "lote");
25
+ private $noDf = array("av", "avenida", "rua", "alameda", "al.", "travessa", "trv", "praça", "praca");
26
+ private $without = array("sem ", "s.", "s/", "s. ", "s/ ");
27
+ private $number = array('n.º', 'nº', "numero", "num", "número", "núm", "n");
28
+
29
+ /**
30
+ * getAdress
31
+ * @param string $adress
32
+ * @return array
33
+ */
34
+ public function getAdress($adress) {
35
+ if ($this->isDf($adress)) {
36
+ $number = 's/nº';
37
+ list($street, $completion) = $this->partCompletion($adress);
38
+ } else {
39
+ $splited = preg_split('/[-,]/', $adress);
40
+ if (in_array(sizeof($splited), array(2, 3))) {
41
+ list($street, $number, $completion) = $splited;
42
+ } else {
43
+ list($street, $number) = $this->reverse($adress);
44
+ }
45
+ $street = $this->cleanNumber($street);
46
+ if (strlen($completion)==0)
47
+ list($numberb,$completion) = $this->partNumber($number);
48
+ }
49
+ return array($this->endtrim($street), $this->endtrim($number), $this->endtrim($completion));
50
+ }
51
+
52
+ /**
53
+ * partNumber
54
+ * @param string $n
55
+ * @return array
56
+ */
57
+ public function partNumber($n) {
58
+ $withoutNumber = $this->withoutNumber();
59
+ $n = $this->endtrim($n);
60
+ foreach ($withoutNumber as $sn) {
61
+ if ($n == $sn)return array($n, '');
62
+ if (substr($n, 0, strlen($sn)) == $sn)
63
+ return array(substr($n, 0, strlen($sn)), substr($n, strlen($sn)));
64
+ }
65
+ $q = preg_split('/\D/', $n);
66
+ $pos = strlen($q[0]);
67
+ return array(substr($n, 0, $pos), substr($n,$pos));
68
+ }
69
+
70
+ /**
71
+ * partCompletion
72
+ * @param string $adress
73
+ * @return array
74
+ */
75
+ function partCompletion($adress) {
76
+ foreach ($this->$completion as $c)
77
+ if ($pos = strpos(strtolower($adress), $c))
78
+ return array(substr($adress, 0 ,$pos), substr($adress, $pos));
79
+ return array($adress, '');
80
+ }
81
+
82
+ /**
83
+ * @param string
84
+ * @return string
85
+ */
86
+ function endtrim($e){
87
+ return preg_replace('/^\W+|\W+$/', '', $e);
88
+ }
89
+
90
+ /**
91
+ * cleanNumber
92
+ * @param string $street Endereço a ser tratado
93
+ * @return string
94
+ */
95
+ function cleanNumber($street) {
96
+ foreach ($this->number as $n)
97
+ foreach (array(" $n"," $n ") as $N)
98
+ if (substr($street, -strlen($N)) == $N)
99
+ return substr($street, 0, -strlen($N));
100
+ return $street;
101
+ }
102
+
103
+ /**
104
+ * @param string $adress
105
+ * @return array
106
+ */
107
+ function reverse($adress) {
108
+ $find = substr($adress, -10);
109
+ for ($i = 0; $i < 10; $i++) {
110
+ if (is_numeric(substr($find, $i, 1))) {
111
+ return array( substr($adress, 0, -10+$i), substr($adress, -10+$i) );
112
+ }
113
+ }
114
+ }
115
+
116
+ /**
117
+ * @param string $adress
118
+ * @return bool
119
+ */
120
+ function isDf($adress) {
121
+ $df = false;
122
+ foreach ($this->df as $b)
123
+ if (strpos(strtolower($adress),$b) != false)
124
+ $df = true;
125
+ if ($df)
126
+ foreach ($this->noDf as $b)
127
+ if (strpos(strtolower($adress),$b) != false)
128
+ $df = false;
129
+ return $df;
130
+ }
131
+
132
+ /**
133
+ * @return array
134
+ */
135
+ function withoutNumber() {
136
+ foreach ($this->number as $n)
137
+ foreach ($this->without as $s)
138
+ $withoutNum[] = "$s$n";
139
+ return $withoutNum;
140
+ }
141
+
142
+ }
app/code/community/Tray/CheckoutApi/Helper/Data.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Helper_Data extends Tray_CheckoutApi_Helper_Adress
21
+ {
22
+ public function prepareLineItems(Mage_Core_Model_Abstract $salesEntity, $discountTotalAsItem = true, $shippingTotalAsItem = false)
23
+ {
24
+ $items = array();
25
+
26
+ foreach ($salesEntity->getAllItems() as $item) {
27
+
28
+ if (!$item->getParentItem()) {
29
+ $items[] = new Varien_Object($this->_prepareLineItemFields($salesEntity, $item));
30
+ }
31
+ }
32
+
33
+ $discountAmount = 0;
34
+
35
+ $shippingDescription = '';
36
+
37
+ if ($salesEntity instanceof Mage_Sales_Model_Order) {
38
+
39
+ $discountAmount = abs(1 * $salesEntity->getBaseDiscountAmount());
40
+
41
+ $shippingDescription = $salesEntity->getShippingDescription();
42
+
43
+ $totals = array(
44
+ 'subtotal' => $salesEntity->getBaseSubtotal() - $discountAmount,
45
+ 'tax' => $salesEntity->getBaseTaxAmount(),
46
+ 'shipping' => $salesEntity->getBaseShippingAmount(),
47
+ 'discount' => $discountAmount
48
+ );
49
+ } else {
50
+
51
+ $address = $salesEntity->getIsVirtual() ? $salesEntity->getBillingAddress() : $salesEntity->getShippingAddress();
52
+
53
+ $discountAmount = abs(1 * $address->getBaseDiscountAmount());
54
+
55
+ $shippingDescription = $address->getShippingDescription();
56
+
57
+ $totals = array (
58
+ 'subtotal' => $salesEntity->getBaseSubtotal() - $discountAmount,
59
+ 'tax' => $address->getBaseTaxAmount(),
60
+ 'shipping' => $address->getBaseShippingAmount(),
61
+ 'discount' => $discountAmount
62
+ );
63
+ }
64
+
65
+ // discount total as line item (negative)
66
+ if ($discountTotalAsItem && $discountAmount) {
67
+ $items[] = new Varien_Object(array(
68
+ 'name' => Mage::helper('checkoutapi')->__('Discount'),
69
+ 'qty' => 1,
70
+ 'amount' => -1.00 * $discountAmount,
71
+ ));
72
+ }
73
+
74
+ // shipping total as line item
75
+ if ($shippingTotalAsItem && (!$salesEntity->getIsVirtual()) && (float)$totals['shipping']) {
76
+ $items[] = new Varien_Object(array(
77
+ 'id' => Mage::helper('checkoutapi')->__('Shipping'),
78
+ 'name' => $shippingDescription,
79
+ 'qty' => 1,
80
+ 'amount' => (float) $totals['shipping'],
81
+ ));
82
+ }
83
+
84
+ $hiddenTax = (float) $salesEntity->getBaseHiddenTaxAmount();
85
+
86
+ if ($hiddenTax) {
87
+ $items[] = new Varien_Object(array(
88
+ 'name' => Mage::helper('checkoutapi')->__('Discount Tax'),
89
+ 'qty' => 1,
90
+ 'amount' => (float)$hiddenTax,
91
+ ));
92
+ }
93
+
94
+ return array($items, $totals, $discountAmount, $totals['shipping']);
95
+ }
96
+
97
+ /**
98
+ * Get one line item key-value array
99
+ *
100
+ * @param Mage_Core_Model_Abstract $salesEntity
101
+ * @param Varien_Object $item
102
+ * @return array
103
+ */
104
+ protected function _prepareLineItemFields(Mage_Core_Model_Abstract $salesEntity, Varien_Object $item)
105
+ {
106
+ if ($salesEntity instanceof Mage_Sales_Model_Order) {
107
+ $qty = $item->getQtyOrdered();
108
+ $amount = $item->getBasePrice();
109
+ // TODO: nominal item for order
110
+ } else {
111
+ $qty = $item->getTotalQty();
112
+ $amount = $item->isNominal() ? 0 : $item->getBaseCalculationPrice();
113
+ }
114
+
115
+ // workaround in case if item subtotal precision is not compatible with PayPal (.2)
116
+ $subAggregatedLabel = '';
117
+
118
+ if ((float) $amount - round((float) $amount, 2)) {
119
+ $amount = $amount * $qty;
120
+ $subAggregatedLabel = ' x' . $qty;
121
+ $qty = 1;
122
+ }
123
+
124
+ return array(
125
+ 'id' => $item->getSku(),
126
+ 'name' => $item->getName() . $subAggregatedLabel,
127
+ 'qty' => $qty,
128
+ 'amount' => (float)$amount,
129
+ );
130
+ }
131
+ }
app/code/community/Tray/CheckoutApi/Model/Config.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Model_Config extends Varien_Object
21
+ {
22
+ const XML_PATH = 'payment/checkoutapi_standard/';
23
+
24
+ const XML_PATH_CONFIG = 'checkoutapi/settings/';
25
+
26
+ protected $_config = array();
27
+
28
+ protected $_config_settings = array();
29
+
30
+ public function getConfigData($key, $storeId = null)
31
+ {
32
+ if (!isset($this->_config[$key][$storeId])) {
33
+ $value = Mage::getStoreConfig(self::XML_PATH . $key, $storeId);
34
+ $this->_config[$key][$storeId] = $value;
35
+ }
36
+ return $this->_config[$key][$storeId];
37
+ }
38
+
39
+ public function getConfigDataSettings($key, $storeId = null)
40
+ {
41
+ if (!isset($this->_config_settings[$key][$storeId])) {
42
+ $value = Mage::getStoreConfig(self::XML_PATH_CONFIG . $key, $storeId);
43
+ $this->_config_settings[$key][$storeId] = $value;
44
+ }
45
+ return $this->_config_settings[$key][$storeId];
46
+ }
47
+
48
+ public function getExibitionWebCheckout($storeId = null)
49
+ {
50
+ if (!$this->hasData('exibitionmodal')) {
51
+ $this->setData('exibitionmodal', $this->getConfigData('exibitionmodal', $storeId));
52
+ }
53
+ return $this->getData('exibitionmodal');
54
+ }
55
+
56
+ }
app/code/community/Tray/CheckoutApi/Model/Geral_D.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Model_Standard extends Tray_CheckoutApi_Model_Standard
21
+ {
22
+ protected $_code = 'checkoutapi_standard';
23
+
24
+ protected $_formBlockType = 'checkoutapi/form_standard';
25
+
26
+ protected $_blockType = 'checkoutapi/standard';
27
+
28
+ protected $_infoBlockType = 'checkoutapi/info_standard';
29
+
30
+ public function getOrderPlaceRedirectUrl()
31
+ {
32
+ return Mage::getUrl('checkoutapi/standard/payment', array('_secure' => true, 'type' => 'standard'));
33
+ }
34
+ }
app/code/community/Tray/CheckoutApi/Model/Mysql4/Setup.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Model_Mysql4_Setup extends Mage_Eav_Model_Entity_Setup
21
+ {
22
+
23
+ }
app/code/community/Tray/CheckoutApi/Model/Observer.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Model_Observer extends Varien_Object
21
+ {
22
+ public function sendEmailFrontend()
23
+ {
24
+ $session = Mage::getSingleton('checkout/session');
25
+ $lastSuccessOrderId = $session->getData('last_real_order_id');
26
+
27
+ $order = Mage::getModel('sales/order')->loadByAttribute('increment_id',$lastSuccessOrderId);
28
+
29
+ // $sendNewOrderEmail = Mage::getStoreConfig('sales_email/order/enabled');
30
+ // if ($sendNewOrderEmail && !$order->getData('email_sent')) {
31
+ // $order->sendNewOrderEmail();
32
+ // $order->setEmailSent(true);
33
+ // $order->save();
34
+ // }
35
+ }
36
+
37
+ }
app/code/community/Tray/CheckoutApi/Model/Source/Country.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Model_Source_Country
21
+ {
22
+ public function toOptionArray()
23
+ {
24
+ return array(
25
+ array('value' => 'BR', 'label'=>Mage::helper('adminhtml')->__('Brasil')),
26
+ );
27
+ }
28
+ }
app/code/community/Tray/CheckoutApi/Model/Source/Paymentmethods.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Model_Source_Paymentmethods
21
+ {
22
+ public function toOptionArray()
23
+ {
24
+ return array(
25
+ array('value' => '3', 'label'=>Mage::helper('adminhtml')->__('Visa')),
26
+ array('value' => '4', 'label'=>Mage::helper('adminhtml')->__('Mastercard')),
27
+ array('value' => '2', 'label'=>Mage::helper('adminhtml')->__('Diners')),
28
+ array('value' => '5', 'label'=>Mage::helper('adminhtml')->__('American Express')),
29
+ array('value' => '18', 'label'=>Mage::helper('adminhtml')->__('Aura')),
30
+ array('value' => '16', 'label'=>Mage::helper('adminhtml')->__('Elo')),
31
+ array('value' => '15', 'label'=>Mage::helper('adminhtml')->__('Discover')),
32
+ array('value' => '19', 'label'=>Mage::helper('adminhtml')->__('JCB')),
33
+ array('value' => '14', 'label'=>Mage::helper('adminhtml')->__('Peela')),
34
+ array('value' => '7', 'label'=>Mage::helper('adminhtml')->__('Itaú Shopline (Transferência)')),
35
+ array('value' => '22', 'label'=>Mage::helper('adminhtml')->__('Transf. Online Bradesco')),
36
+ array('value' => '23', 'label'=>Mage::helper('adminhtml')->__('Transf. Online Banco do Brasil')),
37
+ array('value' => '6', 'label'=>Mage::helper('adminhtml')->__('Boleto Bancário')),
38
+ );
39
+ }
40
+ }
app/code/community/Tray/CheckoutApi/Model/Source/Qtdsplit.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Model_Source_Qtdsplit
21
+ {
22
+ public function toOptionArray()
23
+ {
24
+ return array(
25
+ array('value' => '1', 'label'=>"1"),
26
+ array('value' => '2', 'label'=>"2"),
27
+ array('value' => '3', 'label'=>"3"),
28
+ array('value' => '4', 'label'=>"4"),
29
+ array('value' => '5', 'label'=>"5"),
30
+ array('value' => '6', 'label'=>"6"),
31
+ array('value' => '7', 'label'=>"7"),
32
+ array('value' => '8', 'label'=>"8"),
33
+ array('value' => '9', 'label'=>"9"),
34
+ array('value' => '10', 'label'=>"10"),
35
+ array('value' => '11', 'label'=>"11"),
36
+ array('value' => '12', 'label'=>"12"),
37
+ );
38
+ }
39
+ }
app/code/community/Tray/CheckoutApi/Model/Source/Specificcountries.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Model_Source_Specificcountries
21
+ {
22
+ public function toOptionArray()
23
+ {
24
+ return array(
25
+ array('value'=>1, 'label'=>Mage::helper('adminhtml')->__('Specific Countries')),
26
+ );
27
+ }
28
+ }
app/code/community/Tray/CheckoutApi/Model/Standard.php ADDED
@@ -0,0 +1,653 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_Model_Standard extends Mage_Payment_Model_Method_Abstract
21
+ {
22
+ const PAYMENT_TYPE_AUTH = 'AUTHORIZATION'; //retirar
23
+ const PAYMENT_TYPE_SALE = 'SALE'; //retirar
24
+
25
+ protected $_allowCurrencyCode = array('BRL');
26
+
27
+ protected $_code = 'traycheckoutapi';
28
+
29
+ protected $_formBlockType = 'checkoutapi/form_standard';
30
+
31
+ protected $_blockType = 'checkoutapi/standard';
32
+
33
+ protected $_infoBlockType = 'checkoutapi/info_standard';
34
+
35
+ protected $errorMessageTrayCheckout = '';
36
+
37
+ protected $errorCodeTrayCheckout = '';
38
+
39
+ protected $errorTypeErrorTrayCheckout = '';
40
+
41
+ /**
42
+ * Availability options
43
+ */
44
+
45
+
46
+ /**
47
+ * Can be edit order (renew order)
48
+ *
49
+ * @return bool
50
+ */
51
+ public function canEdit()
52
+ {
53
+ return false;
54
+ }
55
+
56
+ /**
57
+ * Return Order Place Redirect URL
58
+ *
59
+ * @return string Order Redirect URL
60
+ */
61
+ public function getOrderPlaceRedirectUrl()
62
+ {
63
+ return Mage::getUrl('checkoutapi/standard/payment', array('_secure' => true, 'type' => 'standard'));
64
+ //return Mage::getUrl('checkoutapi/redirect');
65
+ }
66
+
67
+ /**
68
+ * Get checkoutapi session namespace
69
+ *
70
+ * @return Tray_CheckoutApi_Model_Session
71
+ */
72
+ public function getSession()
73
+ {
74
+ return Mage::getSingleton('checkoutapi/session');
75
+ }
76
+
77
+ /**
78
+ * Get checkout session namespace
79
+ *
80
+ * @return Mage_Checkout_Model_Session
81
+ */
82
+ public function getCheckout()
83
+ {
84
+ return Mage::getSingleton('checkout/session');
85
+ }
86
+
87
+ /**
88
+ * Get current quote
89
+ *
90
+ * @return Mage_Sales_Model_Quote
91
+ */
92
+ public function getQuote()
93
+ {
94
+ return $this->getCheckout()->getQuote();
95
+ }
96
+
97
+ /**
98
+ * Using for multiple shipping address
99
+ *
100
+ * @return bool
101
+ */
102
+ public function canUseForMultishipping()
103
+ {
104
+ return false;
105
+ }
106
+
107
+ public function createFormBlock($name)
108
+ {
109
+ $block = $this->getLayout()->createBlock($_formBlockType, $name)
110
+ ->setMethod('checkoutapi')
111
+ ->setPayment($this->getPayment())
112
+ ->setTemplate('tray/checkoutapi/form.phtml');
113
+ return $block;
114
+ }
115
+
116
+ public function assignData($data)
117
+ {
118
+ if (!($data instanceof Varien_Object)) {
119
+ $data = new Varien_Object($data);
120
+ }
121
+ $info = $this->getInfoInstance();
122
+ $info->setCcType($data->getCcType())
123
+ ->setCcOwner($data->getCcOwner())
124
+ ->setCcLast4(substr($data->getCcNumber(), -4))
125
+ ->setCcNumber($data->getCcNumber())
126
+ ->setCcCid($data->getCcCid())
127
+ ->setCcExpMonth($data->getCcExpMonth())
128
+ ->setCcExpYear($data->getCcExpYear())
129
+ ->setTraycheckoutSplitNumber($data->getTraycheckoutSplitNumber())
130
+ ->setTraycheckoutSplitValue($data->getTraycheckoutSplitValue())
131
+ ->setCcNumber($data->getCcNumber());
132
+ return $this;
133
+ }
134
+
135
+ public function prepareSave()
136
+ {
137
+ $info = $this->getInfoInstance();
138
+ $info->setCcNumberEnc($info->encrypt($info->getCcNumber()));
139
+
140
+ $info->setCcCidEnc($info->encrypt($info->getCcCid()));
141
+ $info->setCcNumber(null)
142
+ ->setCcCid(null);
143
+ return $this;
144
+ }
145
+
146
+ public function validateCcNum($ccNumber)
147
+ {
148
+ $cardNumber = strrev($ccNumber);
149
+ $numSum = 0;
150
+
151
+ for ($i=0; $i<strlen($cardNumber); $i++) {
152
+ $currentNum = substr($cardNumber, $i, 1);
153
+
154
+ /**
155
+ * Double every second digit
156
+ */
157
+ if ($i % 2 == 1) {
158
+ $currentNum *= 2;
159
+ }
160
+
161
+ /**
162
+ * Add digits of 2-digit numbers together
163
+ */
164
+ if ($currentNum > 9) {
165
+ $firstNum = $currentNum % 10;
166
+ $secondNum = ($currentNum - $firstNum) / 10;
167
+ $currentNum = $firstNum + $secondNum;
168
+ }
169
+
170
+ $numSum += $currentNum;
171
+ }
172
+
173
+ /**
174
+ * If the total has no remainder it's OK
175
+ */
176
+ return ($numSum % 10 == 0);
177
+ }
178
+
179
+ public function validate()
180
+ {
181
+ parent::validate();
182
+
183
+ $errorMsg = "";
184
+ $quote = $this->getCheckout()->getQuote();
185
+
186
+ $shippingAddress = $quote->getShippingAddress();
187
+ $billingAddress = $quote->getBillingAddress();
188
+
189
+ // Verificação se consta o nome vazio do consumidor
190
+ if (str_replace(" ","",$billingAddress->getData("firstname")." ".$billingAddress->getData("lastname")) == "") {
191
+ $errorMsg .= "Nome do comprador em branco ou inválido!!\n";
192
+ }
193
+ // Validação do CPF do cliente
194
+ $number_taxvat = str_replace(" ","",str_replace(".","",str_replace("-","",$quote->getCustomer()->getData("taxvat"))));
195
+ if($number_taxvat == null){
196
+ $number_taxvat = str_replace(" ","",str_replace(".","",str_replace("-","",$billingAddress->getData("taxvat"))));
197
+ }
198
+ if (preg_match("/[a-zA-Z]/",$number_taxvat)) {
199
+ $errorMsg .= "CPF em branco ou inválido!!\n";
200
+ }
201
+ // Validação do email do cliente
202
+ if (!filter_var($billingAddress->getData("email"), FILTER_VALIDATE_EMAIL)) {
203
+ $errorMsg .= "E-mail em branco ou inválido!!\n";
204
+ }
205
+ // Validação do telefone do cliente
206
+ $number_contact = substr(str_replace(" ","",str_replace("(","",str_replace(")","",str_replace("-","",$shippingAddress->getTelephone())))),0,2) . substr(str_replace(" ","",str_replace("-","",$shippingAddress->getTelephone())),-8);
207
+ if (preg_match('/[a-zA-Z]/',$number_contact)) {
208
+ $errorMsg .= "Telefone em branco ou inválido!!\n";
209
+ }
210
+ // Verificação se consta o endereço do cliente
211
+ if (str_replace(" ","",$shippingAddress->getStreet(1)) == "") {
212
+ $errorMsg .= "Endereço em branco ou inválido!!\n";
213
+ }
214
+ // Validação do número do endereço.
215
+ if (preg_match('/[a-zA-Z]/',$shippingAddress->getStreet(2))) {
216
+ $errorMsg .= "Número do endereço em branco ou inválido!!\n";
217
+ }
218
+ // Verificação se consta o bairro do endereço do cliente
219
+ if (str_replace(" ","",$shippingAddress->getStreet(4)) == "") {
220
+ $errorMsg .= "Bairro em branco ou inválido!!\n";
221
+ }
222
+ // Verificação se consta o cidade do endereço do cliente
223
+ if (str_replace(" ","",$shippingAddress->getCity()) == "") {
224
+ $errorMsg .= "Cidade em branco ou inválido!!\n";
225
+ }
226
+ // Validação do número do endereço.
227
+ if (!preg_match('/[A-Z]{2}$/',$shippingAddress->getRegionCode())) {
228
+ if (!preg_match('/[A-Z]{2}$/',$shippingAddress->getRegion())) {
229
+ $errorMsg .= "Estado em branco ou inválido!!\n";
230
+ }
231
+ }
232
+ //var_dump($shippingAddress->getRegionCode());
233
+ $currency_code = $this->getQuote()->getBaseCurrencyCode();
234
+ if (!$currency_code){
235
+ $session = Mage::getSingleton('adminhtml/session_quote');
236
+ $currency_code = $session->getQuote()->getBaseCurrencyCode();
237
+ }
238
+ if (!in_array($currency_code,$this->_allowCurrencyCode)) {
239
+ Mage::throwException(Mage::helper('checkoutapi')->__('A moeda selecionada ('.$currency_code.') não é compatível com o Tray'));
240
+ }
241
+
242
+ $ccType = $quote->getPayment()->getData('cc_type');
243
+ $ccNumber = $quote->getPayment()->getData('cc_number');
244
+ if(!in_array($ccType, array("2","6","7","14","22","23"))){
245
+ if ($this->validateCcNum($ccNumber)) {
246
+ switch ($ccType){
247
+ // Validação Visa
248
+ case "3":
249
+ if (!preg_match('/^4([0-9]{12}|[0-9]{15})$/', $ccNumber)) {
250
+ $errorMsg .= Mage::helper('payment')->__('Invalid Credit Card Number')."\n";
251
+ }
252
+ break;
253
+ // Validação Master
254
+ case "4":
255
+ if (!preg_match('/^5([1-5][0-9]{14})$/', $ccNumber)) {
256
+ $errorMsg .= Mage::helper('payment')->__('Invalid Credit Card Number')."\n";
257
+ }
258
+ break;
259
+ // Validação American Express
260
+ case "5":
261
+ if (!preg_match('/^3[47][0-9]{13}$/', $ccNumber)) {
262
+ $errorMsg .= Mage::helper('payment')->__('Invalid Credit Card Number')."\n";
263
+ }
264
+ break;
265
+ // Validação Discovery
266
+ case "15":
267
+ if (!preg_match('/^6011[0-9]{12}$/', $ccNumber)) {
268
+ $errorMsg .= Mage::helper('payment')->__('Invalid Credit Card Number')."\n";
269
+ }
270
+ break;
271
+ // Validação JCB
272
+ case "19":
273
+ if (!preg_match('/^(3[0-9]{15}|(2131|1800)[0-9]{11})$/', $ccNumber)) {
274
+ $errorMsg .= Mage::helper('payment')->__('Invalid Credit Card Number')."\n";
275
+ }
276
+ break;
277
+ }
278
+ }
279
+ else {
280
+ $errorMsg = Mage::helper('payment')->__('Invalid Credit Card Number')."\n";
281
+ }
282
+ }
283
+ if($ccType == "2"){
284
+ if (!preg_match('/^3(6|8)[0-9]{12}|^3(00|01|02|03|04|05)[0-9]{11}$/', $ccNumber)) {
285
+ $errorMsg .= Mage::helper('payment')->__('Invalid Credit Card Number')."\n";
286
+ }
287
+ }
288
+
289
+ if($errorMsg != ""){
290
+ $errorMsg .= "\nVerifique as informações para finalizar a compra pelo TrayCheckout!";
291
+ Mage::throwException($errorMsg);
292
+ }
293
+ return $this;
294
+ }
295
+
296
+ public function onOrderValidate(Mage_Sales_Model_Order_Payment $payment)
297
+ {
298
+ return $this;
299
+ }
300
+
301
+ public function onInvoiceCreate(Mage_Sales_Model_Invoice_Payment $payment)
302
+ {
303
+ return $this;
304
+ }
305
+
306
+ public function canCapture()
307
+ {
308
+ return true;
309
+ }
310
+
311
+ public function decrypt($data)
312
+ {
313
+ if ($data) {
314
+ return Mage::helper('core')->decrypt($data);
315
+ }
316
+ return $data;
317
+ }
318
+
319
+ public function getCheckoutFormFields()
320
+ {
321
+ $orderIncrementId = $this->getCheckout()->getLastRealOrderId();
322
+
323
+ if (!$orderIncrementId) {
324
+ $quoteidbackend = $this->getCheckout()->getData('checkoutapi_quote_id');
325
+ $order = Mage::getModel('sales/order')->loadByAttribute('quote_id', $quoteidbackend);
326
+ $orderIncrementId = $order->getData('increment_id');
327
+ }
328
+ else {
329
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
330
+ }
331
+
332
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
333
+
334
+ // Envia email de confirmação ao cliente
335
+ if(!$order->getEmailSent()) {
336
+ $order->sendNewOrderEmail();
337
+ $order->setEmailSent(true);
338
+ $order->save();
339
+ }
340
+
341
+ $isOrderVirtual = $order->getIsVirtual();
342
+ $ac = $order->getBillingAddress();
343
+ $a = $isOrderVirtual ? $order->getBillingAddress() : $order->getShippingAddress();
344
+
345
+ list($items, $totals, $discountAmount, $shippingAmount) = Mage::helper('checkoutapi')->prepareLineItems($order, false, false);
346
+
347
+ $shipping_description = $order->getData('shipping_description');
348
+
349
+ $sArr = array();
350
+ $number_contact = substr(str_replace(" ","",str_replace("(","",str_replace(")","",str_replace("-","",$a->getTelephone())))),0,2) . substr(str_replace(" ","",str_replace("-","",$a->getTelephone())),-8);
351
+
352
+ $sArr['token_account']= $this->getConfigData('token');
353
+ $sArr['transaction[order_number]']= $this->getConfigData('prefixo').$orderIncrementId;
354
+
355
+ $sArr['customer[name]']= $order->getData("customer_firstname") . ' ' . str_replace("(pj)", "", $order->getData("customer_lastname"));
356
+ $sArr['customer[cpf]']= $order->getData("customer_taxvat");
357
+ $sArr['customer[contacts][][number_contact]']= $number_contact;
358
+ $sArr['customer[contacts][][type_contact]']= "H";
359
+ $sArr['customer[email]']= $a->getEmail();
360
+
361
+ // Endereço de Entrega
362
+ $sArr['customer[addresses][0][type_address]']= "D";
363
+ $sArr['customer[addresses][0][postal_code]']= trim(str_replace("-", "", $a->getPostcode()));
364
+ $sArr['customer[addresses][0][street]']= $a->getStreet(1);
365
+ $sArr['customer[addresses][0][number]']= $a->getStreet(2);
366
+ $sArr['customer[addresses][0][completion]']= $a->getStreet(3);
367
+ $sArr['customer[addresses][0][neighborhood]']=$a->getStreet(4);
368
+ $sArr['customer[addresses][0][city]']= $a->getCity();
369
+ $sArr['customer[addresses][0][state]']= ($a->getRegionCode() != "") ? $a->getRegionCode() : $a->getRegion();
370
+
371
+ // Endereço de Cobrança
372
+ $sArr['customer[addresses][1][type_address]']= "B";
373
+ $sArr['customer[addresses][1][postal_code]']= trim(str_replace("-", "", $ac->getPostcode()));
374
+ $sArr['customer[addresses][1][street]']= $ac->getStreet(1);
375
+ $sArr['customer[addresses][1][number]']= $ac->getStreet(2);
376
+ $sArr['customer[addresses][1][completion]']= $ac->getStreet(3);
377
+ $sArr['customer[addresses][1][neighborhood]']=$ac->getStreet(4);
378
+ $sArr['customer[addresses][1][city]']= $ac->getCity();
379
+ $sArr['customer[addresses][1][state]']= ($ac->getRegionCode() != "") ? $ac->getRegionCode() : $ac->getRegion();
380
+
381
+ if ($items) {
382
+ $i = 0;
383
+ foreach($items as $item) {
384
+ if ($item->getAmount() > 0) {
385
+ $sArr ["transaction_product[$i][code]"] = $item->getId();
386
+ $sArr ["transaction_product[$i][description]"] = $item->getName();
387
+ $sArr ["transaction_product[$i][quantity]"] = $item->getQty();
388
+ $sArr ["transaction_product[$i][price_unit]"] = sprintf('%.2f',$item->getAmount());
389
+ $sArr ["transaction_product[$i][sku_code]"] = $item->getId();
390
+ $i++;
391
+ }
392
+ }
393
+ $sArr["transaction[price_discount]"] = is_numeric( $discountAmount ) ? sprintf('%.2f',$discountAmount) : 0;
394
+ $sArr["transaction[price_additional]"] = is_numeric( $order->getData("base_tax_amount") ) ? sprintf('%.2f',$order->getData("base_tax_amount")) : 0;
395
+ }
396
+
397
+ $shipping = sprintf('%.2f',$shippingAmount) ;
398
+
399
+ $sArr['transaction[shipping_type]'] = $shipping_description;
400
+ $sArr['transaction[shipping_price]'] = $shipping;
401
+
402
+ $sArr['transaction[url_process]'] = Mage::getUrl('checkoutapi/standard/return', array('_secure' => true));
403
+ $sArr['transaction[url_success]'] = Mage::getUrl('checkoutapi/standard/return', array('_secure' => true));
404
+ $sArr['transaction[url_notification]'] = Mage::getUrl('checkoutapi/standard/success', array('_secure' => true, 'type' => 'standard'));
405
+
406
+ $sArr['payment[payment_method_id]'] = $order->getPayment()->getData('cc_type');
407
+ $sArr['payment[split]'] = ($order->getPayment()->getData('traycheckout_split_number') == NULL ? '1' : $order->getPayment()->getData('traycheckout_split_number'));
408
+ $sArr['payment[card_name]'] = $order->getPayment()->getData('cc_owner');
409
+ $sArr['payment[card_number]'] = $this->decrypt($order->getPayment()->getData('cc_number_enc'));
410
+ $sArr['payment[card_expdate_month]'] = $order->getPayment()->getData('cc_exp_month');
411
+ $sArr['payment[card_expdate_year]'] = $order->getPayment()->getData('cc_exp_year');
412
+ $sArr['payment[card_cvv]'] = $this->decrypt(Mage::getModel('sales/quote_payment')->load($order->getData("quote_id"),"quote_id")->getData("cc_cid_enc"));
413
+
414
+ $sReq = '';
415
+ $rArr = array();
416
+ foreach ($sArr as $k=>$v) {
417
+ $value = str_replace("&","and",$v);
418
+ $rArr[$k] = $value;
419
+ $sReq .= '&'.$k.'='.$value;
420
+ }
421
+ return $rArr;
422
+ }
423
+
424
+ public function getTrayCheckoutUrl()
425
+ {
426
+ if ($this->getConfigData('sandbox') == '1')
427
+ {
428
+ return 'http://api.sandbox.traycheckout.com.br';
429
+ } else {
430
+ return 'https://api.traycheckout.com.br';
431
+ }
432
+ }
433
+
434
+ public function getErrorMessageTrayCheckout() {
435
+ return $this->errorMessageTrayCheckout;
436
+ }
437
+
438
+ public function getErrorCodeTrayCheckout() {
439
+ return $this->errorCodeTrayCheckout;
440
+ }
441
+ public function getTypeErrorTrayCheckout() {
442
+ return $this->errorTypeErrorTrayCheckout;
443
+ }
444
+
445
+ public function hasErrorTrayCheckout($res){
446
+ $xml = simplexml_load_string($res);
447
+ $codeTc = "";
448
+ $messageTc = "";
449
+
450
+ if($xml->message_response->message == "error"){
451
+ if(!empty($xml->error_response->general_errors)){
452
+ $this->errorTypeErrorTrayCheckout = "G";
453
+ $qtdError = sizeof($xml->error_response->general_errors->general_error);
454
+ for($i = 0; $i < $qtdError; $i++){
455
+ $codeTc .= $xml->error_response->general_errors->general_error[$i]->code . " | ";
456
+ $messageTc .= $xml->error_response->general_errors->general_error[$i]->message . " | ";
457
+ }
458
+
459
+ }
460
+ if(!empty($xml->error_response->validation_errors)){
461
+ $this->errorTypeErrorTrayCheckout = "V";
462
+ $qtdError = sizeof($xml->error_response->validation_errors->validation_error);
463
+ for($i = 0; $i < $qtdError; $i++){
464
+ $codeTc .= $xml->error_response->validation_errors->validation_error[$i]->field . " | ";
465
+ $messageTc .= $xml->error_response->validation_errors->validation_error[$i]->message_complete . " | ";
466
+ }
467
+ }
468
+ $codeTc = substr($codeTc, 0, - 3);
469
+ $messageTc = substr($messageTc, 0, - 3);
470
+ $this->errorCodeTrayCheckout = $codeTc;
471
+ $this->errorMessageTrayCheckout = $messageTc;
472
+ return true;
473
+ }else{
474
+ return false;
475
+ }
476
+ }
477
+
478
+ public function getTrayCheckoutRequest($url = "", $params = "")
479
+ {
480
+ $ch = curl_init ( $this->getTrayCheckoutUrl().$url );
481
+
482
+ curl_setopt ( $ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1 );
483
+ curl_setopt ( $ch, CURLOPT_POST, 1 );
484
+ curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );
485
+ curl_setopt ( $ch, CURLOPT_POSTFIELDS, $params);
486
+ curl_setopt ( $ch, CURLOPT_SSL_VERIFYPEER, 1 );
487
+ curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, 2 );
488
+ curl_setopt ( $ch, CURLOPT_FORBID_REUSE, 1 );
489
+ curl_setopt ( $ch, CURLOPT_HTTPHEADER, array ('Connection: Close' ) );
490
+
491
+ if (! ($res = curl_exec ( $ch ))) {
492
+ Mage::app()->getResponse()->setRedirect('checkoutapi/standard/error', array('_secure' => true , 'descricao' => urlencode(utf8_encode("Erro de execução!")),'codigo' => urlencode("999")))->sendResponse();
493
+ echo "Erro na execucao!";
494
+ curl_close ( $ch );
495
+ exit ();
496
+ }
497
+ $httpCode = curl_getinfo ( $ch, CURLINFO_HTTP_CODE );
498
+
499
+ if ($httpCode != "200") {
500
+ http::httpError("Erro de requisicao em: $urlPost");
501
+ Mage::app()->getResponse()->setRedirect('checkoutapi/standard/error', array('_secure' => true , 'descricao' => urlencode(utf8_encode("Erro ao conectar em: $url")),'codigo' => urlencode($httpCode)))->sendResponse();
502
+ }
503
+ if(curl_errno($ch)){
504
+ http::httpError("Erro de conexão: " . curl_error($ch));
505
+ Mage::app()->getResponse()->setRedirect('checkoutapi/standard/error', array('_secure' => true , 'descricao' => urlencode(utf8_encode("Erro de conexão: " . curl_error($ch))),'codigo' => urlencode($httpCode)))->sendResponse();
506
+ }
507
+ curl_close($ch);
508
+
509
+ if($this->hasErrorTrayCheckout($res)){
510
+ Mage::app()->getResponse()->setRedirect(Mage::getModel('core/url')->getUrl('checkoutapi/standard/error', array('_secure' => true , 'descricao' => urlencode($this->getErrorMessageTrayCheckout()),'codigo' => urlencode($this->getErrorCodeTrayCheckout()),'type' => $this->getTypeErrorTrayCheckout())))->sendResponse();
511
+ exit;
512
+ }
513
+ return $res;
514
+ }
515
+
516
+ function updateTransactionTrayCheckout($transactionTc){
517
+
518
+ $order = Mage::getModel('sales/order')->loadByIncrementId($transactionTc->order_number);
519
+ $quote = Mage::getModel('sales/quote')->load($order->getData("quote_id"));
520
+
521
+ $quote->getPayment()->setData("traycheckout_transaction_id", $transactionTc->transaction_id);
522
+ $quote->getPayment()->setData("traycheckout_token_transaction", $transactionTc->token_transaction);
523
+ $quote->getPayment()->setData("traycheckout_url_payment", $transactionTc->payment->url_payment);
524
+ $quote->getPayment()->setData("traycheckout_typeful_line", $transactionTc->payment->linha_digitavel);
525
+
526
+ $quote->getPayment()->save();
527
+
528
+ $order->getPayment()->setData("traycheckout_transaction_id", $transactionTc->transaction_id);
529
+ $order->getPayment()->setData("traycheckout_token_transaction", $transactionTc->token_transaction);
530
+ $order->getPayment()->setData("traycheckout_url_payment", $transactionTc->payment->url_payment);
531
+ $order->getPayment()->setData("traycheckout_typeful_line", $transactionTc->payment->linha_digitavel);
532
+
533
+
534
+ $cod_status = $transactionTc->status_id;
535
+ $comment = "";
536
+ if (isset($transactionTc->status_id)) {
537
+ $comment .= " " . $transactionTc->status_id;
538
+ }
539
+
540
+ if (isset($transactionTc->status_name)) {
541
+ $comment .= " - " . $transactionTc->status_name;
542
+ }
543
+ switch ($cod_status){
544
+ case '4':
545
+ case '5':
546
+ case '88':
547
+ $order->addStatusToHistory(
548
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('checkoutapi')->__('TrayCheckout retornou o status: %s', $comment)
549
+
550
+ );
551
+ break;
552
+ case '6':
553
+ $items = $order->getAllItems();
554
+
555
+ $thereIsVirtual = false;
556
+
557
+ foreach ($items as $itemId => $item) {
558
+ if ($item["is_virtual"] == "1" || $item["is_downloadable"] == "1") {
559
+ $thereIsVirtual = true;
560
+ }
561
+ }
562
+
563
+ // what to do - from admin
564
+ $toInvoice = $this->getApi()->getConfigData('acaopadraovirtual') == "1" ? true : false;
565
+
566
+ if ($thereIsVirtual && !$toInvoice) {
567
+
568
+ $frase = 'Tray - Aprovado. Pagamento (fatura) confirmado automaticamente.';
569
+
570
+ $order->addStatusToHistory(
571
+ $order->getStatus(), //continue setting current order status
572
+ Mage::helper('checkoutapi')->__($frase), true
573
+ );
574
+
575
+ $order->sendOrderUpdateEmail(true, $frase);
576
+ } else {
577
+
578
+ if (!$order->canInvoice()) {
579
+ $isHolded = ( $order->getStatus() == Mage_Sales_Model_Order::STATE_HOLDED );
580
+
581
+ $status = ($isHolded) ? Mage_Sales_Model_Order::STATE_PROCESSING : $order->getStatus();
582
+ $frase = ($isHolded) ? 'Tray - Aprovado. Confirmado automaticamente o pagamento do pedido.' : 'Erro ao criar pagamento (fatura).';
583
+
584
+ //when order cannot create invoice, need to have some logic to take care
585
+ $order->addStatusToHistory(
586
+ $status, //continue setting current order status
587
+ Mage::helper('checkoutapi')->__( $frase )
588
+ );
589
+
590
+ } else {
591
+
592
+ //need to save transaction id
593
+ $order->getPayment()->setTransactionId($dados_post['transaction']['transaction_id']);
594
+
595
+ //need to convert from order into invoice
596
+ $invoice = $order->prepareInvoice();
597
+
598
+ if ($this->getApi()->canCapture()) {
599
+ $invoice->register()->capture();
600
+ }
601
+
602
+ Mage::getModel('core/resource_transaction')
603
+ ->addObject($invoice)
604
+ ->addObject($invoice->getOrder())
605
+ ->save();
606
+
607
+ $frase = 'Pagamento (fatura) ' . $invoice->getIncrementId() . ' foi criado. Tray - Aprovado. Confirmado automaticamente o pagamento do pedido.';
608
+
609
+ if ($thereIsVirtual) {
610
+
611
+ $order->addStatusToHistory(
612
+ $order->getStatus(), Mage::helper('checkoutapi')->__($frase), true
613
+ );
614
+
615
+ } else {
616
+
617
+ $order->addStatusToHistory(
618
+ Mage_Sales_Model_Order::STATE_PROCESSING, //update order status to processing after creating an invoice
619
+ Mage::helper('checkoutapi')->__($frase), true
620
+ );
621
+ }
622
+
623
+ $invoice->sendEmail(true, $frase);
624
+ }
625
+ }
626
+ break;
627
+ case '24':
628
+ $order->addStatusToHistory(
629
+ Mage_Sales_Model_Order::STATE_HOLDED, Mage::helper('checkoutapi')->__('TrayCheckout retornou o status: %s', $comment)
630
+ );
631
+ break;
632
+ case '7':
633
+ case '89':
634
+ $frase = 'Tray - Cancelado. Pedido cancelado automaticamente (transação foi cancelada ou pagamento foi negado).';
635
+
636
+ $order->addStatusToHistory(
637
+ Mage_Sales_Model_Order::STATE_CANCELED, Mage::helper('checkoutapi')->__($frase), true
638
+ );
639
+
640
+ $order->sendOrderUpdateEmail(true, $frase);
641
+
642
+ $order->cancel();
643
+ break;
644
+ case '87':
645
+ $order->addStatusToHistory(
646
+ Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, Mage::helper('checkoutapi')->__('TrayCheckout retornou o status: %s', $comment)
647
+ );
648
+ break;
649
+ }
650
+ $order->save();
651
+ }
652
+
653
+ }
app/code/community/Tray/CheckoutApi/controllers/StandardController.php ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ class Tray_CheckoutApi_StandardController extends Mage_Core_Controller_Front_Action
21
+ {
22
+
23
+ /**
24
+ * Order instance
25
+ */
26
+ protected $_order;
27
+
28
+
29
+ public function paymentAction()
30
+ {
31
+ $this->loadLayout();
32
+ $this->renderLayout();
33
+ }
34
+
35
+ public function returnAction()
36
+ {
37
+ $this->loadLayout();
38
+ $this->renderLayout();
39
+ }
40
+
41
+ public function paymentbackendAction()
42
+ {
43
+ $this->loadLayout();
44
+ $this->renderLayout();
45
+
46
+ $hash = explode("/order/", $this->getRequest()->getOriginalRequest()->getRequestUri());
47
+ $hashdecode = explode(":", Mage::getModel('core/encryption')->decrypt($hash[1]));
48
+
49
+ $order = Mage::getModel('sales/order')
50
+ ->getCollection()
51
+ ->addFieldToFilter('increment_id', $hashdecode[0])
52
+ ->addFieldToFilter('quote_id', $hashdecode[1])
53
+ ->getFirstItem();
54
+
55
+ if ($order) {
56
+ $session = Mage::getSingleton('checkout/session');
57
+ $session->setLastQuoteId($order->getData('quote_id'));
58
+ $session->setLastOrderId($order->getData('entity_id'));
59
+ $session->setLastSuccessQuoteId($order->getData('quote_id'));
60
+ $session->setLastRealOrderId($order->getData('increment_id'));
61
+ $session->setCheckoutApiQuoteId($order->getData('quote_id'));
62
+ $this->_redirect('checkoutapi/standard/payment/type/standard');
63
+ } else {
64
+ Mage::getSingleton('checkout/session')->addError('URL informada é inválida!');
65
+ $this->_redirect('checkout/cart');
66
+ }
67
+ }
68
+
69
+ public function errorAction()
70
+ {
71
+ $this->loadLayout();
72
+ $this->renderLayout();
73
+ }
74
+
75
+ /**
76
+ * Get order
77
+ *
78
+ * @return Mage_Sales_Model_Order
79
+ */
80
+ public function getOrder() {
81
+
82
+ if ($this->_order == null) {
83
+
84
+ }
85
+
86
+ return $this->_order;
87
+ }
88
+
89
+ protected function _expireAjax() {
90
+ if (!Mage::getSingleton('checkout/session')->getQuote()->hasItems()) {
91
+ $this->getResponse()->setHeader('HTTP/1.1', '403 Session Expired');
92
+ exit;
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Get singleton with checkout standard order transaction information
98
+ *
99
+ * @return Tray_CheckoutApi_Model_Api
100
+ */
101
+ public function getApi()
102
+ {
103
+ return Mage::getSingleton('checkoutapi/'.$this->getRequest()->getParam("type"));
104
+ }
105
+
106
+ /**
107
+ * When a customer chooses Tray on Checkout/Payment page
108
+ *
109
+ */
110
+ public function redirectAction()
111
+ {
112
+
113
+ $type = $this->getRequest()->getParam('type', false);
114
+
115
+ $session = Mage::getSingleton('checkout/session');
116
+
117
+ $session->setCheckoutApiQuoteId($session->getQuoteId());
118
+
119
+ $this->getResponse()->setHeader("Content-Type", "text/html; charset=ISO-8859-1", true);
120
+
121
+ $this->getResponse()->setBody($this->getLayout()->createBlock('checkoutapi/redirect')->toHtml());
122
+
123
+ $session->unsQuoteId();
124
+ }
125
+
126
+ /**
127
+ * When a customer cancel payment from traycheckout .
128
+ */
129
+ public function cancelAction()
130
+ {
131
+
132
+ $session = Mage::getSingleton('checkout/session');
133
+
134
+ $session->setQuoteId($session->getCheckoutApiQuoteId(true));
135
+
136
+ // cancel order
137
+ if ($session->getLastRealOrderId()) {
138
+
139
+ $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
140
+
141
+ if ($order->getId()) {
142
+ $order->cancel()->save();
143
+ }
144
+ }
145
+
146
+ $this->_redirect('checkout/cart');
147
+ }
148
+
149
+ private function getUrlPostCheckoutApi($sandbox)
150
+ {
151
+ if ($sandbox == '1')
152
+ {
153
+ return "http://api.sandbox.checkout.tray.com.br/api/v1/transactions/get_by_token";
154
+ } else {
155
+ return "http://api.checkout.tray.com.br/api/v1/transactions/get_by_token";
156
+ }
157
+ }
158
+
159
+ /**
160
+ * when checkout returns
161
+ * The order information at this point is in POST
162
+ * variables. However, you don't want to "process" the order until you
163
+ * get validation from the return post.
164
+ */
165
+ public function successAction()
166
+ {
167
+ $_type = $this->getRequest()->getParam('type', false);
168
+ $token = $this->getApi()->getConfigData('token');;
169
+
170
+ $urlPost = $this->getUrlPostCheckoutApi($this->getApi()->getConfigData('sandbox'));
171
+
172
+ $dados_post = $this->getRequest()->getPost();
173
+
174
+ $order_number_conf = utf8_encode(str_replace($this->getApi()->getConfigData('prefixo'),'',$dados_post['transaction']['order_number']));
175
+ $transaction_token= $dados_post['transaction']['transaction_token'];
176
+
177
+ ob_start();
178
+ $ch = curl_init();
179
+ curl_setopt($ch, CURLOPT_URL, $urlPost);
180
+ curl_setopt($ch, CURLOPT_POST, 1);
181
+ curl_setopt($ch, CURLOPT_POSTFIELDS, array("token"=>trim($transaction_token), "type_response"=>"J"));
182
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Expect:"));
183
+ curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
184
+ curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
185
+ curl_exec ($ch);
186
+
187
+ /* XML ou Json de retorno */
188
+ $resposta = ob_get_contents();
189
+ ob_end_clean();
190
+
191
+ /* Capturando o http code para tratamento dos erros na requisi��o*/
192
+ $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
193
+ curl_close($ch);
194
+ $arrResponse = json_decode($resposta,TRUE);
195
+
196
+ $xml = simplexml_load_string($resposta);
197
+ if($httpCode != "200" ){
198
+ $codigo_erro = $xml->codigo;
199
+ $descricao_erro = $xml->descricao;
200
+ if ($codigo_erro == ''){
201
+ $codigo_erro = '0000000';
202
+ }
203
+ if ($descricao_erro == ''){
204
+ $descricao_erro = 'Erro Desconhecido';
205
+ }
206
+ $this->_redirect('checkoutapi/standard/error', array('_secure' => true , 'descricao' => urlencode(utf8_encode($descricao_erro)),'codigo' => urlencode($codigo_erro)));
207
+ }else{
208
+
209
+ $transaction = $arrResponse['data_response']['transaction'];
210
+ $order_number = str_replace($this->getApi()->getConfigData('prefixo'),'',$transaction['order_number']);
211
+ if($order_number != $order_number_conf) {
212
+ $codigo_erro = '0000000';
213
+ $descricao_erro = "Pedido: " . $order_number_conf . " não corresponte com a pedido consultado: ".$order_number."!";
214
+ $this->_redirect('checkoutapi/standard/error', array('_secure' => true , 'descricao' => urlencode(utf8_encode($descricao_erro)),'codigo' => urlencode($codigo_erro)));
215
+ }
216
+
217
+ if (isset($transaction['status_id'])) {
218
+ $comment .= " " . $transaction['status_id'];
219
+ }
220
+
221
+ if (isset($transaction['status_name'])) {
222
+ $comment .= " - " . $transaction['status_name'];
223
+ }
224
+ echo "Pedido: $order_number - $comment - ID: ".$dados_post['transaction']['transaction_id'];
225
+ $order = Mage::getModel('sales/order');
226
+
227
+ $order->loadByIncrementId($order_number);
228
+
229
+ if ($order->getId()) {
230
+
231
+ if ($transaction['price_original'] != $order->getGrandTotal()) {
232
+
233
+ $frase = 'Total pago à Tray é diferente do valor original.';
234
+
235
+ $order->addStatusToHistory(
236
+ $order->getStatus(), //continue setting current order status
237
+ Mage::helper('checkoutapi')->__($frase), true
238
+ );
239
+
240
+ $order->sendOrderUpdateEmail(true, $frase);
241
+ } else {
242
+ $cod_status = $transaction['status_id'];
243
+
244
+ switch ($cod_status){
245
+ case '4':
246
+ case '5':
247
+ case '88':
248
+ $order->addStatusToHistory(
249
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('checkoutapi')->__('Tray enviou automaticamente o status: %s', $comment)
250
+
251
+ );
252
+ break;
253
+ case '6':
254
+ $items = $order->getAllItems();
255
+
256
+ $thereIsVirtual = false;
257
+
258
+ foreach ($items as $itemId => $item) {
259
+ if ($item["is_virtual"] == "1" || $item["is_downloadable"] == "1") {
260
+ $thereIsVirtual = true;
261
+ }
262
+ }
263
+
264
+ // what to do - from admin
265
+ $toInvoice = $this->getApi()->getConfigData('acaopadraovirtual') == "1" ? true : false;
266
+
267
+ if ($thereIsVirtual && !$toInvoice) {
268
+
269
+ $frase = 'Tray - Aprovado. Pagamento (fatura) confirmado automaticamente.';
270
+
271
+ $order->addStatusToHistory(
272
+ $order->getStatus(), //continue setting current order status
273
+ Mage::helper('checkoutapi')->__($frase), true
274
+ );
275
+
276
+ $order->sendOrderUpdateEmail(true, $frase);
277
+ } else {
278
+
279
+ if (!$order->canInvoice()) {
280
+ $isHolded = ( $order->getStatus() == Mage_Sales_Model_Order::STATE_HOLDED );
281
+
282
+ $status = ($isHolded) ? Mage_Sales_Model_Order::STATE_PROCESSING : $order->getStatus();
283
+ $frase = ($isHolded) ? 'Tray - Aprovado. Confirmado automaticamente o pagamento do pedido.' : 'Erro ao criar pagamento (fatura).';
284
+
285
+ //when order cannot create invoice, need to have some logic to take care
286
+ $order->addStatusToHistory(
287
+ $status, //continue setting current order status
288
+ Mage::helper('checkoutapi')->__( $frase )
289
+ );
290
+
291
+ } else {
292
+
293
+ //need to save transaction id
294
+ $order->getPayment()->setTransactionId($dados_post['transaction']['transaction_id']);
295
+
296
+ //need to convert from order into invoice
297
+ $invoice = $order->prepareInvoice();
298
+
299
+ if ($this->getApi()->canCapture()) {
300
+ $invoice->register()->capture();
301
+ }
302
+
303
+ Mage::getModel('core/resource_transaction')
304
+ ->addObject($invoice)
305
+ ->addObject($invoice->getOrder())
306
+ ->save();
307
+
308
+ $frase = 'Pagamento (fatura) ' . $invoice->getIncrementId() . ' foi criado. Tray - Aprovado. Confirmado automaticamente o pagamento do pedido.';
309
+
310
+ if ($thereIsVirtual) {
311
+
312
+ $order->addStatusToHistory(
313
+ $order->getStatus(), Mage::helper('checkoutapi')->__($frase), true
314
+ );
315
+
316
+ } else {
317
+
318
+ $order->addStatusToHistory(
319
+ Mage_Sales_Model_Order::STATE_PROCESSING, //update order status to processing after creating an invoice
320
+ Mage::helper('checkoutapi')->__($frase), true
321
+ );
322
+ }
323
+
324
+ $invoice->sendEmail(true, $frase);
325
+ }
326
+ }
327
+ break;
328
+ case '24':
329
+ $order->addStatusToHistory(
330
+ Mage_Sales_Model_Order::STATE_HOLDED, Mage::helper('checkoutapi')->__('Tray enviou automaticamente o status: %s', $comment)
331
+ );
332
+ break;
333
+ case '7':
334
+ case '89':
335
+ $frase = 'Tray - Cancelado. Pedido cancelado automaticamente (transação foi cancelada, pagamento foi negado, pagamento foi estornado ou ocorreu um chargeback).';
336
+
337
+ $order->addStatusToHistory(
338
+ Mage_Sales_Model_Order::STATE_CANCELED, Mage::helper('checkoutapi')->__($frase), true
339
+ );
340
+
341
+ $order->sendOrderUpdateEmail(true, $frase);
342
+
343
+ $order->cancel();
344
+ break;
345
+ case '87':
346
+ $order->addStatusToHistory(
347
+ Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, Mage::helper('checkoutapi')->__('Tray enviou automaticamente o status: %s', $comment)
348
+ );
349
+ break;
350
+ }
351
+ }
352
+ $order->save();
353
+ }
354
+ }
355
+ }
356
+
357
+ }
app/code/community/Tray/CheckoutApi/etc/adminhtml.xml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to suporte@tray.net.br so we can send you a copy immediately.
15
+ *
16
+ * @category Tray
17
+ * @package Tray_CheckoutApi
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ -->
21
+
22
+ <config>
23
+ <acl>
24
+ <resources>
25
+ <all>
26
+ <title>Allow Everything</title>
27
+ </all>
28
+ <admin>
29
+ <children>
30
+ <system>
31
+ <children>
32
+ <config>
33
+ <children>
34
+ <checkoutapi>
35
+ <title>Tray - Settings</title>
36
+ </checkoutapi>
37
+ </children>
38
+ </config>
39
+ </children>
40
+ </system>
41
+ </children>
42
+ </admin>
43
+ </resources>
44
+ </acl>
45
+ </config>
app/code/community/Tray/CheckoutApi/etc/config.xml ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to suporte@tray.net.br so we can send you a copy immediately.
15
+ *
16
+ * @category Tray
17
+ * @package Tray_CheckoutApi
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ -->
21
+ <config>
22
+ <modules>
23
+ <Tray_CheckoutApi>
24
+ <version>0.1.0</version>
25
+ </Tray_CheckoutApi>
26
+ </modules>
27
+ <global>
28
+ <models>
29
+ <checkoutapi>
30
+ <class>Tray_CheckoutApi_Model</class>
31
+ <resourceModel>checkoutapi_mysql4</resourceModel>
32
+ </checkoutapi>
33
+ <checkoutapi_mysql4>
34
+ <class>Tray_CheckoutApi_Model_Mysql4</class>
35
+ <entities>
36
+ <api_debug>
37
+ <table>checkoutapi_api_debug</table>
38
+ </api_debug>
39
+ </entities>
40
+ </checkoutapi_mysql4>
41
+ </models>
42
+ <resources>
43
+ <checkoutapi_setup>
44
+ <setup>
45
+ <module>Tray_CheckoutApi</module>
46
+ </setup>
47
+ <connection>
48
+ <use>core_setup</use>
49
+ </connection>
50
+ </checkoutapi_setup>
51
+ <checkoutapi_write>
52
+ <connection>
53
+ <use>core_write</use>
54
+ </connection>
55
+ </checkoutapi_write>
56
+ <checkoutapi_read>
57
+ <connection>
58
+ <use>core_read</use>
59
+ </connection>
60
+ </checkoutapi_read>
61
+ </resources>
62
+ <blocks>
63
+ <checkoutapi>
64
+ <class>Tray_CheckoutApi_Block</class>
65
+ </checkoutapi>
66
+ </blocks>
67
+ <helpers>
68
+ <checkoutapi>
69
+ <class>Tray_CheckoutApi_Helper</class>
70
+ </checkoutapi>
71
+ </helpers>
72
+ <events>
73
+ <checkout_onepage_controller_success_action>
74
+ <observers>
75
+ <checkoutapi_observer>
76
+ <type>singleton</type>
77
+ <class>checkoutapi/observer</class>
78
+ <method>sendEmailFrontend</method>
79
+ </checkoutapi_observer>
80
+ </observers>
81
+ </checkout_onepage_controller_success_action>
82
+ <checkout_multishipping_controller_success_action>
83
+ <observers>
84
+ <checkoutapi_observer>
85
+ <type>singleton</type>
86
+ <class>checkoutapi/observer</class>
87
+ <method>sendEmailFrontend</method>
88
+ </checkoutapi_observer>
89
+ </observers>
90
+ </checkout_multishipping_controller_success_action>
91
+ </events>
92
+ <fieldsets>
93
+ <sales_convert_quote_payment>
94
+ <traycheckout_transaction_id>
95
+ <to_order_payment>*</to_order_payment>
96
+ </traycheckout_transaction_id>
97
+ <traycheckout_split_number>
98
+ <to_order_payment>*</to_order_payment>
99
+ </traycheckout_split_number>
100
+ <traycheckout_split_value>
101
+ <to_order_payment>*</to_order_payment>
102
+ </traycheckout_split_value>
103
+ <traycheckout_token_transaction>
104
+ <to_order_payment>*</to_order_payment>
105
+ </traycheckout_token_transaction>
106
+ <traycheckout_url_payment>
107
+ <to_order_payment>*</to_order_payment>
108
+ </traycheckout_url_payment>
109
+ <traycheckout_typeful_line>
110
+ <to_order_payment>*</to_order_payment>
111
+ </traycheckout_typeful_line>
112
+ </sales_convert_quote_payment>
113
+ </fieldsets>
114
+ </global>
115
+ <frontend>
116
+ <secure_url>
117
+ <checkoutapi>/checkoutapi/standard</checkoutapi>
118
+ </secure_url>
119
+ <routers>
120
+ <checkoutapi>
121
+ <use>standard</use>
122
+ <args>
123
+ <module>Tray_CheckoutApi</module>
124
+ <frontName>checkoutapi</frontName>
125
+ </args>
126
+ </checkoutapi>
127
+ </routers>
128
+ <translate>
129
+ <modules>
130
+ <checkoutapi>
131
+ <files>
132
+ <default>Tray_CheckoutApi.csv</default>
133
+ </files>
134
+ </checkoutapi>
135
+ </modules>
136
+ </translate>
137
+ <layout>
138
+ <updates>
139
+ <traycheckoutapi>
140
+ <file>tray_checkoutapi.xml</file>
141
+ </traycheckoutapi>
142
+ </updates>
143
+ </layout>
144
+ </frontend>
145
+ <adminhtml>
146
+ <translate>
147
+ <modules>
148
+ <checkoutapi>
149
+ <files>
150
+ <default>Tray_CheckoutApi.csv</default>
151
+ </files>
152
+ </checkoutapi>
153
+ </modules>
154
+ </translate>
155
+ <layout>
156
+ <updates>
157
+ <traycheckoutapi>
158
+ <file>tray_checkoutapi.xml</file>
159
+ </traycheckoutapi>
160
+ </updates>
161
+ </layout>
162
+ </adminhtml>
163
+ <default>
164
+ <payment>
165
+ <traycheckoutapi>
166
+ <active>0</active>
167
+ <model>Tray_CheckoutApi_Model_Standard</model>
168
+ <order_status>pending</order_status>
169
+ <title>TrayCheckout</title>
170
+ <allowspecific>1</allowspecific>
171
+ <splitTax>1.99</splitTax>
172
+ <retorno>http://www.urldoseusite.com.br/index.php/CheckoutApi_Standard/standard/success/</retorno>
173
+ </traycheckoutapi>
174
+ </payment>
175
+ <checkoutapi>
176
+ <settings>
177
+ <exibitionmodal>1</exibitionmodal>
178
+ </settings>
179
+ </checkoutapi>
180
+ </default>
181
+ </config>
app/code/community/Tray/CheckoutApi/etc/system.xml ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to suporte@tray.net.br so we can send you a copy immediately.
15
+ *
16
+ * @category Tray
17
+ * @package Tray_CheckoutApi
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ -->
21
+ <config>
22
+ <tabs>
23
+ <tray translate="label" module="checkoutapi">
24
+ <label>Tray Commerce</label>
25
+ <sort_order>100</sort_order>
26
+ </tray>
27
+ </tabs>
28
+ <sections>
29
+ <payment translate="label" module="checkoutapi">
30
+ <groups>
31
+ <traycheckoutapi translate="label">
32
+ <label>TrayCheckout - Transparente</label>
33
+ <sort_order>670</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>0</show_in_store>
37
+ <fields>
38
+ <active translate="label">
39
+ <label>Enabled</label>
40
+ <frontend_type>select</frontend_type>
41
+ <source_model>adminhtml/system_config_source_yesno</source_model>
42
+ <sort_order>1</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>0</show_in_store>
46
+ </active>
47
+ <title translate="label">
48
+ <label>Título</label>
49
+ <frontend_type>text</frontend_type>
50
+ <sort_order>2</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>0</show_in_store>
54
+ </title>
55
+ <order_status translate="label">
56
+ <label>Status dos novos pedidos</label>
57
+ <frontend_type>select</frontend_type>
58
+ <source_model>adminhtml/system_config_source_order_status_new</source_model>
59
+ <sort_order>3</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>0</show_in_store>
63
+ </order_status>
64
+ <!--custom_address_model translate="label, comment">
65
+ <label>Modelo de Endereço Personalizado</label>
66
+ <frontend_type>select</frontend_type>
67
+ <source_model>adminhtml/system_config_source_yesno</source_model>
68
+ <sort_order>5</sort_order>
69
+ <show_in_default>1</show_in_default>
70
+ <show_in_website>1</show_in_website>
71
+ <show_in_store>1</show_in_store>
72
+ <comment>Necessário disponibilizar quatro campos de endereço para habilitar.</comment>
73
+ </custom_address_model-->
74
+ <token translate="label">
75
+ <label>Token</label>
76
+ <frontend_type>text</frontend_type>
77
+ <sort_order>4</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>0</show_in_store>
81
+ </token>
82
+ <acaopadraovirtual translate="label">
83
+ <label>Gerar Fatura automaticamente para pedidos com produtos virtuais?</label>
84
+ <frontend_type>select</frontend_type>
85
+ <sort_order>5</sort_order>
86
+ <source_model>adminhtml/system_config_source_yesno</source_model>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>0</show_in_store>
90
+ </acaopadraovirtual>
91
+ <tcQtdSplit translate="label">
92
+ <label>Quantidade Máxima de Parcelas</label>
93
+ <frontend_type>select</frontend_type>
94
+ <sort_order>6</sort_order>
95
+ <source_model>checkoutapi/source_qtdsplit</source_model>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>1</show_in_store>
99
+ </tcQtdSplit>
100
+ <tcPaymentMethods translate="label">
101
+ <label>Meios de Pagamento disponíveis</label>
102
+ <frontend_type>multiselect</frontend_type>
103
+ <sort_order>7</sort_order>
104
+ <source_model>checkoutapi/source_paymentmethods</source_model>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>1</show_in_store>
108
+ </tcPaymentMethods>
109
+ <tcNoSplitTaxRate translate="label">
110
+ <label>Parcelas sem Acréscimo</label>
111
+ <frontend_type>multiselect</frontend_type>
112
+ <sort_order>8</sort_order>
113
+ <source_model>checkoutapi/source_qtdsplit</source_model>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>1</show_in_store>
117
+ </tcNoSplitTaxRate>
118
+ <splitTax translate="label">
119
+ <label>Taxa de Acréscimo</label>
120
+ <frontend_type>text</frontend_type>
121
+ <sort_order>10</sort_order>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>1</show_in_website>
124
+ <show_in_store>0</show_in_store>
125
+ </splitTax>
126
+ <allowspecific translate="label">
127
+ <label>Tipos de Países Permitidos</label>
128
+ <frontend_type>select</frontend_type>
129
+ <sort_order>11</sort_order>
130
+ <source_model>checkoutapi/source_specificcountries</source_model>
131
+ <show_in_default>1</show_in_default>
132
+ <show_in_website>1</show_in_website>
133
+ <show_in_store>1</show_in_store>
134
+ </allowspecific>
135
+ <specificcountry translate="label">
136
+ <label>Permitir Pagamento de Países Específicos</label>
137
+ <frontend_type>select</frontend_type>
138
+ <sort_order>12</sort_order>
139
+ <source_model>checkoutapi/source_country</source_model>
140
+ <show_in_default>1</show_in_default>
141
+ <show_in_website>1</show_in_website>
142
+ <show_in_store>1</show_in_store>
143
+ </specificcountry>
144
+ <prefixo translate="label">
145
+ <label>Prefixo do Pedido</label>
146
+ <frontend_type>text</frontend_type>
147
+ <sort_order>15</sort_order>
148
+ <show_in_default>1</show_in_default>
149
+ <show_in_website>1</show_in_website>
150
+ <show_in_store>1</show_in_store>
151
+ </prefixo>
152
+ <sort_order translate="label">
153
+ <label>Ordem de Exibição</label>
154
+ <frontend_type>text</frontend_type>
155
+ <sort_order>100</sort_order>
156
+ <show_in_default>1</show_in_default>
157
+ <show_in_website>1</show_in_website>
158
+ <show_in_store>1</show_in_store>
159
+ </sort_order>
160
+ <sandbox translate="label">
161
+ <label>Ambiente de Teste (Sandbox)</label>
162
+ <frontend_type>select</frontend_type>
163
+ <source_model>adminhtml/system_config_source_yesno</source_model>
164
+ <sort_order>200</sort_order>
165
+ <show_in_default>1</show_in_default>
166
+ <show_in_website>1</show_in_website>
167
+ <show_in_store>0</show_in_store>
168
+ </sandbox>
169
+ </fields>
170
+ </traycheckoutapi>
171
+ </groups>
172
+ </payment>
173
+ </sections>
174
+ </config>
app/code/community/Tray/CheckoutApi/sql/checkoutapi_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ /** @var $installer Mage_Paypal_Model_Resource_Setup */
21
+ $installer = $this;
22
+
23
+ /**
24
+ * Prepare database for install
25
+ */
26
+ $installer->startSetup();
27
+
28
+ /**
29
+ * Add paypal attributes to the:
30
+ * - sales/flat_quote_payment_item table
31
+ * - sales/flat_order table
32
+ */
33
+ //$installer->addAttribute('quote_payment', 'traycheckout_transaction_id', array());
34
+ //$installer->addAttribute('quote_payment', 'traycheckout_split_number', array());
35
+ //$installer->addAttribute('quote_payment', 'traycheckout_split_value', array());
36
+ //$installer->addAttribute('quote_payment', 'traycheckout_token_transaction', array());
37
+ //$installer->addAttribute('quote_payment', 'traycheckout_url_payment', array());
38
+ //$installer->addAttribute('quote_payment', 'traycheckout_typeful_line', array());
39
+
40
+
41
+ $installer->run("
42
+ ALTER TABLE {$this->getTable('sales_flat_quote_payment')} ADD `traycheckout_transaction_id` VARCHAR( 255 ) NULL DEFAULT NULL;
43
+ ALTER TABLE {$this->getTable('sales_flat_quote_payment')} ADD `traycheckout_split_number` VARCHAR( 255 ) NULL DEFAULT NULL;
44
+ ALTER TABLE {$this->getTable('sales_flat_quote_payment')} ADD `traycheckout_split_value` VARCHAR( 255 ) NULL DEFAULT NULL;
45
+ ALTER TABLE {$this->getTable('sales_flat_quote_payment')} ADD `traycheckout_token_transaction` VARCHAR( 255 ) NULL DEFAULT NULL;
46
+ ALTER TABLE {$this->getTable('sales_flat_quote_payment')} ADD `traycheckout_url_payment` VARCHAR( 255 ) NULL DEFAULT NULL;
47
+ ALTER TABLE {$this->getTable('sales_flat_quote_payment')} ADD `traycheckout_typeful_line` VARCHAR( 255 ) NULL DEFAULT NULL;
48
+
49
+ ALTER TABLE {$this->getTable('sales_flat_order_payment')} ADD `traycheckout_transaction_id` VARCHAR( 255 ) NULL DEFAULT NULL;
50
+ ALTER TABLE {$this->getTable('sales_flat_order_payment')} ADD `traycheckout_split_number` VARCHAR( 255 ) NULL DEFAULT NULL;
51
+ ALTER TABLE {$this->getTable('sales_flat_order_payment')} ADD `traycheckout_split_value` VARCHAR( 255 ) NULL DEFAULT NULL;
52
+ ALTER TABLE {$this->getTable('sales_flat_order_payment')} ADD `traycheckout_token_transaction` VARCHAR( 255 ) NULL DEFAULT NULL;
53
+ ALTER TABLE {$this->getTable('sales_flat_order_payment')} ADD `traycheckout_url_payment` VARCHAR( 255 ) NULL DEFAULT NULL;
54
+ ALTER TABLE {$this->getTable('sales_flat_order_payment')} ADD `traycheckout_typeful_line` VARCHAR( 255 ) NULL DEFAULT NULL;
55
+ ");
56
+ /**
57
+ * Prepare database after install
58
+ */
59
+
60
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/tray_checkoutapi.xml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to suporte@tray.net.br so we can send you a copy immediately.
15
+ *
16
+ * @category Tray
17
+ * @package Tray_CheckoutApi
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ -->
21
+ <layout version="1.0.0">
22
+ <adminhtml_system_config_edit>
23
+ <reference name="head">
24
+ <action method="addItem">
25
+ <type>skin_js</type>
26
+ <script>tray/checkoutapi/js/exibitionsettingswebcheckout.js</script>
27
+ </action>
28
+ <action method="addCss">
29
+ <stylesheet>tray/checkoutapi/css/magentomodal.css</stylesheet>
30
+ </action>
31
+ </reference>
32
+ <reference name="content">
33
+ <block type="page/html" name="getbaseurl" template="tray/checkoutapi/getbaseurl.phtml" />
34
+ </reference>
35
+ </adminhtml_system_config_edit>
36
+ </layout>
app/design/adminhtml/default/default/template/tray/checkoutredir/form/standard.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ ?>
20
+ <fieldset class="form-list">
21
+ <?php
22
+ $_code = $this->getMethodCode();
23
+ $_standardPD = Mage::getSingleton('checkoutapi/geral');
24
+
25
+ $totals = Mage::getSingleton('adminhtml/session_quote')->getQuote()->collectTotals();
26
+ ?>
27
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
28
+ <ul class="forma_pagamento"></ul>
29
+ </ul>
30
+ </fieldset>
app/design/adminhtml/default/default/template/tray/checkoutredir/getbaseurl.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Itwin
22
+ * @package Itwin_PostcodeComplete
23
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
+ */
25
+ ?>
26
+
27
+ <script type="text/javascript">
28
+ var checkoutapi_baseurl = "<?php echo $this->getBaseUrl(); ?>";
29
+ </script>
30
+
app/design/adminhtml/default/default/template/tray/checkoutredir/info/standard.phtml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ ?>
20
+ <p>
21
+ <strong>
22
+ <?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?>
23
+ </strong>
24
+ </p>
25
+ <?php echo $this->getLinkPayment($this->getInfo()->getOrder()); ?>
app/design/frontend/base/default/layout/tray_checkoutapi.xml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to suporte@tray.net.br so we can send you a copy immediately.
15
+ *
16
+ * @category Tray
17
+ * @package Tray_CheckoutApi
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ -->
21
+ <layout version="0.1.0">
22
+ <checkoutapi_standard_payment>
23
+ <reference name="head">
24
+ <action method="addCss">
25
+ <stylesheet>tray/checkoutapi/css/styles.css</stylesheet>
26
+ </action>
27
+ </reference>
28
+ <remove name="left"/>
29
+ <reference name="root">
30
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
31
+ </reference>
32
+ <reference name="content">
33
+ <block type="checkoutapi/payment" name="payment" template="tray/checkoutapi/payment.phtml" />
34
+ </reference>
35
+ </checkoutapi_standard_payment>
36
+
37
+ <checkoutapi_standard_return>
38
+ <remove name="left"/>
39
+ <reference name="root">
40
+ <action method="setTemplate"><template>page/empty.phtml</template></action>
41
+ </reference>
42
+ <reference name="content">
43
+ <block type="checkoutapi/return" name="return" template="tray/checkoutapi/return.phtml" />
44
+ </reference>
45
+ </checkoutapi_standard_return>
46
+
47
+ <checkoutapi_standard_error>
48
+ <remove name="left"/>
49
+ <reference name="root">
50
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
51
+ </reference>
52
+ <reference name="content">
53
+ <block type="checkoutapi/error" name="error" template="tray/checkoutapi/error.phtml" />
54
+ </reference>
55
+ </checkoutapi_standard_error>
56
+ </layout>
app/design/frontend/base/default/template/tray/checkoutapi/error.phtml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ $title = "";
21
+ $message = "";
22
+ ?>
23
+ <?php
24
+ if($this->getRequest()->getParam("type") == 'G' || $this->getRequest()->getParam("type") == 'V'){
25
+ $title = "Erro ao realizar seu pedido pelo TrayCheckout";
26
+ $message = "Ocorreu um erro ao realizar o seu pedido pelo TrayCheckout.";
27
+
28
+ }else{
29
+ $title = "Erro ao realizar o Retorno Autom&aacute;tico";
30
+ $message = "Ocorreu um erro ao realizar o retorno autom&aacute;tico.";
31
+ }
32
+ ?>
33
+ <div class="page-head">
34
+
35
+ <h2 class="sub-title"><?php echo $title;?></h2>
36
+ </div>
37
+ <table style="width:100%;">
38
+ <tr>
39
+ <td style="width:100%">
40
+ <?php echo $message;?><br /><br />
41
+ Dados do Erro:<br />
42
+ <?php
43
+ if($this->getRequest()->getParam("type") == 'V'){
44
+ ?>
45
+ Campos: <?php echo utf8_decode($this->getRequest()->getParam("codigo")); ?><br />
46
+ <?php
47
+ }else{
48
+ ?>
49
+ C&oacute;digo: <?php echo utf8_decode($this->getRequest()->getParam("codigo")); ?><br />
50
+ <?php
51
+ }
52
+ ?>
53
+ Descri&ccedil;&atilde;o: <?php echo $this->getRequest()->getParam("descricao"); ?><br />
54
+ </td>
55
+ </tr>
56
+ </table>
app/design/frontend/base/default/template/tray/checkoutapi/form/images/overlay.png ADDED
Binary file
app/design/frontend/base/default/template/tray/checkoutapi/form/standard.phtml ADDED
@@ -0,0 +1,190 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ ?>
20
+ <fieldset class="form-list">
21
+ <?php
22
+ $_code = $this->getMethodCode();
23
+ $_standardPD = Mage::getSingleton('checkoutapi/standard');
24
+
25
+ $totals = Mage::getSingleton('checkout/session')->getQuote()->collectTotals();
26
+ //$shippingAmount = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getShippingAmount();
27
+ $strTcPaymentMethods = $_standardPD->getConfigData("tcPaymentMethods");
28
+
29
+ if($strTcPaymentMethods == "" || $strTcPaymentMethods == null){
30
+ $tcPaymentMethods = explode(",","3,4,2,5,18,16,15,19,14,7,22,23,6");
31
+ }else{
32
+ $tcPaymentMethods = explode(",",$strTcPaymentMethods);
33
+ }
34
+ ?>
35
+ <style>
36
+ ul li.tcPaymentMethod{
37
+ float: left;
38
+ padding: 5px;
39
+ width: 80px;
40
+ height: 30px;
41
+ }
42
+ ul li input{
43
+ float: left;
44
+ margin-right: 5px;
45
+ }
46
+ ul li span.tcPaymentFlag{
47
+ float: left;
48
+ width: 60px;
49
+ height: 50px;
50
+ background-image: url(<?php echo $this->getSkinUrl('tray/checkoutapi/images/paymentFlags1.png'); ?>);
51
+ background-repeat: no-repeat;
52
+ }
53
+ /* Diners */
54
+ ul li span.tcPaymentFlag2{
55
+ background-position: -184px -8px;
56
+ }
57
+ /* Visa */
58
+ ul li span.tcPaymentFlag3{
59
+ background-position: 1px -8px;
60
+ }
61
+ /* Master */
62
+ ul li span.tcPaymentFlag4{
63
+ background-position: -60px -8px;
64
+ }
65
+ /* Amex */
66
+ ul li span.tcPaymentFlag5{
67
+ background-position: -123px -8px;
68
+ }
69
+ /* Boleto */
70
+ ul li span.tcPaymentFlag6{
71
+ background-position: -556px -8px;
72
+ }
73
+ /* Itaú */
74
+ ul li span.tcPaymentFlag7{
75
+ background-position: -618px -8px;
76
+ }
77
+ /* Peela */
78
+ ul li span.tcPaymentFlag14{
79
+ background-position: -369px -8px;
80
+ }
81
+ /* Discover */
82
+ ul li span.tcPaymentFlag15{
83
+ background-position: -308px -8px;
84
+ }
85
+ /* Elo */
86
+ ul li span.tcPaymentFlag16{
87
+ background-position: -246px -8px;
88
+ }
89
+ /* Aura */
90
+ ul li span.tcPaymentFlag18{
91
+ background-position: -431px -8px;
92
+ }
93
+ /* JCB */
94
+ ul li span.tcPaymentFlag19{
95
+ background-position: -494px -8px;
96
+ }
97
+ /* Bradesco */
98
+ ul li span.tcPaymentFlag22{
99
+ background-position: -679px -8px;
100
+ }
101
+ /* Banco do Brasil */
102
+ ul li span.tcPaymentFlag23{
103
+ background-position: -741px -8px;
104
+ }
105
+ </style>
106
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
107
+
108
+ <li class="forma_pagamento" style="float:left;;">
109
+ <ul>
110
+ <li>
111
+ <label for="tcPaymentMethod"><?php echo Mage::helper('payment')->__('Selecione a forma de pagamento') ?> <span class="required">*</span></label><br/>
112
+ <input type="hidden" id="tcPaymentMethod" name="payment[cc_type]" class="required-entry" value=""/>
113
+ <ul>
114
+ <?php
115
+ foreach ($tcPaymentMethods as $idTcPayment){
116
+ $displayCcInfo = "none";
117
+ if(!in_array($idTcPayment, array("6","7","14","22","23"))){
118
+ $displayCcInfo = "block";
119
+ }
120
+ ?>
121
+ <li class="tcPaymentMethod">
122
+ <input type="radio" name="tcPaymentMethodR" value="<?php echo $idTcPayment;?>" onclick="document.getElementById('tcPaymentMethod').value = this.value; document.getElementById('displayCcInfo').style.display = '<?php echo $displayCcInfo;?>'"/>
123
+ <span class="tcPaymentFlag tcPaymentFlag<?php echo $idTcPayment;?>">
124
+ &nbsp;
125
+ </span>
126
+ </li>
127
+ <?php
128
+
129
+ }
130
+ ?>
131
+ </ul>
132
+ </li>
133
+ </ul>
134
+ </li>
135
+ <li id="displayCcInfo" style="display: none;">
136
+ <ul>
137
+ <li>
138
+ <div class="input-box">
139
+ <label for="<?php echo $_code ?>_cc_owner"><?php echo Mage::helper('payment')->__('Name on Card') ?> <span class="required">*</span></label><br/>
140
+ <input type="text" title="<?php echo Mage::helper('payment')->__('Name on Card') ?>" class="required-entry input-text" id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->getInfoData('cc_owner') ?>"/>
141
+ </div>
142
+ </li>
143
+ <li>
144
+ <div class="input-box">
145
+ <label for="<?php echo $_code ?>_cc_number"><?php echo Mage::helper('payment')->__('Credit Card Number') ?> <span class="required">*</span></label><br/>
146
+ <input type="text" id="<?php echo $_code ?>_cc_number" name="payment[cc_number]" title="<?php echo Mage::helper('payment')->__('Credit Card Number') ?>" class="required-entry input-text validate-cc-number" value="<?php echo $this->getInfoData('cc_number')?>"/>
147
+ </div>
148
+ </li>
149
+ <li>
150
+ <div class="input-box">
151
+ <label for="<?php echo $_code ?>_expiration"><?php echo Mage::helper('payment')->__('Expiration Date') ?> <span class="required">*</span></label><br/>
152
+ <select id="<?php echo $_code ?>_expiration" style="width:140px;" name="payment[cc_exp_month]" class="validate-cc-exp required-entry">
153
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
154
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
155
+ <option value="<?php echo $k ?>" <?php if($k==$_ccExpMonth): ?>selected="selected"<?php endif ?>><?php echo $v ?></option>
156
+ <?php endforeach ?>
157
+ </select>
158
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
159
+ <select id="<?php echo $_code ?>_expiration_yr" style="width:103px;" name="payment[cc_exp_year]" class="required-entry">
160
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
161
+ <option value="<?php echo $k ? $k : '' ?>" <?php if($k==$_ccExpYear): ?>selected="selected"<?php endif ?>><?php echo $v ?></option>
162
+ <?php endforeach ?>
163
+ </select>
164
+ </div>
165
+ </li>
166
+ <li>
167
+ <div class="input-box">
168
+ <input type="hidden" id="<?php echo $_code ?>_split_value" name="payment[traycheckout_split_value]" value="<?php echo $this->getInfoData('traycheckout_split_value')?>"/>
169
+ <label for="<?php echo $_code ?>_split"><?php echo Mage::helper('payment')->__('Parcelas') ?> <span class="required">*</span></label><br/>
170
+ <select id="<?php echo $_code ?>_split" style="width:140px;" name="payment[traycheckout_split_number]" class="required-entry" onchange="document.getElementById('<?php echo $_code ?>_split_value').value = this.options[this.selectedIndex].text.replace(/.*R\$/,'').replace(/\,/,'.');">
171
+ <?php $_ccSplitSimulator = $this->getInfoData('traycheckout_split_number') ?>
172
+ <?php foreach ($this->getSplitSimulate($totals->grand_total) as $k=>$v): ?>
173
+ <option value="<?php echo $k ?>" <?php if($k==$_ccSplitSimulator): ?>selected="selected"<?php endif ?>><?php echo $v ?></option>
174
+ <?php endforeach ?>
175
+ </select>
176
+ </div>
177
+ </li>
178
+ <li>
179
+ <label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
180
+ <div class="input-box">
181
+ <div class="v-fix">
182
+ <input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" value="" />
183
+ </div>
184
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
185
+ </div>
186
+ </li>
187
+ </ul>
188
+ </li>
189
+ </ul>
190
+ </fieldset>
app/design/frontend/base/default/template/tray/checkoutapi/head.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ ?>
20
+ <title><?php echo $this->getTitle() ?></title>
21
+ <meta http-equiv="Content-Type" content="<?php echo $this->getContentType() ?>" />
22
+ <meta name="description" content="<?php echo htmlspecialchars($this->getDescription()) ?>" />
23
+ <meta name="keywords" content="<?php echo htmlspecialchars($this->getKeywords()) ?>" />
24
+ <meta name="robots" content="<?php echo htmlspecialchars($this->getRobots()) ?>" />
25
+ <link rel="icon" href="<?php echo $this->getSkinUrl('favicon.ico') ?>" type="image/x-icon" />
26
+ <link rel="shortcut icon" href="<?php echo $this->getSkinUrl('favicon.ico') ?>" type="image/x-icon" />
27
+ <script type="text/javascript">
28
+ //<![CDATA[
29
+ var BLANK_URL = '<?php echo $this->helper('core/js')->getJsUrl('blank.html') ?>';
30
+ var BLANK_IMG = '<?php echo $this->helper('core/js')->getJsUrl('spacer.gif') ?>';
31
+ //]]>
32
+ </script>
33
+ <?php echo $this->getCssJsHtml() ?>
34
+ <?php echo $this->getChildHtml() ?>
35
+ <?php echo $this->helper('core/js')->getTranslatorScript() ?>
36
+ <?php echo $this->getIncludes() ?>
app/design/frontend/base/default/template/tray/checkoutapi/info/standard.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ ?>
20
+ <p>
21
+ <strong>
22
+ <?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?>
23
+ </strong>
24
+ <br/>
25
+ <?php
26
+ if($this->getInfo()->getData("cc_type") != NULL){
27
+ $tcTxtPaymentMethod = array("Diners Club","Visa","Mastercard","American Express","Boleto Bancário","Itaú Shopline","Peela","Discovery","Elo","Aura","JCB","Transf. Online Bradesco","Transf. Online Banco do Brasil");
28
+ $tcIdPaymentMethod = array("2","3","4","5","6","7","14","15","16","18","19","22","23");
29
+ $tcIdPaymentMethodCreditCard = array("","2","3","4","5","15","16","18","19");
30
+
31
+ echo $tcTxtPaymentMethod[array_search($this->getInfo()->getData("cc_type"), $tcIdPaymentMethod)];
32
+ }
33
+ ?>
34
+ <?php echo (array_search($this->getInfo()->getData("cc_type"), $tcIdPaymentMethodCreditCard)) ? $this->getInfo()->getData("traycheckout_split_number") . " x R$". number_format((float)$this->getInfo()->getData("traycheckout_split_value"), 2, ',','') : ""; ?>
35
+ </p>
36
+ <?php echo $this->getLinkPayment($this->getInfo()->getOrder()); ?>
app/design/frontend/base/default/template/tray/checkoutapi/overlay.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ ?>
20
+
21
+ <div id="overlay-tc">
22
+ <center>
23
+ <div id="lightboxtc" style="padding: 10px;background-color: #fff;width: 980px;margin-top: 50px" >
24
+ <img src="<?php echo $this->getSkinUrl('tray/checkoutapi/images/close.png'); ?>" style="position: relative;margin-left: 970px;margin-top: -20px;" />
25
+ <iframe name="tc_frame" width="970" height="700" style="border:0px" ></iframe>
26
+ </div>
27
+ </center>
28
+ </div>
app/design/frontend/base/default/template/tray/checkoutapi/payment.phtml ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ ?>
20
+ <?php
21
+ $this->getPayment();
22
+ $title = "";
23
+ $descriptionPaymentTC = "";
24
+ switch ($this->getStatusId()){
25
+ case '4':
26
+ case '5':
27
+ case '87':
28
+ $title = "Sua compra foi finalizada com TrayCheckout";
29
+ $descriptionPaymentTC = "Sua compra foi finalizada através do TrayCheckout.<br/>Estamos aguardando a confirmação do pagamento.";
30
+ break;
31
+ case '6':
32
+ $title = "Sua compra foi finalizada com TrayCheckout";
33
+ $descriptionPaymentTC = "Sua compra foi finalizada com sucesso através do TrayCheckout.";
34
+ break;
35
+ case '7':
36
+ case '89':
37
+ $title = "Ocorreu um problema ao finalizar a compra pelo TrayCheckout";
38
+ $descriptionPaymentTC = "Ocorreu um problema ao finalizar a compra através do TrayCheckout.";
39
+ break;
40
+ case '88':
41
+ $title = "Sua compra foi finalizada com TrayCheckout";
42
+ $descriptionPaymentTC = "Sua compra foi finalizada através do TrayCheckout.<br/>Estamos aguardando a confirmação do pagamento.";
43
+ break;
44
+ }
45
+ ?>
46
+
47
+ <div class="page-head">
48
+ <h2 class="sub-title"><?php echo $title;?></h2>
49
+ </div>
50
+ <div>
51
+ <table style="width:100%;">
52
+ <tr>
53
+ <td style="width:100%">
54
+ <?php echo $descriptionPaymentTC;?><br/><br/>
55
+ <strong>Dados do Pedido:</strong><br/>
56
+ Seu n&uacute;mero de pedido &eacute;: <strong><?php echo $this->getOrderNumber()?></strong><br />
57
+ N&uacute;mero da transa&ccedil;&atilde;o no TrayCheckout: <strong><?php echo $this->getTransactionId()?></strong><br />
58
+ Meio de Pagamento: <strong>TrayCheckout - <?php echo $this->getPaymentMethodName()?></strong><br />
59
+ Situa&ccedil;&atilde;o da transa&ccedil;&atilde;o no TrayCheckout: <strong><?php echo $this->getStatusName()?></strong><br /><br />
60
+
61
+ <?php
62
+ switch ($this->getPaymentMethodId()) {
63
+ case "6":
64
+ ?>
65
+ <button onclick="window.open('<?php echo $this->getUrlPayment()?>');" class="button btn-proceed-checkout btn-checkout" title="Imprimir Boleto" type="button"><span><span>Imprimir Boleto</span></span></button><br />
66
+ <?php
67
+ break;
68
+ case "7":
69
+ case "14":
70
+ case "22":
71
+ case "23":
72
+ ?>
73
+ <button onclick="window.open('<?php echo $this->getUrlPayment()?>');" class="button btn-proceed-checkout btn-checkout" title="Efetuar Transfer&ecirc;ncia Online" type="button"><span><span>Efetuar Transfer&ecirc;ncia Online</span></span></button><br />
74
+ <?php
75
+ break;
76
+ }
77
+ ?>
78
+ <br />
79
+ <br />
80
+ <img src="<?php echo $this->getSkinUrl('tray/checkoutapi/images/BannerTrayCheckout890px.png'); ?>" />
81
+ </td>
82
+ </tr>
83
+ </table>
84
+ </div>
app/design/frontend/base/default/template/tray/checkoutapi/return.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to suporte@tray.net.br so we can send you a copy immediately.
14
+ *
15
+ * @category Tray
16
+ * @package Tray_CheckoutApi
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ ?>
20
+
21
+ <script type="text/javascript">
22
+ parent.window.location = "<?php echo Mage::getUrl('checkout/onepage/success', array('_secure' => true));?>";
23
+ </script>
app/etc/modules/Tray_CheckoutApi.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to suporte@tray.net.br so we can send you a copy immediately.
15
+ *
16
+ * @category Tray
17
+ * @package Tray_CheckoutApi
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ -->
21
+ <config>
22
+ <modules>
23
+ <Tray_CheckoutApi>
24
+ <active>true</active>
25
+ <codePool>community</codePool>
26
+ </Tray_CheckoutApi>
27
+ <depends>
28
+ <Mage_Payment />
29
+ <Mage_Checkout/>
30
+ </depends>
31
+ </modules>
32
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Tray_CheckoutApi</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Extens&#xE3;o Tray Checkout API para Magento</summary>
10
+ <description>O TrayCheckout &#xE9; um facilitador de pagamento que oferece benef&#xED;cios aos lojistas e aos compradores. Focado em praticidade e convers&#xE3;o, possibilita que as lojas virtuais ofere&#xE7;am diversas formas de pagamento, sem burocracia ou necessidade de contrato com operadoras financeiras.</description>
11
+ <notes>Primeira vers&#xE3;o liberada no Magento Connect</notes>
12
+ <authors><author><name>TrayCheckout</name><user>traycheckout</user><email>integracao@traycheckout.com.br</email></author></authors>
13
+ <date>2014-01-13</date>
14
+ <time>12:30:14</time>
15
+ <contents><target name="magecommunity"><dir name="Tray"><dir name="CheckoutApi"><dir name="Block"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Label.php" hash="6eb581cddd1fb9380930da38e4404f5e"/></dir></dir></dir></dir><file name="Error.php" hash="a3a8aa9edb5c7718b7941e85421f0aa2"/><dir name="Form"><file name="Standard.php" hash="8e6f1b128ebbb58f381bd8d169bddd44"/></dir><dir name="Info"><file name="Standard.php" hash="e383d51eaaa9a0afd82a1ec60024e752"/></dir><file name="Link.php" hash="06ad7cb8eb1a52c7f130caacc0921657"/><file name="Payment.php" hash="889bd2a45399c30470523c4472e3417b"/><file name="Redirect_D.php" hash="5500cadf24369462c8deaeb03deefb64"/><file name="Return.php" hash="6b5700113c184160ee447d1c6116b1c0"/></dir><dir name="Helper"><file name="Adress.php" hash="6064f62a723b2075290964e3e980d92b"/><file name="Data.php" hash="9a1da0d7564539c0b2fc307fc815b4ea"/></dir><dir name="Model"><file name="Config.php" hash="7377296737b655ad3c01b3ae6081b507"/><file name="Geral_D.php" hash="bf4cfa5e87c591a5b11e4b01465ab707"/><dir name="Mysql4"><file name="Setup.php" hash="8a42c69f5c1a1be59d99985982a3703b"/></dir><file name="Observer.php" hash="059a8bfe166f862477127c8b7b63afad"/><dir name="Source"><file name="Country.php" hash="153d0153071b72f23ac2a1c4fee93c24"/><file name="Paymentmethods.php" hash="e19dc6aa0d7846fb4358bf11c18ba6ce"/><file name="Qtdsplit.php" hash="1273ee53626482898aefd7a3d31ebaea"/><file name="Specificcountries.php" hash="e41658287e6c68041d3f0042130f7db3"/></dir><file name="Standard.php" hash="e7601ed73af5638c13f0d20ac9cd80d7"/></dir><dir name="controllers"><file name="StandardController.php" hash="d6f7b6ffaf604dc95554fc889bcd4376"/></dir><dir name="etc"><file name="adminhtml.xml" hash="2b0114a2ffbce1930787f7a4e20ce73b"/><file name="config.xml" hash="a1e5911b7b18b2c0ee86903c2144bba8"/><file name="system.xml" hash="3948c445ded660c565540836f3063d2c"/></dir><dir name="sql"><dir name="checkoutapi_setup"><file name="mysql4-install-0.1.0.php" hash="8eb2972ea2fcdd38306041ed37665902"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="tray"><dir name="checkoutapi"><file name="error.phtml" hash="9e07c1164917e9118c3b21d5bf8c864b"/><dir name="form"><dir name="images"><file name="overlay.png" hash="143d209e15051311fdae758b295036b5"/></dir><file name="standard.phtml" hash="54d2ee862308188506ce9a881a971de7"/></dir><file name="head.phtml" hash="750d167a7a10ef1f56a73262f918dca5"/><dir name="info"><file name="standard.phtml" hash="ba1bbd8cc8504bd299aa36df42c61f2a"/></dir><file name="overlay.phtml" hash="d4ee4dbb85f9a7a350c6e8d5f59a9978"/><file name="payment.phtml" hash="a19bd7e8e7ec695e15a96deeccd85c57"/><file name="return.phtml" hash="47d5e3e1c3bda47721573e9639a54ca6"/></dir></dir></dir><dir name="layout"><file name="tray_checkoutapi.xml" hash="a8c98d02dc6be894803e1957d1422b79"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="tray"><dir name="checkoutredir"><dir name="form"><file name="standard.phtml" hash="9abb8cb909140d1af4cdd6afb5b5d7f5"/></dir><file name="getbaseurl.phtml" hash="05fba34637bc8da3958d1342f54c0ed4"/><dir name="info"><file name="standard.phtml" hash="1e9ba28c30b9a88c3fd6a53420ae8419"/></dir></dir></dir></dir><dir name="layout"><file name="tray_checkoutapi.xml" hash="5b288e1243541c19aad017941544e5a5"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="tray"><dir name="checkoutapi"><dir name="css"><file name="styles.css" hash="5d09463e234fd2f20622f63795019be6"/></dir><dir name="images"><file name="BannerTrayCheckout890px.png" hash="535d5a4a4f190d03df38664dcb6463f8"/><file name="banner_comlogo_formas.jpg" hash="e02a16c32109746786c24db177ddad3a"/><file name="banner_semlogo_formas.jpg" hash="4f13591f17ed96347f136eab09343121"/><file name="banner_semlogo_formas.png" hash="84a82c3d7ed9a42ade9660b8dd16511d"/><file name="close.png" hash="6e2879a324a76e9972ebc98201aae1d8"/><file name="overlay.png" hash="143d209e15051311fdae758b295036b5"/><file name="paymentFlags1.png" hash="2a1724b718bf2ff7a1b25b53acc0cefd"/><file name="paymentFlagsTc.png" hash="6dd7df4802b30ea61b96ad5752bab4ed"/></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="tray"><dir name="checkoutapi"><dir name="css"><file name="magentomodal.css" hash="2c6dd38e421f644475a121b8d6c96503"/></dir><dir name="images"><file name="btn_bg.gif" hash="37c51a4d48a92da9648dcd3ca011039f"/><file name="content_bg.gif" hash="21278ea0da2d4256f4ced96b6080ba2e"/><file name="top_bg.gif" hash="26f28090de87d64f9b01bf624f89bfe2"/><file name="window_close.png" hash="3af14f053f360bf31f8ba2df73ec7f1e"/></dir><dir name="js"><file name="exibitionsettingswebcheckout.js" hash="1d9d374cad719e27ffa6a78f1239c63a"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Tray_CheckoutApi.xml" hash="c95a8f82fd3200b98898f0b9712ea0c8"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0.0</min><max>1.8</max></package></required></dependencies>
18
+ </package>
skin/adminhtml/default/default/tray/checkoutapi/css/magentomodal.css ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .overlay_dialog {
2
+ background-color: #666666;
3
+ filter:alpha(opacity=60);
4
+ -moz-opacity: 0.6;
5
+ opacity: 0.6;
6
+ }
7
+
8
+ .overlay___invisible__ {
9
+ background-color: #666666;
10
+ filter:alpha(opacity=0);
11
+ -moz-opacity: 0;
12
+ opacity: 0;
13
+ }
14
+
15
+ .dialog_nw {
16
+ width: 9px;
17
+ height: 23px;
18
+ background: transparent url(../images/top_left.gif) no-repeat 0 0;
19
+ }
20
+
21
+ .dialog_n {
22
+ background: transparent url(../images/top_mid.gif) repeat-x 0 0;
23
+ height: 23px;
24
+ }
25
+
26
+ .dialog_ne {
27
+ width: 9px;
28
+ height: 23px;
29
+ background: transparent url(../images/top_right.gif) no-repeat 0 0;
30
+ }
31
+
32
+ .dialog_e {
33
+ width: 2px;
34
+ background: transparent url(../images/center_right.gif) repeat-y 0 0;
35
+ }
36
+
37
+ .dialog_w {
38
+ width: 2px;
39
+ background: transparent url(../images/center_left.gif) repeat-y 0 0;
40
+ }
41
+
42
+ .dialog_sw {
43
+ width: 9px;
44
+ height: 19px;
45
+ background: transparent url(../images/bottom_left.gif) no-repeat 0 0;
46
+ }
47
+
48
+ .dialog_s {
49
+ background: transparent url(../images/bottom_mid.gif) repeat-x 0 0;
50
+ height: 19px;
51
+ }
52
+
53
+ .dialog_se {
54
+ width: 9px;
55
+ height: 19px;
56
+ background: transparent url(../images/bottom_right.gif) no-repeat 0 0;
57
+ }
58
+
59
+ .dialog_sizer {
60
+ width: 9px;
61
+ height: 19px;
62
+ background: transparent url(../images/sizer.gif) no-repeat 0 0;
63
+ cursor:se-resize;
64
+ }
65
+
66
+ .dialog_close {
67
+ width: 14px;
68
+ height: 14px;
69
+ background: transparent url(../images/close.gif) no-repeat 0 0;
70
+ position:absolute;
71
+ top:5px;
72
+ left:8px;
73
+ cursor:pointer;
74
+ z-index:2000;
75
+ }
76
+
77
+ .dialog_minimize {
78
+ width: 14px;
79
+ height: 15px;
80
+ background: transparent url(../images/minimize.gif) no-repeat 0 0;
81
+ position:absolute;
82
+ top:5px;
83
+ left:28px;
84
+ cursor:pointer;
85
+ z-index:2000;
86
+ }
87
+
88
+ .dialog_maximize {
89
+ width: 14px;
90
+ height: 15px;
91
+ background: transparent url(../images/maximize.gif) no-repeat 0 0;
92
+ position:absolute;
93
+ top:5px;
94
+ left:49px;
95
+ cursor:pointer;
96
+ z-index:2000;
97
+ }
98
+
99
+ .dialog_title {
100
+ float:left;
101
+ height:14px;
102
+ font-family: Tahoma, Arial, sans-serif;
103
+ font-size:12px;
104
+ text-align:center;
105
+ width:100%;
106
+ color:#000;
107
+ }
108
+
109
+ .dialog_content {
110
+ overflow:auto;
111
+ color: #DDD;
112
+ font-family: Tahoma, Arial, sans-serif;
113
+ font-size: 10px;
114
+ background-color:#123;
115
+ }
116
+
117
+ .top_draggable, .bottom_draggable {
118
+ cursor:move;
119
+ }
120
+
121
+ .status_bar {
122
+ font-size:12px;
123
+ }
124
+ .status_bar input{
125
+ font-size:12px;
126
+ }
127
+
128
+ .wired_frame {
129
+ display: block;
130
+ position: absolute;
131
+ border: 1px #000 dashed;
132
+ }
133
+
134
+ /* DO NOT CHANGE THESE VALUES*/
135
+ .dialog {
136
+ display: block;
137
+ position: absolute;
138
+ }
139
+
140
+ .dialog table.table_window {
141
+ border-collapse: collapse;
142
+ border-spacing: 0;
143
+ width: 100%;
144
+ margin: 0px;
145
+ padding:0px;
146
+ }
147
+
148
+ .dialog table.table_window td , .dialog table.table_window th {
149
+ padding: 0;
150
+ }
151
+
152
+ .dialog .title_window {
153
+ -moz-user-select:none;
154
+ }
155
+
156
+ .dialog { border:1px solid #555; }
157
+ .dialog .bot { display:none !important; }
158
+ .overlay_magento { background-color:#000; filter:alpha(opacity=60); -moz-opacity:.6; opacity:.6; -webkit-opacity:.6; }
159
+ .top.table_window { border-bottom:1px solid #e6e6e6; background:#6a838b url(../images/top_bg.gif) 0 100% repeat-x; }
160
+
161
+ .magento_nw { width:6px; height:28px; }
162
+ .magento_n { height:28px; }
163
+ .magento_ne { width:6px; height:28px; }
164
+
165
+ .magento_w { width:6px; }
166
+ .magento_e { width:6px; }
167
+ .magento_w,
168
+ .magento_e,
169
+ .magento_content { background: #fafafa url(../images/content_bg.gif) 0 0 repeat-x; }
170
+
171
+ .magento_sw { background:#deebf0; width:5px; height:3px; }
172
+ .magento_s { background:#deebf0; height:3px; }
173
+ .magento_se,
174
+
175
+ .magento_sizer { background:#deebf0; width:5px; height:3px; }
176
+ .magento_sizer { cursor:se-resize; }
177
+
178
+ .magento_close { width:16px; height:16px; background:url(../images/window_close.png) no-repeat 0 0; position:absolute; top:5px; right:7px; cursor:pointer; z-index:1000; }
179
+ .magento_minimize { width:16px; height:16px; background:url(../images/window_minimize.png) 0 0 no-repeat; position:absolute; top:5px; right:28px; cursor:pointer; z-index:1000; }
180
+ .magento_maximize { width:16px; height:16px; background:url(../images/window_maximize.png)0 0 no-repeat; position:absolute; top:5px; right:49px; cursor:pointer; z-index:1000; }
181
+
182
+ .magento_title { float:left; width:100%; font:bold 12px/28px Arial, Helvetica, sans-serif; color:#fff; text-align:left; }
183
+
184
+ .magento_content { overflow:auto; font-size:12px; }
185
+ .magento_content,
186
+ .magento_content label { color:#333; font-family:Arial, sans-serif; }
187
+
188
+ .magento_buttons { padding:10px; text-align:right; }
189
+ .magento_buttons input.button { border-width:1px; border-style:solid; border-color:#ed6502 #a04300 #a04300 #ed6502; background:#ffac47 url(../images/btn_bg.gif) 0 100% repeat-x; padding:0 7px 1px 7px; font:bold 12px/18px Arial, Helvetica, sans-serif; color:#fff; cursor:pointer; text-align:center; white-space:nowrap; }
190
+
191
+ /* FOR IE */
192
+ * html .magento_close { background-image:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../images/window_maximize.png", sizingMethod="crop"); }
193
+ * html .magento_minimize { background-image:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../images/window_close.png", sizingMethod="crop");}
194
+ * html .magento_maximize { background-image:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../images/window_minimize.png", sizingMethod="crop"); }
skin/adminhtml/default/default/tray/checkoutapi/images/btn_bg.gif ADDED
Binary file
skin/adminhtml/default/default/tray/checkoutapi/images/content_bg.gif ADDED
Binary file
skin/adminhtml/default/default/tray/checkoutapi/images/top_bg.gif ADDED
Binary file
skin/adminhtml/default/default/tray/checkoutapi/images/window_close.png ADDED
Binary file
skin/adminhtml/default/default/tray/checkoutapi/js/exibitionsettingswebcheckout.js ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ function openModalTray(url, txtTitle)
3
+ {
4
+ var _url = checkoutapi_baseurl + url;
5
+
6
+ if(txtTitle === null || txtTitle === '') {
7
+ txtTitle = 'Validação das informações do Anúncio';
8
+ }
9
+ winCompare = new Window({
10
+ className:'magento',
11
+ title:txtTitle,
12
+ url:_url,
13
+ width:820,
14
+ height:600,
15
+ minimizable:false,
16
+ maximizable:false,
17
+ showEffectOptions:{
18
+ duration:0.4
19
+ },
20
+ hideEffectOptions:{
21
+ duration:0.4
22
+ }
23
+ });
24
+ winCompare.setZIndex(100000);
25
+ winCompare.showCenter(true);
26
+ }
skin/frontend/base/default/tray/checkoutapi/css/styles.css ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ #overlay-tc {
2
+ background-image: url('../images/overlay.png');
3
+ display:block;
4
+ position: absolute;
5
+ top: 0px;
6
+ left: 0px;
7
+ width: 100%;
8
+ height: 100%;
9
+ z-index: 2147483647;
10
+ }
skin/frontend/base/default/tray/checkoutapi/images/BannerTrayCheckout890px.png ADDED
Binary file
skin/frontend/base/default/tray/checkoutapi/images/banner_comlogo_formas.jpg ADDED
Binary file
skin/frontend/base/default/tray/checkoutapi/images/banner_semlogo_formas.jpg ADDED
Binary file
skin/frontend/base/default/tray/checkoutapi/images/banner_semlogo_formas.png ADDED
Binary file
skin/frontend/base/default/tray/checkoutapi/images/close.png ADDED
Binary file
skin/frontend/base/default/tray/checkoutapi/images/overlay.png ADDED
Binary file
skin/frontend/base/default/tray/checkoutapi/images/paymentFlags1.png ADDED
Binary file
skin/frontend/base/default/tray/checkoutapi/images/paymentFlagsTc.png ADDED
Binary file