Klarna Docs - Module structure

Module structure

When you installed the Klarna Checkout module 3 folders will be created at vendor/klarna:

module-backend: This is used for post order creation management like capturing, cancel or refund a order

module-base: It contains basic logic which will be used from module-kco and optionally other Klarna modules who requires it

module-kco: Here you can find the core Klarna Checkout workflow logic

module-kss: The core logic for Klarna Shipping Assistant can be found here.

Module-kco

Controller: Since the Klarna Checkout makes use of several urls which must be indicated in the request to generate the Klarna session you can find the actions of them in the directory "Controller". You can find for example the actions for the Klarna push (see Controller/Api/Push.php) and validation (see Controller/Api/Validate.php) callbacks.

Observer: The Observer directory is mainly used to add the checkbox logic (if Klarna checkboxes are used), load the Klarna checkout page and create the Klarna session

Plugin: This directory is mainly needed so that the logic of the Klarna Shipping Service module is working with the Klarna Checkout workflow and to avoid issues with the core integration of Klarna Payments.

Model/Api: Everything what is about to do something with the Klarna api like creating the request, sending the request, validating the response and other things can be found here.

Model/Checkout: Since the Klarna Checkout is a replacement of the whole checkout page the logic for working with the different like the address, checkbox or the order creation can be found here. Moreover at Model/Checkout/Validations you can find a set of validations which are used before the order in the shop will be created.

Model/Payment/Kco.php: This is the payment class.

Model/ResourceModel: Here you can find the resource model for the klarna_kco_quote table. The respective model and repository of it can be found at Model/Quote.php and Model/QuoteRepository.php.

Model/System/Message: When you change any Klarna Checkout configuration in your shop admin page a set of validations will run to check if any issue on your storefront Klarna Checkout page will happen. This set of validations can be found in the directory Model/System/Message.

view/frontend/web/js: The Klarna Checkout iframe is interacting with javascript. For this case some kind of logic is written to ensure that the iframe is triggering the correct actions. The logic for it can be found in the directory view/frontend/web/js.

Module-base

Logger: In this directory you can find the whole logger logic. It provides for example several methods for logging, filtering text before it will be logged or the file name.

Model/Api/OrderLineProcessor.php: The purpose of this class is to trigger the orderline creation for the Klarna API order creation and update. Its also used to create the orderlines for the Klarna capture and refund API request.

Model/Calculator: Here you can find different calculation class to ensure that the correct values are sent through the Klarna API.

Model/Checkout/Orderline/Items: In this directory you can find the logic which values are added to the orderline items in the Klarna API request.

Model/Fpt: The logic for products which are using Fixed Product Taxescan be found here.

Model/Quote/Update: When the Klarna system sends a callback to the shop with different values compared to the shop quote (because of for example the address was changed in the iframe) the quote must be updated with these new values. This logic can be found in the directory Model/Quote/Update.

Model/ResourceModel: Here you can find the resource model for the klarna_core_order table. The respective model and repository of it can be found at Model/Order.php and Model/OrderRepository.php.

Model/System/Message: When you change any generic Klarna configuration (no product specific configuration) in your shop admin page a set of validations will run to check if any issue will happen on any Klarna product. This set of validations can be found in the directory Model/System/Message.

Model/MerchantPortal.php: This class returns the merchant portal url for the respective order which is printed in the shop admin order page.

Module-backend

Gateway/Command: Here are the starting points for the different post order management actions in the backend module.

Model/Api/Ordermanagement.php: In this class the logic for the different post order management actions can be found.

Module-kss

Model/Checkout/Update.php: This class updated the Klarna Shipping Assistant database table.

Model/ResourceModel: Here you can find the resource model for the klarna_shipping_method_gateway table. The respective model and repository of it can be found at Model/ShippingMethodGateway.php and Model/ShippingMethodGatewayRepository.php.

Model/Assignment.php: This class includes the core logic for updating the shipping values for the quote based on the stored Klarna API reponse in the database.