Skip to content

Commit

Permalink
Add multiple currency support (#12)
Browse files Browse the repository at this point in the history
* Add multiple currency support

* Add display currency and amount from quote currency and amount

* Fix conflict where quote currency and base currency were both INR
  • Loading branch information
73SL4 committed May 13, 2016
1 parent dd09bd4 commit 03511c9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
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.6';
const VERSION = '1.1.7';

protected $_code = self::METHOD_CODE;
protected $_canOrder = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ protected function _expireAjax()

public function orderAction()
{
$amount = (int) ((float) $this->_getQuote()->getGrandTotal())*100;
$amount = (int) ((float) $this->_getQuote()->getBaseGrandTotal())*100;
$base_currency = $this->_getQuote()->getBaseCurrencyCode();
$quote_currency = $this->_getQuote()->getQuoteCurrencyCode();
$quote_amount = round($this->_getQuote()->getGrandTotal(), 2);

$orderId = $this->_getQuote()->getReservedOrderId();

Expand All @@ -35,7 +38,10 @@ public function orderAction()
$responseArray['customer_phone'] = $bA->getTelephone() ?: '';
$responseArray['order_id'] = $orderId;
$responseArray['amount'] = $amount;
$responseArray['currency'] = $base_currency;
$responseArray['customer_email'] = $this->_getQuote()->getData('customer_email') ?: '';
$responseArray['quote_currency'] = $quote_currency;
$responseArray['quote_amount'] = $quote_amount;

$this->getResponse()
->setHttpResponseCode(200)
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.6</version>
<version>1.1.7</version>
</Razorpay_Payments>
</modules>
<global>
Expand Down
7 changes: 7 additions & 0 deletions js/razorpay/razorpay-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ RazorpayUtils.prototype = {
key: this.keyId,
name: this.merchantName,
amount: this.orderInfo.amount,
currency: this.orderInfo.currency,
handler: onSuccess,
order_id: this.orderInfo.razorpay_order_id,
modal: {
Expand All @@ -91,6 +92,12 @@ RazorpayUtils.prototype = {
}
};

if (this.orderInfo.quote_currency !== 'INR')
{
options.display_amount = this.orderInfo.quote_amount;
options.display_currency = this.orderInfo.quote_currency;
}

checkout = new Razorpay(options);

checkout.open();
Expand Down
14 changes: 7 additions & 7 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.6</version>
<version>1.1.7</version>
<stability>beta</stability>
<license>MIT</license>
<channel>community</channel>
Expand All @@ -16,8 +16,8 @@
<email>[email protected]</email>
</author>
</authors>
<date>2016-05-05</date>
<time>07:25:18</time>
<date>2016-05-11</date>
<time>11:53:33</time>
<contents>
<target name="magecommunity">
<dir name="Razorpay">
Expand All @@ -30,13 +30,13 @@
<file hash="3eb01c681f348c86a4ec3c7dc7855439" name="Data.php"/>
</dir>
<dir name="Model">
<file hash="044b94ddc09ff4bab47dad25bfe84326" name="Paymentmethod.php"/>
<file hash="4c693ef5311d70d0998c792f3b930580" name="Paymentmethod.php"/>
</dir>
<dir name="controllers">
<file hash="5d119068ed59ebe6bc27ff235762cb2c" name="CheckoutController.php"/>
<file hash="7301af9c32af7570f9624ef58c42fec8" name="CheckoutController.php"/>
</dir>
<dir name="etc">
<file hash="d2ea53be9c50e6888d5d86737ea41b67" name="config.xml"/>
<file hash="4f0d6043f7dd79a8ba0fb893e5941354" name="config.xml"/>
<file hash="890c3193ccf85870cb0bd25f31ddf076" name="system.xml"/>
</dir>
</dir>
Expand Down Expand Up @@ -79,7 +79,7 @@
<target name="mage">
<dir name="js">
<dir name="razorpay">
<file hash="0e0cc3ec6b477a1fb397951141f1ca35" name="razorpay-utils.js"/>
<file hash="a5140a7b8b2caf66d6e148f590b96ba7" name="razorpay-utils.js"/>
</dir>
</dir>
</target>
Expand Down

0 comments on commit 03511c9

Please sign in to comment.