Jump to content

passing variables to paypal


Lassie

Recommended Posts

I am trying to link my cart to paypal.

I have successffully done this passing the total value of the cart.

I now want to pass the individual line items and prices.

 

These are required to be passsed as form variables.

These are in the form of

item_name_1

amount_1

item_name_2

amount_2 etc for all the items in the cart.

 

For this I have the following function.

 


function display_pp_form($name,$email, $Cheque = true)
{
?>
  <table border = 0 width = '700' cellspacing = 0 align = center>
  <tr><th colspan = 2 bgcolor="#cccccc">Thank you <?php echo "$name";?></br>"If you wish to pay by CREDIT CARD
  please click on the the PayPal logo and you will be transferred to a secure processing center.</br>
  If you wish to pay by CHEQUE, please choose the cheque button.</br>
  </th></tr>
  <tr><td>
  
  <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="business" value="[email protected]">
<?php
		$fld_idx = 1;

		foreach ($cart as $product_id => $qty)
  {
    		$book = get_book_details($product_id);

    		echo '<input type="hidden" name="item_name_' . $fld_idx . '" value="' . $book["title"] . '">';
    		echo '<input type="hidden" name="amount_' . $fld_idx . '" value="' . $book["price"] . '">';

    		$fld_idx++;
  }
?>
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="amount" value="<?php echo $_SESSION['total_price'] ?>">
<input type="hidden" name="custom" value="<?php echo $name ?>">
//<input type="hidden" name="email" value="<?php echo $email ?>">
<input type="image" src="images/paypal.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" align="center">
</form>
  

 

The problem is that I get an invalid argument error and no values are passed to the paypal site.

Warning: Invalid argument supplied for foreach() in c:\easyserv\www\e_cart12\display_fns.php on line 500

 

How can I debug the form?

 

 

Link to comment
https://forums.phpfreaks.com/topic/47549-passing-variables-to-paypal/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.