PayPal IPN - 在打开paypal网站之前重定向页面

时间:2016-11-24 20:11:33

标签: javascript php html security paypal

有人可以帮我修一下paypal表单问题,一旦点击提交,需要重定向到paypal.php然后去paypal网站付款。问题是,在这样做时,paypel网站中的付款值为空,并且没有显示产品名称和价格。

提前谢谢!

的index.php



<?
$products = $mysqli->query("SELECT * FROM `product` WHERE `id` > '0' ORDER BY `price` ASC");
for($j=1; $product = $products->fetch_assoc(); $j++){
?>							
<?
	if(isset($_POST['submit'])){
			redirect_to('functions/paypal/paypal.php');
		}
?>
		<form method="post">
                    	<tr style="border-bottom:1px solid #f2f3f6;">
                        	<td><?=$product['name'];?></td>
                            <td><?=$product['price'];?></td>
                            <td><input type="submit" value="Buy" name="submit" /></td>
                        </tr>
		</form>
<?}?>
&#13;
&#13;
&#13;

paypal.php表格

&#13;
&#13;
<?
require('functions/db.php');
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head><title>redirect to paypal service..</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<script type="text/javascript">
	setTimeout('document.formpaypal.submit()',1000);
</script>
</head>
<body>
<form name="formpaypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="<?=$sites['paypal']?>">
<input type="hidden" name="item_name" value="<?=$product['name'];?>">
<input type="hidden" name="custom" value="<?=$data['id'];?>">
<input type="hidden" name="amount" value="<?=$product['price'];?>">
<input type="hidden" name="currency_code" value="USD">
<input type="hidden" name="button_subtype" value="services">
<input type="hidden" name="no_note" value="1">
<input type="hidden" name="no_shipping" value="2">
<input type="hidden" name="rm" value="1">
<input type="hidden" name="return" value="index.php?success">
<input type="hidden" name="cancel_return" value="index.php?cancel">
<input type="hidden" name="notify_url" value="funtions/paypal/ipn.php">
</form>
</body>
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

你在paypal.php中所做的事情应该只在index.php中完成。您可以直接在索引中构建付款表单,当他们从那里点击提交时,它会将它们直接发送到PayPal。不需要“中间人”剧本。