Example #1
0
        public ViewPullPaymentModel(PullPaymentData data, DateTimeOffset now)
        {
            Id      = data.Id;
            StoreId = data.StoreId;
            var blob = data.GetBlob();

            PaymentMethods        = blob.SupportedPaymentMethods;
            SelectedPaymentMethod = PaymentMethods.First().ToString();
            Archived      = data.Archived;
            AutoApprove   = blob.AutoApproveClaims;
            Title         = blob.View.Title;
            Description   = blob.View.Description;
            Amount        = blob.Limit;
            Currency      = blob.Currency;
            Description   = blob.View.Description;
            ExpiryDate    = data.EndDate is DateTimeOffset dt ? (DateTime?)dt.UtcDateTime : null;
            Email         = blob.View.Email;
            MinimumClaim  = blob.MinimumClaim;
            EmbeddedCSS   = blob.View.EmbeddedCSS;
            CustomCSSLink = blob.View.CustomCSSLink;
            if (!string.IsNullOrEmpty(EmbeddedCSS))
            {
                EmbeddedCSS = $"<style>{EmbeddedCSS}</style>";
            }
            IsPending = !data.IsExpired();
            var period = data.GetPeriod(now);

            if (data.Archived)
            {
                Status = "Archived";
            }
            else if (data.IsExpired())
            {
                Status = "Expired";
            }
            else if (period is null)
            {
                Status = "Not yet started";
            }
            else
            {
                Status = string.Empty;
            }

            ResetIn = string.Empty;
            if (period?.End is DateTimeOffset pe)
            {
                var resetIn = (pe - DateTimeOffset.UtcNow);
                if (resetIn < TimeSpan.Zero)
                {
                    resetIn = TimeSpan.Zero;
                }
                ResetIn = resetIn.TimeString();
            }
        }
Example #2
0
 public static bool IsSupported(this PullPaymentData data, BTCPayServer.Payments.PaymentMethodId paymentId)
 {
     return(data.GetBlob().SupportedPaymentMethods.Contains(paymentId));
 }