views:

165

answers:

2

I'm designing a simple web-app in CI. I have a registration controller, and a paypal controller. Both work fine separately, but I need to use some functions of the paypal controller as a part of registration. How can I borrow those functions w/o pasting new functions into the registration controller?

It really wouldn't be a problem to paste in the paypal controller to the reg_controller, but I'd like to separate these functions if possible! :)

BTW, I'm new to CI/MVC so if there's a better way to do things, let me know!

+1  A: 

I think you need to move your PayPal controller into a library or model. I'm not sure exactly how you're using the PayPal controller to do PayPal functions, unless you're doing a lot of redirects.

I use this class that I made in CI to do PayPal transactions (was recently updated too):

On Google Code: http://code.google.com/p/phppaypal/ On GitHub: http://github.com/drewjoh/phpPayPal

You can tweak it just a little to make it a CI library. I have working code if that helps too. You can see example code (not CI example code) to see how simple it is here: http://drewjoh.com/wiki/code/classes/phppaypal

drewjoh
I agree. The controller code is not the reusable part of the system. It's supposed to be just glue between a model and the http request. The model is meant to be used by multiple controllers.
Juan Mendes
A: 

Jamie Rumbelow made a decent PayPal library for CodeIgniter.

http://github.com/jamierumbelow/codeigniter-paypal

Phil Sturgeon