Search

Hi moonoo, thanks for your help, sorry if i did'nt explain it clear.
But forget about paypal's $POST Data. i already managed to map this to symphony fields as explained in the topic you mentioned.
But that's not what i am trying to do here.
All i am trying to do is autosubmit a form on the redirectpage, when paypal sends it's response.
So i can post some data when the transaction has completed. And i'd like to do this through a hidden form on the page which is rendered from xslt, not php.

Btw: thanks fot the postbin.heroku.com link! that's a great help

Ahh right.

Is there a real requirement for the XSLT form then?

The form i am trying to submit is a dynamicly created multiple entries form, and is a result of calculating the number of products in the shopping cart with the products in the catalogue and their matching id's, Here an example.
I have no idea how to gather this data in the event directly from the database without the xslt form..
Therefore it would be handy if somehow i could just autosubmit the form after the paypal transaction is succesfull.

Do you see any values populated in the XSLT form then?

As in: are all the values present in the hidden form before the event is triggered?

I have no idea how to gather this data in the event directly from the database without the xslt form..

SymQL is what you could use here.. Seriously it's not too difficult to gather an entry based on an ID/IPN value sent from PAYPAL to retrieve the data to post into your section:

public function load(){
        require_once(EXTENSIONS . '/symql/lib/class.symql.php');
        //build a new SymQl query with a root node of your choseing 'discount-used'
        $query = new SymQLQuery('discount-used');
        //MySql like syntax for retrieving the entry data            
        $query->select('*')->from('discounts')->where('system:id',     $_POST['refid'])->perPage(1)->page(1);

        //Build an array with the result of the Query
        $res = SymQL::run($query, SymQL::RETURN_RAW_COLUMNS);
        //Traverse the array down to the entry ID and the values we want.            

        $test = $res['entries'][$_POST[refid]]['active']['value'];
        //I was looking for a match for $_POST['fields']['hash_reference'] to ['link']['code'] in the database and only fire the trigger function if the match is true.                

        $hash = $res['entries'][$_POST[refid]]['link']['code'] ==      $_POST['fields']['hash_reference'];

//Check the values match and presence of POST array and if they do fire the trigger. 
if(isset($_POST['refid']) && isset($_POST['fields']['hash_reference']) && $hash = true && $test != 'yes') return $this->__trigger();    
}

I installed the extension and then added this to the load() function to compare a value being posted to a value in the database for a match and then if it was found fire the trigger function

You could put the SymQl query in the trigger function to find the entry in your section with the IPN reference sent in the POST array and then build your POST data you want to submit in the database.

Because I have 2 events triggering when I get $POST data back from my webhook, I had to remember to unset($POST['id']) in the second event, otherwise it would try and edit an entry that doesn't exist.

Do you see any values populated in the XSLT form then?

Yes they are, i got the catalogue and shoppingcart datasources attached to the page.

Thank you so much for the example, i am gonna look into this.
Still, wouldn't it be a lot easier to somehow just autosubmit the form. or is this not possible at al?

Greetings

It should be possible yes.

The Event should be doing this:

On page load check for existence of POST values coming from the PayPal/or redirect page and if they are there submit the form with the name that matches the hidden submit form in XSLT.

Have you checked the existence of errors in your event XML using Chrome -> Developer console?

Maybe something is missing there?

EDIT

It just occured to me.. I wonder if the POST data is checked before the XSLT is transformed? As in no values are POSTED.. might need confirmation from core team if this is the case.

It just occured to me.. I wonder if the POST data is checked before the XSLT is transformed? As in no values are POSTED.. might need confirmation from core team if this is the case.

I am pretty sure this is the case,
when you take away the condition in the load function, the event is executed on page load, but only posts empty values...

So i guess somehow i need to get the event triggered after the page is loaded? does anyone know how to do this, or if it's possible?

Javascript?.. but that would require the page to be viewed I think.

Yep, you're right, got it working, but unfortunately only when the page is viewed...

What if your redirect was back to this page that you need to trigger the update to the section and then the JS does an immediate redirect to the thank you page... or have we already done this bit with the user?

Yeah, i already tried that as well... It is working, but i need a direct redirect back to the site after payment and that's only possible with a pro account i think. Because i really need to make sure the event get's triggered. So i have to think about this one, or maybe take a total different approach...
Anyway, thanks for your suggestions!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details