Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Payment Gateway page in a iframe
 
BinaryBird
Jr. Member
 
Total Posts:  27
Joined:  2011-05-17
 

Hi, i managed to integrate a 3rd party paymentgateway into magento. After clicking on the place order button in checkout page, the user is redirected to the payment gateway page on a form submit and depending on the success or failure response the user is redirected back to the site. Now i want to display the payment gateway in a iframe. I tried to something like this, but its not working. Could some one guide me as to how i get this working?

Here is my Redirect.php block which gets called on clicking the place order button in the checkout page

<?php

class Foostor_Direcpay_Block_Redirect extends Mage_Core_Block_Template
{
    
//Mage::log("Entering Redirect Block Page");
    
protected function _toHtml()
    
{
        Mage
::log("Entering _toHtml()");
        
$standard Mage::getModel('direcpay/standard');
        
$successurl 'http://localhost/magento/index.php/direcpay/standard/successResponse';
        
$failureurl 'http://localhost/magento/index.php/direcpay/standard/failureResponse';
        
$cmporder $standard->setOrder($this->getOrder())->getStandardCheckoutFormFields() ;
        
        
$reqparamvalue '200904281000001|DOM|IND|INR|'.$cmporder['AMOUNT'].'|'.$cmporder['ORDERID'].'06222011'.'|others|'.$successurl.'|'.$failureurl.'|TOML';
        
Mage::log("Requestparameter value is:".$reqparamvalue);
        
$form = new Varien_Data_Form();
        
//$form->setAction($standard->getDirecpayUrl())
          
$form->setId('worldnettps_checkout')
            ->
setName('worldnettps_checkout')
            ->
setMethod('POST')
            ->
setOnsubmit('encodeTxnRequest();')
            ->
setUseContainer(true);
        
/*
        foreach ($standard->setOrder($this->getOrder())->getStandardCheckoutFormFields() as $field => $value) {
            $form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
        }
        */
        
        
$form->addField('requestparameter''hidden', array('name' => 'requestparameter''value' => $reqparamvalue));
        
$form->addField('custName''hidden', array('name' => 'custName''value' => 'Nithin'));
        
$form->addField('custAddress''hidden', array('name' => 'custAddress''value' => '29 E'));
        
$form->addField('custCity''hidden', array('name' => 'custCity''value' => 'Bangalore'));
        
$form->addField('custState''hidden', array('name' => 'custState''value' => 'Karnataka'));
        
$form->addField('custPinCode''hidden', array('name' => 'custPinCode''value' => '560052'));
        
$form->addField('custCountry''hidden', array('name' => 'custCountry''value' => 'IN'));
        
$form->addField('custPhoneNo1''hidden', array('name' => 'custPhoneNo1''value' => '91'));
        
$form->addField('custPhoneNo2''hidden', array('name' => 'custPhoneNo2''value' => '080'));
        
$form->addField('custPhoneNo3''hidden', array('name' => 'custPhoneNo3''value' => '23510619'));
        
$form->addField('custMobileNo''hidden', array('name' => 'custMobileNo''value' => '9886990619'));
        
$form->addField('custEmailId''hidden', array('name' => 'custEmailId''value' => 'thefornax@gmail.com'));
        
$form->addField('otherNotes''hidden', array('name' => 'otherNotes''value' => 'Test transaction for direcpay'));
        
$form->addField('submit','submit',array('name' => 'submit''value' => 'Submit'));
        
$html '<html>
        <head>
        <script src="../../../../js/direcpay/dpEncodeRequest.js">
        </script>
        <script>
        function encodeTxnRequest()
        {
            document.worldnettps_checkout.requestparameter.value = encodeValue(document.worldnettps_checkout.requestparameter.value);
            
            document.getElementById(\'
frame\').src = \''.$standard->getDirecpayUrl().'\';
            #document.worldnettps_checkout.submit();
            
        }
        </script>
        </head>
        <body>'
;
        
$html.= $this->__('You will be redirected to Direcpay in a few seconds.');
        
/*
        foreach ($standard->setOrder($this->getOrder())->getStandardCheckoutFormFields() as $field => $value) {
            $form->addField($field, 'hidden', array('name' => $field, 'value' => $value));
            echo $field . '->' . $value .'<br/>';
        }
        */
        
$html.= $form->toHtml();
        
//$html.= '<script type="text/javascript">document.getElementById("worldnettps_checkout").submit();</script>';
        
$html.='<iframe id="frame" name="my_iframe" src="" width="100%" height="300"></iframe>';
        
$html.= '</body></html>';
        return 
$html;
    
}
}

Thanks.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top