private string CheckLtc(Invoice invoice) { var litecoin = db.PaymentTypeConfig.Where(p => p.PaymentId == invoice.PaymentTypeId).OrderByDescending(p => p.Id).FirstOrDefault(); if (litecoin != null) { BitCoinCore = new Services.BitCoinCore.Litecoin(litecoin.Login, litecoin.Pass, litecoin.Host, litecoin.Port); var TxList = BitCoinCore.GetListTransactions(invoice.AccountNumber); //Найден платеж с нужным кол-во ltc if (TxList != null && TxList.Count > 0 && TxList[TxList.Count - 1].amount >= invoice.Value) { DateTime pDate = (new DateTime(1970, 1, 1, 0, 0, 0, 0)).AddSeconds(TxList[TxList.Count - 1].timereceived); if (pDate > invoice.CreateTimestamp.Value.AddMinutes(invoice.LifeTimeDuration.Value.Minutes)) { return("Вы оплатили позже положеного времени. Свяжитесь с технической поддержкой!"); } else { if (invoice.Paid == false) { InvoicePaid(this.Order.Id); } invoice.Payment.Add(AddPayment(invoice.Id, TxList[TxList.Count - 1].txid, TxList[TxList.Count - 1].amount, pDate)); return("Платеж найден. Заказ отправлен на обработку!"); } } else { return("Платеж не найден."); } } else { return("Ошибка при подключении к сети Litectoin.Свяжитесь с технической поддержкой!"); } }
public async Task <IActionResult> TestConnection([FromBody] PaymentTypeConfig config) { if (config.PaymentId == Bot.Core.ConstantVariable.PaymentTypeVariable.QIWI) { if (await Services.Qiwi.QiwiFunction.TestConnection(config.Login, config.Pass)) { return(new JsonResult("Успех")); } else { return(new JsonResult("Ошибка соединения")); } } if (config.PaymentId != Bot.Core.ConstantVariable.PaymentTypeVariable.QIWI && config != null) { string FirstBlockHash = String.Empty; Services.BitCoinCore.BitCoin ltc = new Services.BitCoinCore.BitCoin(config.Login, config.Pass, config.Host, config.Port); var block = ltc.GetInfo <Services.BitCoinCore.GetInfo>(); if (block != null && block.result != null && block.result.blocks > 0) { return(new JsonResult("Успех")); } else { return(new JsonResult("Ошибка соединения")); } } else { return(new JsonResult("Ошибка соединения")); } }
/// <summary> /// Создать счет на оплату в Криптовалюте /// </summary> /// <param name="order">Заказ</param> /// <param name="paymentTypeId">Тип платежа. Лайткоин, БиткоинКэш и т.д</param> /// <param name="Total">Сумма в фиате.</param> /// <param name="LifeTimeDuration">Время жизни счета в минутах</param> /// <returns></returns> private Invoice AddCryptoCurrencyInvoice(Orders order, int paymentTypeId, double Total, int LifeTimeDuration = 30) { double Summa = 0.0; string AccountNumber = ""; var type = db.PaymentType.Where(p => p.Id == paymentTypeId).FirstOrDefault(); var PaymentConfig = db.PaymentTypeConfig.Where(p => p.PaymentId == paymentTypeId && p.Enable == true).OrderByDescending(p => p.Id).FirstOrDefault(); if (PaymentConfig != null) { CryptoCurrency = new Services.BitCoinCore.BitCoin(PaymentConfig.Login, PaymentConfig.Pass, PaymentConfig.Host, PaymentConfig.Port); } if (type != null) // конвертируем из фиата в крипту { Summa = MoneyConvert(Total, type.Code, ConfigurationFunction.MainCurrencyInSystem().Code); } if (CryptoCurrency != null) // Генерируем адрес куда необходимо перевести деньги { AccountNumber = CryptoCurrency.GetNewAddress(); } if (type != null && CryptoCurrency != null && AccountNumber != null && AccountNumber != null && Summa > 0) { return(InsertInvoice(AccountNumber: AccountNumber, PaymentTypeId: paymentTypeId, Value: Summa)); } else { return(null); } }