Add Payone support
LATEST VERSION
- open up app/design/frontend/base/default/layout/payone/core.xml and make all the things that are referenced to checkout_onepage_index to onestepcheckout_index_index. easiest way is to make a copy of checkout_onepage_index and rename the parent tags
<pre>
<onestepcheckout_index_index>
<reference name="head">
..
</reference>
<reference name="head">
..
</reference>
<reference name="checkout.payment.methods">
...
</reference>
</onestepcheckout_index_index>
</pre>
- next step is to add ajax event listener to checkout.phtml template to spy on ipayment ajax calls in app/design/frontend/base/default/template/onestepcheckout/checkout.phtml by replacing the following (search for !already_placing_order to find the right place)
/* Submit the form */
$('onestepcheckout-form').submit();
with
if(payment.currentMethod == 'payone_creditcard'){
Ajax.Responders.register({
onComplete: function(event) {
if(event.parameters["payment[method]"]=='payone_creditcard'){
$('onestepcheckout-form').submit();
}
}
});
loaderelement.remove();
submitelement.removeClassName('grey').addClassName('orange');
submitelement.disabled = false;
already_placing_order = false;
payment.save();
Event.stop(e);
} else {
/* Submit the form */
$('onestepcheckout-form').submit();
}
OLDER PAYONE VERSIONS
To enable Ipayment cc support in OneStepCheckout you need to :
- add ipayment references to onestepcheckout_index_index in app/design/frontend/base/default/layout/onestepcheckout.xml. You can copy the references from app/design/frontend/base/default/layout/ipayment.xml and add them as follows by replacing (serach for to find the right place):
<reference name="head">
....
<action method="addJs" ifconfig="payment/payone_cc/active"><script>phoenix/payone/processing.js</script></action>
.....
</reference>
<reference name="content">
<block type="payone/jsinclude" name="payone_jsinclude" template="payone/jsinclude.phtml"/>
....
- next step is to add ajax event listener to checkout.phtml template to spy on ipayment ajax calls in app/design/frontend/base/default/template/onestepcheckout/checkout.phtml by replacing the following (search for !already_placing_order to find the right place)
if(!already_placing_order) {
already_placing_order = true;
var submitelement = $('onestepcheckout-place-order');
var loaderelement = new Element('div').
addClassName('onestepcheckout-place-order-loading').
update('<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif'); ?>" /> <?php echo $this->__('Please wait, processing your order...'); ?>');
submitelement.parentNode.appendChild(loaderelement);
/* Disable button to avoid multiple clicks */
submitelement.removeClassName('orange').addClassName('grey');
submitelement.disabled = true;
/* Submit the form */
$('onestepcheckout-form').submit();
}
with
if(!already_placing_order) {
already_placing_order = true;
var submitelement = $('onestepcheckout-place-order');
var loaderelement = new Element('div').
addClassName('onestepcheckout-place-order-loading').
update('<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif'); ?>" /> <?php echo $this->__('Please wait, processing your order...'); ?>');
submitelement.parentNode.appendChild(loaderelement);
/* Disable button to avoid multiple clicks */
submitelement.removeClassName('orange').addClassName('grey');
submitelement.disabled = true;
if(payment.currentMethod == 'payone_cc'){
Ajax.Responders.register({
onComplete: function(event) {
if(event.parameters["payment[method]"]=='payone_cc'){
$('onestepcheckout-form').submit();
}
}
});
loaderelement.remove();
submitelement.removeClassName('grey').addClassName('orange');
submitelement.disabled = false;
already_placing_order = false;
payment.save();
Event.stop(e);
} else {
/* Submit the form */
$('onestepcheckout-form').submit();
}
}