Jul 6th, 2010, 9:34 AM
Hi Michael,
Open source software is wonderful. So many people willing to give good advice to those in need. Thank you for your response.
I looked at the Submission Pre-Parser module and thought that was more for submissions directly to FormTools. It is my understanding (Ben, correct me if I am wrong!) that the PayPal code (through paypal_submit.php) talks directly to PayPal and only after success does it add the data to FormTools. If the user cancels their PayPal payment then no entry is made in FormTools.
That being said, your code looks like an excellent starting point for my needs. Unlike the donate select, the session1 and session2 selects have a default hyphen so I would have to cater to the in the IF statement.
With a minor modification to you code I have;
I will experiment with adding this to the top of paypal_submit.php just after the require statements. I'm guessing this is the correct place to put it. If anyone has a better idea, please let me know.
But first I have an irritating Error Code: #100 problem when adding the new form even though I have the form_id and mode correctly set in library.php and I have been clearing the sessions by reloading the success.php page before doing the initializing form submission.
Worked fine when I set up the original PayPal demo and I have no problem when using the standard API approach in other projects that don't use PayPal. Not certain how to troubleshoot this one.
Michael, thanks again for your help.
Scott
Open source software is wonderful. So many people willing to give good advice to those in need. Thank you for your response.
I looked at the Submission Pre-Parser module and thought that was more for submissions directly to FormTools. It is my understanding (Ben, correct me if I am wrong!) that the PayPal code (through paypal_submit.php) talks directly to PayPal and only after success does it add the data to FormTools. If the user cancels their PayPal payment then no entry is made in FormTools.
That being said, your code looks like an excellent starting point for my needs. Unlike the donate select, the session1 and session2 selects have a default hyphen so I would have to cater to the in the IF statement.
Code:
<select id ="session1" name="session1">
<option value="-" selected="selected">-</option>
<option value="25">25</option>
<option value="30">30</option>
<option value="35">35</option>
<option value="40">40</option>
</select>
With a minor modification to you code I have;
PHP Code:
if (isset($_POST["session1"]) && ($_POST[session1] != "-" ))
settype($_POST["session1"], "integer"); // convert the value of session1 to integer if the user set one
else
$_POST["session1"] = 0; // otherwise set the value to 0
if (isset($_POST["session2"]) && ($_POST[session2] != "-" ))
settype($_POST["session2"], "integer"); // convert the value of session1 to integer if the user set one
else
$_POST["session2"] = 0; // otherwise set the value to 0
if (isset($_POST["donate"]) && !empty($_POST["donate"]))
settype($_POST["donate"], "integer"); // convert the value of donate to integer if the user set one
else
$_POST["session2"] = 0; // otherwise set the value to 0
$added_amount = $_POST["session1"] + $_POST["session2"] + $_POST["donate"] // add the three values together and store them in a variable
if ($added_amount == 0)
/* you presumably don’t want to continue to PayPal if the user didn’t select anything,
add code to handle that case here */
else
$_POST["amount"] = $added_amount; // submit the combined values as amount
I will experiment with adding this to the top of paypal_submit.php just after the require statements. I'm guessing this is the correct place to put it. If anyone has a better idea, please let me know.
But first I have an irritating Error Code: #100 problem when adding the new form even though I have the form_id and mode correctly set in library.php and I have been clearing the sessions by reloading the success.php page before doing the initializing form submission.
Code:
// your Form Tools form ID
$pp["form_id"] = 13;
// the Form Tools submission mode
$pp["mode"] = "initialize";
//$pp["mode"] = "live";
Worked fine when I set up the original PayPal demo and I have no problem when using the standard API approach in other projects that don't use PayPal. Not certain how to troubleshoot this one.
Michael, thanks again for your help.
Scott