Version Notes
* Widget cart
* Refund observer
* Widget data view
Download this release
Release Info
| Developer | Aplazame |
| Extension | Aplazame_Aplazame |
| Version | 0.2.2 |
| Comparing to | |
| See all releases | |
Code changes from version 0.2.0 to 0.2.2
- app/code/community/Aplazame/Aplazame/Block/Checkout/Cart/Widget.php +56 -0
- app/code/community/Aplazame/Aplazame/Block/Payment/Redirect.php +5 -3
- app/code/community/Aplazame/Aplazame/Block/Product/Widget.php +3 -2
- app/code/community/Aplazame/Aplazame/Helper/Cart.php +28 -5
- app/code/community/Aplazame/Aplazame/Helper/Data.php +4 -0
- app/code/community/Aplazame/Aplazame/Model/Api/Client.php +61 -31
- app/code/community/Aplazame/Aplazame/Model/Api/Serializers.php +67 -52
- app/code/community/Aplazame/Aplazame/Model/Config.php +7 -2
- app/code/community/Aplazame/Aplazame/Model/Observer.php +54 -4
- app/code/community/Aplazame/Aplazame/Model/Payment.php +41 -9
- app/code/community/Aplazame/Aplazame/controllers/PaymentController.php +9 -3
- app/code/community/Aplazame/Aplazame/etc/config.xml +12 -5
- app/code/community/Aplazame/Aplazame/etc/system.xml +19 -21
- app/design/frontend/base/default/layout/aplazame.xml +7 -0
- app/design/frontend/base/default/template/aplazame/.DS_Store +0 -0
- app/design/frontend/base/default/template/aplazame/checkout/cart/widget.phtml +5 -0
- app/design/frontend/base/default/template/aplazame/payment/common.phtml +4 -3
- app/design/frontend/base/default/template/aplazame/product/widget.phtml +5 -4
- app/locale/es_ES/Aplazame_Aplazame.csv +2 -0
- package.xml +12 -16
app/code/community/Aplazame/Aplazame/Block/Checkout/Cart/Widget.php
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
require_once Mage::getBaseDir('lib').DS.'Aplazame'.DS.'Aplazame.php';
|
| 4 |
+
|
| 5 |
+
class Aplazame_Aplazame_Block_Checkout_Cart_Widget Extends Mage_Core_Block_Template
|
| 6 |
+
{
|
| 7 |
+
/**
|
| 8 |
+
* @var Mage_Sales_Model_Quote $_product
|
| 9 |
+
*/
|
| 10 |
+
protected $_quote;
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
/**
|
| 14 |
+
* Devuelve el quote actual
|
| 15 |
+
* @return Mage_Sales_Model_Quote|mixed
|
| 16 |
+
*/
|
| 17 |
+
public function getQuote()
|
| 18 |
+
{
|
| 19 |
+
if(!$this->_quote)
|
| 20 |
+
{
|
| 21 |
+
$this->_quote = $quote = Mage::getSingleton('checkout/session')->getQuote();
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
return $this->_quote;
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
/**
|
| 28 |
+
* Devuelve el final price del producto, formateado para Aplazame
|
| 29 |
+
* @return int
|
| 30 |
+
*/
|
| 31 |
+
public function getTotal()
|
| 32 |
+
{
|
| 33 |
+
if($this->getQuote() instanceof Mage_Sales_Model_Quote)
|
| 34 |
+
{
|
| 35 |
+
return Aplazame_Util::formatDecimals($this->getQuote()->getBaseGrandTotal());
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
return Aplazame_Util::formatDecimals(0);
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/**
|
| 42 |
+
* Solo renderizamos si el modulo esta activo en la tienda actual
|
| 43 |
+
*
|
| 44 |
+
* @return string
|
| 45 |
+
*/
|
| 46 |
+
public function _toHtml()
|
| 47 |
+
{
|
| 48 |
+
if(Mage::helper('aplazame')->isEnabled())
|
| 49 |
+
{
|
| 50 |
+
return parent::_toHtml();
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
return '';
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
}
|
app/code/community/Aplazame/Aplazame/Block/Payment/Redirect.php
CHANGED
|
@@ -5,6 +5,9 @@ class Aplazame_Aplazame_Block_Payment_Redirect extends Mage_Core_Block_Abstract
|
|
| 5 |
{
|
| 6 |
protected function _toHtml()
|
| 7 |
{
|
|
|
|
|
|
|
|
|
|
| 8 |
$payment = Mage::getModel('aplazame/payment');
|
| 9 |
|
| 10 |
$html = '
|
|
@@ -13,14 +16,13 @@ class Aplazame_Aplazame_Block_Payment_Redirect extends Mage_Core_Block_Abstract
|
|
| 13 |
|
| 14 |
<script
|
| 15 |
type="text/javascript"
|
| 16 |
-
src="'.
|
| 17 |
data-aplazame="publicKey: '. Mage::getStoreConfig('payment/aplazame/public_api_key') . '"
|
| 18 |
-
data-version="'. Mage::getStoreConfig('payment/aplazame/version') . '"
|
| 19 |
data-sandbox="'. (Mage::getStoreConfig('payment/aplazame/sandbox')?'true':'false') . '">
|
| 20 |
</script>
|
| 21 |
|
| 22 |
<script>
|
| 23 |
-
aplazame.checkout(' . json_encode($payment->getCheckoutSerializer()
|
| 24 |
</script>
|
| 25 |
|
| 26 |
<iframe src="'./*Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)*/Mage::getUrl('', array('_secure'=>true)).'" style="position:fixed; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden;">
|
| 5 |
{
|
| 6 |
protected function _toHtml()
|
| 7 |
{
|
| 8 |
+
$aplazameJsUri = getenv('APLAZAME_JS_URI') ? getenv('APLAZAME_JS_URI') : 'https://aplazame.com/static/aplazame.js';
|
| 9 |
+
|
| 10 |
+
/** @var Aplazame_Aplazame_Model_Payment $payment */
|
| 11 |
$payment = Mage::getModel('aplazame/payment');
|
| 12 |
|
| 13 |
$html = '
|
| 16 |
|
| 17 |
<script
|
| 18 |
type="text/javascript"
|
| 19 |
+
src="'. $aplazameJsUri . '"
|
| 20 |
data-aplazame="publicKey: '. Mage::getStoreConfig('payment/aplazame/public_api_key') . '"
|
|
|
|
| 21 |
data-sandbox="'. (Mage::getStoreConfig('payment/aplazame/sandbox')?'true':'false') . '">
|
| 22 |
</script>
|
| 23 |
|
| 24 |
<script>
|
| 25 |
+
aplazame.checkout(' . json_encode($payment->getCheckoutSerializer()) . ');
|
| 26 |
</script>
|
| 27 |
|
| 28 |
<iframe src="'./*Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB)*/Mage::getUrl('', array('_secure'=>true)).'" style="position:fixed; top:0px; left:0px; bottom:0px; right:0px; width:100%; height:100%; border:none; margin:0; padding:0; overflow:hidden;">
|
app/code/community/Aplazame/Aplazame/Block/Product/Widget.php
CHANGED
|
@@ -40,17 +40,18 @@ class Aplazame_Aplazame_Block_Product_Widget Extends Mage_Core_Block_Template
|
|
| 40 |
|
| 41 |
/**
|
| 42 |
* Solo renderizamos si tenemos producto,
|
|
|
|
| 43 |
* si no hay producto no renderizamos nada (empty string).
|
| 44 |
*
|
| 45 |
* @return string
|
| 46 |
*/
|
| 47 |
public function _toHtml()
|
| 48 |
{
|
| 49 |
-
if($this->getProduct() instanceof Mage_Catalog_Model_Product)
|
| 50 |
{
|
| 51 |
return parent::_toHtml();
|
| 52 |
}
|
| 53 |
|
| 54 |
-
return '
|
| 55 |
}
|
| 56 |
}
|
| 40 |
|
| 41 |
/**
|
| 42 |
* Solo renderizamos si tenemos producto,
|
| 43 |
+
* y si el modulo esta activo en la tienda actual
|
| 44 |
* si no hay producto no renderizamos nada (empty string).
|
| 45 |
*
|
| 46 |
* @return string
|
| 47 |
*/
|
| 48 |
public function _toHtml()
|
| 49 |
{
|
| 50 |
+
if(Mage::helper('aplazame')->isEnabled() && $this->getProduct() instanceof Mage_Catalog_Model_Product)
|
| 51 |
{
|
| 52 |
return parent::_toHtml();
|
| 53 |
}
|
| 54 |
|
| 55 |
+
return '';
|
| 56 |
}
|
| 57 |
}
|
app/code/community/Aplazame/Aplazame/Helper/Cart.php
CHANGED
|
@@ -7,11 +7,11 @@ class Aplazame_Aplazame_Helper_Cart extends Mage_Core_Helper_Abstract
|
|
| 7 |
* de producirse algún fallo en el proceso de cobro de aplazame
|
| 8 |
* o bien se ha rechazado la operación.
|
| 9 |
*/
|
| 10 |
-
public function resuscitateCartFromOrder(Mage_Sales_Model_Order $order)
|
| 11 |
{
|
| 12 |
$this
|
| 13 |
->_cancelOrder($order)
|
| 14 |
-
->_resuscitateCartItems($order)
|
| 15 |
->_setCheckoutInfoFromOldOrder($order);
|
| 16 |
|
| 17 |
return $this;
|
|
@@ -39,14 +39,36 @@ class Aplazame_Aplazame_Helper_Cart extends Mage_Core_Helper_Abstract
|
|
| 39 |
* @param Mage_Sales_Model_Order $order
|
| 40 |
* @return $this
|
| 41 |
*/
|
| 42 |
-
protected function _resuscitateCartItems(Mage_Sales_Model_Order $order)
|
| 43 |
{
|
| 44 |
foreach ($order->getItemsCollection() as $orderItem) {
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
}
|
| 47 |
|
| 48 |
$this->getCart()->save();
|
| 49 |
-
|
| 50 |
return $this;
|
| 51 |
}
|
| 52 |
|
|
@@ -62,6 +84,7 @@ class Aplazame_Aplazame_Helper_Cart extends Mage_Core_Helper_Abstract
|
|
| 62 |
{
|
| 63 |
$checkoutSession = $this->getCheckoutSession();
|
| 64 |
$quote = $checkoutSession->getQuote();
|
|
|
|
| 65 |
$oldQuote = Mage::getModel('sales/quote')->load($order->getQuoteId());
|
| 66 |
|
| 67 |
$quote->setCheckoutMethod($oldQuote->getCheckoutMethod());
|
| 7 |
* de producirse algún fallo en el proceso de cobro de aplazame
|
| 8 |
* o bien se ha rechazado la operación.
|
| 9 |
*/
|
| 10 |
+
public function resuscitateCartFromOrder(Mage_Sales_Model_Order $order, Mage_Core_Controller_Front_Action $action = null)
|
| 11 |
{
|
| 12 |
$this
|
| 13 |
->_cancelOrder($order)
|
| 14 |
+
->_resuscitateCartItems($order, $action)
|
| 15 |
->_setCheckoutInfoFromOldOrder($order);
|
| 16 |
|
| 17 |
return $this;
|
| 39 |
* @param Mage_Sales_Model_Order $order
|
| 40 |
* @return $this
|
| 41 |
*/
|
| 42 |
+
protected function _resuscitateCartItems(Mage_Sales_Model_Order $order, Mage_Core_Controller_Front_Action $action=null)
|
| 43 |
{
|
| 44 |
foreach ($order->getItemsCollection() as $orderItem) {
|
| 45 |
+
try {
|
| 46 |
+
$this->getCart()->addOrderItem($orderItem);
|
| 47 |
+
} catch (Mage_Core_Exception $e) {
|
| 48 |
+
/** @var Mage_Checkout_Model_Session $session */
|
| 49 |
+
$session = Mage::getSingleton('checkout/session');
|
| 50 |
+
if ($session->getUseNotice(true)) {
|
| 51 |
+
$session->addNotice($e->getMessage());
|
| 52 |
+
} else {
|
| 53 |
+
$session->addError($e->getMessage());
|
| 54 |
+
}
|
| 55 |
+
if($action)
|
| 56 |
+
{
|
| 57 |
+
$action->setRedirectWithCookieCheck('checkout/cart');
|
| 58 |
+
}
|
| 59 |
+
} catch (Exception $e) {
|
| 60 |
+
/** @var Mage_Checkout_Model_Session $session */
|
| 61 |
+
$session = Mage::getSingleton('checkout/session');
|
| 62 |
+
$session->addNotice($e->getMessage());
|
| 63 |
+
$session->addException($e, Mage::helper('checkout')->__('Cannot add the item to shopping cart.'));
|
| 64 |
+
if($action)
|
| 65 |
+
{
|
| 66 |
+
$action->setRedirectWithCookieCheck('checkout/cart');
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
}
|
| 70 |
|
| 71 |
$this->getCart()->save();
|
|
|
|
| 72 |
return $this;
|
| 73 |
}
|
| 74 |
|
| 84 |
{
|
| 85 |
$checkoutSession = $this->getCheckoutSession();
|
| 86 |
$quote = $checkoutSession->getQuote();
|
| 87 |
+
/** @var Mage_Sales_Model_Quote $oldQuote */
|
| 88 |
$oldQuote = Mage::getModel('sales/quote')->load($order->getQuoteId());
|
| 89 |
|
| 90 |
$quote->setCheckoutMethod($oldQuote->getCheckoutMethod());
|
app/code/community/Aplazame/Aplazame/Helper/Data.php
CHANGED
|
@@ -2,4 +2,8 @@
|
|
| 2 |
|
| 3 |
class Aplazame_Aplazame_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
}
|
| 2 |
|
| 3 |
class Aplazame_Aplazame_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
{
|
| 5 |
+
public function isEnabled()
|
| 6 |
+
{
|
| 7 |
+
return (bool) Mage::getStoreConfig('payment/aplazame/active');
|
| 8 |
+
}
|
| 9 |
}
|
app/code/community/Aplazame/Aplazame/Model/Api/Client.php
CHANGED
|
@@ -1,22 +1,24 @@
|
|
| 1 |
<?php
|
| 2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
class Aplazame_Aplazame_Model_Api_Client extends Varien_Object
|
| 4 |
{
|
| 5 |
-
|
| 6 |
-
|
|
|
|
|
|
|
| 7 |
|
| 8 |
public function __construct()
|
| 9 |
{
|
|
|
|
| 10 |
}
|
| 11 |
|
| 12 |
-
public function
|
| 13 |
{
|
| 14 |
-
|
| 15 |
-
}
|
| 16 |
-
|
| 17 |
-
protected function _api_request($method, $path, $data=null)
|
| 18 |
-
{
|
| 19 |
-
$url = trim($this->getBaseApiUrl(), "/") . self::API_CHECKOUT_PATH . $path;
|
| 20 |
$client = new Zend_Http_Client($url);
|
| 21 |
|
| 22 |
if (in_array($method, array(
|
|
@@ -28,18 +30,16 @@ class Aplazame_Aplazame_Model_Api_Client extends Varien_Object
|
|
| 28 |
$client->setHeaders('Authorization: Bearer '.
|
| 29 |
Mage::getStoreConfig('payment/aplazame/secret_api_key'));
|
| 30 |
|
| 31 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
-
|
| 34 |
-
$version = explode(".", $version);
|
| 35 |
-
$version = $version[0];
|
| 36 |
-
}
|
| 37 |
-
|
| 38 |
-
$client->setHeaders('User-Agent: '. self::USER_AGENT .
|
| 39 |
-
Mage::getConfig()->getModuleConfig('Aplazame_Aplazame')->version);
|
| 40 |
|
| 41 |
$client->setHeaders('Accept: '. 'application/vnd.aplazame.'.
|
| 42 |
-
(Mage::getStoreConfig('payment/aplazame/sandbox')?'sandbox.': '') .
|
| 43 |
|
| 44 |
$response = $client->request($method);
|
| 45 |
$raw_result = $response->getBody();
|
|
@@ -74,28 +74,58 @@ class Aplazame_Aplazame_Model_Api_Client extends Varien_Object
|
|
| 74 |
return $ret_json;
|
| 75 |
}
|
| 76 |
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
{
|
| 79 |
-
return $this->
|
| 80 |
-
$this->getOrderId() . "/authorize");
|
| 81 |
}
|
| 82 |
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
{
|
| 85 |
-
|
| 86 |
-
|
| 87 |
$serializer = Mage::getModel('aplazame/api_serializers');
|
| 88 |
-
$data = $serializer->
|
| 89 |
|
| 90 |
-
return $this->
|
| 91 |
-
'PATCH',
|
| 92 |
}
|
| 93 |
|
| 94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
{
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
|
| 98 |
-
return $this->
|
| 99 |
-
Varien_Http_Client::POST,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
}
|
| 101 |
}
|
| 1 |
<?php
|
| 2 |
|
| 3 |
+
/**
|
| 4 |
+
* @method $this setOrder(Mage_Sales_Model_Resource_Order $order)
|
| 5 |
+
* @method Mage_Sales_Model_Resource_Order getOrder()
|
| 6 |
+
*/
|
| 7 |
class Aplazame_Aplazame_Model_Api_Client extends Varien_Object
|
| 8 |
{
|
| 9 |
+
/**
|
| 10 |
+
* @var string
|
| 11 |
+
*/
|
| 12 |
+
private $apiBaseUri;
|
| 13 |
|
| 14 |
public function __construct()
|
| 15 |
{
|
| 16 |
+
$this->apiBaseUri = getenv('APLAZAME_API_BASE_URI') ? getenv('APLAZAME_API_BASE_URI') : 'https://api.aplazame.com';
|
| 17 |
}
|
| 18 |
|
| 19 |
+
public function request($method, $path, $data=null)
|
| 20 |
{
|
| 21 |
+
$url = $this->apiBaseUri. $path;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
$client = new Zend_Http_Client($url);
|
| 23 |
|
| 24 |
if (in_array($method, array(
|
| 30 |
$client->setHeaders('Authorization: Bearer '.
|
| 31 |
Mage::getStoreConfig('payment/aplazame/secret_api_key'));
|
| 32 |
|
| 33 |
+
$versions = array(
|
| 34 |
+
'PHP/' . PHP_VERSION,
|
| 35 |
+
'Magento/' . Mage::getVersion(),
|
| 36 |
+
'AplazameMagento/' . Mage::getConfig()->getModuleConfig('Aplazame_Aplazame')->version,
|
| 37 |
+
);
|
| 38 |
|
| 39 |
+
$client->setHeaders('User-Agent: '. implode(', ', $versions));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
$client->setHeaders('Accept: '. 'application/vnd.aplazame.'.
|
| 42 |
+
(Mage::getStoreConfig('payment/aplazame/sandbox')?'sandbox.': '') . 'v1+json');
|
| 43 |
|
| 44 |
$response = $client->request($method);
|
| 45 |
$raw_result = $response->getBody();
|
| 74 |
return $ret_json;
|
| 75 |
}
|
| 76 |
|
| 77 |
+
/**
|
| 78 |
+
* @param string $orderId
|
| 79 |
+
* @return array
|
| 80 |
+
*/
|
| 81 |
+
public function authorize($orderId)
|
| 82 |
{
|
| 83 |
+
return $this->request(Varien_Http_Client::POST, "/" . $orderId . "/authorize");
|
|
|
|
| 84 |
}
|
| 85 |
|
| 86 |
+
/**
|
| 87 |
+
* @param Mage_Sales_Model_Order $order
|
| 88 |
+
* @return array
|
| 89 |
+
*/
|
| 90 |
+
public function updateOrder($order)
|
| 91 |
{
|
| 92 |
+
/** @var Aplazame_Aplazame_Model_Api_Serializers $serializer */
|
|
|
|
| 93 |
$serializer = Mage::getModel('aplazame/api_serializers');
|
| 94 |
+
$data = $serializer->getOrderUpdate($order);
|
| 95 |
|
| 96 |
+
return $this->request(
|
| 97 |
+
'PATCH', $this->getEndpointForOrder($order), $data);
|
| 98 |
}
|
| 99 |
|
| 100 |
+
/**
|
| 101 |
+
* @param Mage_Sales_Model_Order $order
|
| 102 |
+
* @return array
|
| 103 |
+
*/
|
| 104 |
+
public function cancelOrder($order)
|
| 105 |
{
|
| 106 |
+
return $this->request(
|
| 107 |
+
Varien_Http_Client::POST, $this->getEndpointForOrder($order) . "/cancel");
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
/**
|
| 111 |
+
* @param Mage_Sales_Model_Order $order
|
| 112 |
+
* @param float $amount
|
| 113 |
+
* @return array
|
| 114 |
+
*/
|
| 115 |
+
public function refundAmount($order, $amount)
|
| 116 |
+
{
|
| 117 |
+
$data = array('amount'=>Aplazame_Util::formatDecimals($amount));
|
| 118 |
|
| 119 |
+
return $this->request(
|
| 120 |
+
Varien_Http_Client::POST, $this->getEndpointForOrder($order) . "/refund", $data);
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
+
/**
|
| 124 |
+
* @param Mage_Sales_Model_Order $order
|
| 125 |
+
* @return string
|
| 126 |
+
*/
|
| 127 |
+
protected function getEndpointForOrder($order)
|
| 128 |
+
{
|
| 129 |
+
return '/orders/' . (int)$order->getIncrementId();
|
| 130 |
}
|
| 131 |
}
|
app/code/community/Aplazame/Aplazame/Model/Api/Serializers.php
CHANGED
|
@@ -21,21 +21,10 @@ class Aplazame_Aplazame_Model_Api_Serializers extends Varien_Object
|
|
| 21 |
);
|
| 22 |
}
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
public function getInvoiceFeeIncludeTax()
|
| 30 |
-
{
|
| 31 |
-
return $this->getTotal()->getAddress()->getInvoiceFee();
|
| 32 |
-
}
|
| 33 |
-
|
| 34 |
-
public function getInvoiceFeeExcludeTax()
|
| 35 |
-
{
|
| 36 |
-
return $this->getTotal()->getAddress()->getInvoiceFeeExcludedVat();
|
| 37 |
-
}
|
| 38 |
-
|
| 39 |
protected function _getAddr($addr)
|
| 40 |
{
|
| 41 |
return array(
|
|
@@ -51,10 +40,15 @@ class Aplazame_Aplazame_Model_Api_Serializers extends Varien_Object
|
|
| 51 |
"postcode" => $addr->getPostcode());
|
| 52 |
}
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
{
|
|
|
|
| 56 |
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
| 57 |
-
$logCustomer = Mage::getModel('log/customer')->
|
| 58 |
$customer_serializer = array("gender"=>0);
|
| 59 |
|
| 60 |
if ($customer->getId()) {
|
|
@@ -67,8 +61,6 @@ class Aplazame_Aplazame_Model_Api_Serializers extends Varien_Object
|
|
| 67 |
"date_joined"=>date(DATE_ISO8601, $customer->getCreatedAtTimestamp()),
|
| 68 |
"last_login"=>date(DATE_ISO8601, $logCustomer->getLoginAtTimestamp())));
|
| 69 |
} else {
|
| 70 |
-
$order = $this->getOrder();
|
| 71 |
-
|
| 72 |
$customer_serializer = array_merge($customer_serializer, array(
|
| 73 |
"type"=>"g",
|
| 74 |
"email"=>$order->getCustomerEmail(),
|
|
@@ -79,18 +71,24 @@ class Aplazame_Aplazame_Model_Api_Serializers extends Varien_Object
|
|
| 79 |
return $customer_serializer;
|
| 80 |
}
|
| 81 |
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
{
|
| 84 |
-
$order = $this->getOrder();
|
| 85 |
$shipping = null;
|
| 86 |
$shipping_address = $order->getShippingAddress();
|
| 87 |
|
| 88 |
if ($shipping_address) {
|
| 89 |
$shipping = array_merge($this->_getAddr($shipping_address), array(
|
| 90 |
-
"price"=>
|
| 91 |
-
"tax_rate"=>static::formatDecimals(100 * $order->getShippingTaxAmount() / $order->getShippingAmount()),
|
| 92 |
"name"=>$order->getShippingMethod()
|
| 93 |
));
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
}
|
| 95 |
|
| 96 |
return $shipping;
|
|
@@ -104,14 +102,19 @@ class Aplazame_Aplazame_Model_Api_Serializers extends Varien_Object
|
|
| 104 |
return Mage::getSingleton('tax/calculation')->getRate($request->setProductClassId($taxclassid));
|
| 105 |
}
|
| 106 |
|
| 107 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
{
|
| 109 |
-
$order = $this->getOrder();
|
| 110 |
$articles = array();
|
| 111 |
$products = Mage::getModel('catalog/product');
|
| 112 |
|
|
|
|
| 113 |
foreach ($order->getAllVisibleItems() as $order_item) {
|
| 114 |
$productId = $order_item->getProductId();
|
|
|
|
| 115 |
$product = $products->load($productId);
|
| 116 |
$discounts = $product->getPrice() - $product->getFinalPrice();
|
| 117 |
|
|
@@ -123,17 +126,20 @@ class Aplazame_Aplazame_Model_Api_Serializers extends Varien_Object
|
|
| 123 |
"url" =>$product->getProductUrl(),
|
| 124 |
"image_url" => $product->getImageUrl(),
|
| 125 |
"quantity" => intval($order_item->getQtyOrdered()),
|
| 126 |
-
"price" =>
|
| 127 |
-
"tax_rate" =>
|
| 128 |
-
"discount" =>
|
| 129 |
}
|
| 130 |
|
| 131 |
return $articles;
|
| 132 |
}
|
| 133 |
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
{
|
| 136 |
-
$order = $this->getOrder();
|
| 137 |
$discounts = $order->getDiscountAmount();
|
| 138 |
|
| 139 |
if (is_null($discounts)) {
|
|
@@ -142,16 +148,20 @@ class Aplazame_Aplazame_Model_Api_Serializers extends Varien_Object
|
|
| 142 |
|
| 143 |
return array(
|
| 144 |
"id"=>$order->getIncrementId(),
|
| 145 |
-
"articles"=>$this->getArticles(),
|
| 146 |
"currency"=>$order->getOrderCurrencyCode(),
|
| 147 |
-
"tax_amount"=>
|
| 148 |
-
"total_amount"=>
|
| 149 |
-
"discount"=>-
|
| 150 |
}
|
| 151 |
|
| 152 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 153 |
{
|
| 154 |
-
|
| 155 |
$history_collection = Mage::getModel('sales/order')
|
| 156 |
->getCollection()
|
| 157 |
->addAttributeToFilter('customer_id', array('like'=>$order->getCustomerId()));
|
|
@@ -160,8 +170,8 @@ class Aplazame_Aplazame_Model_Api_Serializers extends Varien_Object
|
|
| 160 |
foreach ($history_collection as $order_history) {
|
| 161 |
$history[] = array(
|
| 162 |
"id"=>$order_history->getIncrementId(),
|
| 163 |
-
"amount"=>
|
| 164 |
-
"due"=>
|
| 165 |
"status"=>$order_history->getStatus(),
|
| 166 |
"type"=>$order_history->getPayment()->getMethodInstance()->getCode(),
|
| 167 |
"order_date"=>date(DATE_ISO8601, strtotime($order_history->getCreatedAt())),
|
|
@@ -173,35 +183,40 @@ class Aplazame_Aplazame_Model_Api_Serializers extends Varien_Object
|
|
| 173 |
return $history;
|
| 174 |
}
|
| 175 |
|
| 176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 177 |
{
|
| 178 |
-
$order = $this->getOrder();
|
| 179 |
-
|
| 180 |
return array(
|
| 181 |
-
"order"=>$this->getRenderOrder(),
|
| 182 |
"billing"=>$this->_getAddr($order->getBillingAddress()),
|
| 183 |
"shipping"=>$this->getShipping($order),
|
| 184 |
-
"meta"=>
|
| 185 |
}
|
| 186 |
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
{
|
| 189 |
-
$order = $this->getOrder();
|
| 190 |
$info = $this->getInfoInstance();
|
| 191 |
|
| 192 |
$merchant = array(
|
| 193 |
-
"confirmation_url"=>Mage::getUrl("aplazame/payment/confirm"),
|
| 194 |
-
"cancel_url"=>Mage::getUrl('aplazame/payment/cancel') . '?status=error',
|
| 195 |
-
"checkout_url"=>Mage::getUrl('aplazame/payment/cancel'),
|
| 196 |
-
"success_url"=>Mage::getUrl('checkout/onepage/success'));
|
| 197 |
|
| 198 |
return array(
|
| 199 |
"toc"=>true,
|
| 200 |
"merchant"=>$merchant,
|
| 201 |
-
"customer"=>$this->getCustomer(),
|
| 202 |
-
"order"=>$this->getRenderOrder(),
|
| 203 |
"billing"=>$this->_getAddr($order->getBillingAddress()),
|
| 204 |
"shipping"=>$this->getShipping($order),
|
| 205 |
-
"meta"=>
|
| 206 |
}
|
| 207 |
}
|
| 21 |
);
|
| 22 |
}
|
| 23 |
|
| 24 |
+
/**
|
| 25 |
+
* @param Mage_Sales_Model_Order_Address $addr
|
| 26 |
+
* @return array
|
| 27 |
+
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
protected function _getAddr($addr)
|
| 29 |
{
|
| 30 |
return array(
|
| 40 |
"postcode" => $addr->getPostcode());
|
| 41 |
}
|
| 42 |
|
| 43 |
+
/**
|
| 44 |
+
* @param Mage_Sales_Model_Order $order
|
| 45 |
+
* @return array
|
| 46 |
+
*/
|
| 47 |
+
protected function getCustomer($order)
|
| 48 |
{
|
| 49 |
+
/** @var Mage_Customer_Model_Customer $customer */
|
| 50 |
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
| 51 |
+
$logCustomer = Mage::getModel('log/customer')->load($customer->getId());
|
| 52 |
$customer_serializer = array("gender"=>0);
|
| 53 |
|
| 54 |
if ($customer->getId()) {
|
| 61 |
"date_joined"=>date(DATE_ISO8601, $customer->getCreatedAtTimestamp()),
|
| 62 |
"last_login"=>date(DATE_ISO8601, $logCustomer->getLoginAtTimestamp())));
|
| 63 |
} else {
|
|
|
|
|
|
|
| 64 |
$customer_serializer = array_merge($customer_serializer, array(
|
| 65 |
"type"=>"g",
|
| 66 |
"email"=>$order->getCustomerEmail(),
|
| 71 |
return $customer_serializer;
|
| 72 |
}
|
| 73 |
|
| 74 |
+
/**
|
| 75 |
+
* @param Mage_Sales_Model_Order $order
|
| 76 |
+
* @return array
|
| 77 |
+
*/
|
| 78 |
+
protected function getShipping($order)
|
| 79 |
{
|
|
|
|
| 80 |
$shipping = null;
|
| 81 |
$shipping_address = $order->getShippingAddress();
|
| 82 |
|
| 83 |
if ($shipping_address) {
|
| 84 |
$shipping = array_merge($this->_getAddr($shipping_address), array(
|
| 85 |
+
"price"=> self::formatDecimals($order->getShippingAmount()),
|
|
|
|
| 86 |
"name"=>$order->getShippingMethod()
|
| 87 |
));
|
| 88 |
+
|
| 89 |
+
if ($order->getShippingAmount()) {
|
| 90 |
+
$shipping["tax_rate"] = 100 * $order->getShippingTaxAmount() / $order->getShippingAmount();
|
| 91 |
+
}
|
| 92 |
}
|
| 93 |
|
| 94 |
return $shipping;
|
| 102 |
return Mage::getSingleton('tax/calculation')->getRate($request->setProductClassId($taxclassid));
|
| 103 |
}
|
| 104 |
|
| 105 |
+
/**
|
| 106 |
+
* @param Mage_Sales_Model_Order $order
|
| 107 |
+
* @return array
|
| 108 |
+
*/
|
| 109 |
+
protected function getArticles($order)
|
| 110 |
{
|
|
|
|
| 111 |
$articles = array();
|
| 112 |
$products = Mage::getModel('catalog/product');
|
| 113 |
|
| 114 |
+
/** @var Mage_Sales_Model_Order_Item $order_item */
|
| 115 |
foreach ($order->getAllVisibleItems() as $order_item) {
|
| 116 |
$productId = $order_item->getProductId();
|
| 117 |
+
/** @var Mage_Catalog_Model_Product $product */
|
| 118 |
$product = $products->load($productId);
|
| 119 |
$discounts = $product->getPrice() - $product->getFinalPrice();
|
| 120 |
|
| 126 |
"url" =>$product->getProductUrl(),
|
| 127 |
"image_url" => $product->getImageUrl(),
|
| 128 |
"quantity" => intval($order_item->getQtyOrdered()),
|
| 129 |
+
"price" => self::formatDecimals($order_item->getPrice() + $discounts),
|
| 130 |
+
"tax_rate" => self::formatDecimals($this->getProductTaxRate($product)),
|
| 131 |
+
"discount" => self::formatDecimals($discounts));
|
| 132 |
}
|
| 133 |
|
| 134 |
return $articles;
|
| 135 |
}
|
| 136 |
|
| 137 |
+
/**
|
| 138 |
+
* @param Mage_Sales_Model_Order $order
|
| 139 |
+
* @return array
|
| 140 |
+
*/
|
| 141 |
+
protected function getRenderOrder($order)
|
| 142 |
{
|
|
|
|
| 143 |
$discounts = $order->getDiscountAmount();
|
| 144 |
|
| 145 |
if (is_null($discounts)) {
|
| 148 |
|
| 149 |
return array(
|
| 150 |
"id"=>$order->getIncrementId(),
|
| 151 |
+
"articles"=>$this->getArticles($order),
|
| 152 |
"currency"=>$order->getOrderCurrencyCode(),
|
| 153 |
+
"tax_amount"=>self::formatDecimals($order->getTaxAmount()),
|
| 154 |
+
"total_amount"=>self::formatDecimals($order->getTotalDue()),
|
| 155 |
+
"discount"=>-self::formatDecimals($discounts));
|
| 156 |
}
|
| 157 |
|
| 158 |
+
/**
|
| 159 |
+
* @param Mage_Sales_Model_Order $order
|
| 160 |
+
* @return array
|
| 161 |
+
*/
|
| 162 |
+
public function getHistory($order)
|
| 163 |
{
|
| 164 |
+
/** @var Mage_Sales_Model_Order[] $history_collection */
|
| 165 |
$history_collection = Mage::getModel('sales/order')
|
| 166 |
->getCollection()
|
| 167 |
->addAttributeToFilter('customer_id', array('like'=>$order->getCustomerId()));
|
| 170 |
foreach ($history_collection as $order_history) {
|
| 171 |
$history[] = array(
|
| 172 |
"id"=>$order_history->getIncrementId(),
|
| 173 |
+
"amount"=>self::formatDecimals($order_history->getGrandTotal()),
|
| 174 |
+
"due"=>self::formatDecimals($order_history->getTotalDue()),
|
| 175 |
"status"=>$order_history->getStatus(),
|
| 176 |
"type"=>$order_history->getPayment()->getMethodInstance()->getCode(),
|
| 177 |
"order_date"=>date(DATE_ISO8601, strtotime($order_history->getCreatedAt())),
|
| 183 |
return $history;
|
| 184 |
}
|
| 185 |
|
| 186 |
+
/**
|
| 187 |
+
* @param Mage_Sales_Model_Order $order
|
| 188 |
+
* @return array
|
| 189 |
+
*/
|
| 190 |
+
public function getOrderUpdate($order)
|
| 191 |
{
|
|
|
|
|
|
|
| 192 |
return array(
|
| 193 |
+
"order"=>$this->getRenderOrder($order),
|
| 194 |
"billing"=>$this->_getAddr($order->getBillingAddress()),
|
| 195 |
"shipping"=>$this->getShipping($order),
|
| 196 |
+
"meta"=>self::_getMetadata());
|
| 197 |
}
|
| 198 |
|
| 199 |
+
/**
|
| 200 |
+
* @param Mage_Sales_Model_Order $order
|
| 201 |
+
* @return array
|
| 202 |
+
*/
|
| 203 |
+
public function getCheckout($order)
|
| 204 |
{
|
|
|
|
| 205 |
$info = $this->getInfoInstance();
|
| 206 |
|
| 207 |
$merchant = array(
|
| 208 |
+
"confirmation_url"=>Mage::getUrl("aplazame/payment/confirm", array('_secure'=>true)),
|
| 209 |
+
"cancel_url"=>Mage::getUrl('aplazame/payment/cancel', array('_secure'=>true)) . '?status=error',
|
| 210 |
+
"checkout_url"=>Mage::getUrl('aplazame/payment/cancel', array('_secure'=>true)),
|
| 211 |
+
"success_url"=>Mage::getUrl('checkout/onepage/success', array('_secure'=>true)));
|
| 212 |
|
| 213 |
return array(
|
| 214 |
"toc"=>true,
|
| 215 |
"merchant"=>$merchant,
|
| 216 |
+
"customer"=>$this->getCustomer($order),
|
| 217 |
+
"order"=>$this->getRenderOrder($order),
|
| 218 |
"billing"=>$this->_getAddr($order->getBillingAddress()),
|
| 219 |
"shipping"=>$this->getShipping($order),
|
| 220 |
+
"meta"=>self::_getMetadata());
|
| 221 |
}
|
| 222 |
}
|
app/code/community/Aplazame/Aplazame/Model/Config.php
CHANGED
|
@@ -2,6 +2,9 @@
|
|
| 2 |
|
| 3 |
class Aplazame_Aplazame_Model_Config
|
| 4 |
{
|
|
|
|
|
|
|
|
|
|
| 5 |
protected $_storeId = null;
|
| 6 |
|
| 7 |
/**
|
|
@@ -11,12 +14,14 @@ class Aplazame_Aplazame_Model_Config
|
|
| 11 |
{
|
| 12 |
$countryCode = Mage::getStoreConfig("aplazame/general/merchant_country", $this->_storeId);
|
| 13 |
if (!$countryCode) {
|
| 14 |
-
$countryCode = Mage::
|
| 15 |
}
|
| 16 |
return $countryCode;
|
| 17 |
}
|
| 18 |
|
| 19 |
|
|
|
|
|
|
|
| 20 |
/**
|
| 21 |
* Check whether specified currency code is supported
|
| 22 |
*/
|
|
@@ -27,4 +32,4 @@ class Aplazame_Aplazame_Model_Config
|
|
| 27 |
}
|
| 28 |
return false;
|
| 29 |
}
|
| 30 |
-
}
|
| 2 |
|
| 3 |
class Aplazame_Aplazame_Model_Config
|
| 4 |
{
|
| 5 |
+
|
| 6 |
+
const XML_PATH_DEFAULT_COUNTRY = 'general/country/default';
|
| 7 |
+
|
| 8 |
protected $_storeId = null;
|
| 9 |
|
| 10 |
/**
|
| 14 |
{
|
| 15 |
$countryCode = Mage::getStoreConfig("aplazame/general/merchant_country", $this->_storeId);
|
| 16 |
if (!$countryCode) {
|
| 17 |
+
$countryCode = Mage::getStoreConfig(self::XML_PATH_DEFAULT_COUNTRY, $this->_storeId);
|
| 18 |
}
|
| 19 |
return $countryCode;
|
| 20 |
}
|
| 21 |
|
| 22 |
|
| 23 |
+
|
| 24 |
+
|
| 25 |
/**
|
| 26 |
* Check whether specified currency code is supported
|
| 27 |
*/
|
| 32 |
}
|
| 33 |
return false;
|
| 34 |
}
|
| 35 |
+
}
|
app/code/community/Aplazame/Aplazame/Model/Observer.php
CHANGED
|
@@ -3,10 +3,15 @@
|
|
| 3 |
|
| 4 |
class Aplazame_Aplazame_Model_Observer extends Mage_Core_Model_Abstract
|
| 5 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
protected function is_aplazame_payment($order)
|
| 7 |
{
|
| 8 |
$code = Aplazame_Aplazame_Model_Payment::METHOD_CODE;
|
| 9 |
|
|
|
|
| 10 |
$parentOrder = Mage::getModel('sales/order')->loadByIncrementId(
|
| 11 |
(int)$order->getIncrementId());
|
| 12 |
|
|
@@ -18,6 +23,7 @@ class Aplazame_Aplazame_Model_Observer extends Mage_Core_Model_Abstract
|
|
| 18 |
*/
|
| 19 |
public function salesOrderPlaceAfter($observer)
|
| 20 |
{
|
|
|
|
| 21 |
$order = $observer->getOrder();
|
| 22 |
|
| 23 |
if (!isset($order)) {
|
|
@@ -25,8 +31,7 @@ class Aplazame_Aplazame_Model_Observer extends Mage_Core_Model_Abstract
|
|
| 25 |
}
|
| 26 |
|
| 27 |
$payment = $order->getPayment();
|
| 28 |
-
|
| 29 |
-
if (!isset($payment)) {
|
| 30 |
return $this;
|
| 31 |
}
|
| 32 |
|
|
@@ -34,8 +39,9 @@ class Aplazame_Aplazame_Model_Observer extends Mage_Core_Model_Abstract
|
|
| 34 |
return $this;
|
| 35 |
}
|
| 36 |
|
|
|
|
| 37 |
$client = Mage::getModel('aplazame/api_client');
|
| 38 |
-
$
|
| 39 |
|
| 40 |
return $this;
|
| 41 |
}
|
|
@@ -50,14 +56,19 @@ class Aplazame_Aplazame_Model_Observer extends Mage_Core_Model_Abstract
|
|
| 50 |
|
| 51 |
/**
|
| 52 |
* Method used for canceling a Aplazame invoice when a Magento order is canceled
|
|
|
|
|
|
|
| 53 |
*/
|
| 54 |
public function salesOrderPaymentCancel($observer)
|
| 55 |
{
|
| 56 |
$code = Aplazame_Aplazame_Model_Payment::METHOD_CODE;
|
|
|
|
|
|
|
| 57 |
$order = $observer->getOrder();
|
| 58 |
|
| 59 |
$orderId = explode("-", $order->getIncrementId());
|
| 60 |
|
|
|
|
| 61 |
$nextOrder = Mage::getModel('sales/order')->loadByIncrementId(
|
| 62 |
$orderId[0] . '-' . ((int)$orderId[1] + 1));
|
| 63 |
|
|
@@ -69,8 +80,47 @@ class Aplazame_Aplazame_Model_Observer extends Mage_Core_Model_Abstract
|
|
| 69 |
return $this;
|
| 70 |
}
|
| 71 |
|
|
|
|
| 72 |
$client = Mage::getModel('aplazame/api_client');
|
| 73 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
return $this;
|
| 76 |
}
|
| 3 |
|
| 4 |
class Aplazame_Aplazame_Model_Observer extends Mage_Core_Model_Abstract
|
| 5 |
{
|
| 6 |
+
/**
|
| 7 |
+
* @param Mage_Sales_Model_Order $order
|
| 8 |
+
* @return bool
|
| 9 |
+
*/
|
| 10 |
protected function is_aplazame_payment($order)
|
| 11 |
{
|
| 12 |
$code = Aplazame_Aplazame_Model_Payment::METHOD_CODE;
|
| 13 |
|
| 14 |
+
/** @var Mage_Sales_Model_Order $parentOrder */
|
| 15 |
$parentOrder = Mage::getModel('sales/order')->loadByIncrementId(
|
| 16 |
(int)$order->getIncrementId());
|
| 17 |
|
| 23 |
*/
|
| 24 |
public function salesOrderPlaceAfter($observer)
|
| 25 |
{
|
| 26 |
+
/** @var Mage_Sales_Model_Order|null $order */
|
| 27 |
$order = $observer->getOrder();
|
| 28 |
|
| 29 |
if (!isset($order)) {
|
| 31 |
}
|
| 32 |
|
| 33 |
$payment = $order->getPayment();
|
| 34 |
+
if (!$payment) {
|
|
|
|
| 35 |
return $this;
|
| 36 |
}
|
| 37 |
|
| 39 |
return $this;
|
| 40 |
}
|
| 41 |
|
| 42 |
+
/** @var Aplazame_Aplazame_Model_Api_Client $client */
|
| 43 |
$client = Mage::getModel('aplazame/api_client');
|
| 44 |
+
$client->updateOrder($order);
|
| 45 |
|
| 46 |
return $this;
|
| 47 |
}
|
| 56 |
|
| 57 |
/**
|
| 58 |
* Method used for canceling a Aplazame invoice when a Magento order is canceled
|
| 59 |
+
*
|
| 60 |
+
* @param Varien_Event_Observer $observer
|
| 61 |
*/
|
| 62 |
public function salesOrderPaymentCancel($observer)
|
| 63 |
{
|
| 64 |
$code = Aplazame_Aplazame_Model_Payment::METHOD_CODE;
|
| 65 |
+
|
| 66 |
+
/** @var Mage_Sales_Model_Order|null $order */
|
| 67 |
$order = $observer->getOrder();
|
| 68 |
|
| 69 |
$orderId = explode("-", $order->getIncrementId());
|
| 70 |
|
| 71 |
+
/** @var Mage_Sales_Model_Order $nextOrder */
|
| 72 |
$nextOrder = Mage::getModel('sales/order')->loadByIncrementId(
|
| 73 |
$orderId[0] . '-' . ((int)$orderId[1] + 1));
|
| 74 |
|
| 80 |
return $this;
|
| 81 |
}
|
| 82 |
|
| 83 |
+
/** @var Aplazame_Aplazame_Model_Api_Client $client */
|
| 84 |
$client = Mage::getModel('aplazame/api_client');
|
| 85 |
+
$client->cancelOrder($order);
|
| 86 |
+
|
| 87 |
+
return $this;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
/**
|
| 91 |
+
* Method to send a parcial (refund) or total (cancel) refund to aplazame when a creditmemo is created
|
| 92 |
+
*
|
| 93 |
+
* @param Varien_Event_Observer $observer
|
| 94 |
+
* @return $this
|
| 95 |
+
*/
|
| 96 |
+
public function salesOrderPaymentRefund($observer)
|
| 97 |
+
{
|
| 98 |
+
/** @var Mage_Sales_Model_Order_Payment $payment */
|
| 99 |
+
$payment = $observer->getPayment();
|
| 100 |
+
|
| 101 |
+
/** @var Mage_Sales_Model_Order_Creditmemo $creditmemo */
|
| 102 |
+
$creditmemo = $observer->getCreditmemo();
|
| 103 |
+
|
| 104 |
+
/** @var Mage_Sales_Model_Order $order */
|
| 105 |
+
$order = $payment->getOrder();
|
| 106 |
+
|
| 107 |
+
if (!$this->is_aplazame_payment($order)) {
|
| 108 |
+
return $this;
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
$remainingAmountAfterRefund = $order->getBaseGrandTotal() - $order->getBaseTotalRefunded();
|
| 112 |
+
$refundedTotal = $creditmemo->getBaseGrandTotal();
|
| 113 |
+
|
| 114 |
+
/** @var Aplazame_Aplazame_Model_Api_Client $client */
|
| 115 |
+
$client = Mage::getModel('aplazame/api_client');
|
| 116 |
+
if($remainingAmountAfterRefund == 0)
|
| 117 |
+
{
|
| 118 |
+
//total is refunded so we cancel order at aplazame side
|
| 119 |
+
$client->cancelOrder($order);
|
| 120 |
+
} else {
|
| 121 |
+
//partial refund so we refund at aplazame side
|
| 122 |
+
$client->refundAmount($order, $refundedTotal);
|
| 123 |
+
}
|
| 124 |
|
| 125 |
return $this;
|
| 126 |
}
|
app/code/community/Aplazame/Aplazame/Model/Payment.php
CHANGED
|
@@ -67,6 +67,8 @@ class Aplazame_Aplazame_Model_Payment extends Mage_Payment_Model_Method_Abstract
|
|
| 67 |
|
| 68 |
/**
|
| 69 |
* Get checkout session namespace
|
|
|
|
|
|
|
| 70 |
*/
|
| 71 |
public function getCheckout()
|
| 72 |
{
|
|
@@ -101,8 +103,9 @@ class Aplazame_Aplazame_Model_Payment extends Mage_Payment_Model_Method_Abstract
|
|
| 101 |
|
| 102 |
$token = $payment->getAdditionalInformation(self::CHECKOUT_TOKEN);
|
| 103 |
|
|
|
|
| 104 |
$api = Mage::getModel('aplazame/api_client');
|
| 105 |
-
$result = $api->
|
| 106 |
|
| 107 |
if (isset($result["id"])) {
|
| 108 |
$this->getInfoInstance()->setAdditionalInformation("charge_id", $result["id"]);
|
|
@@ -115,37 +118,66 @@ class Aplazame_Aplazame_Model_Payment extends Mage_Payment_Model_Method_Abstract
|
|
| 115 |
return $this;
|
| 116 |
}
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
public function processConfirmOrder($order, $checkout_token)
|
| 119 |
{
|
| 120 |
$payment = $order->getPayment();
|
| 121 |
|
| 122 |
$payment->setAdditionalInformation(self::CHECKOUT_TOKEN, $checkout_token);
|
| 123 |
-
$action = $this->getConfigData('payment_action');
|
| 124 |
|
| 125 |
//authorize the total amount.
|
| 126 |
-
$payment->authorize(true,
|
| 127 |
-
$payment->setAmountAuthorized(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
$order->save();
|
|
|
|
|
|
|
| 129 |
}
|
| 130 |
|
| 131 |
public function processHistory($order, $checkout_token)
|
| 132 |
{
|
|
|
|
| 133 |
$serializer = Mage::getModel('aplazame/api_serializers');
|
| 134 |
|
| 135 |
-
$result = $serializer->
|
| 136 |
-
->getHistory();
|
| 137 |
|
| 138 |
-
return json_encode($result
|
| 139 |
}
|
| 140 |
|
| 141 |
public function getCheckoutSerializer()
|
| 142 |
{
|
| 143 |
$orderIncrementId = $this->getCheckout()->getLastRealOrderId();
|
| 144 |
|
|
|
|
| 145 |
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
|
|
|
| 146 |
$serializer = Mage::getModel('aplazame/api_serializers');
|
| 147 |
|
| 148 |
-
$serializer->
|
| 149 |
-
return $serializer->getCheckout();
|
| 150 |
}
|
| 151 |
}
|
| 67 |
|
| 68 |
/**
|
| 69 |
* Get checkout session namespace
|
| 70 |
+
*
|
| 71 |
+
* @return Mage_Checkout_Model_Session
|
| 72 |
*/
|
| 73 |
public function getCheckout()
|
| 74 |
{
|
| 103 |
|
| 104 |
$token = $payment->getAdditionalInformation(self::CHECKOUT_TOKEN);
|
| 105 |
|
| 106 |
+
/** @var Aplazame_Aplazame_Model_Api_Client $api */
|
| 107 |
$api = Mage::getModel('aplazame/api_client');
|
| 108 |
+
$result = $api->authorize($token);
|
| 109 |
|
| 110 |
if (isset($result["id"])) {
|
| 111 |
$this->getInfoInstance()->setAdditionalInformation("charge_id", $result["id"]);
|
| 118 |
return $this;
|
| 119 |
}
|
| 120 |
|
| 121 |
+
/**
|
| 122 |
+
* @param Mage_Sales_Model_Order $order
|
| 123 |
+
* @param mixed $checkout_token
|
| 124 |
+
* @return $this
|
| 125 |
+
*/
|
| 126 |
public function processConfirmOrder($order, $checkout_token)
|
| 127 |
{
|
| 128 |
$payment = $order->getPayment();
|
| 129 |
|
| 130 |
$payment->setAdditionalInformation(self::CHECKOUT_TOKEN, $checkout_token);
|
|
|
|
| 131 |
|
| 132 |
//authorize the total amount.
|
| 133 |
+
$payment->authorize(true, self::_orderTotal($order));
|
| 134 |
+
$payment->setAmountAuthorized(self::_orderTotal($order));
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
if ((bool) $this->getConfigData('autoinvoice'))
|
| 138 |
+
{
|
| 139 |
+
//permitimos capturar en este caso, sino fallaria la generacion de factura
|
| 140 |
+
$this->_canCapture = true;
|
| 141 |
+
|
| 142 |
+
$invoice = $order->prepareInvoice();
|
| 143 |
+
if ($invoice->getGrandTotal() > 0) { // Evitamos captar un pago con total cero.
|
| 144 |
+
$invoice
|
| 145 |
+
->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE)
|
| 146 |
+
->register()
|
| 147 |
+
->capture();
|
| 148 |
+
$order->addRelatedObject($invoice);
|
| 149 |
+
$payment->setCreatedInvoice($invoice);
|
| 150 |
+
Mage::getModel('core/resource_transaction')
|
| 151 |
+
->addObject($invoice)
|
| 152 |
+
->addObject($invoice->getOrder())
|
| 153 |
+
->save();
|
| 154 |
+
}
|
| 155 |
+
}
|
| 156 |
+
|
| 157 |
$order->save();
|
| 158 |
+
|
| 159 |
+
return $this;
|
| 160 |
}
|
| 161 |
|
| 162 |
public function processHistory($order, $checkout_token)
|
| 163 |
{
|
| 164 |
+
/** @var Aplazame_Aplazame_Model_Api_Serializers $serializer */
|
| 165 |
$serializer = Mage::getModel('aplazame/api_serializers');
|
| 166 |
|
| 167 |
+
$result = $serializer->getHistory($order);
|
|
|
|
| 168 |
|
| 169 |
+
return json_encode($result);
|
| 170 |
}
|
| 171 |
|
| 172 |
public function getCheckoutSerializer()
|
| 173 |
{
|
| 174 |
$orderIncrementId = $this->getCheckout()->getLastRealOrderId();
|
| 175 |
|
| 176 |
+
/** @var Mage_Sales_Model_Order $order */
|
| 177 |
$order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
|
| 178 |
+
/** @var Aplazame_Aplazame_Model_Api_Serializers $serializer */
|
| 179 |
$serializer = Mage::getModel('aplazame/api_serializers');
|
| 180 |
|
| 181 |
+
return $serializer->getCheckout($order);
|
|
|
|
| 182 |
}
|
| 183 |
}
|
app/code/community/Aplazame/Aplazame/controllers/PaymentController.php
CHANGED
|
@@ -2,6 +2,9 @@
|
|
| 2 |
|
| 3 |
class Aplazame_Aplazame_PaymentController extends Mage_Core_Controller_Front_Action
|
| 4 |
{
|
|
|
|
|
|
|
|
|
|
| 5 |
private function _getCheckoutSession()
|
| 6 |
{
|
| 7 |
return Mage::getSingleton('checkout/session');
|
|
@@ -52,6 +55,7 @@ class Aplazame_Aplazame_PaymentController extends Mage_Core_Controller_Front_Act
|
|
| 52 |
|
| 53 |
|
| 54 |
if ($session->getLastRealOrderId()) {
|
|
|
|
| 55 |
$order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
|
| 56 |
$order->getPayment()->getMethodInstance()->processConfirmOrder($order, $checkout_token);
|
| 57 |
|
|
@@ -60,7 +64,7 @@ class Aplazame_Aplazame_PaymentController extends Mage_Core_Controller_Front_Act
|
|
| 60 |
// $this->_redirect('checkout/onepage/success');
|
| 61 |
return;
|
| 62 |
}
|
| 63 |
-
// $this->
|
| 64 |
}
|
| 65 |
|
| 66 |
public function cancelAction()
|
|
@@ -69,13 +73,14 @@ class Aplazame_Aplazame_PaymentController extends Mage_Core_Controller_Front_Act
|
|
| 69 |
$orderId = $session->getLastRealOrderId();
|
| 70 |
|
| 71 |
if ($orderId) {
|
|
|
|
| 72 |
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
| 73 |
if ($order->getId()) {
|
| 74 |
-
Mage::helper('aplazame/cart')->resuscitateCartFromOrder($order);
|
| 75 |
}
|
| 76 |
}
|
| 77 |
|
| 78 |
-
$this->
|
| 79 |
}
|
| 80 |
|
| 81 |
public function historyAction()
|
|
@@ -86,6 +91,7 @@ class Aplazame_Aplazame_PaymentController extends Mage_Core_Controller_Front_Act
|
|
| 86 |
Mage::throwException($this->__('History has no checkout token.'));
|
| 87 |
}
|
| 88 |
|
|
|
|
| 89 |
$order = Mage::getModel('sales/order')->loadByIncrementId($checkout_token);
|
| 90 |
$payment = $order->getPayment()->getMethodInstance();
|
| 91 |
$code = Aplazame_Aplazame_Model_Payment::METHOD_CODE;
|
| 2 |
|
| 3 |
class Aplazame_Aplazame_PaymentController extends Mage_Core_Controller_Front_Action
|
| 4 |
{
|
| 5 |
+
/**
|
| 6 |
+
* @return Mage_Checkout_Model_Session
|
| 7 |
+
*/
|
| 8 |
private function _getCheckoutSession()
|
| 9 |
{
|
| 10 |
return Mage::getSingleton('checkout/session');
|
| 55 |
|
| 56 |
|
| 57 |
if ($session->getLastRealOrderId()) {
|
| 58 |
+
/** @var Mage_Sales_Model_Order $order */
|
| 59 |
$order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
|
| 60 |
$order->getPayment()->getMethodInstance()->processConfirmOrder($order, $checkout_token);
|
| 61 |
|
| 64 |
// $this->_redirect('checkout/onepage/success');
|
| 65 |
return;
|
| 66 |
}
|
| 67 |
+
// $this->_redirectUrl(Mage::helper('checkout/url')->getCheckoutUrl());
|
| 68 |
}
|
| 69 |
|
| 70 |
public function cancelAction()
|
| 73 |
$orderId = $session->getLastRealOrderId();
|
| 74 |
|
| 75 |
if ($orderId) {
|
| 76 |
+
/** @var Mage_Sales_Model_Order $order */
|
| 77 |
$order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
|
| 78 |
if ($order->getId()) {
|
| 79 |
+
Mage::helper('aplazame/cart')->resuscitateCartFromOrder($order, $this);
|
| 80 |
}
|
| 81 |
}
|
| 82 |
|
| 83 |
+
$this->_redirectUrl(Mage::helper('checkout/url')->getCheckoutUrl());
|
| 84 |
}
|
| 85 |
|
| 86 |
public function historyAction()
|
| 91 |
Mage::throwException($this->__('History has no checkout token.'));
|
| 92 |
}
|
| 93 |
|
| 94 |
+
/** @var Mage_Sales_Model_Order $order */
|
| 95 |
$order = Mage::getModel('sales/order')->loadByIncrementId($checkout_token);
|
| 96 |
$payment = $order->getPayment()->getMethodInstance();
|
| 97 |
$code = Aplazame_Aplazame_Model_Payment::METHOD_CODE;
|
app/code/community/Aplazame/Aplazame/etc/config.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<Aplazame_Aplazame>
|
| 5 |
-
<version>0.2.
|
| 6 |
</Aplazame_Aplazame>
|
| 7 |
</modules>
|
| 8 |
<global>
|
|
@@ -57,6 +57,15 @@
|
|
| 57 |
</Aplazame>
|
| 58 |
</observers>
|
| 59 |
</order_cancel_after>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
</events>
|
| 61 |
</adminhtml>
|
| 62 |
|
|
@@ -84,15 +93,13 @@
|
|
| 84 |
<payment>
|
| 85 |
<aplazame>
|
| 86 |
<active>0</active>
|
| 87 |
-
<sandbox>
|
| 88 |
<model>aplazame/payment</model>
|
| 89 |
<title>Aplazame</title>
|
| 90 |
-
<
|
| 91 |
-
<version>v1.2</version>
|
| 92 |
<button>dt:has(input#p_method_aplazame)</button>
|
| 93 |
<button_img>white-148x46</button_img>
|
| 94 |
<sort_order>1</sort_order>
|
| 95 |
-
<secret_api_key backend_model="adminhtml/system_config_backend_encrypted"/>
|
| 96 |
</aplazame>
|
| 97 |
</payment>
|
| 98 |
</default>
|
| 2 |
<config>
|
| 3 |
<modules>
|
| 4 |
<Aplazame_Aplazame>
|
| 5 |
+
<version>0.2.2</version>
|
| 6 |
</Aplazame_Aplazame>
|
| 7 |
</modules>
|
| 8 |
<global>
|
| 57 |
</Aplazame>
|
| 58 |
</observers>
|
| 59 |
</order_cancel_after>
|
| 60 |
+
<sales_order_payment_refund>
|
| 61 |
+
<observers>
|
| 62 |
+
<Aplazame>
|
| 63 |
+
<type>singleton</type>
|
| 64 |
+
<class>aplazame/observer</class>
|
| 65 |
+
<method>salesOrderPaymentRefund</method>
|
| 66 |
+
</Aplazame>
|
| 67 |
+
</observers>
|
| 68 |
+
</sales_order_payment_refund>
|
| 69 |
</events>
|
| 70 |
</adminhtml>
|
| 71 |
|
| 93 |
<payment>
|
| 94 |
<aplazame>
|
| 95 |
<active>0</active>
|
| 96 |
+
<sandbox>0</sandbox>
|
| 97 |
<model>aplazame/payment</model>
|
| 98 |
<title>Aplazame</title>
|
| 99 |
+
<secret_api_key backend_model="adminhtml/system_config_backend_encrypted"/>
|
|
|
|
| 100 |
<button>dt:has(input#p_method_aplazame)</button>
|
| 101 |
<button_img>white-148x46</button_img>
|
| 102 |
<sort_order>1</sort_order>
|
|
|
|
| 103 |
</aplazame>
|
| 104 |
</payment>
|
| 105 |
</default>
|
app/code/community/Aplazame/Aplazame/etc/system.xml
CHANGED
|
@@ -30,22 +30,23 @@
|
|
| 30 |
<show_in_website>1</show_in_website>
|
| 31 |
<show_in_store>1</show_in_store>
|
| 32 |
</sandbox>
|
| 33 |
-
<
|
| 34 |
-
<label>
|
| 35 |
-
<frontend_type>
|
|
|
|
| 36 |
<sort_order>30</sort_order>
|
| 37 |
<show_in_default>1</show_in_default>
|
| 38 |
<show_in_website>1</show_in_website>
|
| 39 |
<show_in_store>1</show_in_store>
|
| 40 |
-
</
|
| 41 |
-
<
|
| 42 |
-
<label>API
|
| 43 |
<frontend_type>text</frontend_type>
|
| 44 |
<sort_order>40</sort_order>
|
| 45 |
<show_in_default>1</show_in_default>
|
| 46 |
<show_in_website>1</show_in_website>
|
| 47 |
<show_in_store>1</show_in_store>
|
| 48 |
-
</
|
| 49 |
<button>
|
| 50 |
<label>Button CSS Selector</label>
|
| 51 |
<frontend_type>text</frontend_type>
|
|
@@ -71,23 +72,20 @@
|
|
| 71 |
<show_in_store>1</show_in_store>
|
| 72 |
<frontend_class>validate-number</frontend_class>
|
| 73 |
</sort_order>
|
| 74 |
-
<
|
| 75 |
-
<label>
|
| 76 |
-
<
|
| 77 |
-
<
|
| 78 |
-
<
|
| 79 |
-
<
|
| 80 |
-
<
|
| 81 |
-
<show_in_store>1</show_in_store>
|
| 82 |
-
</secret_api_key>
|
| 83 |
-
<public_api_key translate="label">
|
| 84 |
-
<label>Public API Key</label>
|
| 85 |
-
<frontend_type>text</frontend_type>
|
| 86 |
-
<sort_order>90</sort_order>
|
| 87 |
<show_in_default>1</show_in_default>
|
| 88 |
<show_in_website>1</show_in_website>
|
| 89 |
<show_in_store>1</show_in_store>
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
| 91 |
</fields>
|
| 92 |
</aplazame>
|
| 93 |
</groups>
|
| 30 |
<show_in_website>1</show_in_website>
|
| 31 |
<show_in_store>1</show_in_store>
|
| 32 |
</sandbox>
|
| 33 |
+
<secret_api_key translate="label">
|
| 34 |
+
<label>Secret API Key</label>
|
| 35 |
+
<frontend_type>obscure</frontend_type>
|
| 36 |
+
<backend_model>adminhtml/system_config_backend_encrypted</backend_model>
|
| 37 |
<sort_order>30</sort_order>
|
| 38 |
<show_in_default>1</show_in_default>
|
| 39 |
<show_in_website>1</show_in_website>
|
| 40 |
<show_in_store>1</show_in_store>
|
| 41 |
+
</secret_api_key>
|
| 42 |
+
<public_api_key translate="label">
|
| 43 |
+
<label>Public API Key</label>
|
| 44 |
<frontend_type>text</frontend_type>
|
| 45 |
<sort_order>40</sort_order>
|
| 46 |
<show_in_default>1</show_in_default>
|
| 47 |
<show_in_website>1</show_in_website>
|
| 48 |
<show_in_store>1</show_in_store>
|
| 49 |
+
</public_api_key>
|
| 50 |
<button>
|
| 51 |
<label>Button CSS Selector</label>
|
| 52 |
<frontend_type>text</frontend_type>
|
| 72 |
<show_in_store>1</show_in_store>
|
| 73 |
<frontend_class>validate-number</frontend_class>
|
| 74 |
</sort_order>
|
| 75 |
+
<autoinvoice translate="label comment tooltip">
|
| 76 |
+
<label>Automatic invoice generation</label>
|
| 77 |
+
<!-- <comment></comment> -->
|
| 78 |
+
<tooltip>Applicable only if the payment was successful.</tooltip>
|
| 79 |
+
<frontend_type>select</frontend_type>
|
| 80 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
| 81 |
+
<sort_order>250</sort_order>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
<show_in_default>1</show_in_default>
|
| 83 |
<show_in_website>1</show_in_website>
|
| 84 |
<show_in_store>1</show_in_store>
|
| 85 |
+
<depends>
|
| 86 |
+
<active>1</active>
|
| 87 |
+
</depends>
|
| 88 |
+
</autoinvoice>
|
| 89 |
</fields>
|
| 90 |
</aplazame>
|
| 91 |
</groups>
|
app/design/frontend/base/default/layout/aplazame.xml
CHANGED
|
@@ -10,4 +10,11 @@
|
|
| 10 |
<block type="aplazame/product_widget" as="aplazame_widget" name="aplazame.widget" template="aplazame/product/widget.phtml" before="-"/>
|
| 11 |
</reference>
|
| 12 |
</catalog_product_view>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
</layout>
|
| 10 |
<block type="aplazame/product_widget" as="aplazame_widget" name="aplazame.widget" template="aplazame/product/widget.phtml" before="-"/>
|
| 11 |
</reference>
|
| 12 |
</catalog_product_view>
|
| 13 |
+
<checkout_cart_index>
|
| 14 |
+
<reference name="checkout.cart">
|
| 15 |
+
<block type="aplazame/checkout_cart_widget" as="checkout.cart.extra"
|
| 16 |
+
name="aplazame.checkout.cart.widget"
|
| 17 |
+
template="aplazame/checkout/cart/widget.phtml" before="-"/>
|
| 18 |
+
</reference>
|
| 19 |
+
</checkout_cart_index>
|
| 20 |
</layout>
|
app/design/frontend/base/default/template/aplazame/.DS_Store
DELETED
|
Binary file
|
app/design/frontend/base/default/template/aplazame/checkout/cart/widget.phtml
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div
|
| 2 |
+
data-aplazame-simulator=""
|
| 3 |
+
data-view="cart"
|
| 4 |
+
data-amount="<?php echo $this->getTotal(); ?>">
|
| 5 |
+
</div>
|
app/design/frontend/base/default/template/aplazame/payment/common.phtml
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
|
|
|
|
|
| 1 |
<script
|
| 2 |
type="text/javascript"
|
| 3 |
-
src="<?php echo
|
| 4 |
data-aplazame="publicKey: <?php echo Mage::getStoreConfig('payment/aplazame/public_api_key') ?>"
|
| 5 |
-
data-version="<?php echo Mage::getStoreConfig('payment/aplazame/version') ?>"
|
| 6 |
data-sandbox="<?php echo Mage::getStoreConfig('payment/aplazame/sandbox')?'true':'false' ?>"
|
| 7 |
-
|
| 1 |
+
<?php $aplazameJsUri = getenv('APLAZAME_JS_URI') ? getenv('APLAZAME_JS_URI') : 'https://aplazame.com/static/aplazame.js'; ?>
|
| 2 |
+
|
| 3 |
<script
|
| 4 |
type="text/javascript"
|
| 5 |
+
src="<?php echo $aplazameJsUri; ?>"
|
| 6 |
data-aplazame="publicKey: <?php echo Mage::getStoreConfig('payment/aplazame/public_api_key') ?>"
|
|
|
|
| 7 |
data-sandbox="<?php echo Mage::getStoreConfig('payment/aplazame/sandbox')?'true':'false' ?>"
|
| 8 |
+
></script>
|
app/design/frontend/base/default/template/aplazame/product/widget.phtml
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
|
|
| 1 |
+
<div
|
| 2 |
+
data-aplazame-simulator=""
|
| 3 |
+
data-view="product"
|
| 4 |
+
data-amount="<?php echo $this->getFinalPrice(); ?>">
|
| 5 |
+
</div>
|
app/locale/es_ES/Aplazame_Aplazame.csv
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
| 1 |
+
"Automatic invoice generation","Facturar automáticamente"
|
| 2 |
+
"Applicable only if the payment was successful.","Genera factura si el pago es correcto."
|
package.xml
CHANGED
|
@@ -1,24 +1,20 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Aplazame_Aplazame</name>
|
| 4 |
-
<version>0.2.
|
| 5 |
<stability>stable</stability>
|
| 6 |
-
<license
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
-
<summary>
|
| 10 |
-
<description>
|
| 11 |
-
<notes
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
<authors><author><name>Daniel Molina</name><user>aplazadev</user><email>dev@aplazame.com</email></author><author><name>Oscar Reales</name><user>oscarreales</user><email>oreales@gmail.com</email></author></authors>
|
| 19 |
-
<date>2015-09-21</date>
|
| 20 |
-
<time>17:37:13</time>
|
| 21 |
-
<contents><target name="magecommunity"><dir name="Aplazame"><dir name="Aplazame"><dir name="Block"><dir name="Checkout"><dir name="Onepage"><file name="Billing.php" hash="d908bf39c8555f436f8841ff30b520f1"/><file name="Shipping.php" hash="8968979cc9140f2f6236ee9f2fbafc98"/></dir></dir><dir name="Payment"><file name="Form.php" hash="d23f592da9ed9ac11b4432f49c2783ac"/><file name="Info.php" hash="eeadafff816256593595d261c9e3b5f8"/><file name="Redirect.php" hash="9cbc88587076d51f187d0ad546258768"/></dir><dir name="Product"><file name="Widget.php" hash="38bdd716a24f62e81dc21c336fb4ea8d"/></dir></dir><dir name="Helper"><file name="Cart.php" hash="6defc39a6e7d125171e177cf6b63c4da"/><file name="Data.php" hash="e738ff35f7bd1a6c8ff7f0f87adfa996"/></dir><dir name="Model"><dir name="Api"><file name="Client.php" hash="2747d7d6317ed83868ea48740008b86c"/><file name="Serializers.php" hash="450e490ea33aad7077a7de623f872ea9"/></dir><file name="Config.php" hash="67254d968ff5a0a95c73484cc13efb33"/><file name="Observer.php" hash="27c58b8acf0a7974f808ff9d3408df34"/><file name="Payment.php" hash="c4e9ebd170f09d3808b7ba772e28a1e7"/></dir><dir name="controllers"><file name="PaymentController.php" hash="750453b9d9fbeb2565e1fae3fd360d07"/></dir><dir name="etc"><file name="config.xml" hash="df630f2da7172f99a3fb4b17c3df9723"/><file name="system.xml" hash="e34dc1a4aa6eae2cc62387cbefbd3bb9"/></dir></dir></dir></target><target name="magelib"><dir name="Aplazame"><dir name="Aplazame"><file name="Util.php" hash="039c093cbf8c1859cd7e159829ec8e82"/></dir><file name="Aplazame.php" hash="e67f083f4079693da19cd634d7e5bae9"/></dir></target><target name="mageetc"><dir name="modules"><file name="Aplazame_Aplazame.xml" hash="d816c618a1829401ca0314c3406482a1"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="aplazame.xml" hash="ae3b3f04f5cf58af1b6021f1b22537f5"/></dir><dir name="template"><dir name="aplazame"><dir name="payment"><file name="common.phtml" hash="cdcc83ab18a52dff8c588fadb06c3c51"/><file name="form.phtml" hash="47d03cc30037d3136790a7e88942c8b9"/></dir><dir name="product"><file name="widget.phtml" hash="ec0f6ad739b26226e04a7a4e864bf90a"/></dir><file name=".DS_Store" hash="c49b1b40bbdb1fc5487a5ff1436a733d"/></dir></dir></dir></dir></dir></target></contents>
|
| 22 |
<compatible/>
|
| 23 |
-
<dependencies><required><php><min>5.2.0</min><max>
|
| 24 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>Aplazame_Aplazame</name>
|
| 4 |
+
<version>0.2.2</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
+
<license>GPL</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
+
<summary>Aplazame, a consumer credit company, offers a payment system that can be used by online buyers to receive funding for their purchases.</summary>
|
| 10 |
+
<description>Aplazame, a consumer credit company, offers a payment system that can be used by online buyers to receive funding for their purchases.</description>
|
| 11 |
+
<notes>* Widget cart
|
| 12 |
+
* Refund observer
|
| 13 |
+
* Widget data view</notes>
|
| 14 |
+
<authors><author><name>Aplazame</name><user>aplazame</user><email>dev@aplazame.com</email></author></authors>
|
| 15 |
+
<date>2016-07-06</date>
|
| 16 |
+
<time>18:19:52</time>
|
| 17 |
+
<contents><target name="magecommunity"><dir name="Aplazame"><dir name="Aplazame"><dir name="Block"><dir name="Checkout"><dir name="Cart"><file name="Widget.php" hash="3942489d065d22d356ce3ffcef1a801f"/></dir><dir name="Onepage"><file name="Billing.php" hash="d908bf39c8555f436f8841ff30b520f1"/><file name="Shipping.php" hash="8968979cc9140f2f6236ee9f2fbafc98"/></dir></dir><dir name="Payment"><file name="Form.php" hash="d23f592da9ed9ac11b4432f49c2783ac"/><file name="Info.php" hash="eeadafff816256593595d261c9e3b5f8"/><file name="Redirect.php" hash="43810d5a8a3201bc8263cddf01156732"/></dir><dir name="Product"><file name="Widget.php" hash="672f3ce4f644fa93206bbbf908a38b15"/></dir></dir><dir name="Helper"><file name="Cart.php" hash="f95a90db86fb4732f7d3ef1fb6a2322a"/><file name="Data.php" hash="35cc7eb331ff48912492cce397918270"/></dir><dir name="Model"><dir name="Api"><file name="Client.php" hash="af66459f7c0abdd97fcde9fd279757cb"/><file name="Serializers.php" hash="b70f21d4e8beeda9f015c0eb18f513ac"/></dir><file name="Config.php" hash="ecff6c7d937b86802dc6c98139b1d7c4"/><file name="Observer.php" hash="c3f0d2877615142f99a5d872363107f5"/><file name="Payment.php" hash="5026810ce6ccb7a44ac682af899e3d51"/></dir><dir name="controllers"><file name="PaymentController.php" hash="66fa5f442de6ba7f9c95f3a49fddeb9f"/></dir><dir name="etc"><file name="config.xml" hash="a34136dabe19ac238f523deaad9b5d5e"/><file name="system.xml" hash="4b6a34f80670427799ebaca4c11d0cb4"/></dir></dir></dir></target><target name="magelib"><dir name="Aplazame"><dir name="Aplazame"><file name="Util.php" hash="039c093cbf8c1859cd7e159829ec8e82"/></dir><file name="Aplazame.php" hash="e67f083f4079693da19cd634d7e5bae9"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="aplazame.xml" hash=""/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="aplazame.xml" hash="e56ae75dc4088c1590d986904ecee676"/></dir><dir name="template"><dir name="aplazame"><dir name="checkout"><dir name="cart"><file name="widget.phtml" hash="d81d7b50e0289f54bd653f9c865712c5"/></dir></dir><dir name="payment"><file name="common.phtml" hash="4832e7710b4c43dad8bb2dcd81e4737d"/><file name="form.phtml" hash="47d03cc30037d3136790a7e88942c8b9"/></dir><dir name="product"><file name="widget.phtml" hash="381b9f5d90cfe4eb5394a862838d7993"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir><dir name="es_ES"><file name="Aplazame_Aplazame.csv" hash="01ee93633a293309873bbba03b3c2a8f"/></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Aplazame_Aplazame.xml" hash="d816c618a1829401ca0314c3406482a1"/></dir></target></contents>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
<compatible/>
|
| 19 |
+
<dependencies><required><php><min>5.2.0</min><max>7.0.0</max></php></required></dependencies>
|
| 20 |
</package>
|
