Skip to content

Commit

Permalink
Fix bug where razorpay utils were included even if it was disabled (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
73SL4 committed Apr 28, 2016
1 parent 0d3a1a6 commit 57ab8e4
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
4 changes: 3 additions & 1 deletion app/code/community/Razorpay/Payments/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public function __construct()

public function isRazorpayEnabled()
{
return Mage::getStoreConfigFlag(self::CONFIG_PATH_RAZORPAY_ENABLED);
return Mage::getSingleton('checkout/type_onepage')->getQuote()->getPayment()->getMethod() ==
Razorpay_Payments_Model_Paymentmethod::METHOD_CODE and
Mage::getStoreConfigFlag(self::CONFIG_PATH_RAZORPAY_ENABLED);
}

public function createOrder($receipt, $amount)
Expand Down
5 changes: 4 additions & 1 deletion app/code/community/Razorpay/Payments/Model/Paymentmethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Razorpay_Payments_Model_Paymentmethod extends Mage_Payment_Model_Method_Ab
const CHANNEL_NAME = 'Razorpay/Magento%s_%s/%s';
const METHOD_CODE = 'razorpay';
const CURRENCY = 'INR';
const VERSION = '1.1.2';
const VERSION = '1.1.3';

protected $_code = self::METHOD_CODE;
protected $_canOrder = true;
Expand Down Expand Up @@ -76,6 +76,9 @@ public function capture(Varien_Object $payment, $amount)
}
else
{
$payment->setStatus(self::STATUS_DECLINED)
->setIsTransactionClosed(true);

Mage::throwException('There was an error capturing the transaction.');
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Razorpay/Payments/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Razorpay_Payments>
<version>1.1.2</version>
<version>1.1.3</version>
</Razorpay_Payments>
</modules>
<global>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php if (Mage::helper('razorpay_payments')->isRazorpayEnabled()) : ?>
<script type="text/javascript">
var defaultPlaceOrderButton = $$('button[type=submit][class~="btn-checkout"]')[0];
defaultPlaceOrderButton.setAttribute('onclick', '');
Expand Down Expand Up @@ -29,3 +30,4 @@

Event.observe(defaultPlaceOrderButton, 'click', placeOrder);
</script>
<?php endif; ?>
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?php if (Mage::helper('razorpay_payments')->isRazorpayEnabled()) : ?>
<script type="text/javascript">
var razorpayUtils = new RazorpayUtils({
orderUrl: '<?php echo $this->getUrl('razorpay/checkout/order') ?>'
Expand All @@ -6,3 +7,4 @@
razorpayUtils.setKeyId('<?php echo $this->getKeyId(); ?>');
razorpayUtils.setMerchantName('<?php echo $this->getMerchantName(); ?>');
</script>
<?php endif; ?>
18 changes: 9 additions & 9 deletions package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package>
<name>Razorpay_Payments</name>
<version>1.1.2</version>
<version>1.1.3</version>
<stability>beta</stability>
<license>MIT</license>
<channel>community</channel>
Expand All @@ -16,8 +16,8 @@
<email>[email protected]</email>
</author>
</authors>
<date>2016-04-13</date>
<time>06:34:34</time>
<date>2016-04-27</date>
<time>20:40:09</time>
<contents>
<target name="magecommunity">
<dir name="Razorpay">
Expand All @@ -27,16 +27,16 @@
<file hash="3d38f8ba62b42fc4decb7dbc7d4e8e1e" name="Setuputils.php"/>
</dir>
<dir name="Helper">
<file hash="3eb01c681f348c86a4ec3c7dc7855439" name="Data.php"/>
<file hash="862a7cf6dbcb9366db3cec82aa1f5c12" name="Data.php"/>
</dir>
<dir name="Model">
<file hash="894e998fb9cdc2da005e418240ad4e65" name="Paymentmethod.php"/>
<file hash="a0292a6eec7d6edca1eb0e7202ab9fbc" name="Paymentmethod.php"/>
</dir>
<dir name="controllers">
<file hash="e50ee030f720f26ef439a1dc6b8c66f8" name="CheckoutController.php"/>
</dir>
<dir name="etc">
<file hash="ac5ef3a3615dcd41b4fea208aec70276" name="config.xml"/>
<file hash="25576319d03f9d410b507e2d968a7b2f" name="config.xml"/>
<file hash="890c3193ccf85870cb0bd25f31ddf076" name="system.xml"/>
</dir>
</dir>
Expand All @@ -47,7 +47,7 @@
<dir name="base">
<dir name="default">
<dir name="layout">
<file hash="38102684ebb4f6d3896b724632d39171" name="razorpay.xml"/>
<file hash="dc0cba4c3a7fca3d05300a613703f60a" name="razorpay.xml"/>
</dir>
<dir name="template">
<dir name="razorpay">
Expand All @@ -60,8 +60,8 @@
</dir>
</dir>
<file hash="1493e996886160b37b930251f7ac78ce" name="order.phtml"/>
<file hash="fb8f5945e404a55be6c7c86038d6d77b" name="placeorder.phtml"/>
<file hash="a4257d4ba888ce8c8c943e08ac052240" name="setuputils.phtml"/>
<file hash="f4d8d340819b98359a78558e82b92a55" name="placeorder.phtml"/>
<file hash="6a96d6f95747d64b37fb6b848ef13007" name="setuputils.phtml"/>
</dir>
</dir>
</dir>
Expand Down

0 comments on commit 57ab8e4

Please sign in to comment.