Page 1 of 1

Generating a unique transaction ID

Posted: Mon Oct 05, 2009 9:09 am
by robgrigg
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.

Re: Generating a unique transaction ID

Posted: Mon Oct 05, 2009 2:43 pm
by robgrigg
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.