public async Task RevertTransaction(CustomerOrder order) { if (order == null) { throw new ArgumentNullException(nameof(order)); } var settings = _settingsManager.Get(order.StoreId); if (!settings.IsActive || !settings.ReverseECommerceTransaction) { return; } using (var tracker = new SimpleTracker(settings.TrackingId, settings.TrackingDomain ?? string.Empty, CreateEnvironment())) { var list = new List <Task <TrackingResult> >(); var task = tracker.TrackAsync(ECommerceConverter.OrderToTransaction(order, true)); list.Add(task); foreach (var lineItem in order.Items) { var lineItemTask = tracker.TrackAsync(ECommerceConverter.LineItemToTransactionItem(order, lineItem, true)); list.Add(lineItemTask); } await Task.WhenAll(list.ToArray()); } }
public void LineItemToRevertTransactionItem() { var customerOrder = GetOrder(); foreach (var lineItem in customerOrder.Items) { var result = ECommerceConverter.LineItemToTransactionItem(customerOrder, lineItem); Assert.Equal(customerOrder.Number, result.TransactionId); Assert.Equal(customerOrder.CustomerId, result.ClientId); Assert.Equal(customerOrder.Currency, result.CurrencyCode); Assert.Equal(lineItem.CategoryId, result.ItemCategory); Assert.Equal(lineItem.Sku, result.ItemCode); Assert.Equal(lineItem.Name, result.ItemName); Assert.Equal(lineItem.PlacedPrice, result.ItemPrice); Assert.Equal(lineItem.Quantity, result.ItemQuantity); Assert.Equal(customerOrder.CustomerId, result.UserId); } }