Add Stripe support
To add Stripe payment method support you would need to edit two files
- app/code/community/TemplateTag/Stripe/Model/Observer.php . Open this file up and replace the method addJsToFrontendCheckout with this
public function addJsToFrontendCheckout(Varien_Event_Observer $observer)
{
$targetBlocks = array(
Mage::getConfig()->getBlockClassName('checkout/onepage_payment'),
Mage::getConfig()->getBlockClassName('onestepcheckout/checkout')
);
$block = $observer->getBlock();
$blockClass = get_class($block);
if (Mage::Helper('stripe')->getActive()) {
if (in_array($blockClass,$targetBlocks) ) {
$transport = $observer->getTransport();
$html = $transport->getHtml();
$extra = $block->getLayout()
->createBlock('core/template')
->setTemplate('stripe/javascript.phtml')
->toHtml();
$transport->setHtml($extra . $html);
}
}
}
- open up app/design/frontend/base/default/template/onestepcheckoutcheckout.phtml and replace
/* Submit the form */
$('onestepcheckout-form').submit();
with
if(payment.currentMethod == 'stripe'){
payment.save();
Event.stop(e);
} else {
/* Submit the form */
$('onestepcheckout-form').submit();
}
in same file just before
// This is a separate page
add this
payment.stripeResponse = payment.stripeResponse.wrap(function($super, status, response){
if (response.error) {
alert(response.error.message);
loaderelement.remove();
submitelement.removeClassName('grey').addClassName('orange');
submitelement.disabled = false;
already_placing_order = false;
} else {
$(TemplateTag.Stripe.MethodCode+'_token').value = response['id'];
$('onestepcheckout-form').submit();
}
});