public async Task <IActionResult> Failed([FromServices] QazKomAckquiringService qazKom, [FromQuery] string orderId, string response) { Log.Information("{EventId} failed {orderId}, {response}", "QAZKOM", orderId, response); await qazKom.TryUpdateTransactionByOrderIdAsync(orderId); return(Ok(0)); }
public async Task <IActionResult> Buy([FromServices] QazKomAckquiringService qazKomAckquiring, [FromServices] Provider provider, [FromBody] BuyPacketRequest request) { int price = 0; using (var rep = new Repository <PacketType>(provider)) { var type = await rep.Get(x => x.Code == request.PacketType).SingleOrDefaultAsync(); if (type == null) { return(Ok(ApiResponse.Failed(ApiErrorCode.ResourceNotFound, "Выбраный тип пакета не найден"))); } if (type.Price == 0) { return(Ok(ApiResponse.Failed(ApiErrorCode.ValidationError, "Выбраный тип пакета не предназначен для покупки"))); } price = type.Price; } var builder = new UriBuilder(this.Request.Scheme, this.Request.Host.Host); if (this.Request.Host.Port.HasValue) { builder.Port = this.Request.Host.Port.Value; } var response = await qazKomAckquiring.CreateTransaction(User.Identity.Name, price, $"Покупка пакета {request.PacketType}", request.PacketType, builder.Uri); return(Ok(ApiResponse.Success(response))); }
public async Task <IActionResult> Complete( [FromServices] QazKomAckquiringService qazKom, [FromServices] RemoteBillingService billing, [FromQuery] string orderId, string response) { Log.Information("{EventId} query with {orderId}, {response}", "QAZKOM", orderId, response); var transaction = await qazKom.TryUpdateTransactionByOrderIdAsync(orderId); await billing.AddPacketAsync(transaction.ProductCode, transaction.Employee); await qazKom.CompleteTransaction(transaction); Log.Information("{EventId} transaction completed {orderId}", "QAZKOM", orderId); return(Ok(0)); }