public InvoiceResponse EntityToDTO() { ServerUrl = ServerUrl ?? ""; InvoiceResponse dto = new InvoiceResponse { Id = Id, OrderId = OrderId, PosData = PosData, CurrentTime = DateTimeOffset.UtcNow, InvoiceTime = InvoiceTime, ExpirationTime = ExpirationTime, BTCPrice = Money.Coins((decimal)(1.0 / Rate)).ToString(), Status = Status, Url = ServerUrl.WithTrailingSlash() + "invoice?id=" + Id, Currency = ProductInformation.Currency, Flags = new Flags() { Refundable = Refundable } }; Populate(ProductInformation, dto); Populate(BuyerInformation, dto); dto.ExRates = new Dictionary <string, double> { { ProductInformation.Currency, Rate } }; dto.PaymentUrls = new InvoicePaymentUrls() { BIP72 = $"bitcoin:{DepositAddress}?amount={GetCryptoDue()}&r={ServerUrl.WithTrailingSlash() + ($"i/{Id}")}", BIP72b = $"bitcoin:?r={ServerUrl.WithTrailingSlash() + ($"i/{Id}")}", BIP73 = ServerUrl.WithTrailingSlash() + ($"i/{Id}"), BIP21 = $"bitcoin:{DepositAddress}?amount={GetCryptoDue()}", }; dto.BitcoinAddress = DepositAddress.ToString(); dto.Token = Encoders.Base58.EncodeData(RandomUtils.GetBytes(16)); //No idea what it is useful for dto.Guid = Guid.NewGuid().ToString(); var paid = Payments.Select(p => p.Output.Value).Sum(); dto.BTCPaid = paid.ToString(); dto.BTCDue = GetCryptoDue().ToString(); dto.ExceptionStatus = ExceptionStatus == null ? new JValue(false) : new JValue(ExceptionStatus); return(dto); }
public string GetPaymentDestination() { return(DepositAddress?.ToString()); }