付款网关向我提供了此代码,该代码旨在集成到付款页面中:
Please replace these items with the appropriate data:
• with the ID auto-generated by Gateway for the merchant.
• with the input field of the transaction amount.
• with the input field of the order id.
• with the input field of the product name.
• with the input field of the customer email.
示例:
<input type="hidden" name="mercId" value="">
<input type="hidden" name="currCode" value="">
<input type="hidden" name="amt" value="">
<input type="hidden" name="orderId" value="">
<input type="hidden" name="prod" value="">
<input type="hidden" name="email" value="">
然后我尝试将其合并到正在运行的redirect.phtml中。
<?php
// Retrieve order
$_order = new Mage_Sales_Model_Order();
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$_order->loadByIncrementId($orderId);
?>
<form name="mygatewayform" method="post" action="https://sample.com/MerchantServices/MakePayment.aspx">
<input type="hidden" name="orderId" value="<?php echo $orderId; ?>">
<input type="hidden" name="amt" value="<?php echo $_order->getBaseGrandTotal(); ?>">
<input type="hidden" name="mercId" value="05430">
<input type="hidden" name="prod" value="BLACKBERRY BLACK SKIN WHITE">
<input type="hidden" name="email" value="<?php echo $_order->getCustomerEmail(); ?>">
</form>
<script type="text/javascript">
document.mygatewayform.submit();
</script>
但每次我尝试插入客户以编程方式购买的产品名称<?php echo $productname = $item->getName(); ?>
都不会将我重定向到付款网关页面,它将停在www.domain.com/index.php/上mygateway /支付/重定向/。这是我尝试过的,它没有重新定向。
<?php
// Retrieve order
$_order = new Mage_Sales_Model_Order();
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
$_order->loadByIncrementId($orderId);
?>
<form name="mygatewayform" method="post" action="https://sample.com/MerchantServices/MakePayment.aspx">
<input type="hidden" name="orderId" value="<?php echo $orderId; ?>">
<input type="hidden" name="amt" value="<?php echo $_order->getBaseGrandTotal(); ?>">
<input type="hidden" name="mercId" value="05430">
<input type="hidden" name="prod" value="<?php echo $productname = $item->getName(); ?>">
<input type="hidden" name="email" value="<?php echo $_order->getCustomerEmail(); ?>">
</form>
<script type="text/javascript">
document.mygatewayform.submit();
</script>
有些人可以告诉我我做错了什么,或者更确切地说如何插入产品名称和信息或将其调入redirect.phtml页面?
由于
答案 0 :(得分:0)
我不确定这段代码是否可以解决您的问题,但如果没有记错,getName()
功能不起作用的原因是$item
。
首先,您应该加载购物车中可用的商品。
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
// then loop on items
foreach ($items as $item) {
echo $item->getName().'<br />';
}