Posts: 33
Threads: 12
Joined: Sep 2009
Reputation:
0
I want to save these values returned from the PayPal IPN into my database; I created hidden fields for each one on the first page of my form so that they each have columns in the database...but they aren't saving there.
How do I get these values to save?
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Hi Jaace,
Good question. You can certainly do it manually (extract the PayPal POST values and update the database in a custom query), but it's a bit of a hack.
What I'm going to do is add a simple ft_api_update_submission function that can handle this. There's a similar function in the Core that does something very similar, but it's closely coupled to the page markup & won't work well in our case.
I'll try and get something going tonight or tomorrow for this.
- Ben
Posts: 2,456
Threads: 39
Joined: Dec 2008
Reputation:
6
Hi Jaace,
Here we go. I haven't tested this, but it *should* work...!
First, upgrade your Form Tools core to the latest version 2.0.0-beta-20091030) and in your ipn.php file (I assume you're using the zipfile from the tutorial?) add in the following line, right after the ft_finalize_submission() line.
PHP Code:
<?php
ft_update_submission_info($pp["form_id"], $_POST["custom"], $_POST);
Then, in Form Tools, create new fields for the PayPal fields you want to save. This is done through the Edit Form -> Database tab. Make sure that you make the form field name and database column name the same as the POST value (e.g. "txn_id", "payer_email" etc.).
Then it should work...
The new
ft_update_submission_info function should just ignore all values in the $_POST variable, if they're not a valid form field name. But if there ARE problems, try creating a separate hash containing the new values you want stored, and pass that as the third parameter instead. e.g.
PHP Code:
<?php
$params = array(
"txn_id" => $_POST["txn_id"],
"payer_email" => $_POST["payer_email"]
);
ft_update_submission_info($pp["form_id"], $_POST["custom"], $params);
Hope this helps! :-)
- Ben