簡體   English   中英

使用沙盒帳戶進行 Paypal 付款,正在測試

[英]Paypal payment with sandbox accounts, TESTING

我實現了一個購物車來使用 PayPal 結賬。 對於單個項目,它有效,但對於多個項目,它不起作用。 按 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"); ?>  

您在 2020 年嘗試將表單發布集成到/cgi-bin/webscr任何特殊原因? 如果您需要將結果記錄在數據庫中,請使用https://developer.paypal.com/demo/checkout/#/pattern/client ,或者那里有兩個服務器端路由的服務器版本。


(如果您確實需要將結果記錄在數據庫中,則需要一條用於“設置交易”的路線和一條用於“捕獲交易”的路線,記錄在此處: https : //developer.paypal.com/docs/checkout/參考/服務器集成/ - 並將這些路由與上述 JavaScript 批准流程配對)

        <input type="hidden" name="cmd" value="_cart">
        <input type="hidden" name="upload" value="1">
        <input type="hidden" name="business" value="agardo@business.example.com">

必須在循環之外! 到此為止! :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM