So I've done quite a few forms before but I'm running into trouble with this one. I'm not exactly sure what I need to do, but let me explain.

I have:

Form A
Form B

Form A collects basic data from a customer. Form B give you the option to select two products (Pay Pal). Depending on what product you pick, the last field on Form A will populate with that value, which was blank before.

I chose to do it this way because my type of Pay Pal account couldn't handle multiple custom fields. I also needed to know which customers data corresponds to what package they ordered and not have to figure it out through Pay Pal incase the e-mail they enter is different for whatever reason. What I need is when the "buy now" button is clicked, the php action for form A to run and for the customer to be redirected to Pay Pal to pay.

I've tried it several ways but nothing is working, the form info is not coming through to my e-mail - it only brings the customer to Pay Pal. I was thinking to have two actions on the Pay Pal form, but something doesn't make sense to me with that. I tried some jQuery to make the form submit without refreshing or redirecting but that didn't work. I really need both actions to be triggered as the absolute last thing they do. For example if the customer selects the higher priced package, and hits submit on the first form, they can go back select the lower level package and pay for that. Granted I would probably catch it, but it just seems like a headache to me.

Here's part of what I'm working with:

<script tyle="text/javascript">
$(document).ready(function(){
   $form = $('citationinfo');
   $form.submit(function(){
      $.post($(this).attr('citations.php'), $(this).serialize(), function(response){
            // do something here on success
      },'json');
      return false;
   });
});
</script>



<script type="text/javascript">
		function setPrice(selObj){
			document.forms['citationinfo'].price.value = selObj.options[selObj.options.selectedIndex].value;			
		}
		</script>


<form id="citationinfo" name="citationinfo" method="post" action="citations.php">
           <br>*14 fields of basic info to fill out*<br />
            <label>Citation Pack:</label>
            <input name="price" type="text" class="form" id="price" size="50" readonly="readonly"/>
            <br />
            <span class="style6">(Select below on Citation Options)            </span><br />
          </form>

<form action="https://www.paypal.com/cgi-bin/webscr" method="post" onSubmit"document.citationinfo.submit()">
<input type="hidden" name="cmd" value="_s-xclick">

<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>

and my php

<?php

$emailSubject = 'Citation'; 
$webMaster = 'myemail@mydomain.com';



$price = $_POST['price'];


$body = <<<EOD
Citation:<br>

Package: $price<br>


EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);


$theResults = <<<EOD

EOD;
echo "$theResults";
?>

Sorry I couldn't post everything. There's not really one thing I'm trying to "fix" I've just been working with a whole bunch of different pieces and moving everything around. Let me know if you have any suggestions.

-Mel

Recommended Answers

All 2 Replies

It's ages since I did any PayPal/eCommerce stuff but the way I remember it, the actions (at least from your perspective) are strictly sequential:

  1. Customer sumbits order to PayPal, including a contact email address (but not necessarily his PayPal email).
  2. Customer logs into PayPal and pays for the goods.
  3. PayPal sends confirmation to customer and forwards the order to the merchant (IIRC, there are options as to how this is achieved - HTTP, email or both?).
  4. Merchant and/or his system acknowledges the order by email to the customer.
  5. Merchant makes up and dispatches the order (progress may be available to the customer online depending on the sophistication of the merchants system).

This way, the merchant only ever gets to see orders that are fully paid for in advance and never needs to marry up a directly-received order with a PayPal payment. The merchant similarly never needs to be concerned with the customer's PayPal email address, which remains private to PayPal and customer (unless the customer uses one email addy for everything).

If I'm right then what you need to do is to:

  1. set up the merchant's account in PayPal's "Merchant Services" appropriately (this can be quite extensive and can involve the establishment of hand-shaking between PayPal and merchant's system, eg for price verification or quantity discounting).
  2. arrange for Form B to populate the appropriate field in Form A, but not be submitted.
  3. cause your Form A to submit to PayPal as a regular HTML/HTTP form submission (not AJAX). I think I'm right in saying that you can include, in the form's fields, a URL to which the browser will return when the payment is complete/aborted (ie. a "continue shopping" page), thus allowing the customer to do everything in a single browser window/tab.

Sorry this is a bit vague but as I say I'm dredging the memory banks from several years ago when I last did this. At that time, there was any amount of detail in Merchant Services but it lacked macroscopic overviews of it's various ordering/payment models like I have tried to give above.

Airshow

It's ages since I did any PayPal/eCommerce stuff but the way I remember it, the actions (at least from your perspective) are strictly sequential:

  1. Customer sumbits order to PayPal, including a contact email address (but not necessarily his PayPal email).
  2. Customer logs into PayPal and pays for the goods.
  3. PayPal sends confirmation to customer and forwards the order to the merchant (IIRC, there are options as to how this is achieved - HTTP, email or both?).
  4. Merchant and/or his system acknowledges the order by email to the customer.
  5. Merchant makes up and dispatches the order (progress may be available to the customer online depending on the sophistication of the merchants system).

This way, the merchant only ever gets to see orders that are fully paid for in advance and never needs to marry up a directly-received order with a PayPal payment. The merchant similarly never needs to be concerned with the customer's PayPal email address, which remains private to PayPal and customer (unless the customer uses one email addy for everything).

If I'm right then what you need to do is to:

  1. set up the merchant's account in PayPal's "Merchant Services" appropriately (this can be quite extensive and can involve the establishment of hand-shaking between PayPal and merchant's system, eg for price verification or quantity discounting).
  2. arrange for Form B to populate the appropriate field in Form A, but not be submitted.
  3. cause your Form A to submit to PayPal as a regular HTML/HTTP form submission (not AJAX). I think I'm right in saying that you can include, in the form's fields, a URL to which the browser will return when the payment is complete/aborted (ie. a "continue shopping" page), thus allowing the customer to do everything in a single browser window/tab.

Sorry this is a bit vague but as I say I'm dredging the memory banks from several years ago when I last did this. At that time, there was any amount of detail in Merchant Services but it lacked macroscopic overviews of it's various ordering/payment models like I have tried to give above.

Airshow

Thank you for the reply. Kind of sort of. I tried to have form A submit to pay pal, and it didn't work. I also tried manually putting some text fields in the actual pay pal form that the pay pal site generates but that didn't work either.

I'm using the personal or basic account, I'm not sure what its called exactly. Everything I need can be done if I upgrade my account to a "higher" account, but I'm not in a position to do that right now. Pay pal only allows two "options" to list with the buy now button.

For this form I do need the customers pay pal email address, their regular email (unless its the same), and other e-mail for general information. Reason being is that when your using the type of account I'm using, pay pal does not redirect you back to the page you ordered from. It will take you to a page with a transaction number, so based on the e-mail they give me in the form I have to reference that with their account it comes from (they are displayed). This cuts out the customer having to e-mail me the transaction number. Hope that makes sense.

I read about calling the actions in hidden iframes? I just can't figure out how to get the buy now button to run the php page and also bring the customer to check out.

I know that this maybe isn't the right forum topic but perhaps it would be better to use a get function in the url? Such as creating a drop down manually (not through pay pal) and depending on what they choose redirects to a correct payment page with only one option?

Thanks again
-m

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.