views:

118

answers:

4

I have a payment gateway api for BluePay. My application is in PHP. I am able to process a transaction with code similar to this:

bp->process(1111111111111111,.....) with 111111111111111 being the card number.

the process function posts the card number to bluepay's site using PHP's CURL wrappers.

How can I safely get a card number from the user?

where I substitute 111111111111111 with a variable that is filled in from the user.

+1  A: 

Give them a form over an encrypted connection?

Anon.
+5  A: 

You'll need to ensure that both receiving the card number (from the user) and sending the card number (to your gateway) is done over an SSL connection. I assume your gateway wouldn't allow it any other way, so that side of the transaction is * probably* already safe.

It's also important not to store the CC data anywhere, simply pass it onto the gateway.

So you need to purchase an SSL certificate for your web server, and make sure all sensitive information sent is encrypted (https://). You can generate the SSL certificate yourself, but that won't give your users a warm fuzzy secure feeling. It also wouldn't verify that your site is who it claims to be.

Tim Lytle
By "store", do you mean on the disk or as a variable? Also, how can you generate the SSL certificate yourself?
Maxim Zaslavsky
By 'store' I mean anything outside of the (temporarily executing) script. Flat file, Database, Cache, any long term storage (so yes, on disk). Self signed certificates can be generated without a signing CA, but lack the authenticity check a CA provides.
Tim Lytle
A: 

You can get a cheap single domain SSL signed certificate at namecheap

In addition to this I would also recommend hashing the number before sending it. SSL is not perfect: Defeating SSL

pcp
A: 

Don't forget, if you are hosting a page which gathers credit card information, this system then becomes 'in-scope' as far as the PCI-DSS (Payment Card Industry Data Security Standard) is concerned, which comes with a whole world of grief if you have to comply to it!

You may be better off using a 'hosted' solution for your payments. i.e. the user is redirected to a page hosted on, say, Worldpay.com, to actually enter their card details, and then redirected back to your site afterwards.

NickD
Hosted pages aren't your only option if you want to eliminate credit card information from your environment. With Braintree's transparent redirect API ( http://bit.ly/braintree-api ), you host the form that gathers the credit card information, but it gets submitted directly to Braintree. You retain control over the checkout process, but your PCI scope is tremendously reduced. Disclosure: I work for Braintree.
dan-manges