public override async Task <bool> Run(UpdateIngenicoPaymentArgument arg, CommercePipelineExecutionContext context) { Condition.Requires(arg).IsNotNull($"{this.Name}: The argument cannot be null."); // Todo: Authenticate request // Fulfill pre-condition: get cart Order order = await getOrderPipeline.Run(arg.OrderId, context).ConfigureAwait(false); if (order == null) { await context.CommerceContext.AddMessage(context.CommerceContext.GetPolicy <KnownResultCodes>().Error, "EntityNotFound", new object[] { arg.OrderId }, $"Entity {0} was not found."); return(false); } var paymentStatus = order.GetComponent <IngenicoPaymentComponent>(); paymentStatus.Brand = arg.Brand; paymentStatus.TransactionStatus = arg.Status; PersistEntityArgument result = await persistEntityPipeline.Run(new PersistEntityArgument(order), context); return(true); }
public override async Task <bool> Run(HandleResponseArgument arg, CommercePipelineExecutionContext context) { var orderId = arg.Parameters["IDENTIFICATION.TRANSACTIONID"]; Order order = await getOrderPipeline.Run(orderId, context).ConfigureAwait(false); if (order == null) { await context.CommerceContext.AddMessage(context.CommerceContext.GetPolicy <KnownResultCodes>().Error, "EntityNotFound", new object[] { orderId }, $"Entity {0} was not found."); return(false); } if (!order.HasComponent <HeidelpayPaymentComponent>()) { return(false); } var payment = order.GetComponent <HeidelpayPaymentComponent>(); UpdatePayment(arg.Parameters, payment); await persistEntityPipeline.Run(new PersistEntityArgument(order), context); return(true); }
public override async Task <bool> Run(RequestPaymentArgument arg, CommercePipelineExecutionContext context) { Condition.Requires(arg).IsNotNull($"{this.Name}: The argument cannot be null."); Order order = await getOrderPipeline.Run(arg.OrderId, context).ConfigureAwait(false); if (order == null) { await context.CommerceContext.AddMessage(context.CommerceContext.GetPolicy <KnownResultCodes>().Error, "EntityNotFound", new object[] { arg.OrderId }, $"Entity {0} was not found."); return(false); } var policy = context.CommerceContext.GetPolicy <HeidelpayPolicy>(); var request = BuildRequest(policy, order); string redirectUrl = await Post(policy.Url, request); context.CommerceContext.AddModel(new PaymentRequested(redirectUrl)); return(true); }