Purpose:
To receive information if the customer has an account at Klarna. If the function answers true, then you should put the part payment as the default payment option
Return value:
String - True or false or Throws an exception with error code and error message.
Code examples
Please note that you can find more code examples in our API-files which you will find under Download API in the left menu.
Code examples for php are not yet available, they will be added shortly.
The code examples have been divided into several steps. Click on the step you would like to see the code example.
1. Initialize and setup the Klarna instance
API klarna = new API ();
/** Configure the Klarna object **/
klarna.Config (new KlarnaConfig () {
EID = 123456,
Secret = "sharedsecret",
Country = API.Country.Sweden,
Language = API.Language.Swedish,
Currency = API.Currency.SEK,
Encoding = API.Encoding.Swedish,
// API.KlarnaServer.Beta or API.KlarnaServer.Live, depending
// on which server your eid is associated with
Mode = API.KlarnaServer.Beta,
PCStorage = "xml",
PCURI = @"/tmp/pclasses.xml"
});
2. Check if the customer has a Klarna Account
try {
if (klarna.HasAccount ("410321-9202", API.Encoding.Swedish)) {
Console.WriteLine ("Customer has a Klarna Account");
} else {
Console.WriteLine ("Customer does not have a Klarna Account");
}
} catch (Exception e) {
//Something went wrong, print the error:
Console.WriteLine ("Error: " + e.Message);
}
Code examples for java can be found in the example files contained in the api.
Code examples for asp can be found in the example files contained in the api.
Input data:
| Variable | Type | Description | |
|---|---|---|---|
| Required | eid | integer | An e-store ID which refers to your store in Klarna's database |
| Required | pno | string | Use the following format: Sweden: yymmdd-nnnn, it can be sent with or without dash "-" or with or without the two first numbers in the year. Finland: ddmmyy-nnnn, it can be sent with or without dash "-". Denmark: ddmmyynnnn Norway: ddmmyynnnnn d = day, m = month, y = year, n = person specific numbers. If it is a purchase with a company registration number, the reference person can be typed in the first and last name fields. If a social security number/birth date belongs to a person under 18 or if the social security number/birth date is invalid, Klarna will not make a credit report and will instead return an error status. |
| Required | secret | string | A shared secret used to secure all traffic exchanged by Klarna and your store |
| Required | pno_encoding | integer | Indicates the country where the person/customer is registered in
Sweden = value: 2 Norway = value: 3 Finland = value: 4 Denmark = value: 5 Please note: Currency, country and language must be the same as where the customer is registered in. E.g. Swedish customer, SEK, Sweden and Swedish. |
