public void SaveChanges(object dto)
        {
            if (!Visible)
            {
                return;
            }

            var paymentMethod = dto as PaymentMethodDto;

            if (paymentMethod == null)
            {
                return;
            }

            var currentMarket = marketDropDownList.SelectedValue;

            var configuration = new VippsConfiguration()
            {
                ClientId             = txtClientId.Text,
                ClientSecret         = txtClientSecret.Text,
                SubscriptionKey      = txtSubscriptionKey.Text,
                MerchantSerialNumber = txtSerialNumber.Text,
                ApiUrl             = txtApiUrl.Text,
                SiteBaseUrl        = txtSiteBaseUrl.Text,
                FallbackUrl        = txtFallbackUrl.Text,
                TransactionMessage = txtTransactionMessage.Text
            };

            var serialized = JsonConvert.SerializeObject(configuration);

            paymentMethod.SetParameter($"{currentMarket}_{VippsConstants.VippsSerializedMarketOptions}", serialized);
        }
 public void BindConfigurationData(VippsConfiguration configuration)
 {
     txtClientId.Text           = configuration.ClientId;
     txtClientSecret.Text       = configuration.ClientSecret;
     txtSubscriptionKey.Text    = configuration.SubscriptionKey;
     txtSerialNumber.Text       = configuration.MerchantSerialNumber;
     txtApiUrl.Text             = configuration.ApiUrl;
     txtSiteBaseUrl.Text        = configuration.SiteBaseUrl;
     txtFallbackUrl.Text        = configuration.FallbackUrl;
     txtTransactionMessage.Text = configuration.TransactionMessage;
 }
 public virtual UpdatePaymentRequest CreateUpdatePaymentRequest(VippsConfiguration configuration, TransactionLogHistory transactionLogHistory)
 {
     return(new UpdatePaymentRequest
     {
         MerchantInfo = new MerchantInfo
         {
             MerchantSerialNumber = Convert.ToInt32(configuration.MerchantSerialNumber)
         },
         Transaction = new Transaction
         {
             Amount = transactionLogHistory.Amount,
             TransactionText = configuration.TransactionMessage
         }
     });
 }
 public virtual UpdatePaymentRequest CreateUpdatePaymentRequest(IPayment payment,
                                                                VippsConfiguration configuration)
 {
     return(new UpdatePaymentRequest
     {
         MerchantInfo = new MerchantInfo
         {
             MerchantSerialNumber = Convert.ToInt32(configuration.MerchantSerialNumber)
         },
         Transaction = new Transaction
         {
             Amount = payment.Amount.FormatAmountToVipps(),
             TransactionText = configuration.TransactionMessage
         }
     });
 }
 public virtual InitiatePaymentRequest CreateInitiatePaymentRequest(IPayment payment, IOrderGroup orderGroup, VippsConfiguration configuration, string orderId, Guid contactId, string marketId)
 {
     return(new InitiatePaymentRequest
     {
         CustomerInfo = new CustomerInfo
         {
             MobileNumber = GetPhoneNumberFromBillingAddress(payment.BillingAddress)
         },
         MerchantInfo = new MerchantInfo
         {
             CallbackPrefix = EnsureCorrectUrl(configuration.SiteBaseUrl, $"vippscallback/{contactId.ToString()}/{marketId}/{orderGroup.Name}"),
             ConsentRemovalPrefix = EnsureCorrectUrl(configuration.SiteBaseUrl, $"vippscallback/"),
             ShippingDetailsPrefix = EnsureCorrectUrl(configuration.SiteBaseUrl, $"vippscallback/{contactId.ToString()}/{marketId}/{orderGroup.Name}"),
             FallBack = $"{configuration.FallbackUrl}?orderId={orderId}&contactId={contactId.ToString()}&marketId={marketId}&cartName={orderGroup.Name}",
             IsApp = false,
             MerchantSerialNumber = Convert.ToInt32(configuration.MerchantSerialNumber),
             PaymentType = GetCheckoutType(orderGroup)
         },
         Transaction = new Transaction
         {
             Amount = payment.Amount.FormatAmountToVipps(),
             OrderId = orderId,
             TimeStamp = DateTime.Now,
             TransactionText = configuration.TransactionMessage
         }
     });
 }