Doing your own credit card processing is a HUGE endeavor.
What you do is create open a business bank account and then sign up
for a credit card merchant account - your bank may partner with
someone. You then use the API from that host to collect and apply
credit card payments.
When you get the credit card information, you pass it to the
merchant account partner and they will return one set of info if
the charge was approved and another if it was not. You will also
get back a unique transaction id.
Under NO circumstances should you store credit card numbers,
not even encrypted. The merchant account provider takes care of all
of that. If you need to process a refund, you send them the
transaction id and they will take it from there. It is a good idea
to store the last four digits of the credit card as well as the
expiration date, so you can display this information from the