Posts: 114
Threads: 42
Joined: Jan 2010
Reputation:
0
Ben,
Perhaps you can make a suggestion here. I need to create a form that allows a person to choose to pay for something either by cheque or through paypal. The form itself can be found at http://oab.zuka.net/events/awards/awards...form04.php However, you will see if you go there you will get and error 306. The modified code I have for Formtools is this:
Code: <?php
echo $mode;
$curr_folder = dirname(__FILE__);
require_once("$curr_folder/includes/library.02.php");
$fields = ft_api_init_form_page($pp["form_id"], $pp["mode"]);
if ($pp["mode"] == "initialize")
{
$params = array(
"submit_button" => "submit",
"next_page" => "success.php",
"form_data" => $_POST,
"finalize" => true
);
}
elseif ($pp["mode"] == "live")
{
if($pay=="cheque") {
$params = array(
"submit_button" => "submit",
"next_page" => "/events/entry-thanks.php",
"form_data" => $_POST,
"file_data" => $_FILES,
"finalize" => true
);
}
elseif($pay=="paypal") {
$params = array(
"submit_button" => "submit",
"next_page" => "paypal-submit.php",
"form_data" => $_POST,
"file_data" => $_FILES
);
}
}
ft_api_process_form($params);
?>
I am setting $pay via:
Code: <input type="radio" name="howpay" id="pcheque" value="cheque" onClick="showhidefield('pcheque')" onmouseup="<?php $pay=""; $pay = "cheque"; ?>" />
<label for="ppaypal"> PayPal:
<input type="radio" name="howpay" id="ppaypal" value="paypal" onClick="showhidefield('ppaypal')" onmouseup="<?php $pay=""; $pay = "paypal"; ?>" />
</label>
So, apparently $pay is not getting passed through or it is being reinitialized or something this producing the 306 Formtools error.
Any ideas how this can be done?
Dave
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Hi Dave,
It looks like what's happening is that on page load, $pp["mode"] doesn't have a value of "initialize" OR "live", so the ft_api_process_form() function isn't being passed any values at all, hence the 306 error.
I see you have an echo $mode; at the top. Is the mode stored in $pp["mode"] or $mode?
- Ben
Posts: 114
Threads: 42
Joined: Jan 2010
Reputation:
0
Well "live" should by set in he library include ... yes? At this point the echo .$Mode is superfluous I think.
Dave
(Jul 23rd, 2011, 9:43 AM)Ben Wrote: Hi Dave,
It looks like what's happening is that on page load, $pp["mode"] doesn't have a value of "initialize" OR "live", so the ft_api_process_form() function isn't being passed any values at all, hence the 306 error.
I see you have an echo $mode; at the top. Is the mode stored in $pp["mode"] or $mode?
- Ben
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Yeah - very possibly! But let's check it out just to make sure. Right before the ft_api_process_form line, add the following, then reload the page.
PHP Code: print_r($params); exit; ft_api_process_form($params);
I really want to see what info is being passed to the function... From the original error, it sounds like that var simply doesn't have the right content.
Oh, daft of me: if you're testing all this with the function being called via ipn by PayPal, email it to yourself instead (since you won't see the page being loaded);
PHP Code: $content = array(); while (list($key, $value) = each($params)) $content .= "$key: $value\n"; mail("your@email.com", "debugging!", $content); exit; ft_api_process_form($params);
Let me know how it goes.
- Ben
Posts: 114
Threads: 42
Joined: Jan 2010
Reputation:
0
OK, so the first thing I did was modify my code to include your code like so:
Code: <?php
$pay = "cheque";
$curr_folder = dirname(__FILE__);
require_once("$curr_folder/includes/library.02.php");
$fields = ft_api_init_form_page($pp["form_id"], $pp["mode"]);
if ($pp["mode"] == "initialize")
{
$params = array(
"submit_button" => "submit",
"next_page" => "success.php",
"form_data" => $_POST,
"finalize" => true
);
}
elseif ($pp["mode"] == "live")
{
echo "mode is live";
if($pay=="cheque") {
$params = array(
"submit_button" => "submit",
"next_page" => "/events/entry-thanks.php",
"form_data" => $_POST,
"file_data" => $_FILES,
"finalize" => true
);
print_r($params);
exit;
}
elseif($pay=="paypal") {
$params = array(
"submit_button" => "submit",
"next_page" => "paypal-submit.php",
"form_data" => $_POST,
"file_data" => $_FILES
);
}
}
ft_api_process_form($params);
?>
This gets me:
Code: mode is live Array ( [submit_button] => submit [next_page] => /events/entry-thanks.php [form_data] => Array ( ) [file_data] => Array ( ) [finalize] => 1 )
Then changed the code to this:
Code: <?php
$pay = "cheque";
$curr_folder = dirname(__FILE__);
require_once("$curr_folder/includes/library.02.php");
$fields = ft_api_init_form_page($pp["form_id"], $pp["mode"]);
if ($pp["mode"] == "initialize")
{
$params = array(
"submit_button" => "submit",
"next_page" => "success.php",
"form_data" => $_POST,
"finalize" => true
);
}
elseif ($pp["mode"] == "live")
{
echo "mode is live\n";
if($pay=="cheque") {
$params = array(
"submit_button" => "submit",
"next_page" => "/events/entry-thanks.php",
"form_data" => $_POST,
"file_data" => $_FILES,
"finalize" => true
);
}
elseif($pay=="paypal") {
$params = array(
"submit_button" => "submit",
"next_page" => "paypal-submit.php",
"form_data" => $_POST,
"file_data" => $_FILES
);
}
}
$content = array();
while (list($key, $value) = each($params))
$content .= "$key: $value\n";
mail("myemail@mydomain.net", "debugging!", $content);
exit;
ft_api_process_form($params);
?>
and got nothing. Email never arrived with the parameters but if I remove the exit; and if $pay is set to cheque, I can process the form and submit it and it bypasses the paypal connection and simply submits it as a normal non-paypal form. However, it does not show me my thank you page. It just shows me a blank page with my "mode is live" echo. Try it and my explanation might be clearer.
Thanks Ben,
Dave
(Jul 23rd, 2011, 11:13 PM)Ben Wrote: Yeah - very possibly! But let's check it out just to make sure. Right before the ft_api_process_form line, add the following, then reload the page.
PHP Code: print_r($params); exit; ft_api_process_form($params);
I really want to see what info is being passed to the function... From the original error, it sounds like that var simply doesn't have the right content.
Oh, daft of me: if you're testing all this with the function being called via ipn by PayPal, email it to yourself instead (since you won't see the page being loaded);
PHP Code: $content = array(); while (list($key, $value) = each($params)) $content .= "$key: $value\n"; mail("your@email.com", "debugging!", $content); exit; ft_api_process_form($params);
Let me know how it goes.
- Ben
Posts: 114
Threads: 42
Joined: Jan 2010
Reputation:
0
Jul 26th, 2011, 4:10 PM
(This post was last modified: Jul 26th, 2011, 4:47 PM by filch.)
Ben,
Man do I hate PayPal!!!
I did manage to get the form I was working on together however NOW, using your tutorial and files, am trying to get it to play nicely with PayPal. I keep getting an error and I cannot see why. It did integrate with formtools fine but will not go with PP.
If you want to have a look it is at http://oab.zuka.net/events/awards/entry2...orm-pp.php
I really appreciate any time you can give me on this Ben. I am two days behind now :-(
Thanks Ben.
Dave
Posts: 415
Threads: 0
Joined: Mar 2009
Reputation:
3
Hey Dave,
Sorry to hear the pains you're experiencing with Paypal. The link you've uploaded seems to go to a 404. If you could upload the form it would give us a better idea of what the issue is.
Cheers,
Joe
Posts: 114
Threads: 42
Joined: Jan 2010
Reputation:
0
Jul 26th, 2011, 4:48 PM
(This post was last modified: Jul 26th, 2011, 5:11 PM by filch.)
Ahh .. sorry. Forgot the s on awards. The link is functional now. Edited it :-)
(Jul 26th, 2011, 4:42 PM)Joe Wrote: Hey Dave,
Sorry to hear the pains you're experiencing with Paypal. The link you've uploaded seems to go to a 404. If you could upload the form it would give us a better idea of what the issue is.
Cheers,
Joe
Just a bit of an update. I am no longer getting the error I was getting but now my issue is that I need to find a way to get the individual items to paypal so that the user sees them both listed in the paypal page. Now, I believe I read somewhere that this integration through Formtools does not work with the PayPal cart? Is that so.
At any rate, if you have some suggestions of how to get this functioning properly I would really appreciate it. As I said, two days behind now.
Thanks much
Dave
Posts: 415
Threads: 0
Joined: Mar 2009
Reputation:
3
Hey Dave,
I think you may need to pass a variable amount through the Buy Button to Paypal. I would just calculate the in PHP and then pass that amount to Paypal.
HTML Variable for Buy Now Buttons: https://www.paypalobjects.com/Integratio...y-now.html
You might want to take a look at this as well: https://cms.paypal.com/us/cgi-bin/?cmd=_...art_upload
Cheers,
Joe
Posts: 114
Threads: 42
Joined: Jan 2010
Reputation:
0
Hi Joe,
Yeah I am familiar with those links and the variables. However I think my problem is that Formtools does not work with a cart because if you try to pass cmd=_cart, you get the error. When you pass cmd=_xclick it is fine. This is using the implementation on the Formtools site at any rate. So I had to be content with building up a single variable for amount & tax and passing that over and it works fine.
If Ben or one of use could come up with a solid implementation of a cart with Formtools that stored the transactions, that would be a very nice thing considering the nice implementation Formtools has. But I guess this is crossing over into shopping cart ecommerce territory.
Dave
(Jul 27th, 2011, 6:17 PM)Joe Wrote: Hey Dave,
I think you may need to pass a variable amount through the Buy Button to Paypal. I would just calculate the in PHP and then pass that amount to Paypal.
HTML Variable for Buy Now Buttons: https://www.paypalobjects.com/Integratio...y-now.html
You might want to take a look at this as well: https://cms.paypal.com/us/cgi-bin/?cmd=_...art_upload
Cheers,
Joe
|