1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
26: class Mage_Paypal_Block_Standard_Redirect extends Mage_Core_Block_Abstract
27: {
28: protected function _toHtml()
29: {
30: $standard = Mage::getModel('paypal/standard');
31:
32: $form = new Varien_Data_Form();
33: $form->setAction($standard->getConfig()->getPaypalUrl())
34: ->setId('paypal_standard_checkout')
35: ->setName('paypal_standard_checkout')
36: ->setMethod('POST')
37: ->setUseContainer(true);
38: foreach ($standard->getStandardCheckoutFormFields() as $field=>$value) {
39: $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
40: }
41: $idSuffix = Mage::helper('core')->uniqHash();
42: $submitButton = new Varien_Data_Form_Element_Submit(array(
43: 'value' => $this->__('Click here if you are not redirected within 10 seconds...'),
44: ));
45: $id = "submit_to_paypal_button_{$idSuffix}";
46: $submitButton->setId($id);
47: $form->addElement($submitButton);
48: $html = '<html><body>';
49: $html.= $this->__('You will be redirected to the PayPal website in a few seconds.');
50: $html.= $form->toHtml();
51: $html.= '<script type="text/javascript">document.getElementById("paypal_standard_checkout").submit();</script>';
52: $html.= '</body></html>';
53:
54: return $html;
55: }
56: }
57: