public async Task <ActionResult <SaleStatusResourceModel> > CompletePayment(CompletePaymentInputModel inputModel) { try { var saleModel = await this.GetSaleInfo(inputModel.SaleId); if (saleModel == null) { return(this.NotFound()); } var currentUserId = this.GetUserId(this.User); if (saleModel.BuyerId == currentUserId) { var saleStatusModel = await this.salesService.CompletePayment <SaleStatusResourceModel>( inputModel.SaleId, inputModel.OrderId); var addedLogModel = await this.saleLogsService.AddLogToSale <AddLogToSaleResourceModel>(saleModel.Id, SaleLogs.Paid); await this.saleLogHubContext.Clients.Group(saleModel.Id.ToString()) .RecieveLogNotification(addedLogModel.Content); return(saleStatusModel); } return(this.Forbid()); } catch (Exception ex) { this.loggerService.LogException(ex); return(this.BadRequest()); } }
public HttpResponseMessage CompletePayment([FromBody] CompletePaymentInputModel model) { var dateStart = DateTime.Now; _performancelog.Debug($"Start,PaymentController,CompletePayment,{string.Empty},{dateStart:hh.mm.ss.ffffff}"); ErrorMessage errorMessage; string userCode; HttpResponseMessage httpResponseMessage; if (GetUserCode(out userCode, out httpResponseMessage)) { return(httpResponseMessage); } if (model == null) { return(Request.CreateResponse( HttpStatusCode.BadRequest, new ErrorResponse { Error = new MessageStyle { Message = Constants.InvalidRequest, MessageType = 0 } })); } bool openCashDrawer; bool isRefund; string changeDue; CustomerDisplay lcdMsg; var receipts = _paymentManager.CompletePayment(model.SaleNumber, model.TillNumber, model.TransactionType, userCode, model.IssueStoreCredit, out errorMessage, out openCashDrawer, out changeDue, out isRefund, out lcdMsg); var kickbackCommunicationMsg = _paymentManager.KickbackCommunicationError(); if (!string.IsNullOrEmpty(errorMessage?.MessageStyle?.Message)) { return(Request.CreateResponse(HttpStatusCode.BadRequest, new ErrorResponse { Error = errorMessage.MessageStyle })); } var newSale = _saleManager.InitializeSale(model.TillNumber, model.RegisterNumber, userCode, out errorMessage); var tillLimitExeceeded = _paymentManager.CheckTillLimit(model.TillNumber); var completePaymentResponseModel = new FinishPaymentResponseModel { NewSale = new NewSale { SaleNumber = newSale.Sale_Num, TillNumber = newSale.TillNumber, Customer = newSale.Customer.Name }, OpenCashDrawer = openCashDrawer, LimitExceedMessage = tillLimitExeceeded, ChangeDue = changeDue, CustomerDisplays = new List <CustomerDisplay> { lcdMsg, newSale.CustomerDisplay }, Receipts = receipts, kickabckServerError = kickbackCommunicationMsg }; KickBackManager.ExchangeRate = 0; return(Request.CreateResponse(HttpStatusCode.OK, completePaymentResponseModel)); }