Feb 21st, 2010, 11:30 AM
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:
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.
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.
I know this is all kind of high level, but hopefully it gives you some idea.
Let me know how it goes!
- Ben
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