Beispiel #1
0
        public virtual Consumer InitiateConsumerSession(CultureInfo currentLanguage, string email = null, string mobilePhone = null, string ssn = null)
        {
            var market            = _currentMarket.GetCurrentMarket();
            var swedbankPayClient = _swedbankPayClientFactory.Create(market);

            var config = _checkoutConfigurationLoader.GetConfiguration(market.MarketId);

            try
            {
                var initiateConsumerSessionRequest =
                    _requestFactory.GetConsumerResourceRequest(new Language(currentLanguage.TextInfo.CultureName),
                                                               config.ShippingAddressRestrictedToCountries.Select(x =>
                                                                                                                  new RegionInfo(CountryCodeHelper.GetTwoLetterCountryCode(x))),
                                                               string.IsNullOrEmpty(email) ? null : new EmailAddress(email),
                                                               string.IsNullOrEmpty(mobilePhone) ? null : new Msisdn(mobilePhone),
                                                               string.IsNullOrEmpty(ssn)
                            ? null
                            : new NationalIdentifier(new RegionInfo(currentLanguage.TextInfo.CultureName), ssn));

                return(AsyncHelper.RunSync(() =>
                                           swedbankPayClient.Consumers.InitiateSession(initiateConsumerSessionRequest)));
            }

            catch (Exception ex)
            {
                _logger.Error(ex.Message, ex);
                throw;
            }
        }
Beispiel #2
0
        public async Task <string> GetSwedbankPayShippingDetails(Uri url)
        {
            var swedbankPayClient = _swedbankPayClientFactory.Create(_currentMarket.GetCurrentMarket());
            var shippingDetails   = await swedbankPayClient.Consumers.GetShippingDetails(url);

            return(JsonConvert.SerializeObject(shippingDetails, JsonSerialization.Settings));
        }
Beispiel #3
0
        protected PaymentStep(IPayment payment, IMarket market, ISwedbankPayClientFactory swedbankPayClientFactory)
        {
            MarketId      = market.MarketId;
            PaymentMethod = PaymentManager.GetPaymentMethod(payment.PaymentMethodId);

            if (PaymentMethod != null)
            {
                SwedbankPayClient = swedbankPayClientFactory.Create(PaymentMethod, market.MarketId);
            }
        }