Exemplo n.º 1
0
        void SetCryptoCurrencies(CheckoutAppearanceViewModel vm, Data.StoreData storeData)
        {
            var enabled          = storeData.GetEnabledPaymentIds(_NetworkProvider);
            var defaultPaymentId = storeData.GetDefaultPaymentId();
            var defaultChoice    = defaultPaymentId is not null?defaultPaymentId.FindNearest(enabled) : null;

            if (defaultChoice is null)
            {
                defaultChoice = enabled.FirstOrDefault(e => e.CryptoCode == "BTC" && e.PaymentType == PaymentTypes.BTCLike) ??
                                enabled.FirstOrDefault(e => e.CryptoCode == "BTC" && e.PaymentType == PaymentTypes.LightningLike) ??
                                enabled.FirstOrDefault();
            }
            var choices = enabled
                          .Select(o =>
                                  new CheckoutAppearanceViewModel.Format()
            {
                Name      = o.ToPrettyString(),
                Value     = o.ToString(),
                PaymentId = o
            }).ToArray();
            var chosen = defaultChoice is null ? null : choices.FirstOrDefault(c => defaultChoice.ToString().Equals(c.Value, StringComparison.OrdinalIgnoreCase));

            vm.PaymentMethods       = new SelectList(choices, nameof(chosen.Value), nameof(chosen.Name), chosen?.Value);
            vm.DefaultPaymentMethod = chosen?.Value;
        }
Exemplo n.º 2
0
        void SetCryptoCurrencies(CheckoutExperienceViewModel vm, Data.StoreData storeData)
        {
            var choices = storeData.GetEnabledPaymentIds(_NetworkProvider)
                          .Select(o => new CheckoutExperienceViewModel.Format()
            {
                Name = o.ToPrettyString(), Value = o.ToString(), PaymentId = o
            }).ToArray();

            var defaultPaymentId = storeData.GetDefaultPaymentId(_NetworkProvider);
            var chosen           = choices.FirstOrDefault(c => c.PaymentId == defaultPaymentId);

            vm.CryptoCurrencies     = new SelectList(choices, nameof(chosen.Value), nameof(chosen.Name), chosen?.Value);
            vm.DefaultPaymentMethod = chosen?.Value;
        }
Exemplo n.º 3
0
        PaymentMethodOptionViewModel.Format?GetDefaultPaymentMethodChoice(Data.StoreData storeData)
        {
            var enabled          = storeData.GetEnabledPaymentIds(_NetworkProvider);
            var defaultPaymentId = storeData.GetDefaultPaymentId();
            var defaultChoice    = defaultPaymentId is not null?defaultPaymentId.FindNearest(enabled) : null;

            if (defaultChoice is null)
            {
                defaultChoice = enabled.FirstOrDefault(e => e.CryptoCode == _NetworkProvider.DefaultNetwork.CryptoCode && e.PaymentType == PaymentTypes.BTCLike) ??
                                enabled.FirstOrDefault(e => e.CryptoCode == _NetworkProvider.DefaultNetwork.CryptoCode && e.PaymentType == PaymentTypes.LightningLike) ??
                                enabled.FirstOrDefault();
            }
            var choices = GetEnabledPaymentMethodChoices(storeData);

            return(defaultChoice is null ? null : choices.FirstOrDefault(c => defaultChoice.ToString().Equals(c.Value, StringComparison.OrdinalIgnoreCase)));
        }
        private Client.Models.StoreData FromModel(Data.StoreData data)
        {
            var storeBlob = data.GetStoreBlob();

            return(new Client.Models.StoreData()
            {
                Id = data.Id,
                Name = data.StoreName,
                Website = data.StoreWebsite,
                SpeedPolicy = data.SpeedPolicy,
                DefaultPaymentMethod = data.GetDefaultPaymentId()?.ToStringNormalized(),
                //blob
                //we do not include DefaultCurrencyPairs,Spread, PreferredExchange, RateScripting, RateScript  in this model and instead opt to set it in stores/storeid/rates endpoints
                //we do not include ExcludedPaymentMethods in this model and instead opt to set it in stores/storeid/payment-methods endpoints
                //we do not include EmailSettings in this model and instead opt to set it in stores/storeid/email endpoints
                //we do not include PaymentMethodCriteria because moving the CurrencyValueJsonConverter to the Client csproj is hard and requires a refactor (#1571 & #1572)
                NetworkFeeMode = storeBlob.NetworkFeeMode,
                RequiresRefundEmail = storeBlob.RequiresRefundEmail,
                Receipt = InvoiceDataBase.ReceiptOptions.Merge(storeBlob.ReceiptOptions, null),
                LightningAmountInSatoshi = storeBlob.LightningAmountInSatoshi,
                LightningPrivateRouteHints = storeBlob.LightningPrivateRouteHints,
                OnChainWithLnInvoiceFallback = storeBlob.OnChainWithLnInvoiceFallback,
                RedirectAutomatically = storeBlob.RedirectAutomatically,
                LazyPaymentMethods = storeBlob.LazyPaymentMethods,
                ShowRecommendedFee = storeBlob.ShowRecommendedFee,
                RecommendedFeeBlockTarget = storeBlob.RecommendedFeeBlockTarget,
                DefaultLang = storeBlob.DefaultLang,
                MonitoringExpiration = storeBlob.MonitoringExpiration,
                InvoiceExpiration = storeBlob.InvoiceExpiration,
                CustomLogo = storeBlob.CustomLogo,
                CustomCSS = storeBlob.CustomCSS,
                HtmlTitle = storeBlob.HtmlTitle,
                AnyoneCanCreateInvoice = storeBlob.AnyoneCanInvoice,
                LightningDescriptionTemplate = storeBlob.LightningDescriptionTemplate,
                PaymentTolerance = storeBlob.PaymentTolerance,
                PayJoinEnabled = storeBlob.PayJoinEnabled
            });
        }