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="tina@hawkesleypublishing.com">
<?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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.