YEAH, TELL ME ABOUT IT!
I am not the person to explain "How to write a correct payment module", but i can tell you what i have done.
(Well, follow at your own risk coz my payment module isn't yet perfect and it messes up when returned from payment gateway
http://www.zen-cart.com/forum/showthread.php?t=143210)
I have taken one of the payment modules (paypalipn) and modified it; i chose that module since it had the talkback module (ipn_main_handler.php) with the payment gateway, which i also needed.
First obeying the file structure, i have copied all the files i might have edited, in a new directory, and edited their name to my module name(includes/modules/payment/).
I first set up the payment class and it's functions (migrated from paypal.php). The functions in this class are called from various places in other routines depending on the payment module customer choses. One example is the checkout_process.php where inside there are calls to for example $payment_modules->before_process() and $payment_modules->after_order_create($insert_id) functions and you know in which order they are called. One important function is process_button function which is executed when your customer hits order confirm button in the final checkout page.
So the first thing not to do: Since the functions in the payment class is called elsewhere, they should remain. However, unless you know exactly what they are doing, to begin with you can empty inside them and return false to keep their functionality.
Then comes the admin functions such as install, remove, keys (check?). These define how you can install the module in the admin section and your module variables. Keep or change the variables according to your use. You will recognize that there are database construction commands there, you will need to change the database name to yours. You will have to find where the names are defined and add your own definition (use Developers Tool Kit in the admin section to search the keywords). Create new files as needed. When you do this your module is ready to be installed in the admin section. Well, it doesn't have any functionality yet, but at least you can install it.
So this is at least what you need to do for the beginning, and not even the visible portion of the iceberg. I will continue for more later on, if i have time and if there is interest. In the mean time i hope the other more experienced people will drop a few words of instructions as well.
Bookmarks