Search

Hi,

I’m using a payment service (www.mollie.nl, Dutch) which calls a custom page after payment (report.php, so not part of Symphony), which in turns must update a specific database entry (based on a transactionid) if the payment is complete.

At first I thought about using custom events, but perhaps it’s much easier to update the entry directly from the report.php? My php is a bit rusty.. is this possible, and if so how?

An example of the report.php is below:

<?php

require_once('ideal.class.php');

$partner_id  = 012345; // Uw mollie partner ID

if (isset($_GET['transaction_id'])) 
{  
    $iDEAL = new iDEAL_Payment ($partner_id);
    $iDEAL->setTestMode();

    $iDEAL->checkPayment($_GET['transaction_id']);

    if ($iDEAL->getPaidStatus() == true) {
        /* Update the specific database entry here based on the $_GET['transaction_id']*/
    } 
}

Couldn’t you use a Symphony page (e. g. /report/) instead of report.php and attach your PHP above via an event? In this case it should be easy to update a Symphony entry form the event.

See my comment in your other thread.

(I’ve closed the other thread as this is a double-post.)

Sorry Nick, I doubled up there ;)

I’m trying it out now, sounds so logical. But how would I update a specific entry based on a transaction_id field from the __trigger function? I guess I need to look up the Entry Id somehow?

Ah so transaction_id is different to a Symphony entry ID. Do you store a transaction_id in a Symphony entry somewhere?

Yes the transaction_id is stored in the entry. The value is passed to the page as a GET value.

So I guess I need to look up the entry ID based on that, zet all new values as POST values and do this in the _trigger?

// set POST values to update the entry
    include(TOOLKIT . '/events/event.section.php');
                    return $result;

Perhaps with a datasource attached to the page as well filtered on the transaction id?

The most efficient way would be to look directly into the database table. If you find the database table that stores the transaction_id (I presume a Text Input field?) it will have the entry_id stored in the same row.

Something like:

$row = Frontend::instance()->Database->fetchVar('entry_id', 0, sprintf("SELECT `entry_id` as `entry_id` FROM sym_entries_data_%d WHERE value='%s'", 123, $_GET['transaction_id']));

Where 123 is the ID of the transaction_id field in Symphony (look in sym_fields for this ID).

Bob, could you publish what you are doing as an extension please?

I will have to use mollie in a few months too, so this would be very helpful!

No problem. I’m still trying it out though, so hang on ;)

Ok, I’m almost there I think. But somehow the entry is not being updated yet altough the entry ID is ok. This is the custom event with a little test POST data to save:

<?php

    require_once('ideal.class.php');
    require_once(TOOLKIT . '/class.event.php');

    Class eventmollie_report extends Event{

        const ROOTELEMENT = 'mollie-report';

        public $eParamFILTERS = array(

        );

        public static function about(){
            return array(
                     'name' => 'Mollie report',
                     'author' => array(
                            'name' => 'Bob Donderwinkel',
                            'website' => 'http://www.esthex.com',
                            'email' => 'b.donderwinkel@gmail.com'),
                     'version' => '1.0',
                     'release-date' => '2010-08-26T14:33:14+00:00',
                     'trigger-condition' => 'action[mollie-report]');   
        }

        public static function getSource(){
            return '34';
        }

        public static function allowEditorToParse(){
            return true;
        }

        public static function documentation(){
            return new XMLElement('p', 'This is an event that updates a mollie order after payment');
        }

        public function load(){     

            $entry_id = Frontend::instance()->Database->fetchVar('entry_id', 0, sprintf("SELECT `entry_id` as `entry_id` FROM sym_entries_data_%d WHERE value='%s'", 206, $_GET['transaction_id']));
            $_POST["id"] = $entry_id;
            $_POST["fields[name]"] = "test";
            //$_POST["fields[address-1]"] = "test";
            //$_POST["fields[address-2]"] = "test";
            //$_POST["fields[town]"] = "test";
            //$_POST["fields[zipcode]"] = "test";
            //$_POST["fields[country]"] = "test";
            //$_POST["fields[transaction-id]"] = "test";
            //$_POST["fields[total-price]"] = "9876";
            //$_POST["fields[payed]"] = "Yes";
            //$_POST["fields[ordered-items]"] = "test";
            //$_POST["fields[date]"] = "test";
            //$_POST["action[mollie-order]"] = "test";

            /*
            $partner_id  = 12345; // Mollie partner ID
            $iDEAL = new iDEAL_Payment ($partner_id);
            $iDEAL->setTestMode();
            $iDEAL->checkPayment($_GET['transaction_id']);

            if ($iDEAL->getPaidStatus() == true) {
                $_POST["fields[payed]"] = "Yes";
                return $this->__trigger();
            } */


            return $this->__trigger();

        }

        protected function __trigger(){
            include(TOOLKIT . '/events/event.section.php');
            return $result;
        }       

    }

Am I still missing a bit perhaps?

Not that I can see right away. Have you filled in the rest of the form?

There is one thing: maybe it’s a good idea to seperate the mollie payments from the actual order. That way the mollie payment itself can be completely on it’s own.

$_POST["fields[name]"] = "test";

might need to be:

$_POST['fields']['name"] = "test";

And are you sure it’s getting the right entry ID to update?

I got it, updating bit should be:

        $entry_id = Frontend::instance()->Database->fetchVar('entry_id', 0, sprintf("SELECT `entry_id` as `entry_id` FROM sym_entries_data_%d WHERE value='%s'", 206, $_GET['transaction_id']));
    $_POST["id"] = $entry_id;
    $_POST["fields"] = array();
    $_POST["fields"]["name"] = "test";

Yeah Mollie has a strict routine after payments. This page will be called in the background by Mollie after the order has been made and payed (or not). So it’s not an actual page anyone will visit.

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