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

The ExternalOrderID has the format LSXXXXXX (for example LS1000071) while the corresponding PaymentInfo ReferenceID has the LSXXXXXXPX (for example LS1000071P1) format.
Changing the PaymentInfo ReferenceID
To change the PaymentInfo reference ID, follow following steps.
- Create a class library project in Visual studio and reference the Litium.Studio.dll and Litium.Foundation.dll assemblies.
- Implement the IPaymentInfoReferenceIdFactory interface.
Following is a sample implementation where external order id of the order is used as the PaymentInfo reference id. Note that, this assumes that you will always have just one PaymentInfo object connected to a given order, because the PaymentInfo referenceID must also 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;
}
}
}