public async Task <ActionResult> PaymentForm(string orderNumber) { var order = await _orderService.GetOrderByNumberAsync(orderNumber); var incomingPayment = order.InPayments?.FirstOrDefault(x => x.PaymentMethodType.EqualsInvariant("PreparedForm")); if (incomingPayment == null) { return(BadRequest("Order doesn't have any payment of type: PreparedForm")); } var processingResult = await _orderApi.ProcessOrderPaymentsAsync(order.Id, incomingPayment.Id); WorkContext.PaymentFormHtml = processingResult.HtmlForm; return(View("payment-form", WorkContext)); }