【问题标题】:Paypal payment with sandbox accounts, TESTINGPaypal 支付沙盒账户,测试
【发布时间】: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 "&#36;".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 "&#36;".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 "&#36;".format_number($total); ?></span></strong> </td>
</tr>


</tbody>

</table>

</div><!-- CART TOTALS-->


 </div><!--Main Content-->


    <?php include(TEMPLATE_FRONT.DS."footer.php"); ?>  

【问题讨论】:

    标签: php html paypal


    【解决方案1】:

    您尝试在 2020 年将表单帖子集成到 /cgi-bin/webscr 的任何特殊原因?如果您需要将结果记录到数据库中,请使用 https://developer.paypal.com/demo/checkout/#/pattern/client 或带有两个服务器端路由的服务器版本。


    (如果您确实需要将结果记录在数据库中,则需要一条用于“设置事务”的路由和一个用于“捕获事务”的路由,此处记录:https://developer.paypal.com/docs/checkout/reference/server-integration/ - 并将这些路由与以上 JavaScript 审批流程)

    【讨论】:

      【解决方案2】:
              <input type="hidden" name="cmd" value="_cart">
              <input type="hidden" name="upload" value="1">
              <input type="hidden" name="business" value="agardo@business.example.com">
      

      必须在循环之外!结束吧! :)

      【讨论】:

        猜你喜欢
        • 2013-08-31
        • 2015-07-11
        • 2013-02-28
        • 2017-03-24
        • 2015-03-25
        • 2018-03-26
        • 2011-12-10
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多