Ah. seems you want to start a payment processor at professional level. Well, I do not have much idea about that but in order to start such processor, you need to pass through some legal procedure I guess. Just search in google for your topic
Unless you have plans to do a lot of volume of transactions, building your own payment gateway is going to cost you tens to hundrends of thousands of dollars. I'd start with getting familiar with PCI compliance and all the other card regs you'll have to follow.
You need to obtain license from government before you do this. Coz without license is illegal. Then you need a good script that have no bug.
You can try AlstraSoft EPay Pro. I don't use it, so can't tell you whether it's a good script or not. - Dynashox -