Advertisement:

Author Topic: Payment plugin - wallet function  (Read 600 times)

kernelpanicit

  • Newbie
  • *
  • Posts: 4
Payment plugin - wallet function
« on: June 24, 2014, 06:37:03 pm »
THE MOST PROBLEMATIC PLUGIN IN OSCLASS EVER!!!!!!

Since january 2014 me and my collab., we tryed to figure out this plugin in a customer's website. This CMS is a good but not really elaborated idea and needs a lot of work to make a good template and make all plugins working, geo and translating. After months (the job beguns at august 2013) i'd studied how it work and his core too so i'd began to modify it and a template starting from an already modified "Modern theme" without too many "automations (ready source-code) ". Pretty good if u are a good programmer making what u want, but it also need lot of time, so my customer got angry but mostly because he is not a technician and he is so stupid about(we are in italy=mess). Our last and unbeliavable problem wast figure out payments for our website. The plug it already work in a really weird way... buy packet that are credits in the website, allow just a single expiration time... is not really as standard packets in the AD's website... usually people can make 3 different kinds of premium ads with 3 different expiration times aswell (try to see gumtree.org or subito.it). Anyway his base-working-way could be usable  so we tryed to install it. To make premium a single AD we hadn't so many problems and then we figured this out. The big problem it was make possible to buy 3 different kinds of Premium Packs... jumping from our website to paypal and come back it was working good and the website sent emails with the correct amount in the invoice-mail(we did this modification for our customer) but... the WALLET it didn't worked the amount it was always 0, so we checked out the db and we discovered a wrong and negative value in the wallet table, ...then i begun to study the plug better than before and after couple days i dicovered the problem was in ModelPayment.php. It was  unbeliavable if the variable type is ever int and everytimes you pass a different kind of type as amount (lol); when db (bigint) store record the value number is wrong and nothing work as aspected:

Code: [Select]
public function addWallet($user, $amount) {
            $amount = (int)($amount*1000000000000);
            $wallet = $this->getWallet($user);
            if(isset($wallet['i_amount'])) {
                return $this->dao->update($this->getTable_wallet(), array('i_amount' => $amount+$wallet['i_amount']), array('fk_i_user_id' => $user));
            } else {
                return $this->dao->insert($this->getTable_wallet(), array('fk_i_user_id' => $user, 'i_amount' => $amount));
            }

        }

    }

REMOVING (int) BEFORE ($amount*1000000000000); the variable not get the type (int) and all of this work good cause the return value make the variable type, then change the db field in the table to something different than int's types.

Code: [Select]
public function addWallet($user, $amount) {
            $amount = /*(int)*/($amount*1000000000000);
            $wallet = $this->getWallet($user);
            if(isset($wallet['i_amount'])) {
                return $this->dao->update($this->getTable_wallet(), array('i_amount' => $amount+$wallet['i_amount']), array('fk_i_user_id' => $user));
            } else {
                return $this->dao->insert($this->getTable_wallet(), array('fk_i_user_id' => $user, 'i_amount' => $amount));
            }

        }

    }

I smashed my brain out and my collab. too to find this error, using type on variable in php is not always needed... actually it is quite weird use type to php variables. Still cannot explain to myself why u did used bigint in db  writing */100 milliard (int) in the source... just use a different typo in db and no type in php variable...

Maybe it could be a db problem!? I'm on AlterVista on a free test account. But i'm quite sure that is a logical and code error from who wrote the script, the same wrong code in 2.0 plugin version and previous version.

Cannot say this is a great job from the creators, payments requires an accurate job and it's the most important and difficoult plug to make(it's enough see how many post in the payment plug section), i can understand..... anyway my job is done now, and i'm quite happy.

Best Regards, italian programmers watch u and says thanks!

 :-X :-X :-X :-X :-X :-X :-X :-X :-X :-X :-X :-X :-X :-X :-X :-X :-X :-X :-X :-X :-X :-X

 ::)  :-*
« Last Edit: June 24, 2014, 06:46:25 pm by kernelpanicit »