-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Version bump to 1.1.0: adds support for different installments plans
- Loading branch information
Showing
25 changed files
with
2,317 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
app/code/community/Alma/Installments/Block/PaymentForm.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
/** | ||
* 2018-2019 Alma SAS | ||
* | ||
* THE MIT LICENSE | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and | ||
* to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | ||
* Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
* | ||
* @author Alma SAS <[email protected]> | ||
* @copyright 2018-2019 Alma SAS | ||
* @license https://opensource.org/licenses/MIT The MIT License | ||
*/ | ||
|
||
|
||
class Alma_Installments_Block_PaymentForm extends Mage_Payment_Block_Form | ||
{ | ||
/** | ||
* @var Alma_Installments_Helper_Config | ||
*/ | ||
private $config; | ||
|
||
protected function _construct() | ||
{ | ||
parent::_construct(); | ||
$this->setTemplate('alma/payment_form.phtml'); | ||
|
||
$this->config = Mage::helper('alma/config'); | ||
} | ||
|
||
public function displayPnX($n) | ||
{ | ||
if (!$this->config->isPnXEnabled($n)) { | ||
return false; | ||
} | ||
|
||
/** @var Mage_Sales_Model_Quote $quote */ | ||
$quote = Mage::helper('checkout/cart')->getQuote(); | ||
if(!$quote) { | ||
return false; | ||
} | ||
|
||
$cartTotal = Alma_Installments_Helper_Functions::priceToCents((float)$quote->getGrandTotal()); | ||
return $cartTotal >= $this->config->pnxMinAmount($n) && $cartTotal < $this->config->pnxMaxAmount($n); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
app/code/community/Alma/Installments/Model/System/Config/Backend/PnXAmountBoundary.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* 2018-2019 Alma SAS | ||
* | ||
* THE MIT LICENSE | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and | ||
* to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | ||
* Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
* | ||
* @author Alma SAS <[email protected]> | ||
* @copyright 2018-2019 Alma SAS | ||
* @license https://opensource.org/licenses/MIT The MIT License | ||
*/ | ||
|
||
class Alma_Installments_Model_System_Config_Backend_PnXAmountBoundary extends Mage_Core_Model_Config_Data | ||
{ | ||
protected $boundary = null; | ||
|
||
public function _afterLoad() | ||
{ | ||
/** @var \Alma\API\Entities\Merchant $merchant */ | ||
$merchant = Mage::helper('alma/Data')->getMerchant(); | ||
|
||
$defaults = array( | ||
"min" => $merchant ? $merchant->minimum_purchase_amount : 10000, | ||
"max" => $merchant ? $merchant->maximum_purchase_amount : 100000 | ||
); | ||
$value = $this->getValue(); | ||
|
||
if (empty($value)) { | ||
$value = $defaults[$this->boundary]; | ||
} | ||
|
||
$this->setValue(Alma_Installments_Helper_Functions::priceFromCents($value)); | ||
} | ||
|
||
public function _beforeSave() | ||
{ | ||
$this->setValue(Alma_Installments_Helper_Functions::priceToCents($this->getValue())); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
app/code/community/Alma/Installments/Model/System/Config/Backend/PnXMaxAmount.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* 2018-2019 Alma SAS | ||
* | ||
* THE MIT LICENSE | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and | ||
* to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | ||
* Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
* | ||
* @author Alma SAS <[email protected]> | ||
* @copyright 2018-2019 Alma SAS | ||
* @license https://opensource.org/licenses/MIT The MIT License | ||
*/ | ||
|
||
class Alma_Installments_Model_System_Config_Backend_PnXMaxAmount extends Alma_Installments_Model_System_Config_Backend_PnXAmountBoundary | ||
{ | ||
protected $boundary = 'max'; | ||
} |
28 changes: 28 additions & 0 deletions
28
app/code/community/Alma/Installments/Model/System/Config/Backend/PnXMinAmount.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/** | ||
* 2018-2019 Alma SAS | ||
* | ||
* THE MIT LICENSE | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation | ||
* the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and | ||
* to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the | ||
* Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE | ||
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
* | ||
* @author Alma SAS <[email protected]> | ||
* @copyright 2018-2019 Alma SAS | ||
* @license https://opensource.org/licenses/MIT The MIT License | ||
*/ | ||
|
||
class Alma_Installments_Model_System_Config_Backend_PnXMinAmount extends Alma_Installments_Model_System_Config_Backend_PnXAmountBoundary | ||
{ | ||
protected $boundary = 'min'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.