void ValidateSaleStatusParams(BrokerSaleStatusParams model) { if (string.IsNullOrEmpty(model.PaymentId)) { throw new ApiException(ErrorCode.PaymentIdEmpty); } }
public async Task <BrokerSaleStatusResult> SaleStatus(BrokerSaleStatusParams model) { _logger.LogInformation("SaleStatus: {@params}", model); ValidateSaleStatusParams(model); _cache.TryGetValue(model.PaymentId, out Payment payment); if (payment == null) { payment = await _db.Payment.FirstOrDefaultAsync(t => t.PaymentId == model.PaymentId); if (payment == null) { throw new ApiException(ErrorCode.PaymentNotFoundOrExpired); } } await _cryptoProviderService.CheckPayment(payment); if (payment.Status == PaymentStatus.Received) { await _wallet.ProcessPayment(payment, _db); } _db.Payment.Update(payment); await _db.SaveChangesAsync(); var res = GetSaleStatusResult(payment); _logger.LogInformation("SaleStatus Result: {@params}", res); return(res); }
public async Task <IActionResult> SaleStatus([FromBody] BrokerSaleStatusParams model) { var res = await _paymentService.SaleStatus(model); return(Ok(res)); }