Aplazame_Aplazame - Version 0.2.0

Version Notes

• Widget de aplazame en ficha de producto
• Pasando country id para toma de decisiones según país en API
• Back to checkout
• aplazame-js
• Allow edit processing orders
• Button Id config field
• Payment method in order config field

Download this release

Release Info

Developer Daniel Molina
Extension Aplazame_Aplazame
Version 0.2.0
Comparing to
See all releases


Code changes from version 0.1.0.1 to 0.2.0

app/code/community/Aplazame/Aplazame/Block/Checkout/Onepage/Billing.php CHANGED
@@ -23,4 +23,4 @@ class Aplazame_Aplazame_Block_Checkout_Onepage_Billing extends Mage_Checkout_Blo
23
 
24
  return $this->_address;
25
  }
26
- }
23
 
24
  return $this->_address;
25
  }
26
+ }
app/code/community/Aplazame/Aplazame/Block/Checkout/Onepage/Shipping.php CHANGED
@@ -23,4 +23,4 @@ class Aplazame_Aplazame_Block_Checkout_Onepage_Shipping extends Mage_Checkout_Bl
23
 
24
  return $this->_address;
25
  }
26
- }
23
 
24
  return $this->_address;
25
  }
26
+ }
app/code/community/Aplazame/Aplazame/Block/Payment/Form.php CHANGED
@@ -22,10 +22,23 @@ class Aplazame_Aplazame_Block_Payment_Form extends Mage_Payment_Block_Form
22
 
23
  $this->setMethodLabelAfterHtml($html);
24
  }
25
-
26
- public function getTotal() {
 
27
  return Aplazame_Util::formatDecimals(
28
- $this->getMethod()->getCheckout()->getQuote()->getGrandTotal());
29
  }
30
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
22
 
23
  $this->setMethodLabelAfterHtml($html);
24
  }
25
+
26
+ public function getTotal()
27
+ {
28
  return Aplazame_Util::formatDecimals(
29
+ $this->getMethod()->getCheckout()->getQuote()->getGrandTotal());
30
  }
31
 
32
+ /**
33
+ * Devuelve el country ID en formato ISO 2 caracteres
34
+ * para comunicarlo a aplazame y que pueda tomar decisiones en base al país de facturación.
35
+ * @return string
36
+ */
37
+ public function getCountry()
38
+ {
39
+ $quote = Mage::getModel('checkout/cart')->getQuote();
40
+ $countryId = $quote->getBillingAddress()->getCountryId();
41
+
42
+ return $countryId;
43
+ }
44
  }
app/code/community/Aplazame/Aplazame/Block/Payment/Info.php CHANGED
@@ -3,11 +3,9 @@
3
 
4
  class Aplazame_Aplazame_Block_Payment_Info extends Mage_Payment_Block_Info
5
  {
6
-
7
  protected function _toHtml()
8
  {
9
  $html = '<a href="https://aplazame.com">Aplazame</a>';
10
  return $html;
11
  }
12
-
13
  }
3
 
4
  class Aplazame_Aplazame_Block_Payment_Info extends Mage_Payment_Block_Info
5
  {
 
6
  protected function _toHtml()
7
  {
8
  $html = '<a href="https://aplazame.com">Aplazame</a>';
9
  return $html;
10
  }
 
11
  }
app/code/community/Aplazame/Aplazame/Block/Product/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_Product_Widget Extends Mage_Core_Block_Template
6
+ {
7
+ /**
8
+ * @var Mage_Catalog_Model_Product $_product
9
+ */
10
+ protected $_product;
11
+
12
+
13
+ /**
14
+ * Devuelve el current product cuando estamos en ficha de producto
15
+ * @return Mage_Catalog_Model_Product|mixed
16
+ */
17
+ public function getProduct()
18
+ {
19
+ if(!$this->_product)
20
+ {
21
+ $this->_product = Mage::registry('current_product');
22
+ }
23
+
24
+ return $this->_product;
25
+ }
26
+
27
+ /**
28
+ * Devuelve el final price del producto, formateado para Aplazame
29
+ * @return int
30
+ */
31
+ public function getFinalPrice()
32
+ {
33
+ if($this->getProduct() instanceof Mage_Catalog_Model_Product)
34
+ {
35
+ return Aplazame_Util::formatDecimals($this->getProduct()->getFinalPrice());
36
+ }
37
+
38
+ return Aplazame_Util::formatDecimals(0);
39
+ }
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 'No Product';
55
+ }
56
+ }
app/code/community/Aplazame/Aplazame/Helper/Cart.php CHANGED
@@ -41,8 +41,7 @@ class Aplazame_Aplazame_Helper_Cart extends Mage_Core_Helper_Abstract
41
  */
42
  protected function _resuscitateCartItems(Mage_Sales_Model_Order $order)
43
  {
44
- foreach($order->getItemsCollection() as $orderItem)
45
- {
46
  $this->getCart()->addOrderItem($orderItem);
47
  }
48
 
@@ -67,8 +66,7 @@ class Aplazame_Aplazame_Helper_Cart extends Mage_Core_Helper_Abstract
67
 
68
  $quote->setCheckoutMethod($oldQuote->getCheckoutMethod());
69
 
70
- if($oldQuote->getId())
71
- {
72
  $billingAddress = clone $oldQuote->getBillingAddress();
73
  $billingAddress->setQuote($quote);
74
 
@@ -102,7 +100,4 @@ class Aplazame_Aplazame_Helper_Cart extends Mage_Core_Helper_Abstract
102
  {
103
  return Mage::getSingleton('checkout/session');
104
  }
105
-
106
-
107
-
108
  }
41
  */
42
  protected function _resuscitateCartItems(Mage_Sales_Model_Order $order)
43
  {
44
+ foreach ($order->getItemsCollection() as $orderItem) {
 
45
  $this->getCart()->addOrderItem($orderItem);
46
  }
47
 
66
 
67
  $quote->setCheckoutMethod($oldQuote->getCheckoutMethod());
68
 
69
+ if ($oldQuote->getId()) {
 
70
  $billingAddress = clone $oldQuote->getBillingAddress();
71
  $billingAddress->setQuote($quote);
72
 
100
  {
101
  return Mage::getSingleton('checkout/session');
102
  }
 
 
 
103
  }
app/code/community/Aplazame/Aplazame/Helper/Data.php CHANGED
@@ -2,5 +2,4 @@
2
 
3
  class Aplazame_Aplazame_Helper_Data extends Mage_Core_Helper_Abstract
4
  {
5
-
6
  }
2
 
3
  class Aplazame_Aplazame_Helper_Data extends Mage_Core_Helper_Abstract
4
  {
 
5
  }
app/code/community/Aplazame/Aplazame/Model/Api/Client.php CHANGED
@@ -20,9 +20,8 @@ class Aplazame_Aplazame_Model_Api_Client extends Varien_Object
20
  $client = new Zend_Http_Client($url);
21
 
22
  if (in_array($method, array(
23
- Zend_Http_Client::POST, Zend_Http_Client::PUT, 'PATCH')) && $data)
24
- {
25
- $client->setHeaders('Content-type: application/json');
26
  $client->setRawData(json_encode($data), 'application/json');
27
  }
28
 
@@ -31,13 +30,13 @@ class Aplazame_Aplazame_Model_Api_Client extends Varien_Object
31
 
32
  $version = Mage::getStoreConfig('payment/aplazame/version');
33
 
34
- if ($version){
35
  $version = explode(".", $version);
36
  $version = $version[0];
37
  }
38
 
39
  $client->setHeaders('User-Agent: '. self::USER_AGENT .
40
- Mage::getConfig()->getModuleConfig('Aplazame_Aplazame')->version);
41
 
42
  $client->setHeaders('Accept: '. 'application/vnd.aplazame.'.
43
  (Mage::getStoreConfig('payment/aplazame/sandbox')?'sandbox.': '') . $version . '+json');
@@ -46,27 +45,23 @@ class Aplazame_Aplazame_Model_Api_Client extends Varien_Object
46
  $raw_result = $response->getBody();
47
  $status_code = $response->getStatus();
48
 
49
- if ($status_code >= 500)
50
- {
51
  Mage::throwException(Mage::helper('aplazame')->__(
52
  'Aplazame error code: ' . $status_code));
53
  }
54
 
55
- try{
56
  $ret_json = Zend_Json::decode($raw_result, Zend_Json::TYPE_ARRAY);
57
- } catch(Zend_Json_Exception $e)
58
- {
59
  Mage::throwException(Mage::helper('aplazame')->__(
60
  'Invalid api response: '. $raw_result));
61
  }
62
 
63
- if ($status_code >= 400)
64
- {
65
  $errorMsg = Mage::helper('aplazame')->__('Aplazame error code ' . $status_code . ': '
66
  . $ret_json['error']['message']);
67
 
68
- if($status_code == 403)
69
- {
70
  //no tiramos exception, pero informamos de error
71
  Mage::getSingleton('adminhtml/session')->addError($errorMsg);
72
  }
20
  $client = new Zend_Http_Client($url);
21
 
22
  if (in_array($method, array(
23
+ Zend_Http_Client::POST, Zend_Http_Client::PUT, 'PATCH')) && $data) {
24
+ $client->setHeaders('Content-type: application/json');
 
25
  $client->setRawData(json_encode($data), 'application/json');
26
  }
27
 
30
 
31
  $version = Mage::getStoreConfig('payment/aplazame/version');
32
 
33
+ if ($version) {
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.': '') . $version . '+json');
45
  $raw_result = $response->getBody();
46
  $status_code = $response->getStatus();
47
 
48
+ if ($status_code >= 500) {
 
49
  Mage::throwException(Mage::helper('aplazame')->__(
50
  'Aplazame error code: ' . $status_code));
51
  }
52
 
53
+ try {
54
  $ret_json = Zend_Json::decode($raw_result, Zend_Json::TYPE_ARRAY);
55
+ } catch (Zend_Json_Exception $e) {
 
56
  Mage::throwException(Mage::helper('aplazame')->__(
57
  'Invalid api response: '. $raw_result));
58
  }
59
 
60
+ if ($status_code >= 400) {
 
61
  $errorMsg = Mage::helper('aplazame')->__('Aplazame error code ' . $status_code . ': '
62
  . $ret_json['error']['message']);
63
 
64
+ if ($status_code == 403) {
 
65
  //no tiramos exception, pero informamos de error
66
  Mage::getSingleton('adminhtml/session')->addError($errorMsg);
67
  }
app/code/community/Aplazame/Aplazame/Model/Api/Serializers.php CHANGED
@@ -48,13 +48,13 @@ class Aplazame_Aplazame_Model_Api_Serializers extends Varien_Object
48
  "city" => $addr->getCity(),
49
  "state" => $addr->getRegion(),
50
  "country" => $addr->getCountryModel()->getIso2Code(),
51
- "zip" => $addr->getPostcode());
52
  }
53
 
54
  protected function getCustomer()
55
  {
56
  $customer = Mage::getSingleton('customer/session')->getCustomer();
57
- $logCustomer = Mage::getModel('log/customer')->loadByCustomer($customer);
58
  $customer_serializer = array("gender"=>0);
59
 
60
  if ($customer->getId()) {
@@ -85,8 +85,7 @@ class Aplazame_Aplazame_Model_Api_Serializers extends Varien_Object
85
  $shipping = null;
86
  $shipping_address = $order->getShippingAddress();
87
 
88
- if ($shipping_address)
89
- {
90
  $shipping = array_merge($this->_getAddr($shipping_address), array(
91
  "price"=> static::formatDecimals($order->getShippingAmount()),
92
  "tax_rate"=>static::formatDecimals(100 * $order->getShippingTaxAmount() / $order->getShippingAmount()),
@@ -111,8 +110,7 @@ class Aplazame_Aplazame_Model_Api_Serializers extends Varien_Object
111
  $articles = array();
112
  $products = Mage::getModel('catalog/product');
113
 
114
- foreach($order->getAllVisibleItems() as $order_item)
115
- {
116
  $productId = $order_item->getProductId();
117
  $product = $products->load($productId);
118
  $discounts = $product->getPrice() - $product->getFinalPrice();
@@ -159,8 +157,7 @@ class Aplazame_Aplazame_Model_Api_Serializers extends Varien_Object
159
  ->addAttributeToFilter('customer_id', array('like'=>$order->getCustomerId()));
160
 
161
  $history = array();
162
- foreach($history_collection as $order_history){
163
-
164
  $history[] = array(
165
  "id"=>$order_history->getIncrementId(),
166
  "amount"=>static::formatDecimals($order_history->getGrandTotal()),
@@ -199,14 +196,12 @@ class Aplazame_Aplazame_Model_Api_Serializers extends Varien_Object
199
  "success_url"=>Mage::getUrl('checkout/onepage/success'));
200
 
201
  return array(
202
- "toc"=>True,
203
  "merchant"=>$merchant,
204
  "customer"=>$this->getCustomer(),
205
  "order"=>$this->getRenderOrder(),
206
  "billing"=>$this->_getAddr($order->getBillingAddress()),
207
  "shipping"=>$this->getShipping($order),
208
  "meta"=>static::_getMetadata());
209
-
210
  }
211
  }
212
-
48
  "city" => $addr->getCity(),
49
  "state" => $addr->getRegion(),
50
  "country" => $addr->getCountryModel()->getIso2Code(),
51
+ "postcode" => $addr->getPostcode());
52
  }
53
 
54
  protected function getCustomer()
55
  {
56
  $customer = Mage::getSingleton('customer/session')->getCustomer();
57
+ $logCustomer = Mage::getModel('log/customer')->loadByCustomer($customer);
58
  $customer_serializer = array("gender"=>0);
59
 
60
  if ($customer->getId()) {
85
  $shipping = null;
86
  $shipping_address = $order->getShippingAddress();
87
 
88
+ if ($shipping_address) {
 
89
  $shipping = array_merge($this->_getAddr($shipping_address), array(
90
  "price"=> static::formatDecimals($order->getShippingAmount()),
91
  "tax_rate"=>static::formatDecimals(100 * $order->getShippingTaxAmount() / $order->getShippingAmount()),
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();
157
  ->addAttributeToFilter('customer_id', array('like'=>$order->getCustomerId()));
158
 
159
  $history = array();
160
+ foreach ($history_collection as $order_history) {
 
161
  $history[] = array(
162
  "id"=>$order_history->getIncrementId(),
163
  "amount"=>static::formatDecimals($order_history->getGrandTotal()),
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"=>static::_getMetadata());
 
206
  }
207
  }
 
app/code/community/Aplazame/Aplazame/Model/Observer.php CHANGED
@@ -3,7 +3,6 @@
3
 
4
  class Aplazame_Aplazame_Model_Observer extends Mage_Core_Model_Abstract
5
  {
6
-
7
  protected function is_aplazame_payment($order)
8
  {
9
  $code = Aplazame_Aplazame_Model_Payment::METHOD_CODE;
@@ -31,7 +30,7 @@ class Aplazame_Aplazame_Model_Observer extends Mage_Core_Model_Abstract
31
  return $this;
32
  }
33
 
34
- if (!$this->is_aplazame_payment($order)) {
35
  return $this;
36
  }
37
 
@@ -66,7 +65,7 @@ class Aplazame_Aplazame_Model_Observer extends Mage_Core_Model_Abstract
66
  return $this;
67
  }
68
 
69
- if (!$this->is_aplazame_payment($order)) {
70
  return $this;
71
  }
72
 
@@ -75,5 +74,4 @@ class Aplazame_Aplazame_Model_Observer extends Mage_Core_Model_Abstract
75
 
76
  return $this;
77
  }
78
-
79
  }
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;
30
  return $this;
31
  }
32
 
33
+ if (!$this->is_aplazame_payment($order)) {
34
  return $this;
35
  }
36
 
65
  return $this;
66
  }
67
 
68
+ if (!$this->is_aplazame_payment($order)) {
69
  return $this;
70
  }
71
 
74
 
75
  return $this;
76
  }
 
77
  }
app/code/community/Aplazame/Aplazame/Model/Payment.php CHANGED
@@ -76,7 +76,7 @@ class Aplazame_Aplazame_Model_Payment extends Mage_Payment_Model_Method_Abstract
76
 
77
  public function getOrderPlaceRedirectUrl()
78
  {
79
- return Mage::getUrl('aplazame/payment/redirect', array('_secure' => true));
80
  }
81
 
82
  public function getChargeId()
@@ -86,10 +86,9 @@ class Aplazame_Aplazame_Model_Payment extends Mage_Payment_Model_Method_Abstract
86
 
87
  protected function _validate_amount_result($amount, $result)
88
  {
89
- if ($result["amount"] != $amount)
90
- {
91
  Mage::throwException(Mage::helper('aplazame')->__(
92
- 'Aplazame authorized amount of ' . $result["amount"] .
93
  ' does not match requested amount of: ' . $amount));
94
  }
95
  }
@@ -105,12 +104,9 @@ class Aplazame_Aplazame_Model_Payment extends Mage_Payment_Model_Method_Abstract
105
  $api = Mage::getModel('aplazame/api_client');
106
  $result = $api->setOrderId($token)->authorize();
107
 
108
- if (isset($result["id"]))
109
- {
110
  $this->getInfoInstance()->setAdditionalInformation("charge_id", $result["id"]);
111
- }
112
- else
113
- {
114
  Mage::throwException(Mage::helper('aplazame')->__('Aplazame charge id not returned from call.'));
115
  }
116
 
@@ -153,4 +149,3 @@ class Aplazame_Aplazame_Model_Payment extends Mage_Payment_Model_Method_Abstract
153
  return $serializer->getCheckout();
154
  }
155
  }
156
-
76
 
77
  public function getOrderPlaceRedirectUrl()
78
  {
79
+ return Mage::getUrl('aplazame/payment/redirect', array('_secure' => true));
80
  }
81
 
82
  public function getChargeId()
86
 
87
  protected function _validate_amount_result($amount, $result)
88
  {
89
+ if ($result["amount"] != $amount) {
 
90
  Mage::throwException(Mage::helper('aplazame')->__(
91
+ 'Aplazame authorized amount of ' . $result["amount"] .
92
  ' does not match requested amount of: ' . $amount));
93
  }
94
  }
104
  $api = Mage::getModel('aplazame/api_client');
105
  $result = $api->setOrderId($token)->authorize();
106
 
107
+ if (isset($result["id"])) {
 
108
  $this->getInfoInstance()->setAdditionalInformation("charge_id", $result["id"]);
109
+ } else {
 
 
110
  Mage::throwException(Mage::helper('aplazame')->__('Aplazame charge id not returned from call.'));
111
  }
112
 
149
  return $serializer->getCheckout();
150
  }
151
  }
 
app/code/community/Aplazame/Aplazame/controllers/PaymentController.php CHANGED
@@ -2,7 +2,6 @@
2
 
3
  class Aplazame_Aplazame_PaymentController extends Mage_Core_Controller_Front_Action
4
  {
5
-
6
  private function _getCheckoutSession()
7
  {
8
  return Mage::getSingleton('checkout/session');
@@ -28,8 +27,7 @@ class Aplazame_Aplazame_PaymentController extends Mage_Core_Controller_Front_Act
28
  {
29
  $session = $this->_getCheckoutSession();
30
 
31
- if (!$session->getLastRealOrderId())
32
- {
33
  $session->addError($this->__('Your order has expired.'));
34
  $this->_redirect('checkout/cart');
35
  return;
@@ -45,12 +43,10 @@ class Aplazame_Aplazame_PaymentController extends Mage_Core_Controller_Front_Act
45
 
46
  public function confirmAction()
47
  {
48
-
49
  $session = $this->_getCheckoutSession();
50
  $checkout_token = $this->getRequest()->getParam("order_id");
51
 
52
- if (!$checkout_token)
53
- {
54
  Mage::throwException($this->__('Confirm has no checkout token.'));
55
  }
56
 
@@ -72,8 +68,7 @@ class Aplazame_Aplazame_PaymentController extends Mage_Core_Controller_Front_Act
72
  $session = $this->_getCheckoutSession();
73
  $orderId = $session->getLastRealOrderId();
74
 
75
- if($orderId)
76
- {
77
  $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
78
  if ($order->getId()) {
79
  Mage::helper('aplazame/cart')->resuscitateCartFromOrder($order);
@@ -87,8 +82,7 @@ class Aplazame_Aplazame_PaymentController extends Mage_Core_Controller_Front_Act
87
  {
88
  $checkout_token = $this->getRequest()->getParam("checkout_token");
89
 
90
- if (!$checkout_token)
91
- {
92
  Mage::throwException($this->__('History has no checkout token.'));
93
  }
94
 
2
 
3
  class Aplazame_Aplazame_PaymentController extends Mage_Core_Controller_Front_Action
4
  {
 
5
  private function _getCheckoutSession()
6
  {
7
  return Mage::getSingleton('checkout/session');
27
  {
28
  $session = $this->_getCheckoutSession();
29
 
30
+ if (!$session->getLastRealOrderId()) {
 
31
  $session->addError($this->__('Your order has expired.'));
32
  $this->_redirect('checkout/cart');
33
  return;
43
 
44
  public function confirmAction()
45
  {
 
46
  $session = $this->_getCheckoutSession();
47
  $checkout_token = $this->getRequest()->getParam("order_id");
48
 
49
+ if (!$checkout_token) {
 
50
  Mage::throwException($this->__('Confirm has no checkout token.'));
51
  }
52
 
68
  $session = $this->_getCheckoutSession();
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);
82
  {
83
  $checkout_token = $this->getRequest()->getParam("checkout_token");
84
 
85
+ if (!$checkout_token) {
 
86
  Mage::throwException($this->__('History has no checkout token.'));
87
  }
88
 
app/code/community/Aplazame/Aplazame/etc/config.xml CHANGED
@@ -2,8 +2,7 @@
2
  <config>
3
  <modules>
4
  <Aplazame_Aplazame>
5
- <version>0.1.0</version>
6
- <build></build>
7
  </Aplazame_Aplazame>
8
  </modules>
9
  <global>
@@ -76,10 +75,10 @@
76
  <updates>
77
  <aplazame>
78
  <file>aplazame.xml</file>
79
- </aplazame>
80
  </updates>
81
  </layout>
82
-
83
  </frontend>
84
  <default>
85
  <payment>
@@ -90,7 +89,7 @@
90
  <title>Aplazame</title>
91
  <host>https://aplazame.com</host>
92
  <version>v1.2</version>
93
- <button_id>p_method_aplazame</button_id>
94
  <button_img>white-148x46</button_img>
95
  <sort_order>1</sort_order>
96
  <secret_api_key backend_model="adminhtml/system_config_backend_encrypted"/>
2
  <config>
3
  <modules>
4
  <Aplazame_Aplazame>
5
+ <version>0.2.0</version>
 
6
  </Aplazame_Aplazame>
7
  </modules>
8
  <global>
75
  <updates>
76
  <aplazame>
77
  <file>aplazame.xml</file>
78
+ </aplazame>
79
  </updates>
80
  </layout>
81
+
82
  </frontend>
83
  <default>
84
  <payment>
89
  <title>Aplazame</title>
90
  <host>https://aplazame.com</host>
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"/>
app/code/community/Aplazame/Aplazame/etc/system.xml CHANGED
@@ -44,16 +44,16 @@
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
  </version>
49
- <button_id>
50
- <label>Button ID</label>
51
  <frontend_type>text</frontend_type>
52
  <sort_order>50</sort_order>
53
  <show_in_default>1</show_in_default>
54
  <show_in_website>1</show_in_website>
55
  <show_in_store>1</show_in_store>
56
- </button_id>
57
  <button_img>
58
  <label>Button Image</label>
59
  <frontend_type>text</frontend_type>
@@ -72,7 +72,7 @@
72
  <frontend_class>validate-number</frontend_class>
73
  </sort_order>
74
  <secret_api_key translate="label">
75
- <label>Secret Api Key</label>
76
  <frontend_type>obscure</frontend_type>
77
  <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
78
  <sort_order>80</sort_order>
@@ -81,7 +81,7 @@
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>
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
  </version>
49
+ <button>
50
+ <label>Button CSS Selector</label>
51
  <frontend_type>text</frontend_type>
52
  <sort_order>50</sort_order>
53
  <show_in_default>1</show_in_default>
54
  <show_in_website>1</show_in_website>
55
  <show_in_store>1</show_in_store>
56
+ </button>
57
  <button_img>
58
  <label>Button Image</label>
59
  <frontend_type>text</frontend_type>
72
  <frontend_class>validate-number</frontend_class>
73
  </sort_order>
74
  <secret_api_key translate="label">
75
+ <label>Secret API Key</label>
76
  <frontend_type>obscure</frontend_type>
77
  <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
78
  <sort_order>80</sort_order>
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>
app/design/frontend/base/default/layout/aplazame.xml CHANGED
@@ -1,7 +1,13 @@
1
  <layout version="0.1.0">
2
  <default>
3
  <reference name="head" before="-">
4
- <block type="page/html" name="aplazame_common" as="aplazame_common" template="aplazame/payment/common.phtml" />
 
5
  </reference>
6
  </default>
 
 
 
 
 
7
  </layout>
1
  <layout version="0.1.0">
2
  <default>
3
  <reference name="head" before="-">
4
+ <block type="page/html" name="aplazame_common" as="aplazame_common"
5
+ template="aplazame/payment/common.phtml"/>
6
  </reference>
7
  </default>
8
+ <catalog_product_view>
9
+ <reference name="product.info.extrahint">
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>
app/design/frontend/base/default/template/aplazame/.DS_Store ADDED
Binary file
app/design/frontend/base/default/template/aplazame/payment/form.phtml CHANGED
@@ -14,10 +14,9 @@
14
 
15
  <script>
16
  aplazame.button({
17
- id: "<?php echo Mage::getStoreConfig('payment/aplazame/button_id') ?>",
18
  amount: <?php echo $this->getTotal() ?>,
19
  currency: "EUR",
20
- parent: "*"
21
- // country: "ES"
22
  });
23
  </script>
14
 
15
  <script>
16
  aplazame.button({
17
+ selector: "<?php echo Mage::getStoreConfig('payment/aplazame/button') ?>",
18
  amount: <?php echo $this->getTotal() ?>,
19
  currency: "EUR",
20
+ country: "<?php echo $this->getCountry(); ?>"
 
21
  });
22
  </script>
app/design/frontend/base/default/template/aplazame/product/widget.phtml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ /** @var Aplazame_Aplazame_Block_Product_Widget $this */
3
+ ?>
4
+ <div data-aplazame-simulator="" data-amount="<?php echo $this->getFinalPrice(); ?>">&nbsp;</div>
app/etc/modules/Aplazame_Aplazame.xml CHANGED
@@ -1,10 +1,12 @@
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
- <Aplazame_Aplazame>
5
- <active>true</active>
6
- <codePool>community</codePool>
7
- </Aplazame_Aplazame>
 
 
 
8
  </modules>
9
  </config>
10
-
1
  <?xml version="1.0"?>
2
  <config>
3
  <modules>
4
+ <Aplazame_Aplazame>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Catalog/>
9
+ </depends>
10
+ </Aplazame_Aplazame>
11
  </modules>
12
  </config>
 
lib/Aplazame/Aplazame.php CHANGED
@@ -2,5 +2,3 @@
2
 
3
  // Utilities
4
  require(dirname(__FILE__) . '/Aplazame/Util.php');
5
-
6
-
2
 
3
  // Utilities
4
  require(dirname(__FILE__) . '/Aplazame/Util.php');
 
 
lib/Aplazame/Aplazame/Util.php CHANGED
@@ -1,35 +1,26 @@
1
  <?php
2
 
3
- class Aplazame_Util {
4
-
5
- public static function formatDecimals($amount = 0) {
6
- $negative = false;
7
- $str = sprintf("%.2f", $amount);
8
-
9
- if (strcmp($str[0], "-") === 0) {
 
10
  $str = substr($str, 1);
11
- $negative = true;
12
  }
13
 
14
- $parts = explode(".", $str, 2);
15
- if ($parts === false) {
16
- return 0;
17
- }
18
 
19
- if (empty($parts)) {
20
- return 0;
21
- }
22
 
23
- if (strcmp($parts[0], 0) === 0 && strcmp($parts[1], "00") === 0) {
24
  return 0;
25
  }
26
 
27
- $retVal = "";
28
- if ($negative) {
29
- $retVal .= "-";
30
- }
31
- $retVal .= ltrim( $parts[0] . substr($parts[1], 0, 2), "0");
32
- return intval($retVal);
33
  }
34
-
35
  }
1
  <?php
2
 
3
+ class Aplazame_Util
4
+ {
5
+ public static function formatDecimals($amount = 0)
6
+ {
7
+ $ret = '';
8
+ $str = sprintf('%.2f', $amount);
9
+
10
+ if (strcmp($str[0], '-') === 0) {
11
  $str = substr($str, 1);
12
+ $ret = '-';
13
  }
14
 
15
+ $parts = explode('.', $str, 2);
 
 
 
16
 
17
+ if (($parts === false) || (empty($parts)) ||
18
+ (strcmp($parts[0], 0) === 0 && strcmp($parts[1], '00') === 0)) {
 
19
 
 
20
  return 0;
21
  }
22
 
23
+ $ret .= ltrim($parts[0] . substr($parts[1], 0, 2), '0');
24
+ return intval($ret);
 
 
 
 
25
  }
 
26
  }
package.xml CHANGED
@@ -1,22 +1,24 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Aplazame_Aplazame</name>
4
- <version>0.1.0.1</version>
5
  <stability>stable</stability>
6
- <license/>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Accept payments in Magento using the Aplazame Payment Gateway, a consumer credit service.</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.&#xD;
11
- &#xD;
12
- The module allows the customer to defer the payment of his online purchases in ecommerces offering Aplazame as a payment method.&#xD;
13
- &#xD;
14
- Aplazame's mission is to increase sales of any online store eliminating any friction in the process.</description>
15
- <notes>Birth</notes>
16
- <authors><author><name>Daniel</name><user>auto-converted</user><email>dani@aplazame.com</email></author><author><name>Oscar</name><user>auto-converted</user><email>oreales@gmail.com</email></author></authors>
17
- <date>2015-08-30</date>
18
- <time>21:44:06</time>
19
- <contents><target name="mageetc"><dir name="modules"><file name="Aplazame_Aplazame.xml" hash="8c6efc3c3906595d577d6952388110a1"/></dir></target><target name="magecommunity"><dir name="Aplazame"><dir name="Aplazame"><dir name="Block"><dir name="Checkout"><dir name="Onepage"><file name="Billing.php" hash="8f6fb00193c844dcf57802f3250e5983"/><file name="Shipping.php" hash="93ee90494a8addb58ae9a3242b44bf5e"/></dir></dir><dir name="Payment"><file name="Form.php" hash="996b6db7b3ac7d9e8b4858dca73802e1"/><file name="Info.php" hash="2e7b83e3cff16c8f813b834a239995ef"/><file name="Redirect.php" hash="9cbc88587076d51f187d0ad546258768"/></dir></dir><dir name="Helper"><file name="Cart.php" hash="85d4cfc9d435efe5f9ddc282e2245179"/><file name="Data.php" hash="eea913840306dfe78841ce22619c3175"/></dir><dir name="Model"><dir name="Api"><file name="Client.php" hash="3e0931300c2ee120f2f06cf33d39a432"/><file name="Serializers.php" hash="e14418bb9b1b4b6602c75b11e11ffe43"/></dir><file name="Config.php" hash="67254d968ff5a0a95c73484cc13efb33"/><file name="Observer.php" hash="28833b6f1f734c1bc0997a4006194bc7"/><file name="Payment.php" hash="8377767ab84c20a51e8cc13f76ad6a1f"/></dir><dir name="controllers"><file name="PaymentController.php" hash="56f3d45f6bfc8d812ff3d7b0e3cf6aed"/></dir><dir name="etc"><file name="config.xml" hash="b73bc9cb00f0ee1bacc692538bd1252c"/><file name="system.xml" hash="0107f888479fc9c099bea94d1084769a"/></dir></dir></dir></target><target name="magelib"><dir name="Aplazame"><dir name="Aplazame"><file name="Util.php" hash="8252beb4d098d2392b5e0bbf2ff7a907"/></dir><file name="Aplazame.php" hash="a7214383b6bf6953acde3153500f76b8"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="aplazame.xml" hash="d8b52c7c03ae464c9ac184d14985b50f"/></dir><dir name="template"><dir name="aplazame"><dir name="payment"><file name="common.phtml" hash="cdcc83ab18a52dff8c588fadb06c3c51"/><file name="form.phtml" hash="c700205046c076b13dd6be2503b6c398"/></dir></dir></dir></dir></dir></dir></target></contents>
 
 
20
  <compatible/>
21
- <dependencies/>
22
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Aplazame_Aplazame</name>
4
+ <version>0.2.0</version>
5
  <stability>stable</stability>
6
+ <license uri="http://www.gnu.org/licenses/gpl-3.0.en.html">GNU General Public License (GPL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Modulo oficial de aplazame.com, medio de pago que permite pagos financiados integrado en el checkout de Magento.</summary>
10
+ <description>Modulo oficial de aplazame.com, medio de pago que permite pagos financiados integrado en el checkout de Magento.</description>
11
+ <notes>&#x2022; Widget de aplazame en ficha de producto&#xD;
12
+ &#x2022; Pasando country id para toma de decisiones seg&#xFA;n pa&#xED;s en API&#xD;
13
+ &#x2022; Back to checkout&#xD;
14
+ &#x2022; aplazame-js&#xD;
15
+ &#x2022; Allow edit processing orders&#xD;
16
+ &#x2022; Button Id config field&#xD;
17
+ &#x2022; Payment method in order config field</notes>
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>6.0.0</max></php></required></dependencies>
24
  </package>