【发布时间】:2021-01-30 09:12:25
【问题描述】:
我实现了一个购物车以使用 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"); ?>
【问题讨论】: