简体   繁体   中英

Paypal payment with sandbox accounts, TESTING

I implemented a shopping cart to checkout with PayPal. For a single item, it works, but for multiple items, it does not. Pressing the paypal Pay Now! button I got an error like this => "https://www.sandbox.paypal.com/webapps/shoppingcart/error?flowlogging_id=3451c32fea2df&code= LACK_OF_BASIC_PARAMS " "Things don't appear to be working at the moment. Please try again later." wow, nice! missing something? showing a little code here, '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"); ?>  

Any particular reason you are trying to integrate a form post to /cgi-bin/webscr in 2020? Please use https://developer.paypal.com/demo/checkout/#/pattern/client , or the server version there with two server side routes if you need to record the result in a database.


( If you do need to record the result in a database, you'll need a route for 'Set Up Transaction' and one for 'Capture Transaction', documented here: https://developer.paypal.com/docs/checkout/reference/server-integration/ -- and pair these routes with the above JavaScript approval flow )

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

must be outside of the loop! END of it! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM