vindi-subscriptions-and-recurring-payments - Version 1.0.10

Version Notes

version 1.0.10

Download this release

Release Info

Developer Tales Galvao
Extension vindi-subscriptions-and-recurring-payments
Version 1.0.10
Comparing to
See all releases


Code changes from version 1.0.7 to 1.0.10

app/code/community/Vindi/Subscription/Block/Form/Cc.php CHANGED
@@ -73,26 +73,25 @@ class Vindi_Subscription_Block_Form_Cc extends Mage_Payment_Block_Form_Cc
73
  public function getInstallments()
74
  {
75
  $maxInstallmentsNumber = Mage::getStoreConfig('payment/vindi_creditcard/max_installments_number');
76
- $minInstallmentsValue = Mage::getStoreConfig('payment/vindi_creditcard/min_installment_value');
77
- // $quote = Mage::getSingleton('checkout/session')->getQuote();
78
- $quote = $this->getQuote();
79
-
80
- $installments = false;
 
81
 
82
  if ($this->isSingleQuote($quote) && $maxInstallmentsNumber > 1) {
83
 
84
- $total = $quote->getGrandTotal();
85
 
86
- $installments = '<option value="">' . Mage::helper('catalog')->__('-- Please Select --') . '</option>';
87
  for ($i = 1; $i <= $maxInstallmentsNumber; $i++) {
88
  $value = ceil($total / $i * 100) / 100;
 
 
 
89
 
90
- if ($value >= $minInstallmentsValue) {
91
- $price = Mage::helper('core')->currency($value, true, false);
92
- $installments .= '<option value="' . $i . '">' . sprintf('%dx de %s', $i, $price) . '</option>';
93
- } else {
94
- break;
95
- }
96
  }
97
  }
98
 
73
  public function getInstallments()
74
  {
75
  $maxInstallmentsNumber = Mage::getStoreConfig('payment/vindi_creditcard/max_installments_number');
76
+ $minInstallmentsValue = Mage::getStoreConfig('payment/vindi_creditcard/min_installment_value');
77
+ // $quote = Mage::getSingleton('checkout/session')->getQuote();
78
+ $quote = $this->getQuote();
79
+ $installments = false;
80
+ $total = $quote->getGrandTotal();
81
+ $installmentsTimes = floor($total / $minInstallmentsValue);
82
 
83
  if ($this->isSingleQuote($quote) && $maxInstallmentsNumber > 1) {
84
 
85
+ $installments = '<option value="">' . Mage::helper('catalog')->__('-- Please Select --') . '</option>';
86
 
 
87
  for ($i = 1; $i <= $maxInstallmentsNumber; $i++) {
88
  $value = ceil($total / $i * 100) / 100;
89
+ $price = Mage::helper('core')->currency($value, true, false);
90
+
91
+ $installments .= '<option value="' . $i . '">' . sprintf('%dx de %s', $i, $price) . '</option>';
92
 
93
+ if(($i + 1) > $installmentsTimes)
94
+ break;
 
 
 
 
95
  }
96
  }
97
 
app/code/community/Vindi/Subscription/Model/CreditCard.php CHANGED
@@ -129,10 +129,13 @@ class Vindi_Subscription_Model_CreditCard extends Mage_Payment_Model_Method_Cc
129
 
130
  $customer = Mage::getModel('customer/customer');
131
 
132
- $customerId = $this->createCustomer($order, $customer);
 
133
 
134
  if (! $payment->getAdditionalInformation('use_saved_cc')) {
135
  $this->createPaymentProfile($customerId);
 
 
136
  }
137
 
138
  if ($this->isSingleOrder($order)) {
@@ -181,6 +184,22 @@ class Vindi_Subscription_Model_CreditCard extends Mage_Payment_Model_Method_Cc
181
  return $paymentProfileId;
182
  }
183
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
  /**
185
  * Check whether payment method can be used
186
  *
@@ -219,7 +238,7 @@ class Vindi_Subscription_Model_CreditCard extends Mage_Payment_Model_Method_Cc
219
  $minInstallmentsValue = Mage::getStoreConfig('payment/vindi_creditcard/min_installment_value');
220
  $installmentValue = ceil($quote->getGrandTotal() / $installments * 100) / 100;
221
 
222
- if (($installmentValue < $minInstallmentsValue) || ($installments > $maxInstallmentsNumber)) {
223
  return $this->error('O número de parcelas selecionado é inválido.');
224
  }
225
  }
129
 
130
  $customer = Mage::getModel('customer/customer');
131
 
132
+ $customerId = $this->createCustomer($order, $customer);
133
+ $customerVindiId = $customer->getVindiUserCode();
134
 
135
  if (! $payment->getAdditionalInformation('use_saved_cc')) {
136
  $this->createPaymentProfile($customerId);
137
+ } else {
138
+ $this->assignDataFromPreviousPaymentProfile($customerVindiId);
139
  }
140
 
141
  if ($this->isSingleOrder($order)) {
184
  return $paymentProfileId;
185
  }
186
 
187
+ /**
188
+ * @param int $customerVindiId
189
+ */
190
+ protected function assignDataFromPreviousPaymentProfile($customerVindiId)
191
+ {
192
+ $api = Mage::helper('vindi_subscription/api');
193
+ $savedCc = $api->getCustomerPaymentProfile($customerVindiId);
194
+ $info = $this->getInfoInstance();
195
+
196
+ $info->setCcType($savedCc['payment_company']['name'])
197
+ ->setCcOwner($savedCc['holder_name'])
198
+ ->setCcLast4($savedCc['card_number_last_four'])
199
+ ->setCcNumber($savedCc['card_number_last_four'])
200
+ ->setAdditionalInformation('use_saved_cc', true);
201
+ }
202
+
203
  /**
204
  * Check whether payment method can be used
205
  *
238
  $minInstallmentsValue = Mage::getStoreConfig('payment/vindi_creditcard/min_installment_value');
239
  $installmentValue = ceil($quote->getGrandTotal() / $installments * 100) / 100;
240
 
241
+ if (($installmentValue < $minInstallmentsValue) && ($installments > 1)) {
242
  return $this->error('O número de parcelas selecionado é inválido.');
243
  }
244
  }
app/code/community/Vindi/Subscription/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Vindi_Subscription>
5
- <version>1.0.7</version>
6
  </Vindi_Subscription>
7
  </modules>
8
  <global>
@@ -138,4 +138,3 @@
138
  </events>
139
  </frontend>
140
  </config>
141
-
2
  <config>
3
  <modules>
4
  <Vindi_Subscription>
5
+ <version>1.0.10</version>
6
  </Vindi_Subscription>
7
  </modules>
8
  <global>
138
  </events>
139
  </frontend>
140
  </config>
 
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Vindi</name>
4
- <version>1.0.7</version>
5
  <stability>stable</stability>
6
  <license>GPLv3</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>A integra&#xE7;&#xE3;o do m&#xF3;dulo da Vindi permite cria&#xE7;&#xE3;o e gest&#xE3;o de planos e assinaturas atrav&#xE9;s do Magento de forma transparente.</summary>
10
  <description>A integra&#xE7;&#xE3;o do m&#xF3;dulo da Vindi permite cria&#xE7;&#xE3;o e gest&#xE3;o de planos e assinaturas atrav&#xE9;s do Magento de forma transparente.</description>
11
- <notes>version 1.0.7</notes>
12
  <authors><author><name>Tales Galvao</name><user>talesgalvao</user><email>tales.galvao@gmail.com</email></author><author><name>Erico Pedroso</name><user>ericopedroso</user><email>erico.pedroso@vindi.com.br</email></author></authors>
13
- <date>2016-01-20</date>
14
- <time>13:27:54</time>
15
- <contents><target name="magecommunity"><dir name="Vindi"><dir name="Subscription"><dir name="Block"><dir name="Config"><file name="Information.php" hash="b324090de6fee25d09572d825709a6a9"/></dir><dir name="Form"><file name="BankSlip.php" hash="bce644dc03d2ed25389dceb21f9762ad"/><file name="Cc.php" hash="d95c0f954ea18ddc04fe0e34734eeae9"/></dir></dir><dir name="Helper"><file name="Api.php" hash="19f742ac0d9af9de02c0731391490026"/><file name="Data.php" hash="d1f0d18d79647a11c991bac60ee2ef44"/><file name="WebhookHandler.php" hash="6daa02ca4572ceedc274e12d92a5abed"/></dir><dir name="Model"><file name="BankSlip.php" hash="f00508693ad4a86ec43b373a5252e942"/><dir name="Config"><file name="Installments.php" hash="0f899e0267b0b0f1d17acaf06a65e493"/><file name="Shippingmethod.php" hash="5afab77a4c4e3a22992350ac41dc57b5"/></dir><file name="CreditCard.php" hash="cec7198003d7ad59fc1b5b45ff586e8f"/><file name="Observer.php" hash="e508b5c67b8a4a5db510939d41a67846"/><dir name="Product"><dir name="Attribute"><file name="Plan.php" hash="b1f3084edcd57f0d480d1376c4d90e4b"/></dir><file name="Type.php" hash="9bb3c00df44019ced9ad1682a2d3c2be"/></dir></dir><dir name="Trait"><file name="PaymentMethod.php" hash="092ecf2cf083bf4c7cc6cbf0d38ad6d3"/></dir><dir name="controllers"><file name="WebhookController.php" hash="d4886b956fe54d7ae8a38b3be22897d4"/></dir><dir name="etc"><file name="adminhtml.xml" hash="19f4eb5c16d561805f7b017186e2140b"/><file name="config.xml" hash="bcc392fdb18b50d0be8e4fd392f4e76f"/><file name="system.xml" hash="c660c9607f6dc584dd93247ef8c3aa7f"/></dir><dir name="sql"><dir name="vindi_subscription_setup"><file name="install-1.0.0.php" hash="cc7722665a2f587d8bf8310a94503353"/><file name="upgrade-1.0.0-1.0.1.php" hash="b4f107c231dd4cdb9e950a1c98c35a3d"/><file name="upgrade-1.0.1-1.0.2.php" hash="a018618fe25d0b3c45d1137a9b07aa7d"/><file name="upgrade-1.0.4-1.0.5.php" hash="acd0ba386942f42bad1ef792e8ac7aa1"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Vindi_Subscription.xml" hash="64a2addef728637da8dcd80a2b3c3415"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="vindi_subscription"><dir name="payment"><dir name="form"><file name="bankslip.phtml" hash="df328f9149c101a6ba5fada0bbca9ef4"/><file name="cc.phtml" hash="07d522a86a3cb64c8d912fd4d431f142"/></dir></dir></dir></dir><dir name="layout"><file name="vindi_subscription.xml" hash="f6aea64fedba97321b653f3ddc83ab11"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="template"><dir name="vindi_subscription"><dir name="payment"><dir name="form"><file name="bankslip.phtml" hash="df328f9149c101a6ba5fada0bbca9ef4"/><file name="cc.phtml" hash="3f2cc2ce886f9488a456b04e2c3a4c96"/></dir></dir></dir></dir><dir name="layout"><file name="vindi_subscription.xml" hash="ab06d89e538b954ce956f5a6674f83c0"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="vindi_subscription"><dir name="css"><file name="vindi_subscription.css" hash="ac7c5eab0913804e1cb90d5e9474e6a0"/></dir><dir name="js"><file name="vindi_subscription.js" hash="7d33f5ced68caf2fbcc3147f32d5c8fb"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.5.0</min><max>7.0.1</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Vindi</name>
4
+ <version>1.0.10</version>
5
  <stability>stable</stability>
6
  <license>GPLv3</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>A integra&#xE7;&#xE3;o do m&#xF3;dulo da Vindi permite cria&#xE7;&#xE3;o e gest&#xE3;o de planos e assinaturas atrav&#xE9;s do Magento de forma transparente.</summary>
10
  <description>A integra&#xE7;&#xE3;o do m&#xF3;dulo da Vindi permite cria&#xE7;&#xE3;o e gest&#xE3;o de planos e assinaturas atrav&#xE9;s do Magento de forma transparente.</description>
11
+ <notes>version 1.0.10</notes>
12
  <authors><author><name>Tales Galvao</name><user>talesgalvao</user><email>tales.galvao@gmail.com</email></author><author><name>Erico Pedroso</name><user>ericopedroso</user><email>erico.pedroso@vindi.com.br</email></author></authors>
13
+ <date>2016-04-04</date>
14
+ <time>13:35:45</time>
15
+ <contents><target name="magecommunity"><dir name="Vindi"><dir name="Subscription"><dir name="Block"><dir name="Config"><file name="Information.php" hash="b324090de6fee25d09572d825709a6a9"/></dir><dir name="Form"><file name="BankSlip.php" hash="bce644dc03d2ed25389dceb21f9762ad"/><file name="Cc.php" hash="2172e8310dfe0fd7a0b019ee0aa8daad"/></dir></dir><dir name="Helper"><file name="Api.php" hash="19f742ac0d9af9de02c0731391490026"/><file name="Data.php" hash="d1f0d18d79647a11c991bac60ee2ef44"/><file name="WebhookHandler.php" hash="6daa02ca4572ceedc274e12d92a5abed"/></dir><dir name="Model"><file name="BankSlip.php" hash="f00508693ad4a86ec43b373a5252e942"/><dir name="Config"><file name="Installments.php" hash="0f899e0267b0b0f1d17acaf06a65e493"/><file name="Shippingmethod.php" hash="5afab77a4c4e3a22992350ac41dc57b5"/></dir><file name="CreditCard.php" hash="bcf2e389a1560c47dd56a2b485ca44a7"/><file name="Observer.php" hash="e508b5c67b8a4a5db510939d41a67846"/><dir name="Product"><dir name="Attribute"><file name="Plan.php" hash="b1f3084edcd57f0d480d1376c4d90e4b"/></dir><file name="Type.php" hash="9bb3c00df44019ced9ad1682a2d3c2be"/></dir></dir><dir name="Trait"><file name="PaymentMethod.php" hash="092ecf2cf083bf4c7cc6cbf0d38ad6d3"/></dir><dir name="controllers"><file name="WebhookController.php" hash="d4886b956fe54d7ae8a38b3be22897d4"/></dir><dir name="etc"><file name="adminhtml.xml" hash="19f4eb5c16d561805f7b017186e2140b"/><file name="config.xml" hash="f8b2b15e5420b847f70c7234d22856d2"/><file name="system.xml" hash="c660c9607f6dc584dd93247ef8c3aa7f"/></dir><dir name="sql"><dir name="vindi_subscription_setup"><file name="install-1.0.0.php" hash="cc7722665a2f587d8bf8310a94503353"/><file name="upgrade-1.0.0-1.0.1.php" hash="b4f107c231dd4cdb9e950a1c98c35a3d"/><file name="upgrade-1.0.1-1.0.2.php" hash="a018618fe25d0b3c45d1137a9b07aa7d"/><file name="upgrade-1.0.4-1.0.5.php" hash="acd0ba386942f42bad1ef792e8ac7aa1"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Vindi_Subscription.xml" hash="64a2addef728637da8dcd80a2b3c3415"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="vindi_subscription"><dir name="payment"><dir name="form"><file name="bankslip.phtml" hash="df328f9149c101a6ba5fada0bbca9ef4"/><file name="cc.phtml" hash="07d522a86a3cb64c8d912fd4d431f142"/></dir></dir></dir></dir><dir name="layout"><file name="vindi_subscription.xml" hash="f6aea64fedba97321b653f3ddc83ab11"/></dir></dir></dir></dir><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="template"><dir name="vindi_subscription"><dir name="payment"><dir name="form"><file name="bankslip.phtml" hash="df328f9149c101a6ba5fada0bbca9ef4"/><file name="cc.phtml" hash="3f2cc2ce886f9488a456b04e2c3a4c96"/></dir></dir></dir></dir><dir name="layout"><file name="vindi_subscription.xml" hash="ab06d89e538b954ce956f5a6674f83c0"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="vindi_subscription"><dir name="css"><file name="vindi_subscription.css" hash="ac7c5eab0913804e1cb90d5e9474e6a0"/></dir><dir name="js"><file name="vindi_subscription.js" hash="7d33f5ced68caf2fbcc3147f32d5c8fb"/></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.5.0</min><max>7.0.1</max></php></required></dependencies>
18
  </package>