ePages 6.15.1 - DE_EPAGES/Klarna/API/KlarnaClient.pm

Package DE_EPAGES::Klarna::API::KlarnaClient

This class implements the client for Klarna web interface.

Base
-
@EXPORT_OK
Gross2net
Net2gross
GetPclass

Functions

ActivateInvoice
AddTransaction
CancelInvoice
CheckOrderStatus
DeleteInvoice
GetMonthlyCost
GetPclass
GetPclasses
GetPeriodicCost
GetTotalCreditPurchaseCost
Gross2net
Net2gross
SendInvoiceToCustomer
UpdateInvoice
_GetLastName
new

ActivateInvoice

Function sends activating request to Klarna.

Syntax
   my $hResponse = $self->ActivateInvoice($hParams)
Input
$hParams (hash reference)
- PaymentMethod payment method object,
- InvoiceNo invoice number string
Return
$hResponse (hash reference)
Returned data
- Message Status message
- StatusCode Status code

AddTransaction

Function sends a transaction to Klarna.

Syntax
   my $hResponse = $self->AddTransaction($hParams)
Input
$hParams (hash reference)
- BasketOrder basket or order object,
- PaymentMethod payment method object,
- SecurityNumber social security or organization number,
- RemoteAddr customer's ip,
- Salary customer's salary,
- Street customer's street address,
- HouseNo house number if customer is from Germany
Return
$hResponse (hash reference)
Returned data
- Message Message
- StatusCode Status code

CancelInvoice

Cancels an invoice at Klarna

Syntax
 $self->CancelInvoice($LineItemContainer);
Input
$LineItemContainer (object)
the LineItemContainer to use
Return
$hResponse (hash reference)
Returned data
- Message Status message
- StatusCode Status code

CheckOrderStatus

Check status of Klarna payment for existing order

Syntax
 $self->CheckOrderStatus($LineItemContainer);
Input
$LineItemContainer (object)
the LineItemContainer to use
Return
$hResponse (hash reference)
Returned data
- Message Status message
- StatusCode Status code

DeleteInvoice

Function sends deleting request to Klarna.

Syntax
   my $hResponse = $self->DeleteInvoice($hParams)
Input
$hParams (hash reference)
- PaymentMethod payment method object,
- InvoiceNo invoice number string
Return
$hResponse (hash reference)
Returned data
- Message Status message
- StatusCode Status code

GetMonthlyCost

Function calculates monthly cost. Formulas are copied from php package of Klarna (monthly_cost function).

Syntax
   my $result = $self->GetMonthlyCost($hParams)
Input
$hParams (hash reference)
- PaymentMethod payment method object,
- Sum grand total of basket
Return
$result (float)
calculated monthly cost

GetPclass

Function returns pclass id number.

Syntax
   my $Encoding = GetPclass($LineItemContainer);
Input
$LineItemContainer (object)
line item container
Return
$PclassID (integer)
numerical id number of pclass

GetPclasses

Function gets pclass values from Klarna.

Syntax
   my $hResponse = $self->GetPclasses($hParams)
Input
$hParams (hash reference)
- PaymentMethod payment method object
Return
$hResponse (hash reference)
Returned data
- Message Status message
- StatusCode Status code

GetPeriodicCost

Function calculates periodic cost. Formulas are copied from php package of Klarna (periodic_cost function).

Syntax
   my $result = $self->GetPeriodicCost($hParams)
Input
$hParams (hash reference)
- Pclass Pclass object,
- Sum grand total of basket
Return
$result (float)
calculated periodic cost

GetTotalCreditPurchaseCost

Function calculates total credit purchase cost. Formulas are copied from php package of Klarna (total_credit_purchase_cost function).

Syntax
   my $result = $self->GetTotalCreditPurchaseCost($hParams)
Input
$hParams (hash reference)
- Pclass: Pclass object,
- Sum: grand total of basket
$PaymentTypeName (String)
Kind of klarna payment type
Return
$result (float)
calculated periodic cost

Gross2net

Converts a price from gross to net if necessary

Syntax
 Gross2net($PaymentMethod, $GrossValue);
Input
$PaymentMethod (object)
the PaymentMethod object to use
$GrossValue (float)
the value to convert
Return
$NetValue (float)
the gross value of the input var

Net2gross

Converts a price from net to gross if necessary

Syntax
 Net2gross($PaymentMethod, $NetValue);
Input
$PaymentMethod (object)
the PaymentMethod to use
$NetValue (float)
the value to convert
Return
$GrossValue (float)
the gross value of the input var

SendInvoiceToCustomer

Function sends request to Klarna that invoice can be sent to customer.

Syntax
   my $hResponse = $self->SendInvoiceToCustomer($hParams)
Input
$hParams (hash reference)
- PaymentMethod payment method object,
- InvoiceNo invoice number string
Return
$hResponse (hash reference)
Returned data
- Message Status message
- StatusCode Status code

UpdateInvoice

Function sends update request to Klarna.

Syntax
   my $hResponse = $self->UpdateInvoice($hParams)
Input
$hParams (hash reference)
- PaymentMethod payment method object,
- InvoiceNo invoice number string
Return
$hResponse (hash reference)
Returned data
- Message Status message
- StatusCode Status code

_GetLastName

Function returns the last name

Syntax
   my $LastName = _GetLastName($Address);
Input
$Address (object)
address
Return
$LastName (string)
last name

new

Constructor for KlarnaClient

Syntax
 $Object = DE_EPAGES::Klarna::API::KlarnaClient->new();
Input
-
Return
-