The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.28 (Linux)
|
Multiple PayPal Forms in same location - how? - Printable Version +- Form Tools (https://forums.formtools.org) +-- Forum: Form Tools (https://forums.formtools.org/forumdisplay.php?fid=1) +--- Forum: General Discussion (https://forums.formtools.org/forumdisplay.php?fid=5) +--- Thread: Multiple PayPal Forms in same location - how? (/showthread.php?tid=525) Pages:
1
2
|
Multiple PayPal Forms in same location - how? - martin_undefined - Feb 21st, 2010 I have three different forms on the same domain that have three different costs associated with them (each form is different). I want to be able to process each form via Paypal. I have the first form integrated and working correctly. The problem is that the library.php form requires the form id number to be entered into it. So, as it currently stands, you can't use that single library.php file to handle all three forms (without some modification). For my particular application, it's possible to share the success, cancelled and paypal_submit files - it just seems to be library that doesn't work. As far as I can see the solution will either be: 1) Modify the installation so it has multiple library.php files in different locations - no very elegant as solutions go. 2) Get the form itself to pass the relevant form number to paypal_submit (presumably) thereby making it work for all 3 forms. Assuming we go down the route of solution 2) has anybody a) Done this and can share their findings? b) Got an idea on how best to do this? Thanks RE: Multiple PayPal Forms in same location - how? - Ben - Feb 21st, 2010 Hey Martin, Neat problem. I think (2) is definitely the best route, but it could be tricky with the API... hmm. Will you know what form the user will be submitting for once they hit the donation page, or would that be determined after they filled in the page? If the latter, we could have trouble. The problem is that when you first hit the paypal page, this line is called: PHP Code: $fields = ft_api_init_form_page($pp["form_id"], $pp["mode"]); That creates sessions and sets the $form_id. So it would be problematic to decide on a form AFTER that step. But if you already know what form the PayPal page is going to be used for, you could just pass in the form ID via the query string, extract it, and use that in the aforementioned function, e.g. Code: paypalform.php?form_id=X But yes, like you said, you'll need to drop the hardcoded $pp["form_id"] in library.php and store it in sessions. In terms of passing it to and from PayPal, that's no problem. Just update the $_POST["custom"] value to store something like "X,Y" where X is the form ID and Y is the submission ID - instead of just passing the submission ID like you do now. You could then just split the return value and extract the values for finalizing the submission. PHP Code: list($form_id, $submission_id) = split(",", $_POST["custom"]); I know this is all kind of high level, but hopefully it gives you some idea. Let me know how it goes! - Ben RE: Multiple PayPal Forms in same location - how? - martin_undefined - Feb 23rd, 2010 (Feb 21st, 2010, 11:30 AM)Ben Wrote: In terms of passing it to and from PayPal, that's no problem. Just update the $_POST["custom"] value to store something like "X,Y" where X is the form ID and Y is the submission ID - instead of just passing the submission ID like you do now. You could then just split the return value and extract the values for finalizing the submission. The good news is that I do know what form the user is submitting. So if I understand you correctly, I need to: 1) Call my form and pass the id in eg. myform.php?form_id=5 2) Once the session has been started, store the form_id in the session 3) Pass it into Paypal using the custom value and then bring it back in so the ft_api knows where to store the submission But I'm confused by your last point on spliting the return value - where does that process happen i.e. which file contains list($form_id etc? Thanks Martin RE: Multiple PayPal Forms in same location - how? - Ben - Feb 24th, 2010 (Feb 23rd, 2010, 3:41 PM)martin_undefined Wrote: So if I understand you correctly, I need to: Yup! (Feb 23rd, 2010, 3:41 PM)martin_undefined Wrote: 2) Once the session has been started, store the form_id in the session Yes. The Form Tools API functions will handle this for you - as long as you pass in the $_GET["form_id"] to the ft_api_init_form_page function. (Feb 23rd, 2010, 3:41 PM)martin_undefined Wrote: 3) Pass it into Paypal using the custom value and then bring it back in so the ft_api knows where to store the submission Exactly. (Feb 23rd, 2010, 3:41 PM)martin_undefined Wrote: But I'm confused by your last point on spliting the return value - where does that process happen i.e. which file contains list($form_id etc?) Ah, this bit will occur in ipn.php. That page is where the ft_finalize_submission() function is called that tells Form Tools that the PayPal payment went through correctly. Right now, it thinks that the $_POST["custom"] value being sent from PayPal contains just the Submission ID, but after you pass the "form ID,submission ID" value you'll need to do the split() stuff to separate them. This will allow you to finalize any submission in any of the three forms - all using the same, single ipn.php page. Hope that makes sense! - Ben RE: Multiple PayPal Forms in same location - how? - martin_undefined - Feb 28th, 2010 (Feb 24th, 2010, 9:35 PM)Ben Wrote:(Feb 23rd, 2010, 3:41 PM)martin_undefined Wrote: So if I understand you correctly, I need to: Hi Ben, It makes perfect sense, but I seem to falling at the first hurdle. I've attempted various permutations of using $_GET to pass in the form id. However, I seem to keep running into the same problem, namely that when the form is submitted, I get error messages like this: Quote:Notice: Undefined index: form_id in /home/sites/mysite.com/public_html/forms/myform1.php on line 6 I've tried using $_GET both to assign the value to $form_id before using the ft_api expression and also directly in the expression (although not sure I can do that!). Given that the page loads okay when called by myform.php?form_index=5, it almost seems like the page is being reloaded without the query string - therefore causing this error. Could validation be causing this? On a seperate note, I notice when putting through test submissions (without trying the multi-form paypal code) my success.php displays First Name: Test Last Name: User i.e. not the values being submitted in the form. Is this what Paypal's sandbox normally bounces back or is it another problem on my side? Thank you! Martin RE: Multiple PayPal Forms in same location - how? - Ben - Mar 7th, 2010 Hey Martin, Sorry for the wait - I'll look at this today & email you back then. - Ben RE: Multiple PayPal Forms in same location - how? - xcrunner529 - Mar 11th, 2010 Hi. i'd like to do the same thing. By reading this am I correct that I'd have to link to the forms themselves with the ?form_id= appended or could I just send the formid from the form to the paypal processing page? I really don't want form_id added to any front-end links if at all possible, couldn't I just store in in a php variable in the form code? Thanks! RE: Multiple PayPal Forms in same location - how? - martin_undefined - Mar 11th, 2010 (Mar 11th, 2010, 8:55 AM)xcrunner529 Wrote: Hi. i'd like to do the same thing. By reading this am I correct that I'd have to link to the forms themselves with the ?form_id= appended or could I just send the formid from the form to the paypal processing page? Hi, I'm still working my way through the mods that Ben made - but all appears well. Ben's solution was Quote:The issue was that after first arriving at the page, the form ID was available in the GET variable, but after posting the form back to itself, the form ID was lost. I just tweaked it a bit to pass it hidden in a form field, and got the code to pull the form ID out of EITHER $_POST or $_GET. That circumvented the problem. The key bits of code being PHP Code: // a simple trick to combine $_POST and $_GET, so that the $form_id is always found in a single and PHP Code: <input type="hidden" name="form_id" value="<?php echo $form_id; ?>" /> Regarding your question about whether you have to pass the form_id in via the url - I think the answer is yes. Otherwise won't you lose reference to the form_id? RE: Multiple PayPal Forms in same location - how? - xcrunner529 - Mar 11th, 2010 Don't we already have the form id as part of the variables, though? IE the form id is already part of the code needed to submit to formtools, isn't it? So couldn't we just use one variable to house that? RE: Multiple PayPal Forms in same location - how? - martin_undefined - Mar 11th, 2010 (Mar 11th, 2010, 1:51 PM)xcrunner529 Wrote: Don't we already have the form id as part of the variables, though? IE the form id is already part of the code needed to submit to formtools, isn't it? So couldn't we just use one variable to house that? I understand what you mean. I'm assuming that because Ben suggested the route outlined above that it can't be done so simply, can it... In the end, the form_id is being passed to the Paypal routines through a hidden field rather than the original route of passing it with the session id so maybe it can be done that easily. I'm going to have to go away and check, hopefully Ben will comment when he sees this. Martin |