diff --git a/app/code/community/RicardoMartins/PagSeguro/Helper/Data.php b/app/code/community/RicardoMartins/PagSeguro/Helper/Data.php index ba16f5a5..6dfc6c45 100644 --- a/app/code/community/RicardoMartins/PagSeguro/Helper/Data.php +++ b/app/code/community/RicardoMartins/PagSeguro/Helper/Data.php @@ -667,11 +667,14 @@ public function getMaxInstallmentsNoInterest($amount) $freeAmt = Mage::getStoreConfig( self::XML_PATH_PAYMENT_PAGSEGURO_CC_INSTALLMENT_FREE_INTEREST_MINIMUM_AMT ); - $selectedMaxInstallmentNoInterest = $freeAmt === 0 ? : ''; - if ($freeAmt > 0) { - $selectedMaxInstallmentNoInterest = $amount / $freeAmt; - $selectedMaxInstallmentNoInterest = (int)floor($selectedMaxInstallmentNoInterest); + + if (!$freeAmt || $freeAmt <= 0) { + return false; } - return $selectedMaxInstallmentNoInterest; + + $selectedMaxInstallmentNoInterest = $amount / $freeAmt; + $selectedMaxInstallmentNoInterest = (int)floor($selectedMaxInstallmentNoInterest); + + return ($selectedMaxInstallmentNoInterest > 1) ? $selectedMaxInstallmentNoInterest : false; //prevents 0 or 1 } } \ No newline at end of file diff --git a/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php b/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php index 2d802c4a..23b55282 100644 --- a/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php +++ b/app/code/community/RicardoMartins/PagSeguro/Helper/Params.php @@ -159,7 +159,7 @@ public function getCreditCardInstallmentsParams(Mage_Sales_Model_Order $order, $ isset($cardData["installments_qty"]) && isset($cardData["installments_value"]) ) { - return array + $return = array ( 'installmentQuantity' => $cardData["installments_qty"], 'installmentValue' => $cardData["installments_value"], @@ -170,7 +170,7 @@ public function getCreditCardInstallmentsParams(Mage_Sales_Model_Order $order, $ { if ($payment->getAdditionalInformation('installment_quantity') && $payment->getAdditionalInformation('installment_value')) { - return array + $return = array ( 'installmentQuantity' => $payment->getAdditionalInformation('installment_quantity'), 'installmentValue' => number_format( @@ -180,11 +180,12 @@ public function getCreditCardInstallmentsParams(Mage_Sales_Model_Order $order, $ } } - return array - ( - 'installmentQuantity' => '1', - 'installmentValue' => number_format($order->getGrandTotal(), 2, '.', ''), - ); + $maxInstallmentsNoInterest = Mage::helper('ricardomartins_pagseguro') + ->getMaxInstallmentsNoInterest($order->getGrandTotal()); + + if ($maxInstallmentsNoInterest !== false) { + $return['noInterestInstallmentQuantity'] = $maxInstallmentsNoInterest; + } return $return; } diff --git a/app/code/community/RicardoMartins/PagSeguro/Model/Abstract.php b/app/code/community/RicardoMartins/PagSeguro/Model/Abstract.php index b117deae..3da22a3e 100644 --- a/app/code/community/RicardoMartins/PagSeguro/Model/Abstract.php +++ b/app/code/community/RicardoMartins/PagSeguro/Model/Abstract.php @@ -727,6 +727,13 @@ protected function _cancelOrder($payment, $notification) if($orderCancellation->getShouldCancel()) { + // checks if the order state is 'Pending Payment' and changes it + // so that the order can be cancelled. Orders with STATE_PAYMENT_REVIEW cannot be cancelled by default in + // Magento. See #181550828 for details + if ($order->getState() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) { + $order->setState(Mage_Sales_Model_Order::STATE_NEW); + } + $order->cancel(); } } diff --git a/app/code/community/RicardoMartins/PagSeguro/etc/config.xml b/app/code/community/RicardoMartins/PagSeguro/etc/config.xml index bf21155a..db6d3bbb 100644 --- a/app/code/community/RicardoMartins/PagSeguro/etc/config.xml +++ b/app/code/community/RicardoMartins/PagSeguro/etc/config.xml @@ -2,7 +2,7 @@ - 3.15.0 + 3.15.1 diff --git a/app/code/community/RicardoMartins/PagSeguro/etc/system.xml b/app/code/community/RicardoMartins/PagSeguro/etc/system.xml index 4ef63ffb..c1ebdf35 100644 --- a/app/code/community/RicardoMartins/PagSeguro/etc/system.xml +++ b/app/code/community/RicardoMartins/PagSeguro/etc/system.xml @@ -442,10 +442,10 @@ 1 1 validate-number validate-not-negative-number - Saiba mais.]]> + DEVE desativar ou remover qualquer promoção salva no seu painel PagSeguro. Saiba mais.]]> diff --git a/js/pagseguro/pagseguro.js b/js/pagseguro/pagseguro.js index b73ac16c..e23a80a1 100644 --- a/js/pagseguro/pagseguro.js +++ b/js/pagseguro/pagseguro.js @@ -87,6 +87,7 @@ RMPagSeguro = Class.create({ if (RMPagSeguroObj.config.installment_free_interest_minimum_amt > 0) { maxInstallmentNoInterest = grandTotal / RMPagSeguroObj.config.installment_free_interest_minimum_amt; maxInstallmentNoInterest = Math.floor(maxInstallmentNoInterest); + maxInstallmentNoInterest = (maxInstallmentNoInterest > 1) ? maxInstallmentNoInterest : ''; } PagSeguroDirectPayment.getInstallments({ amount: grandTotal, @@ -1331,6 +1332,7 @@ RMPagSeguro_Multicc_CardForm = Class.create if (this.config.installment_free_interest_minimum_amt > 0) { maxInstallmentNoInterest = this.getCardData("total").toFixed(2) / this.config.installment_free_interest_minimum_amt; maxInstallmentNoInterest = Math.floor(maxInstallmentNoInterest); + maxInstallmentNoInterest = (maxInstallmentNoInterest > 1) ? maxInstallmentNoInterest : ''; } var params =