The following warnings occurred: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Warning [2] Undefined array key "avatartype" - Line: 783 - File: global.php PHP 8.1.31 (Linux)
|
Finalize and clear after Nochex transaction - 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: Finalize and clear after Nochex transaction (/showthread.php?tid=1694) |
Finalize and clear after Nochex transaction - adam1001 - Oct 17th, 2011 Firstly thanks so much for Form Tools, I'm a complete PHP noob but it's allowed me to set up a nice, functional transaction form incredibly easily. Sincere apologies if this is a stupid request, but I've spent half a day trying to find a solution and drawn a complete blank. I'm using Nochex to process payments on my site. When a successful transaction is completed, Nochex send a callback to a listener on my site (listener code here). All good so far. However I'm trying to add a finalize and clear_form_sessions command to the end of the script which run if the payment has been successful. ft_finalize_submission doesn't work as $form_id and $sumbission_id don't appear to exist. I've also tried pasting in the standard finalize and clear form code from the api guide but these don't work either. Any help would be very much appreciated. RE: Finalize and clear after Nochex transaction - Ben - Oct 17th, 2011 Hi Adam, Quote:ft_finalize_submission doesn't work as $form_id and $sumbission_id don't appear to exist Ah, that's a big problem! You'll definitely need to get access to those. So does Nochex permit sending arbitrary values back in the callback? That's pretty standard, so I'd be surprised if not. What I'd suggest is email yourself (or better yet, log the info in temporary file) the content of whatever information is being sent by Nochex so you can locate the form & submission IDs. In the very least, it would identify whether or not those values are contained in the request being sent to your listener page. But yes, you *must* get access to those in order to continue. Good luck...! - Ben RE: Finalize and clear after Nochex transaction - adam1001 - Oct 17th, 2011 Thanks Ben, that makes it clearer, but has in fact ended up confusing me more! As I understand it I pass these IDs to Nochex who then send them to the listener? What's confusing me is that I haven't finalized the form before sending the info to Nochex, so it doesn't yet have a submission ID... Secondly I've tried assigning some values to $form_id and $submission_id as follows but this is still sending a mail with blank values. $form_id = 8; $submission_id = 12345; mail("me@me", "debugging", "Form ID: {$pp["form_id"]}, sub ID: {$_POST['custom']}"); As I understand it the form tools session data is still active after the successful transaction, and there's a condition in the listener to verify the transaction worked, so all I need to do is finalize the active data within this condition? Sorry again if I'm being dumb about this. RE: Finalize and clear after Nochex transaction - Ben - Oct 17th, 2011 Hi Adam, Quote:I haven't finalized the form before sending the info to Nochex, so it doesn't yet have a submission ID... Ah! Is it an API form? If not, then I'm afraid you'll need to convert it to one. API forms create unique submission IDs for each visitor when they come to the form. It's stored in: Code: $_SESSION["form_tools_form"]["form_tools_submission_id"]; (assuming you haven't specified a custom namespace). So you'll need to pull that value out when constructing the information to send along with the form ID to Nochex. Regarding that code you posted, I don't quite follow... you set $form_id and $submission ID vars, but reference totally different variables in the mail() line. So no, they wouldn't work. The point of sending the form ID + submission ID to and from the callback is so that it (a) validates the transaction and (b) provides you with all the info you need to tell Form Tools to show the submission (i.e. to finalize it). Sessions won't necessarily be active when the listener is called, so this technique ensures it has all the data it needs. Hope this is a bit clearer...! It's kind of technical, I must admit. - Ben RE: Finalize and clear after Nochex transaction - adam1001 - Oct 18th, 2011 Awesome, thanks so much Ben. Problem was I was trying to reconcile Paypal, Formtools and Nochex systems in my head and was ending up thoroughly confused. However your two messages helped me to work my way through it and I've finally got it working this morning. Just in case anyone needs to do this in the future and ends up here, this is what you need to do: Put these two lines on the page which submits to Nochex: Code: <input type="hidden" name ="order_id" value="<?php echo $_SESSION["form_tools_form"]["form_tools_submission_id"]; ?>"> Put this line in the successful condition section at the bottom of the listener page: Code: ft_finalize_submission($_POST['custom'],$_POST['order_id']); Hard to belive it's taken me over a day to do this :-) RE: Finalize and clear after Nochex transaction - adam1001 - Oct 18th, 2011 Further to my last post it actually seems to be necessary to call the api from the listener as well. So code in listener is: Code: require_once("../formtools/global/api/api.php"); RE: Finalize and clear after Nochex transaction - Ben - Oct 24th, 2011 Marvellous! And yes - any time you call Core or API files, you'll need to include the api.php file. Very glad you got it sorted. These things are always a pain to configure. Ben |