Changing payment reference id
This article describes how to change the auto generated PaymentInfo reference id. Changing the auto generated reference is most useful in ERP integration scenarios where the ERP system expects a reference id in a pre-defined format.
When an order is created, the order external reference id and its payments reference id is automatically created by Litium.
The Order object may have multiple payments, each with its own reference id. The ExternalOrderID in the Order object and the ReferenceID in the PaymentInfo object are both unique strings in human readable format.

The ExternalOrderID has the format LSXXXXXX (for example LS1000071) while the corresponding PaymentInfo ReferenceID has the format LSXXXXXXPX (for example LS1000071P1).
Changing the PaymentInfo ReferenceID
To change the PaymentInfo ReferenceID:
- Create a class library project in Visual studio and reference the Litium.Studio.dll and Litium.Foundation.dll assemblies.
- Implement the IPaymentInfoReferenceIdFactory interface.
The following code is a sample implementation where the external order id of the order is used as the PaymentInfo ReferenceID. Note that this assumes that you will only have one PaymentInfo object connected to a given order, because the PaymentInfo ReferenceID must be unique.
using Litium.Foundation.Modules.ECommerce.Plugins.Payments;
using Litium.Foundation.Modules.ECommerce.Carriers;
namespace Litium.Studio.AddOns.Samples.Checkout
{
/// <summary>
/// Changes the <see cref="PaymentInfo.ReferenceID"/> to be equal to <see cref="Order.ExternalOrderID"/>
/// </summary>
public class SamplePaymentInfoReferenceIdFactory : IPaymentInfoReferenceIdFactory
{
/// <summary>
/// Creates the specified index.
/// </summary>
/// <param name="index">The index. If the order contains more than one payment info. use this index to differenciate between them</param>
/// <param name="orderCarrier">The order carrier.</param>
/// <param name="paymentInfoCarrier">The payment info carrier.</param>
/// <returns>
/// Reference id that the payment info should use.
/// </returns>
/// <exception cref="System.NotImplementedException"></exception>
public string Create(int index, OrderCarrier orderCarrier, PaymentInfoCarrier paymentInfoCarrier)
{
//assume for this example, the order contains only one payment info,
//and the payment info ReferenceID should be same as order externalOrderId
return orderCarrier.ExternalOrderID;
}
}
}