private void HandleTicketResponse(ITicketResponse ticketResponse) { _log.Info($"Ticket '{ticketResponse.TicketId}' response is {ticketResponse.Status}. Reason={ticketResponse.Reason?.Message}"); if (ticketResponse.Status == TicketAcceptance.Accepted) { //required only if 'explicit acking' is enabled in MTS admin ticketResponse.Acknowledge(); // handle ticket response //if for some reason we want to cancel ticket, this is how we can do it var ticketCancel = _factory.CreateTicketCancelBuilder().SetTicketId(ticketResponse.TicketId).SetCode(TicketCancellationReason.BookmakerTechnicalIssue).BuildTicket(); _mtsSdk.SendTicket(ticketCancel); } else { // if the ticket was declined and response has reoffer, the reoffer or reoffer cancellation can be send // the reoffer or reoffer cancellation must be send before predefined timeout, or is automatically canceled if (ticketResponse.BetDetails.Any(a => a.Reoffer != null)) { if (ReofferShouldBeAccepted()) { // ReSharper disable once RedundantArgumentDefaultValue var reofferTicket = _factory.CreateTicketReofferBuilder().Set(_originalTicket, ticketResponse, null).BuildTicket(); _mtsSdk.SendTicket(reofferTicket); } else { var reofferCancel = _factory.CreateTicketReofferCancelBuilder().SetTicketId(ticketResponse.TicketId).BuildTicket(); _mtsSdk.SendTicket(reofferCancel); } } } }
public void CheckWithAutoTicketReofferRefIdTest() { var ticketBuilder = TicketBuilderHelper.GetTicketBuilder(_sender, null, 1, 1); var ticket = ticketBuilder.BuildTicket(); var reofferRefId = "R-" + SR.S1000; var reofferTicket = _builderFactory.CreateTicketReofferBuilder().Set(ticket, 200000, reofferRefId).BuildTicket(); var dto = new TicketMapper().Map(reofferTicket); var json = dto.ToJson(); CheckRequiredFields(json); Assert.IsTrue(json.Contains("reofferRefId")); Assert.IsTrue(json.Contains(ticket.TicketId)); Assert.IsTrue(json.Contains(reofferRefId)); Assert.IsTrue(json.Contains("200000")); }
public Task HandleTicketResponse(ITicketResponse ticket) { Task task = null; _log.Info($"Ticket '{ticket.TicketId}' response is {ticket.Status}. Reason={ticket.Reason?.Message}"); if (ticket.BetDetails != null && ticket.BetDetails.Any()) { foreach (var betDetail in ticket.BetDetails) { _log.Info($"Bet decline reason: '{betDetail.Reason?.Message}'."); if (betDetail.SelectionDetails != null && betDetail.SelectionDetails.Any()) { foreach (var selectionDetail in betDetail.SelectionDetails) { _log.Info($"Selection decline reason: '{selectionDetail.Reason?.Message}'."); } } } var tkId = Convert.ToInt64(ticket.TicketId.Split('_')[1]); if (ticket.Status == TicketAcceptance.Accepted) { //required only if 'explicit acking' is enabled in MTS admin //ticket.Acknowledge(); //update ticket status in db task = Task.Run(() => { //int stat = (int)BetStatus.r; int stat = (int)TicketStatus.running; _ticketService.AcceptTicket(tkId, stat.ToString()); }); return(task); } else if (ticket.Status == TicketAcceptance.Rejected) { //REOFFER //// if the ticket was declined and response has reoffer, the reoffer or reoffer cancellation can be send //// the reoffer or reoffer cancellation must be send before predefined timeout, or is automatically canceled if (ticket.BetDetails.Any(a => a.Reoffer != null)) { if (ReofferShouldBeAccepted(ticket.Reason.Code)) { // ReSharper disable once RedundantArgumentDefaultValue var reofferTicket = _factory.CreateTicketReofferBuilder().Set(mtsTicket, ticket, null).BuildTicket(); _mtsSdk.SendTicket(reofferTicket); // } else { var reofferCancel = _factory.CreateTicketReofferCancelBuilder().SetTicketId(ticket.TicketId).BuildTicket(); _mtsSdk.SendTicket(reofferCancel); //update ticket status in db task = Task.Run(() => { //int stat = (int)BetStatus.d; int stat = (int)TicketStatus.refused; //_ticketService.UpdateTicketStatus(tkId, stat.ToString()); _ticketService.RejectTicket(tkId, stat.ToString(), ticket.Reason.Code); }); return(task); } } else { if (ticket.Reason.Code == 101 || ticket.Reason.Code == 103 || ticket.Reason.Code == -101 || ticket.Reason.Code == -103) { ticket.Acknowledge(); } //update ticket status in db task = Task.Run(() => { //int stat = (int)BetStatus.d; int stat = (int)TicketStatus.refused; //_ticketService.UpdateTicketStatus(tkId, stat.ToString()); _ticketService.RejectTicket(tkId, stat.ToString(), ticket.Reason.Code); }); return(task); } } } return(task); }