Forked from millejano/Mage_Paypal_Block_Standard_Redirect
Created
November 7, 2013 15:12
-
-
Save federivo/7356222 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Mage_Paypal_Block_Standard_Redirect extends Mage_Core_Block_Abstract | |
{ | |
protected function _toHtml() | |
{ | |
$standard = Mage::getModel('paypal/standard'); | |
$form = new Varien_Data_Form(); | |
$form->setAction($standard->getConfig()->getPaypalUrl()) | |
->setId('paypal_standard_checkout') | |
->setName('paypal_standard_checkout') | |
->setMethod('POST') | |
->setUseContainer(true); | |
foreach ($standard->getStandardCheckoutFormFields() as $field=>$value) { | |
$form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value)); | |
} | |
$idSuffix = Mage::helper('core')->uniqHash(); | |
$submitButton = new Varien_Data_Form_Element_Submit(array( | |
'value' => $this->__('Click here if you are not redirected within 10 seconds...'), | |
)); | |
$id = "submit_to_paypal_button_{$idSuffix}"; | |
$submitButton->setId($id); | |
$form->addElement($submitButton); | |
// $html = '<html><body>'; | |
$html = ''; | |
$html.= $this->__('You will be redirected to the PayPal website in a few seconds.'); | |
$html.= $form->toHtml(); | |
$html.= '<script type="text/javascript">document.getElementById("paypal_standard_checkout").submit();</script>'; // uncomment to style view | |
// $html.= '</body></html>'; | |
return $html; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* When a customer chooses Paypal on Checkout/Payment page | |
* | |
*/ | |
public function redirectAction() | |
{ | |
$session = Mage::getSingleton('checkout/session'); | |
$session->setPaypalStandardQuoteId($session->getQuoteId()); | |
// + core hack to load template layout @ 2012-08-17 | |
// $this->getResponse()->setBody($this->getLayout()->createBlock('paypal/standard_redirect')->toHtml()); // not needed | |
// load layout from paypal.xml | |
$this->loadLayout(); | |
// redner layout | |
$this->renderLayout(); | |
// = core hack to load template layout @ 2012-08-17 | |
$session->unsQuoteId(); | |
$session->unsRedirectUrl(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<paypal_standard_redirect translate="label"> | |
<reference name="root"> | |
<action method="setTemplate"><template>page/1column.phtml</template></action> | |
</reference> | |
<reference name="content"> | |
<block type="paypal/standard_redirect" name="paypal.standard.redirect" /> | |
</reference> | |
</paypal_standard_redirect> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment