我实施了一个购物车以使用PayPal结帐。对于单个项目,它起作用,但是对于多个项目,它不起作用。按贝宝立即付款!按钮,我收到这样的错误=>“ https://www.sandbox.paypal.com/webapps/shoppingcart/error?flowlogging_id=3451c32fea2df&code= LACK_OF_BASIC_PARAMS ” “目前看来一切都没有发生。请稍后再试。” 喔,不错!遗漏了什么?在此处显示一些代码“ checkout.php”:
<?php require_once('../resources/includes/initialize.php'); ?>
<?php
$products = Product::find_product_items();
$count = count($products);
$items = 0;
$total = 0;
?>
<?php include(TEMPLATE_FRONT.DS."header.php"); ?>
<!-- Page Content -->
<div class="container">
<!-- /.row -->
<div class="row">
<h1>Checkout</h1>
<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<table id="myTable" class="table table-striped">
<thead>
<tr>
<th>ID</th>
<th>Product</th>
<th>Price</th>
<th>Quantity</th>
<th>Sub-total</th>
</tr>
</thead>
<?php
$i = 0;
foreach($products as $product){
$i = ++$i;
?>
<tbody id="<?php echo "t".$i ?>">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="agardo@business.example.com">
<input type="hidden" name="item_name_<?php echo $i; ?>" value="<?php echo $product->title; ?>">
<input type="hidden" name="item_number_<?php echo $i; ?>" value="<?php echo $product->id; ?>">
<input type="hidden" name="quantity_<?php echo $i; ?>" value="<?php echo $product->quantity; ?>">
<input type="hidden" name="amount_<?php echo $i; ?>" value="<?php echo $product->price; ?>">
<input type="hidden" name="currency_code_<?php echo $i; ?>" value="USD">
<!--<input type="hidden" name="return" value="https://localhost/public/thank_you.php">-->
<tr>
<td><?php echo $product->id; ?></td>
<td><?php echo $product->title; ?></td>
<td id="<?php echo "p".$i ?>"><?php echo "$".format_number($product->price); ?></td>
<td id="<?php echo "q".$i ?>"><?php echo $product->quantity; ?></td>
<td id="<?php echo "s_t".$i ?>"><?php echo "$".format_number($product->price*$product->quantity); ?></td>
<td>
<span class="btn btn-warning glyphicon glyphicon-minus" data-id="<?php echo $product->id; ?>"></span>
<span class="btn btn-success glyphicon glyphicon-plus" data-id="<?php echo $product->id; ?>"></span>
<span class="btn btn-danger glyphicon glyphicon-remove" data-id="<?php echo $product->id; ?>"></span>
</td>
</tr>
</tbody>
<?php $items+=$product->quantity;
$total+=$product->price*$product->quantity;
} ?>
</table>
<input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!">
</form>
<!-- ***********CART TOTALS*************-->
<div class="col-xs-4 pull-right ">
<h2>Cart Totals</h2>
<table class="table table-bordered" cellspacing="0">
<tr class="cart-subtotal">
<th>Items:</th>
<td><span id="count" class="amount"><?php echo $items; ?></span></td>
</tr>
<tr class="shipping">
<th>Shipping and Handling</th>
<td>Free Shipping</td>
</tr>
<tr class="order-total">
<th>Order Total</th>
<td><strong><span id="total" class="amount"><?php echo "$".format_number($total); ?></span></strong> </td>
</tr>
</tbody>
</table>
</div><!-- CART TOTALS-->
</div><!--Main Content-->
<?php include(TEMPLATE_FRONT.DS."footer.php"); ?>
答案 0 :(得分:0)
您是否有特定原因要在2020年将表单发布整合到/cgi-bin/webscr
中?如果您需要将结果记录在数据库中,请使用https://developer.paypal.com/demo/checkout/#/pattern/client或带有两个服务器端路由的服务器版本。
((如果您确实需要将结果记录在数据库中,则需要一个用于“设置交易”的路由和一个用于“捕获交易”的路由,在此处记录:https://developer.paypal.com/docs/checkout/reference/server-integration/-并配对这些路由上面的JavaScript批准流程)
答案 1 :(得分:0)
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="agardo@business.example.com">
必须在循环之外!到此为止! :)