views:

156

answers:

3

I have a shopping cart. I want to integrate with the CCAvenue payment gateway. I always send order ID from database. After checkout, suddenly my system turns off. Then again I have to check out it send again. The order id from my database is duplicate for the payment gateway. This is my problem.

My question is: How do I send a unique order ID every time? My site is in PHP.

A: 

I think there should be a separate function for this - running all time, checking whether a previous version of the order is in the cart or not. Also, a copy of the process should be stored in the db always. This way, if for some reason, the server restarts, still, the order can be proceeded from the same position (thus there won't be any problem of duplication of orders).

NEVER store the complete credit card details in your db. At best you're running the risk of having the info being stolen. At worst, you can well be in direct violation of your agreements with your Merchant Account provider. Remember that something you don't have (full credit card info) can never be stolen. Instead, store just the last 4 digits of the credit card to enable auditing.
Larry K
@Larry K: +1 ugh. Violation of the agreement with the payment gateway is never fun, and it's annoying how many people do it.
scraimer
A: 

Probably want a unique id like this http://us3.php.net/uniqid though your question is kind of vague

jarrett
+1  A: 

With most payment gateways you can send a single auth+capture AKA "sale" transaction or you can send an authorize and capture transaction as two separate requests.

If you are worried about transactional consistancy issues with sending a single sale transaction my recommendation is to send an authorize to first reserve the funds and then send a capture at the end of your ordering process.

If the system fails during the initial authorize worse case the funds are freed within three days when your auth expires. You should take care to not have the worse case for authorize occur as it blocks the authorized funds from being used until cleared which can occasionally lead to upset customers.

If the system fails during the final capture and you cannot record status you can simply rerun the capture later in which case the result will either be success or a message from the gateway indicating the capture already occured which can then be used to update the payment status of your system.

Einstein
thanks for your comment my problem is solve