public static PaymentMethodId GetpaymentMethodId(this InvoiceCryptoInfo info) { return new PaymentMethodId(info.CryptoCode, Enum.Parse<PaymentTypes>(info.PaymentType)); }
public override void PopulateCryptoInfo(PaymentMethod details, InvoiceCryptoInfo invoiceCryptoInfo, string serverUrl) { }
public static PaymentMethodId GetpaymentMethodId(this InvoiceCryptoInfo info) { return(new PaymentMethodId(info.CryptoCode, PaymentTypes.Parse(info.PaymentType))); }
public InvoiceResponse EntityToDTO(BTCPayNetworkProvider networkProvider) { ServerUrl = ServerUrl ?? ""; InvoiceResponse dto = new InvoiceResponse { Id = Id, OrderId = OrderId, PosData = PosData, CurrentTime = DateTimeOffset.UtcNow, InvoiceTime = InvoiceTime, ExpirationTime = ExpirationTime, Status = Status, Currency = ProductInformation.Currency, Flags = new Flags() { Refundable = Refundable } }; dto.CryptoInfo = new List <InvoiceCryptoInfo>(); foreach (var info in this.GetCryptoData().Values) { var accounting = info.Calculate(); var cryptoInfo = new InvoiceCryptoInfo(); cryptoInfo.CryptoCode = info.CryptoCode; cryptoInfo.Rate = info.Rate; cryptoInfo.Price = Money.Coins(ProductInformation.Price / cryptoInfo.Rate).ToString(); cryptoInfo.Due = accounting.Due.ToString(); cryptoInfo.Paid = accounting.Paid.ToString(); cryptoInfo.TotalDue = accounting.TotalDue.ToString(); cryptoInfo.NetworkFee = accounting.NetworkFee.ToString(); cryptoInfo.TxCount = accounting.TxCount; cryptoInfo.CryptoPaid = accounting.CryptoPaid; cryptoInfo.Address = info.DepositAddress; cryptoInfo.ExRates = new Dictionary <string, double> { { ProductInformation.Currency, (double)cryptoInfo.Rate } }; var scheme = networkProvider.GetNetwork(info.CryptoCode)?.UriScheme ?? "BTC"; var cryptoSuffix = cryptoInfo.CryptoCode == "BTC" ? "" : "/" + cryptoInfo.CryptoCode; cryptoInfo.Url = ServerUrl.WithTrailingSlash() + $"invoice{cryptoSuffix}?id=" + Id; cryptoInfo.PaymentUrls = new InvoicePaymentUrls() { BIP72 = $"{scheme}:{cryptoInfo.Address}?amount={cryptoInfo.Due}&r={ServerUrl.WithTrailingSlash() + ($"i/{Id}{cryptoSuffix}")}", BIP72b = $"{scheme}:?r={ServerUrl.WithTrailingSlash() + ($"i/{Id}{cryptoSuffix}")}", BIP73 = ServerUrl.WithTrailingSlash() + ($"i/{Id}{cryptoSuffix}"), BIP21 = $"{scheme}:{cryptoInfo.Address}?amount={cryptoInfo.Due}", }; #pragma warning disable CS0618 if (info.CryptoCode == "BTC") { dto.Url = cryptoInfo.Url; dto.BTCPrice = cryptoInfo.Price; dto.Rate = cryptoInfo.Rate; dto.ExRates = cryptoInfo.ExRates; dto.BitcoinAddress = cryptoInfo.Address; dto.BTCPaid = cryptoInfo.Paid; dto.BTCDue = cryptoInfo.Due; dto.PaymentUrls = cryptoInfo.PaymentUrls; } #pragma warning restore CS0618 dto.CryptoInfo.Add(cryptoInfo); } Populate(ProductInformation, dto); Populate(BuyerInformation, dto); dto.Token = Encoders.Base58.EncodeData(RandomUtils.GetBytes(16)); //No idea what it is useful for dto.Guid = Guid.NewGuid().ToString(); dto.ExceptionStatus = ExceptionStatus == null ? new JValue(false) : new JValue(ExceptionStatus); return(dto); }