The purpose of this module is mainly to send order management API calls to Klarna. This includes all post order action capture, refund, and cancellation. The starting entry points for each of these actions can be found at Gateway/Command. If the API call to Klarna returns a successful response the order in Magento will be handled in the same way. For example, if the order was successfully canceled at Klarna the order will then be canceled as well in the shop.
This module contains all the logic that is needed so that KCO is usable. Since KCO is a checkout solution there is a broad set of important parts to make it work. In the following you find a small summary of some of the key components:
Controller/Api: This is the entry point of all our callback URLs.
Controller/Klarna: Here you find a set of controllers which are either used by ajax calls or to redirect the customer to the correct page
Model/Api/Builder/Kasper.php: This class is responsible for creating the API request parameter.
Model/Checkout/Validation.php: This class is called in the validate callback. Depending on its result, the customer is forwarded to the confirmation controller or will be redirected back to a specific error message to a different page like the cart page. You can find the set of validations at Model/Checkout/Validations.
Model/System/Message: Checking specific KCO settings and showing a message in the admin if there is a misconfiguration.
Model/KcoConfigProvider.php: The return values of the method getConfig() are used in the whole KCO JS workflow and define how KCO should behave on specific actions.
Model/QuoteRepository.php: Updating and getting back the Klarna KCO quote from the table klarna_kco_quote. You can find the migration for it at etc/db_schema.xml.
view/frontend/web/js: In this directory, you find all JS files to make KCO workable.
With this module, KP orders can be placed with GraphQl. It's a small extension of module-payments. The entry point for its logic is at Model/Resolver/CreateKlarnaPaymentsSession.php. In this class, the Klarna session is initiated and the client token and payment methods are returned.
This module extends module-kco by adding the KSA functionality. Its logic will just run if KSA is enabled in the shop admin and also on the used MID. The key components of it are:
Model/Checkout/Update.php: The Klarna KSA table will be updated for different use cases.
Model/ShippingMethodGatewayRepository.php: Updating and getting back the Klarna KSS state of a KCO session from the table klarna_shipping_method_gateway. You can find the migration for it at etc/db_schema.xml.
Model/Validator.php: This class decides if KSA is used and not. Its logic has a big impact if there is a KCO flow without KSA or with KSA.
The whole logic for Klarna OSM is located here. Since not so much logic for osm is needed, there is just 1 location which is important to know. It is about the classes in the Block directory. These classes decide if OSM is displayed on the respective pages (cart, product).