I have created custom payment gateway to redirect user to an external link where payment will be processed. This is the redirect.phtml which redirect to the external payment gateway

$order = new Mage_Sales_Model_Order();
$customer = new Mage_Customer_Model_Customer();

$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$customer = Mage::getSingleton('customer/session')->getCustomer();

$orderData = Mage::getModel('sales/order')->loadByIncrementId($orderId);

$orderDetails = $order->getData();   // order details
$shippingAddress = $order->getShippingAddress();

$_SESSION['dataArray']['names'] = $orderDetails['customer_lastname']." ".$orderDetails['customer_firstname']." ".$orderDetails['customer_middlename'];
$_SESSION['dataArray']['amount'] = $orderData->getGrandTotal();

  <div class = "row">

    <form name="mygatewayform" class="form-horizontal" method="post" action="<!-- my payment gateway -->"> 
       <input type="hidden" name="merchantid" value="376" />
     <input type="hidden" name="phone_number" value="<?php echo $shippingAddress->getTelephone(); ?>" />

      <input type="hidden" name="orderId" value="<?php echo $orderId; ?>">
      <input type="hidden" name="merch_txnref" value="<?php echo time()."_".$orderId; ?>">
      <input type="hidden" name="amount" value="<?php echo round($orderData->getGrandTotal(), 2); ?>">
      <input type="hidden" name="email_address" value="<?php echo $orderDetails['customer_email'] ?>">
      <input type="hidden" name="last-name" value="<?php echo $orderDetails['customer_lastname'] ?>" > 

      <input type="hidden" name ="other-names" value="<?php echo $orderDetails['customer_firstname']." ".$orderDetails['customer_middlename'] ?>">
      <input type="hidden" name="currency" value="<?php echo $orderData->getOrderCurrencyCode(); ?>">

 <script type="text/javascript">

As you can see I have been able to generate

  1. Order Id
  2. Customer Name
  3. Grand Total Amount
  4. Currency


How can i generate the product(s) ordered by the customer, because I need to use it my payment gateway


2 Answers 2


you can get product details from order object as follows:-

$order = Mage::getModel('sales/order')->load($orderId);
foreach($order->getAllVisibleItems() as $item){
    echo $item->getName();
  • Thanks For this. Please how can i add it to the form above so that it can be processed in my payment gateway .. Rgeards
    – codePhree
    Commented Jul 23, 2016 at 10:03

Try this :

$product = Mage::registry('current_product'); then

You can try this for product :

$id = $this->getRequest()->getParam('id');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.