![]() |
Constructor being ignored after redirect from paypal - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Constructor being ignored after redirect from paypal (/showthread.php?tid=60401) |
Constructor being ignored after redirect from paypal - El Forum - 03-18-2014 [eluser]keld[/eluser] Hello, I'm having a weird problem here. I have a controller called booking.php that contains a checkout() function, a payment() function, a success() function and a cancel() function to use with paypal express checkout. The transaction starts here: mysite.com/booking/checkout where I check for the user's data being submitted, check for errors and calculate the price of the products. When the user clickts the paypal Pay Now button, I load this url: mysite.com/booking/payment which handles all the paypal api stuff like token, sending the user info and price to paypal then redirects to paypal to proceed with the payments. The user then pays, using paypal account or credit card then gets redirect to: mysite.com/booking/success. This is where it stops working, after the redirect, the constructor of the controller doesn't get loaded at all, meaning that all my CI sessions are gone, firephp output doesn't work, email lib and paypal lib don't load. Using basic php like $_SESSION works but CI functions don't. I have to re-declare everything in the success function. This is what the constructor looks like: Code: function __construct() My success function: Code: public function success(){ Any idea why my constructor is ignored? Thank you. Constructor being ignored after redirect from paypal - El Forum - 03-19-2014 [eluser]InsiteFX[/eluser] Did you try autoloading the Session library? Constructor being ignored after redirect from paypal - El Forum - 03-20-2014 [eluser]keld[/eluser] Yes it was already autoloaded. I fixed it I was in production mode so I couldn't see errors but the paypal.php library was causing some headers already sent and other stuff because when loading the library, the constructor required parameters that I wasn't providing. So by the way how do I load a lib without causing error due to the constructor and at the same time instanciating the class. Right now I'm doing this: Code: $paypalParams = array('user' => $user, 'pass' => $pass, 'signature' => $signature, 'paypal_server' => $paypal_server); If I only do: Code: $this->load->library('paypal'); I get a bunch of warnings. This is what is in the Paypal.php: Code: public function __construct($user, $pass, $signature, $paypal_server = 'sandbox', $request_method = 'file_get_contents'){ Constructor being ignored after redirect from paypal - El Forum - 03-21-2014 [eluser]InsiteFX[/eluser] Either way the parameters need to be passed through the constructor for it to work. You could rewrite the constructor to a config array and then use this: Code: $this->load->library('class_name', $config, 'object name'); You would need to loop through the config array and assign all the values. |