public async Task <string> CreatePullPayment(CreatePullPayment create) { if (create == null) { throw new ArgumentNullException(nameof(create)); } if (create.Amount <= 0.0m) { throw new ArgumentException("Amount out of bound", nameof(create)); } using var ctx = this._dbContextFactory.CreateContext(); var o = new Data.PullPaymentData(); o.StartDate = create.StartsAt is DateTimeOffset date ? date : DateTimeOffset.UtcNow; o.EndDate = create.ExpiresAt is DateTimeOffset date2 ? new DateTimeOffset?(date2) : null; o.Period = create.Period is TimeSpan period ? (long?)period.TotalSeconds : null; o.Id = Encoders.Base58.EncodeData(RandomUtils.GetBytes(20)); o.StoreId = create.StoreId; o.SetBlob(new PullPaymentBlob() { Name = create.Name ?? string.Empty, Currency = create.Currency, Limit = create.Amount, Period = o.Period is long periodSeconds ? (TimeSpan?)TimeSpan.FromSeconds(periodSeconds) : null, SupportedPaymentMethods = create.PaymentMethodIds, View = new PullPaymentView() { Title = create.Name ?? string.Empty, Description = string.Empty, CustomCSSLink = null, Email = null, EmbeddedCSS = null, } });
private Client.Models.PullPaymentData CreatePullPaymentData(Data.PullPaymentData pp) { var ppBlob = pp.GetBlob(); return(new BTCPayServer.Client.Models.PullPaymentData() { Id = pp.Id, StartsAt = pp.StartDate, ExpiresAt = pp.EndDate, Amount = ppBlob.Limit, Name = ppBlob.Name, Currency = ppBlob.Currency, Period = ppBlob.Period, Archived = pp.Archived, ViewLink = _linkGenerator.GetUriByAction( nameof(PullPaymentController.ViewPullPayment), "PullPayment", new { pullPaymentId = pp.Id }, Request.Scheme, Request.Host, Request.PathBase) }); }