Forum Moderators: phranque
I need to collect CC details and have a script send them via email for proccessing by hand. Not ideal I know, but that's what I need to do.
So, if the form/script is on a secure server, how can I send mail securely?
(i know how to send the mail, just not the 'wherewithall' of sending it securely.)
Thanks for any help/advice..
Nick
It is a good question, but I don't think you can easily do it.
For email to be secure you would have to encypt it, and then de-encrypt it on the receiving end to see the contents......A lot of hassle.
I would either use SSL or if your want to keep it simple write the info to an SQL database instead of using email.
There are some implications with the SQL database, but much easier to overcome that the email issue IMHO.
So, if the form/script is on a secure server, how can I send mail securely
Easiest way is probably to take credit card details over SSL and store them on a secure server. When an order is taken, generate an email telling you that there is a new order.
Then just log into the secure server and pick up the details for processing. We have a couple of clients that do this ... not as clean as a payment gateway, but it works OK.
You might want to download commerce.cgi and look at the source ... this'll give you some ideas for implementing this system.
So, if I stored them on MySQL vial a secure server? Or as a text file on a secure server or what...?
Download that commerce.cgi source, Nick. Card numbers are actually split ... half is stored on a secure server (in a text file by default), and the other half is mailed to you.
I have changed the way this works for client sites, but it will give you a good starting point (and save you some development time ... commerce.cgi is open source and freely modifiable)
Q. I need to keep the prd's in a db of my own design. What I'd like to do is to just allow customers to 'buy' without having to use some pre-built store catelog scripts...
Could I interface with commerce.cgi only for that purpose do you think?
Lorax
So as long as the scripts were on the secore server and the cc no-s encrypted that'd be about it?
Many thanks everyone, much apprecaited..
Nick
Q. I need to keep the prd's in a db of my own design. What I'd like to do is to just allow customers to 'buy' without having to use some pre-built store catelog scripts...
Shouldn't be too tricky ... commerce.cgi uses a text database driver stored in its own file. Somebody has already modified this to use MySQL on the back end (I think that the source is available for this too ... look around on the commerce.cgi site)
Just hack the relevant parts out of these scripts and use them.
The safest thing to do is NOT store the data on a web server. Just push that card info along .... SSL to encrypt the data in transit, then use GnuPG or PGP to encrypt it with the public key, and then send the encrypted data via email which the client can decrypt using their private key. Never store or the private key on the web server. Use PHP's proc_open function to shell out to the GnuPG or PGP command line utilities - backticks, shell_exec, etc expose the data to the shell.
Remember web servers by their very nature are insecure... assume it's been rooted.
There is one instance where I did store the CC info in a mysql db, however. The basic concept is SSL in transit, encryption in storage. It defeats the purpose using an SSL connection only to store the data in plain view. That's like having an armoured car deliver a bag of money to your office and leave it on the counter, right? ;)
What I did is two-way encrypt the data using mysql's encode function. The encode function needs a passphrase, BUT you don't want to store the passphrase on the server (read: in your script) because that will be visible to other users/hackers. So what I did is used PHP's mt_rand() function to create a random passphrase with each transaction. The credit card data is encrypted using the random phrase and stored in the database, then the random passphrase is disguised and sent to the client via email - never stored on the server. To retrieve the cc info the client logs in to an SSL secured admin I created where they can enter the phrase, the script uses the phrase to decode the data and displays it in the browser.
There was a great discussion about this here [webmasterworld.com] as well.