Get Address
Klarna supports getting customer address in Sweden using the personal number. This article explains how to call the Klarna API method to fetch the address.
To get the address call the following API method in Klarna plugin.
public static AddressCarrier[] GetAddresses(string customerPersonalNumber,
string languageCode,
string countryCode,
string currencyCode,
string paymentAccIdentifier = null);
Following code fragment shows how this method is called from the checkout page template.
OrderCarrier currentOrderCarrier = CurrentState.Current.ShoppingCart.OrderCarrier;
Currency currency = Solution.Instance.Currencies.Get(currentOrderCarrier.CurrencyID);
string countryCode = null;
if (currentOrderCarrier.PaymentInfo.Count > 0 && currentOrderCarrier.PaymentInfo[0].BillingAddress != null)
countryCode = currentOrderCarrier.PaymentInfo[0].BillingAddress.Country;
var registeredAddresses = Litium.Studio.AddOns.Klarna.KlarnaProvider.GetAddresses(personId,
CurrentState.Current.WebSite.Language.Culture.
TwoLetterISOLanguageName, countryCode,
currency.CurrencyCode, null);
if (registeredAddresses != null && registeredAddresses.Length > 0 && registeredAddresses[0] != null)
{
AddressCarrier address = registeredAddresses[0];
//TODO: use the above address returned to populate UI address fields.
}