/// <summary> /// Creates an instance of the Klarna client. /// </summary> /// <param name="credentials">DTO class for Klarna API Credentials</param> /// <param name="environment"> /// The API is accessible through a few different URLS. There are different URLs for testing and for making /// live purchases as well as different URLs for depending on if you are based in Europe or in the U.S. /// </param> /// <param name="userAgent">The user agent string used when calling the Klarna API</param> public Klarna(ApiCredentials credentials, KlarnaEnvironment environment, string userAgent = "") : this(new ApiSession { ApiUrl = ApiUrlFromEnvironment(environment), UserAgent = userAgent, Credentials = credentials }) { }
/// <summary> /// Gets API URL from the environment. /// </summary> /// <param name="environment">Klarna environment</param> /// <returns>Klarna API URL</returns> public static string ApiUrlFromEnvironment(KlarnaEnvironment environment) { switch (environment) { case KlarnaEnvironment.LiveEurope: return(Constants.ProdUrlEurope); case KlarnaEnvironment.LiveNorthAmerica: return(Constants.ProdUrlNorthAmerica); case KlarnaEnvironment.TestingEurope: return(Constants.TestUrlEurope); case KlarnaEnvironment.TestingNorthAmerica: return(Constants.TestUrlNorthAmerica); default: return(string.Empty); } }
/// <summary> /// Creates an instance of the Klarna client. /// </summary> /// <param name="username"> /// Consists of your Merchant ID (eid) - a unique number that identifies your e-store, combined with a random string. /// </param> /// <param name="password"> /// a string which is associated with your Merchant ID and is used to authorize use of Klarna's APIs /// </param> /// <param name="environment"> /// The API is accessible through a few different URLS. There are different URLs for testing and for making /// live purchases as well as different URLs for depending on if you are based in Europe or in the U.S. /// </param> /// <param name="userAgent">The user agent string used when calling the Klarna API</param> public Klarna(string username, string password, KlarnaEnvironment environment, string userAgent = "") : this(username, password, ApiUrlFromEnvironment(environment), userAgent) { }