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
Throws
See
|
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
Throws
See
|
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
|
public
|
#
setCountry( string|integer $country )
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
Throws
See
|
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
|
public
|
#
setLanguage( string|integer $language )
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
Throws
See
|
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
|
public
|
#
setCurrency( string|integer $currency )
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
Throws
See
|
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
|
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
|
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
Throws
|
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
See
|
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
Throws
|
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
Throws
|
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
Throws
|
public
|
#
setClientIP( string $clientIP )
Set client IP.
Parameters
- $clientIP
- Client IP address
|
public
string
|
#
getClientIP( )
Returns the clients IP address.
Returns the clients IP address.
Returns
string
|
public
|
|
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
See
|
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
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
Throws
|
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
Throws
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.
|
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
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
Returns
DateTime The new expiration date.
Throws
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.
Parameters
Returns
boolean True, if the cancellation was successful.
Throws
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
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
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
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
Returns
array An array of OCR numbers.
Throws
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
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().
Parameters
- $qty
- Quantity of specified article.
- $artNo
- Article number.
Throws
|
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
Returns
string Invoice number.
Throws
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
Returns
string Invoice number.
Throws
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
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
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
See
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.
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
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
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
|
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
|
public
Klarna\XMLRPC\CurlTransport
|
#
createTransport( )
Create a new CurlTransport.
Create a new CurlTransport.
Returns
|
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
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
|
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.
|