Skip to content

Commit

Permalink
Add FireCheckout support (#7)
Browse files Browse the repository at this point in the history
* Add FireCheckout support

* Remove unnecessary variables
  • Loading branch information
73SL4 committed Apr 13, 2016
1 parent e061fb9 commit 10a8227
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 16 deletions.
8 changes: 4 additions & 4 deletions 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 = '0.2.0';
const VERSION = '0.2.2';

protected $_code = self::METHOD_CODE;
protected $_canOrder = true;
Expand All @@ -30,7 +30,7 @@ public function __construct()

/**
* Authorizes specified amount
*
*
* @param Varien_Object $payment
* @param decimal $amount
*/
Expand All @@ -41,7 +41,7 @@ public function authorize(Varien_Object $payment, $amount)

/**
* Captures specified amount
*
*
* @param Varien_Object $payment
* @param decimal $amount
* @return Razorpay_Payments_Model_Paymentmethod
Expand Down Expand Up @@ -92,7 +92,7 @@ public function capture(Varien_Object $payment, $amount)

/**
* Format param "channel" for transaction
*
*
* @return string
*/
public function _getChannel()
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>0.2.0</version>
<version>0.2.2</version>
</Razorpay_Payments>
</modules>
<global>
Expand Down
25 changes: 25 additions & 0 deletions app/design/frontend/base/default/layout/razorpay.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,29 @@
</reference>
</opc_index_index>
<!-- Compatibility with Iwd_Opc extension end-->
<!-- Compatibility with FireCheckout extension start-->
<firecheckout_index_index>
<reference name="head">
<block type="core/text" name="razorpay.checkout">
<action method="setText">
<text>
<![CDATA[<script type="text/javascript" src="https://checkout.razorpay.com/v1/checkout.js"></script>]]>
</text>
</action>
</block>
<action method="addJs"><file>razorpay/razorpay-utils.js</file></action>
</reference>
<reference name="before_body_end">
<block type="razorpay_payments/setuputils" name="razorpay_payments_setuputils" template="razorpay/setuputils.phtml" />
</reference>
<reference name="before_body_end">
<block type="core/template" name="razorpay_placeorder_firecheckout" template="razorpay/extensions/firecheckout/payments.phtml">
<action method="setData">
<key>form_id</key>
<value>co-payment-form</value>
</action>
</block>
</reference>
</firecheckout_index_index>
<!-- Compatibility with FireCheckout extension end-->
</layout>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php $helper = Mage::helper('razorpay_payments'); ?>
<?php if ($helper->isRazorpayEnabled()) : ?>
<?php $code = Razorpay_Payments_Model_Paymentmethod::METHOD_CODE ; ?>
<script type="text/javascript">
var formId = 'firecheckout-form';
var paymentIdField = 'razorpay_payment_id';
var nativeButton = $$('#review-buttons-container .btn-checkout').first();

// Change native extension place order button onclick
nativeButton.setAttribute('onclick', 'processRazorpayOrder()');

// Click extension "place order" button
var processNativeExtensionOrder = function(){
nativeButton.show();

checkout.save();
};

var showErrorMessage = function(message){
alert(message);

nativeButton.show();
};

var processRazorpayOrder = function() {
if (payment.currentMethod == '<?php echo $code ?>') {

if (razorpayUtils.isOrderSet()) {
placeRazorpayOrder();
} else {
razorpayUtils.createOrder(placeRazorpayOrder, showErrorMessage);
}
} else {
processNativeExtensionOrder();
}
};

var placeRazorpayOrder = function() {
var onUserClose = function() {
nativeButton.disabled = false;
nativeButton.show();
};

var onSuccess = function(data) {
$(paymentIdField).value = data.razorpay_payment_id;

processNativeExtensionOrder();
};

var beforeStart = function() {
nativeButton.disabled = true;
};

razorpayUtils.placeOrder(
onSuccess,
onUserClose,
beforeStart,
formId,
paymentIdField
);
};
</script>
<?php endif; ?>
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@
// Payment method is Razorpay Credit Card
IWD.OPC.Checkout.showLoader();

var $paymentId = $(paymentIdField);

var captureOrder = $paymentId && ($paymentId.value != '');

if (razorpayUtils.isOrderSet()) {
placeRazorpayOrder();
} else {
Expand Down
17 changes: 10 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>0.2.1</version>
<version>0.2.2</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-09</date>
<time>17:36:04</time>
<date>2016-04-13</date>
<time>06:34:34</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="0fbad0dbec0c8dcf1d597a4a3d15b1c7" name="Paymentmethod.php"/>
<file hash="894e998fb9cdc2da005e418240ad4e65" name="Paymentmethod.php"/>
</dir>
<dir name="controllers">
<file hash="e50ee030f720f26ef439a1dc6b8c66f8" name="CheckoutController.php"/>
</dir>
<dir name="etc">
<file hash="2686b409f17d4c9466fa0efc7f8d00b3" name="config.xml"/>
<file hash="ac5ef3a3615dcd41b4fea208aec70276" name="config.xml"/>
<file hash="890c3193ccf85870cb0bd25f31ddf076" name="system.xml"/>
</dir>
</dir>
Expand All @@ -47,13 +47,16 @@
<dir name="base">
<dir name="default">
<dir name="layout">
<file hash="c0098eef0d3e3571a97834c9cdfd90d5" name="razorpay.xml"/>
<file hash="38102684ebb4f6d3896b724632d39171" name="razorpay.xml"/>
</dir>
<dir name="template">
<dir name="razorpay">
<dir name="extensions">
<dir name="firecheckout">
<file hash="b792a741e5e8839202e93e6b9442b58b" name="payments.phtml"/>
</dir>
<dir name="iwd_opc">
<file hash="b5525d043934d55eda8bfb90a89efcd9" name="payments.phtml"/>
<file hash="48fec536ebfee1dbe0c48c208f41b5c8" name="payments.phtml"/>
</dir>
</dir>
<file hash="1493e996886160b37b930251f7ac78ce" name="order.phtml"/>
Expand Down

0 comments on commit 10a8227

Please sign in to comment.