Generating a unique transaction ID

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
robgrigg
Lieutenant (LT)
Lieutenant (LT)
Posts: 76
Joined: Fri Jun 12, 2009 2:22 am

Generating a unique transaction ID

Post by robgrigg » Mon Oct 05, 2009 9:09 am

Hi,

I am building a custom payment Gateway and I wondered if any of you smart people had already solved a problem I have.

I need to create a unique transaction ID. I have previously used (in other applications) the order number and the number of payments, such as 12345-2.

How might I do this with Able? Is there a better way? Should I use the OrderID or OrderNumber?

Any help greatly appreciated.

Thanks.

Rob.

robgrigg
Lieutenant (LT)
Lieutenant (LT)
Posts: 76
Joined: Fri Jun 12, 2009 2:22 am

Re: Generating a unique transaction ID

Post by robgrigg » Mon Oct 05, 2009 2:43 pm

I decided on this

Code: Select all

        /// <summary>
        /// Gets the transaction ID.
        /// </summary>
        /// <param name="order">The order.</param>
        /// <returns>a string containing a unique tranaction ID</returns>
        private string GetTransactionID(Order order)
        {
            return string.Format("{0}-{1}", order.OrderNumber.ToString(), order.Payments.LastPayment.Transactions.Count);
        }
this will give me the ordernum (obviously) + the count of transactions, so if they are retried due to failed attempts or part shipments / payments each of the transIds on our providers side will be unique and marry up with the actual tranaction.

Rob.

Post Reply