/// <summary> /// Runs the specified argument. /// </summary> /// <param name="arg">The argument.</param> /// <param name="context">The context.</param> /// <returns> /// A cart with federate payment component /// </returns> public override async Task <SalesActivity> Run(SalesActivity arg, CommercePipelineExecutionContext context) { Condition.Requires(arg).IsNotNull($"{Name}: sales activity can not be null."); if (!arg.HasComponent <FederatedPaymentComponent>() || !arg.PaymentStatus.Equals(context.GetPolicy <KnownSalesActivityStatusesPolicy>().Settled, StringComparison.OrdinalIgnoreCase)) { return(arg); } var order = await _getOrderCommand.Process(context.CommerceContext, arg.Order.EntityTarget).ConfigureAwait(false); if (order == null || !order.HasComponent <FederatedPaymentComponent>()) { return(arg); } var orderPayment = order.GetComponent <FederatedPaymentComponent>(); var payment = arg.GetComponent <FederatedPaymentComponent>(); orderPayment.TransactionStatus = payment.TransactionStatus; await _persistEntityPipeline.Run(new PersistEntityArgument(order), context).ConfigureAwait(false); return(arg); }
public override async Task <Order> Run(string arg, CommercePipelineExecutionContext context) { Condition.Requires(arg).IsNotNull($"{Name}: The compare collection id can not be null"); return(await _getOrderCommand.Process(context.CommerceContext, arg)); }