I'm in the same spot. I need to get a module, I have php samples, and I have actually moved one step further: I tried to model my module on one of the "ready-made" modules, namely Authorize.net.
What I have found out is summarized to this:
Each module contains the definition of a single class, the name of which is the name of the module itself. It is included dynamically in the scripts.
The class has 4 member variables for sure (it may have extra). These are:
string $code: the code of the module
string $title: the Title of the module (used in the admin pages)
string $description: Description of the module (used in the admin pages too)
bool $enabled: whether it is installed or not.
The class constructor has invariably the same structure, which I will not post here for reasons of brevity. One thing to notice is that there is a member variable called form_action_url, which is probably where the url of the payserver should go.
from then on, there are the following methods:
update_status():Haven't figured it out, but has the same appearance in all modules.
javascript_validation():usually it's just "return false;"
selection():Some modules create a form with this, where you fill in the credit card number. The others have roughly the same appearance.
pre_comfirmation_check():Checks validity of credit card. Same (?) in all modules.
comfirmation(): collects all info passed in through selection(), as well as some others in an array.
process_button(): Makes a form full of hidden input fields. I guess this is where we put all the information the payserver needs to have. Also, this is where the form_action_url variable probably comes into play.
before_process():?
after_process():?
output_error(): Probably self explanatory. Haven't looked into it
check(): Seems to be checking whether the module is installed or not.
install(): Installs the module. Mainly one large INSERT sql query.
remove(): Same as above, but DELETE instead of INSERT.
keys():Returns an array with some of the configuration constants associated with the module.
Apart from the modue itself, there needs to be another file: It has the same name, and it goes in the "language/modules/payment" directory. It contains all the configuration constants for the module.
My effort to create my own module came to a grinding halt when I realised that my payserver requires the order_id to do the comfirmation, but OSCommerce creates the order_id AFTER it receives comfirmation

Hope it helps (or I typed for 5 minutes in vain :-))
Yiangos