ePages 6.17.12 - DE_EPAGES/Klarna/API/KlarnaCalc.pm

Package DE_EPAGES::Klarna::API::KlarnaCalc

This class implements calculation functions for Klarna

Base
-
@EXPORT_OK
CalcMonthlyAccountCost
CalcMonthlyFinancingCost
CalcTotalFinancingPurchaseCost
Gross2net
Net2gross

Functions

CalcMonthlyAccountCost
CalcMonthlyFinancingCost
CalcTotalFinancingPurchaseCost
Gross2net
Net2gross

CalcMonthlyAccountCost

Function calculates monthly cost. Formulas are copied from php package of Klarna (monthly_cost function). To be used with Klarna Account

Syntax
   my $result = CalcMonthlyAccountCost($hParams)
Input
$hParams (hash reference)
- PaymentMethod payment method object,
| - Pclass the pclass to use | object
| - Basket the basket object | object
- Sum grand total of basket
Return
$result (float)
calculated monthly cost

CalcMonthlyFinancingCost

Function calculates periodic cost. Formulas are copied from php package of Klarna (periodic_cost function). To be used with Klarna Financing

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

CalcTotalFinancingPurchaseCost

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

Syntax
   my $result = CalcTotalFinancingPurchaseCost($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