Overview
  • Namespace
  • Class

Namespaces

  • Klarna
    • XMLRPC
      • Exception

Classes

  • Address
  • Calc
  • CheckoutServiceRequest
  • CheckoutServiceResponse
  • Config
  • Country
  • CurlHandle
  • CurlTransport
  • Currency
  • Encoding
  • Flags
  • Klarna
  • Language

Class Klarna

This API provides a way to integrate with Klarna's services over the XMLRPC protocol.

All strings inputted need to be encoded with ISO-8859-1.
In addition you need to decode HTML entities, if they exist.

Namespace: Klarna\XMLRPC
Located at Klarna/XMLRPC/Klarna.php

Methods summary

public
# __construct( )

Empty constructor, because sometimes it's needed.

Empty constructor, because sometimes it's needed.

protected
# hasFields( )

Checks if the config has fields described in argument.
Missing field(s) is in the exception message.

Checks if the config has fields described in argument.
Missing field(s) is in the exception message.

To check that the config has eid and secret:

try {
    $this->hasFields('eid', 'secret');
}
catch(\Exception $e) {
    echo "Missing fields: " . $e->getMessage();
}

Throws

RuntimeException
protected
# init( )

Initializes the Klarna object accordingly to the set config object.

Initializes the Klarna object accordingly to the set config object.

Throws

RuntimeException
For invalid configuration
public
# config( integer $eid, string $secret, integer $country, integer $language, integer $currency, integer $mode = self::LIVE )

Method of ease for setting common config fields.

Method of ease for setting common config fields.

Note:
This disables the config file storage.

Parameters

$eid
Merchant ID/EID
$secret
Secret key/Shared key
$country
Klarna\XMLRPC\Country
$language
Klarna\XMLRPC\Language
$currency
Klarna\XMLRPC\Currency
$mode
Klarna::LIVE or Klarna::BETA

Throws

Klarna\XMLRPC\Exception\KlarnaException

See

Klarna\XMLRPC\Klarna::setConfig()
Klarna\XMLRPC\Config
public
# setConfig( Klarna\XMLRPC\Config & $config )

Sets and initializes this Klarna object using the supplied config object.

Sets and initializes this Klarna object using the supplied config object.

Parameters

$config
Config object.

Throws

Klarna\XMLRPC\Exception\KlarnaException

See

Klarna\XMLRPC\Config
public array
# getLocale( mixed $country = null, mixed $language = null, mixed $currency = null )

Get the complete locale (country, language, currency) to use for the values passed, or the configured value if passing null.

Get the complete locale (country, language, currency) to use for the values passed, or the configured value if passing null.

Parameters

$country
country constant or code
$language
language constant or code
$currency
currency constant or code

Returns

array

Throws

Klarna\XMLRPC\Exception\KlarnaException
public
# setCountry( string|integer $country )

Sets the country used.

Sets the country used.

Note:
If you input 'dk', 'fi', 'de', 'nl', 'no' or 'se',
then currency and language will be set to mirror that country.

Parameters

$country
Klarna\XMLRPC\Country

Throws

Klarna\XMLRPC\Exception\KlarnaException

See

Klarna\XMLRPC\Country
public string
# getCountryCode( integer $country = null )

Returns the country code for the set country constant.

Returns the country code for the set country constant.

Parameters

$country
Country Country constant.

Returns

string
Two letter code, e.g. "se", "no", etc.
public static integer
# getCountryForCode( string $code )

Returns the Country country constant from the country code.

Returns the Country country constant from the country code.

Parameters

$code
Two letter code, e.g. "se", "no", etc.

Returns

integer
Country Country constant.

Throws

RuntimeException
public integer
# getCountry( )

Returns the country constant.

Returns the country constant.

Returns

integer
Klarna\XMLRPC\Country
public
# setLanguage( string|integer $language )

Sets the language used.

Sets the language used.

Note:
You can use the two letter language code instead of the constant.
E.g. 'da' instead of using Language::DA.

Parameters

$language
Klarna\XMLRPC\Language

Throws

Klarna\XMLRPC\Exception\KlarnaException

See

Klarna\XMLRPC\Language
public string
# getLanguageCode( integer $language = null )

Returns the language code for the set language constant.

Returns the language code for the set language constant.

Parameters

$language
Language Language constant.

Returns

string
Two letter code, e.g. "da", "de", etc.
public static integer
# getLanguageForCode( string $code )

Returns the Language language constant from the language code.

Returns the Language language constant from the language code.

Parameters

$code
Two letter code, e.g. "da", "de", etc.

Returns

integer
Language Language constant.

Throws

RuntimeException
public integer
# getLanguage( )

Returns the language constant.

Returns the language constant.

Returns

integer
Klarna\XMLRPC\Language
public
# setCurrency( string|integer $currency )

Sets the currency used.

Sets the currency used.

Note:
You can use the three letter shortening of the currency.
E.g. "dkk", "eur", "nok" or "sek" instead of the constant.

Parameters

$currency
Klarna\XMLRPC\Currency

Throws

Klarna\XMLRPC\Exception\KlarnaException

See

Klarna\XMLRPC\Currency
public static integer
# getCurrencyForCode( string $code )

Returns the Currency currency constant from the currency code.

Returns the Currency currency constant from the currency code.

Parameters

$code
Two letter code, e.g. "dkk", "eur", etc.

Returns

integer
Currency Currency constant.

Throws

RuntimeException
public string
# getCurrencyCode( integer $currency = null )

Returns the the currency code for the set currency constant.

Returns the the currency code for the set currency constant.

Parameters

$currency
Currency Currency constant.

Returns

string
Three letter currency code.
public integer
# getCurrency( )

Returns the set currency constant.

Returns the set currency constant.

Returns

integer
Klarna\XMLRPC\Currency
public
# setSessionID( string $name, string $sid )

Sets the session id's for various device identification, behaviour identification software.

Sets the session id's for various device identification, behaviour identification software.

Available named session id's:
string - dev_id_1
string - dev_id_2
string - dev_id_3
string - beh_id_1
string - beh_id_2
string - beh_id_3

Parameters

$name
Session ID identifier, e.g. 'dev_id_1'.
$sid
Session ID.

Throws

Klarna\XMLRPC\Exception\KlarnaException
public
# setShipmentInfo( string $name, mixed $value )

Sets the shipment information for the upcoming transaction.
.

Sets the shipment information for the upcoming transaction.
.

Using this method is optional.

Available named values are:
int - delay_adjust
string - shipping_company
string - shipping_product
string - tracking_no
array - warehouse_addr

"warehouse_addr" is sent using Address::toArray().

Make sure you send in the values as the right data type.
Use strval, intval or similar methods to ensure the right type is sent.

Parameters

$name
key
$value
value

Throws

Klarna\XMLRPC\Exception\KlarnaException
public
# setActivateInfo( string $name, mixed $value )

Sets the Activation information for the upcoming transaction.
.

Sets the Activation information for the upcoming transaction.
.

Using this method is optional.

Available named values are:
int - flags
int - bclass
string - orderid1
string - orderid2
string - ocr
string - reference
string - reference_code
string - cust_no

Make sure you send in the values as the right data type.
Use strval, intval or similar methods to ensure the right type is sent.

Parameters

$name
key
$value
value

See

Klarna\XMLRPC\Klarna::setShipmentInfo()
public
# setExtraInfo( string $name, mixed $value )

Sets the extra information for the upcoming transaction.
.

Sets the extra information for the upcoming transaction.
.

Using this method is optional.

Available named values are:
string - cust_no
string - ready_date
string - rand_string
int - bclass
string - pin

Make sure you send in the values as the right data type.
Use strval, intval or similar methods to ensure the right type is sent.

Parameters

$name
key
$value
value

Throws

Klarna\XMLRPC\Exception\KlarnaException
public
# setIncomeInfo( string $name, mixed $value )

Sets the income expense information for the upcoming transaction.
.

Sets the income expense information for the upcoming transaction.
.

Using this method is optional.

Make sure you send in the values as the right data type.
Use strval, intval or similar methods to ensure the right type is sent.

Parameters

$name
key
$value
value

Throws

Klarna\XMLRPC\Exception\KlarnaException
public
# setBankInfo( string $name, mixed $value )

Sets the bank information for the upcoming transaction.
.

Sets the bank information for the upcoming transaction.
.

Using this method is optional.

Make sure you send in the values as the right data type.
Use strval, intval or similar methods to ensure the right type is sent.

Parameters

$name
key
$value
value

Throws

Klarna\XMLRPC\Exception\KlarnaException
public
# setTravelInfo( string $name, mixed $value )

Sets the travel information for the upcoming transaction.
.

Sets the travel information for the upcoming transaction.
.

Using this method is optional.

Make sure you send in the values as the right data type.
Use strval, intval or similar methods to ensure the right type is sent.

Parameters

$name
key
$value
value

Throws

Klarna\XMLRPC\Exception\KlarnaException
public
# setClientIP( string $clientIP )

Set client IP.

Set client IP.

Parameters

$clientIP
Client IP address
public string
# getClientIP( )

Returns the clients IP address.

Returns the clients IP address.

Returns

string
public
# setAddress( integer $type, Klarna\XMLRPC\Address $addr )

Sets the specified address for the current order.

Sets the specified address for the current order.

Address type can be:
Flags::IS_SHIPPING
Flags::IS_BILLING

Parameters

$type
Address type.
$addr
Specified address.

Throws

Klarna\XMLRPC\Exception\KlarnaException
public
# setEstoreInfo( string $orderid1 = '', string $orderid2 = '' )

Sets order id's from other systems for the upcoming transaction.
.

Sets order id's from other systems for the upcoming transaction.
.

Parameters

$orderid1
order id 1
$orderid2
order id 2

Throws

Klarna\XMLRPC\Exception\KlarnaException

See

Klarna\XMLRPC\Klarna::setExtraInfo()
public
# setReference( string $ref, string $code )

Sets the reference (person) and reference code, for the upcoming transaction.

Sets the reference (person) and reference code, for the upcoming transaction.

If this is omitted, it can grab first name, last name from the address and use that as a reference person.

Parameters

$ref
Reference person / message to customer on invoice.
$code
Reference code / message to customer on invoice.
public string
# getReference( )

Returns the reference (person).

Returns the reference (person).

Returns

string
protected array
# assembleAddr( Klarna\XMLRPC\Address $addr )

Returns an associative array used to send the address to Klarna. TODO: Kill it all.

Returns an associative array used to send the address to Klarna. TODO: Kill it all.

Parameters

$addr
Address object to assemble.

Returns

array
The address for the specified method.
public
# setComment( string $data )

Sets the comment field, which can be shown in the invoice.

Sets the comment field, which can be shown in the invoice.

Parameters

$data
comment to set
public integer
# getPNOEncoding( )

Returns the PNO/SSN encoding constant for currently set country.

Returns the PNO/SSN encoding constant for currently set country.

Note:
Country, language and currency needs to match!

Returns

integer
Klarna\XMLRPC\Encoding constant.

Throws

Klarna\XMLRPC\Exception\KlarnaException
public array
# getAddresses( string $pno, integer $encoding = null, integer $type = Flags::GA_GIVEN )

Purpose: The get_addresses function is used to retrieve a customer's address(es). Using this, the customer is not required to enter any information, only confirm the one presented to him/her.
.

Purpose: The get_addresses function is used to retrieve a customer's address(es). Using this, the customer is not required to enter any information, only confirm the one presented to him/her.
.

The get_addresses function can also be used for companies.
If the customer enters a company number, it will return all the addresses where the company is registered at.

The get_addresses function is ONLY allowed to be used for Swedish persons with the following conditions:

  • It can be only used if invoice or part payment is the default payment method
  • It has to disappear if the customer chooses another payment method
  • The button is not allowed to be called "get address", but "continue" or
    it can be picked up automatically when all the numbers have been typed.

Type can be one of these:
Flags::GA_ALL,
Flags::GA_LAST,
Flags::GA_GIVEN.

Parameters

$pno
Social security number, personal number, ...
$encoding
Encoding PNO Encoding constant.
$type
Specifies returned information.

Returns

array
An array of Klarna\XMLRPC\Address objects.

Throws

Klarna\XMLRPC\Exception\KlarnaException

Example

docs/examples/getAddresses.php How to get a customers address.
public
# addArticle( integer $qty, string $artNo, string $title, integer $price, float $vat, float $discount = 0, integer $flags = Flags::INC_VAT )

Adds an article to the current goods list for the current order.

Adds an article to the current goods list for the current order.

Note:
It is recommended that you use Flags::INC_VAT.

Flags can be:
Flags::INC_VAT
Flags::IS_SHIPMENT
Flags::IS_HANDLING
Flags::PRINT_1000
Flags::PRINT_100
Flags::PRINT_10
Flags::NO_FLAG

Some flags can be added to each other for multiple options.

Parameters

$qty
Quantity.
$artNo
Article number.
$title
Article title.
$price
Article price.
$vat
VAT in percent, e.g. 25% is inputted as 25.
$discount
Possible discount on article.
$flags

Options which specify the article (Flags::IS_HANDLING) and it's price (Flags::INC_VAT)

Throws

Klarna\XMLRPC\Exception\KlarnaException

See

Klarna\XMLRPC\Klarna::reserveAmount()
public integer
# summarizeGoodsList( )

Summarizes the prices of the held goods list.

Summarizes the prices of the held goods list.

Returns

integer
total amount
public array
# reserveAmount( string $pno, integer $gender, integer $amount, integer $flags = 0, integer $pclass = PClass::INVOICE, integer $encoding = null, boolean $clear = true )

Reserves a purchase amount for a specific customer.
The reservation is valid, by default, for 7 days.
.

Reserves a purchase amount for a specific customer.
The reservation is valid, by default, for 7 days.
.

This method returns an array with:
A reservation number (rno)
Order status flag

Order status can be:
Flags::ACCEPTED
Flags::PENDING
Flags::DENIED

Please note:
Activation must be done with activate_reservation, i.e. you cannot activate through Klarna Online.

Gender is only required for Germany and Netherlands.

Flags can be set to:
Flags::NO_FLAG
Flags::TEST_MODE
Flags::RSRV_SENSITIVE_ORDER
Flags::RSRV_PHONE_TRANSACTION
Flags::RSRV_SEND_PHONE_PIN

Some flags can be added to each other for multiple options.

Note:
Normal shipment type is assumed unless otherwise specified, you can do this by calling:
setShipmentInfo('delay_adjust', ...) with either: NORMAL_SHIPMENT or EXPRESS_SHIPMENT

Parameters

$pno
Personal number, SSN, date of birth, etc.
$gender

Flags::FEMALE or Flags::MALE, null for unspecified.

$amount
Amount to be reserved, including VAT.
$flags
Options which affect the behaviour.
$pclass
PClass ID.
$encoding
Encoding PNO Encoding constant.
$clear

Whether customer info should be cleared after this call.

Returns

array

An array with reservation number and order status. [string, int]

Throws

InvalidArgumentException
Klarna\XMLRPC\Exception\KlarnaException

Example

docs/examples/reserveAmount.php How to create a reservation.
public DateTime
# extendExpiryDate( string $rno )

Extends the reservations expiration date.

Extends the reservations expiration date.

Parameters

$rno
Reservation number.

Returns

DateTime
The new expiration date.

Throws

Klarna\XMLRPC\Exception\KlarnaException

Example

docs/examples/extendExpiryDate.php How to extend a reservations expiry date.
public array
# extendInvoiceDueDate( string $invNo, integer $numDays, boolean $dryRun = false )

Extends the due date on the specified invoice.

Extends the due date on the specified invoice.

Parameters

$invNo
Invoice number.
$numDays
Amount of days to extend the invoice with.
$dryRun
Enabling dry run will only calculate cost.

Returns

array

An array with cost as a float, and the new expiry date in the format YYYY-MM-DD. ['cost' => float, 'new_date' => string]

Throws

KlarnaException
public boolean
# cancelReservation( string $rno )

Cancels a reservation.

Cancels a reservation.

Parameters

$rno
Reservation number.

Returns

boolean
True, if the cancellation was successful.

Throws

Klarna\XMLRPC\Exception\KlarnaException

Example

docs/examples/cancelReservation.php How to cancel a reservation.
public true
# update( string $rno, boolean $clear = true )

Update the reservation matching the given reservation number.

Update the reservation matching the given reservation number.

Parameters

$rno
Reservation number
$clear
clear set data after updating. Defaulted to true.

Returns

true
if the update was successful

Throws

Klarna\XMLRPC\Exception\KlarnaException

if no RNO is given, or if an error is received from Klarna Online.

Example

docs/examples/update.php How to update a reservation.
public A
# activate( string $rno, string $ocr = null, string $flags = null, boolean $clear = true )

Activate the reservation matching the given reservation number. Optional information should be set in ActivateInfo.

Activate the reservation matching the given reservation number. Optional information should be set in ActivateInfo.

To perform a partial activation, use the addArtNo function to specify which items in the reservation to include in the activation.

Parameters

$rno
Reservation number
$ocr

optional OCR number to attach to the reservation when activating. Overrides OCR specified in activateInfo.

$flags

optional flags to affect behaviour. If specified it will overwrite any flag set in activateInfo.

$clear
clear set data after activating. Defaulted to true.

Returns

A
string array with risk status and reservation number.

Throws

Klarna\XMLRPC\Exception\KlarnaException

when the RNO is not specified, or if an error is received from Klarna Online.

Example

docs/examples/activate.php How to activate a reservation.
public string
# splitReservation( string $rno, integer $amount, integer $flags = Flags::NO_FLAG )

Splits a reservation due to for example outstanding articles.

Splits a reservation due to for example outstanding articles.

For flags usage see:
Klarna::reserveAmount()

Parameters

$rno
Reservation number.
$amount
The amount to be subtracted from the reservation.
$flags
Options which affect the behaviour.

Returns

string
A new reservation number.

Throws

InvalidArgumentException
Klarna\XMLRPC\Exception\KlarnaException

Example

docs/examples/splitReservation.php How to split a reservation.
public array
# reserveOCR( integer $no, integer $country = null )

Reserves a specified number of OCR numbers.
For the specified country or the set country.
.

Reserves a specified number of OCR numbers.
For the specified country or the set country.
.

Parameters

$no
The number of OCR numbers to reserve.
$country
Klarna\XMLRPC\Country constant.

Returns

array
An array of OCR numbers.

Throws

InvalidArgumentException
Klarna\XMLRPC\Exception\KlarnaException

Example

docs/examples/reserveOCR.php How to reserve OCRs.
public boolean
# hasAccount( string $pno, integer $encoding = null )

Checks if the specified SSN/PNO has an part payment account with Klarna.

Checks if the specified SSN/PNO has an part payment account with Klarna.

Parameters

$pno
Social security number, Personal number, ...
$encoding
Encoding PNO Encoding constant.

Returns

boolean
True, if customer has an account.

Throws

Klarna\XMLRPC\Exception\KlarnaException

Example

docs/examples/hasAccount.php How to check for a part payment account.
public
# addArtNo( integer $qty, string $artNo )

Adds an article number and quantity to be used in Klarna::creditPart().

Adds an article number and quantity to be used in Klarna::creditPart().

Parameters

$qty
Quantity of specified article.
$artNo
Article number.

Throws

Klarna\XMLRPC\Exception\KlarnaException
public string
# emailInvoice( string $invNo )

Sends an activated invoice to the customer via e-mail.
The email is sent in plain text format and contains a link to a PDF-invoice.
.

Sends an activated invoice to the customer via e-mail.
The email is sent in plain text format and contains a link to a PDF-invoice.
.

Please note!
Regular postal service is used if the customer has not entered his/her e-mail address when making the purchase (charges may apply).

Parameters

$invNo
Invoice number.

Returns

string
Invoice number.

Throws

Klarna\XMLRPC\Exception\KlarnaException

Example

docs/examples/emailInvoice.php How to email an invoice.
public string
# sendInvoice( string $invNo )

Requests a postal send-out of an activated invoice to a customer by Klarna (charges may apply).

Requests a postal send-out of an activated invoice to a customer by Klarna (charges may apply).

Parameters

$invNo
Invoice number.

Returns

string
Invoice number.

Throws

Klarna\XMLRPC\Exception\KlarnaException

Example

docs/examples/sendInvoice.php How to send an invoice.
public string
# returnAmount( string $invNo, integer $amount, float $vat, integer $flags = Klarna\XMLRPC\Flags::INC_VAT, string $description = '' )

Gives discounts on invoices.
If you are using standard integration and the purchase is not yet activated (you have not yet delivered the goods),
just change the article list in our online interface Klarna Online.
.

Gives discounts on invoices.
If you are using standard integration and the purchase is not yet activated (you have not yet delivered the goods),
just change the article list in our online interface Klarna Online.
.

Flags can be:
Flags::INC_VAT
Flags::NO_FLAG, NOT RECOMMENDED!

Parameters

$invNo
Invoice number.
$amount
The amount given as a discount.
$vat
VAT in percent, e.g. 22.2 for 22.2%.
$flags

If amount is including or excluding VAT.

$description

Optional custom text to present as discount in the invoice.

Returns

string
Invoice number.

Throws

Klarna\XMLRPC\Exception\KlarnaException

Example

docs/examples/returnAmount.php How to perform a return.
public string
# creditInvoice( string $invNo, string $credNo = '' )

Performs a complete refund on an invoice, part payment and mobile purchase.

Performs a complete refund on an invoice, part payment and mobile purchase.

Parameters

$invNo
Invoice number.
$credNo
Credit number.

Returns

string
Invoice number.

Throws

Klarna\XMLRPC\Exception\KlarnaException

Example

docs/examples/creditInvoice.php How to credit an invoice.
public string
# creditPart( string $invNo, string $credNo = '' )

Performs a partial refund on an invoice, part payment or mobile purchase.

Performs a partial refund on an invoice, part payment or mobile purchase.

Note:
You need to call Klarna::addArtNo() first.

Parameters

$invNo
Invoice number.
$credNo
Credit number.

Returns

string
Invoice number.

Throws

Klarna\XMLRPC\Exception\KlarnaException

See

Klarna\XMLRPC\Klarna::addArtNo()

Example

docs/examples/creditPart.php How to partially credit an invoice.
public string
# checkOrderStatus( string $id, integer $type = 0 )

Returns the current order status for a specific reservation or invoice. Use this when Klarna::reserveAmount() returns a Flags::PENDING status.

Returns the current order status for a specific reservation or invoice. Use this when Klarna::reserveAmount() returns a Flags::PENDING status.

Order status can be:
Flags::ACCEPTED
Flags::PENDING
Flags::DENIED

Parameters

$id
Reservation number or invoice number.
$type
0 if $id is an invoice or reservation, 1 for order id

Returns

string
The order status.

Throws

InvalidArgumentException
Klarna\XMLRPC\Exception\KlarnaException

Example

docs/examples/checkOrderStatus.php How to check a order status.
public PClass[]
# getPClasses( string|integer $country = null, mixed $language = null, mixed $currency = null )

Get the PClasses from Klarna Online.
You are only allowed to call this once, or once per update of PClasses in KO.
.

Get the PClasses from Klarna Online.
You are only allowed to call this once, or once per update of PClasses in KO.
.

Note:
You should store these in a DB of choice for later use.

Parameters

$country

Country Country constant, or two letter code.

$language

Language Language constant, or two letter code.

$currency

Currency Currency constant, or three letter code.

Returns

PClass[]
A list of pclasses.

Throws

Klarna\XMLRPC\Exception\KlarnaException

Example

docs/examples/getPClasses.php How to get your estore PClasses.
public PClass
# getCheapestPClass( float $sum, integer $flags, PClass[] $pclasses )

Returns the cheapest, per month, PClass related to the specified sum.

Returns the cheapest, per month, PClass related to the specified sum.

Note: This choose the cheapest PClass for the current country.
Klarna::setCountry()

Flags can be:
Flags::CHECKOUT_PAGE
Flags::PRODUCT_PAGE

Parameters

$sum
The product cost, or total sum of the cart.
$flags
Which type of page the info will be displayed on.
$pclasses
The list of pclasses to search in.

Returns

PClass
or false if none was found.

Throws

InvalidArgumentException
Klarna\XMLRPC\Exception\KlarnaException
protected mixed
# xmlrpcCall( string $method, array $array )

Creates a XMLRPC call with specified XMLRPC method and parameters from array.

Creates a XMLRPC call with specified XMLRPC method and parameters from array.

Parameters

$method
XMLRPC method.
$array
XMLRPC parameters.

Returns

mixed

Throws

InvalidArgumentException
Klarna\XMLRPC\Exception\KlarnaException
public Klarna\XMLRPC\CurlTransport
# createTransport( )

Create a new CurlTransport.

Create a new CurlTransport.

Returns

Klarna\XMLRPC\CurlTransport
New CurlTransport instance
public Klarna\XMLRPC\CheckoutServiceResponse
# checkoutService( integer|float $price, string $currency, string $locale, string $country = null )

Perform a checkout service request.

Perform a checkout service request.

Parameters

$price
The total price for the checkout including VAT.
$currency
ISO 4217 Currency Code
$locale

Specify what locale is used by the checkout. ISO 639 language and ISO 3166-1 country separated by underscore. Example: sv_SE

$country

(Optional) Specify what ISO 3166-1 country to use for fetching payment methods. If not specified the locale country will be used.

Returns

Klarna\XMLRPC\CheckoutServiceResponse
Response with payment methods

Throws

RuntimeException
If the curl extension is not loaded

Example

docs/examples/checkoutService.php How to use the checkout service.
public
# clear( )

Removes all relevant order/customer data from the internal structure.

Removes all relevant order/customer data from the internal structure.

public static string
# colon( )

Implodes parameters with delimiter ':'. Null and "" values are ignored by the colon function to ensure there is not several colons in succession.

Implodes parameters with delimiter ':'. Null and "" values are ignored by the colon function to ensure there is not several colons in succession.

Returns

string
Colon separated string.
public static string
# pipe( )

Implodes parameters with delimiter '|'.

Implodes parameters with delimiter '|'.

Returns

string
Pipe separated string.
public static boolean
# filterDigest( mixed $value )

Check if the value has a string length larger than 0.

Check if the value has a string length larger than 0.

Parameters

$value
The value to check.

Returns

boolean
True if string length is larger than 0
public static string
# digest( string $data, string $hash = null )

Creates a digest hash from the inputted string, and the specified or the preferred hash algorithm.

Creates a digest hash from the inputted string, and the specified or the preferred hash algorithm.

Parameters

$data
Data to be hashed.
$hash
hash algoritm to use

Returns

string
Base64 encoded hash.

Throws

Klarna\XMLRPC\Exception\KlarnaException
public static
# printDebug( string $msg, mixed $mixed )

Prints debug information if debug is set to true. $msg is used as header/footer in the output.

Prints debug information if debug is set to true. $msg is used as header/footer in the output.

If FirePHP is available it will be used instead of dumping the debug info into the document.

It uses print_r and encapsulates it in HTML/XML comments. ()

Parameters

$msg
Debug identifier, e.g. "my array".
$mixed
Object, type, etc, to be debugged.

Magic methods summary

Constants summary

integer LIVE

Constants used with LIVE mode for the communications with Klarna.

Constants used with LIVE mode for the communications with Klarna.

# 0
integer BETA

Constants used with BETA mode for the communications with Klarna.

Constants used with BETA mode for the communications with Klarna.

# 1

Properties summary

protected string $version

Klarna PHP API version identifier.

Klarna PHP API version identifier.

# 'php:api:5.0.0'
protected string $proto

Klarna protocol identifier.

Klarna protocol identifier.

# '4.1'
protected string $encoding

The encoding used in Klarna.

The encoding used in Klarna.

# 'ISO-8859-1'
protected PhpXmlRpc\Client $xmlrpc

An object of PhpXmlRpc\Client, used to communicate with Klarna.

An object of PhpXmlRpc\Client, used to communicate with Klarna.

Link

https://packagist.org/packages/phpxmlrpc/phpxmlrpc
#
protected integer $mode

Which server the Klarna API is using, LIVE or BETA (TESTING).

Which server the Klarna API is using, LIVE or BETA (TESTING).

See

Klarna\XMLRPC\Klarna::LIVE
Klarna\XMLRPC\Klarna::BETA
#
protected array $goodsList

An array of articles for the current order.

An array of articles for the current order.

#
protected array $artNos

An array of article numbers and quantity.

An array of article numbers and quantity.

#
protected Klarna\XMLRPC\Address $billing

An Address object containing the billing address.

An Address object containing the billing address.

#
protected Klarna\XMLRPC\Address $shipping

An Address object containing the shipping address.

An Address object containing the shipping address.

#
protected string $orderid

External order numbers from other systems.

External order numbers from other systems.

# array('', '')
protected string $reference

Reference (person) parameter.

Reference (person) parameter.

# ''
protected string $reference_code

Reference code parameter.

Reference code parameter.

# ''
protected array $extraInfo

An array of named extra info.

An array of named extra info.

# array()
protected array $bankInfo

An array of named bank info.

An array of named bank info.

# array()
protected array $incomeInfo

An array of named income expense info.

An array of named income expense info.

# array()
protected array $shipInfo

An array of named shipment info.

An array of named shipment info.

# array()
protected array $sid

An array of named session id's.
E.g. "dev_id_1" => ...
.

An array of named session id's.
E.g. "dev_id_1" => ...
.

# array()
protected string $comment

A comment sent in the XMLRPC communications. This is resetted using clear().

A comment sent in the XMLRPC communications. This is resetted using clear().

# ''
public static boolean $debug

Flag to indicate if the API should output verbose debugging information.

Flag to indicate if the API should output verbose debugging information.

# false
public static boolean $xmlrpcDebug

Turns on the internal XMLRPC debugging.

Turns on the internal XMLRPC debugging.

# false
public static boolean $disableXMLRPC

If this is set to true, XMLRPC invocation is disabled.

If this is set to true, XMLRPC invocation is disabled.

# false
public static boolean $x_forwarded_for

If the estore is using a proxy which populates the clients IP to x_forwarded_for then and only then should this be set to true.

If the estore is using a proxy which populates the clients IP to x_forwarded_for then and only then should this be set to true.

Note:
USE WITH CARE!

# false
protected string $clientIP

Client IP.

Client IP.

#
API documentation generated by ApiGen