Klarna Checkout SDK was previously a stand alone library, but now it has become part of the Klarna Mobile SDK developed solutions.
As of the previous version the new Klarna Checkout can be integrated in the mobile projects in the following ways:
Integration | Old Implementation | New Implementation |
---|---|---|
Cocoapods | pod 'KlarnaCheckoutSDK' | pod 'KlarnaMobileSDK' |
Swift Package Manager | https://github.com/klarna/kco-mobile-sdk | https://github.com/klarna/klarna-mobile-sdk-spm |
Carthage | binary "https://raw.githubusercontent.com/klarna/kco-mobile-sdk/master/KlarnaCheckoutSDK.json" | binary "https://raw.githubusercontent.com/klarna/klarna-mobile-sdk/master/KlarnaMobileSDK.json" |
In the previous implementation of the checkout, the initialization of the library was done using the KCOKlarnaCheckout class, like in the following example:
@objc
swift
And there was the possibility to use the checkout interface in two different modes:
After initializing the checkout SDK, previously you needed to get the checkout controller from he SDK and present/push it , as the following example:
@objc
In the new Klarna checkout implementation in order to simplify the SDK usage this fullscreen mode is no longer available, instead the embedded mode should be used.
In case you have your own native checkout flow and want to embed the Klarna checkout view, the KlarnaCheckoutView is the recommended way.
When handling the checkout in the embedded mode, there are some behaviours that need to be taken care of on your side, like the scrolling (only for old SDK) and the resizing of the view.
In the previous implementation the handling was done as follows (where sizingDelegate should implement the KCOCheckoutSizingDelegate protocol:
Then as you are responsible to manage the resizing the checkout, you needed to implement the following method:
For the new implementation in the KlarnaMobileSDK of the Klarna checkout part of the process is the same for disabling the automatic scrolling, but the sizing delegate protocol was renamed to KlarnaSizingDelegate:
Then for the resizing behaviour the sizingDelegate should implement the following method:
Hybrid Mode
In the old version of the Checkout SDK, the hybrid mode setup was done by creating the KCOKlarnaCheckout object and attaching an external webView to it, as the following example:
To use the checkout in the new SDK, you can follow the hybrid guide, which has the unified information related to all integrations in hybrid mode.
In the previous version of the SDK notifications were used to alert about important events in the checkout flow, an example of that is the following code:
For this new implementation, this is no longer the case. Now an event handler must be set in place, and will be the one receiving the different events triggered by checkout. The KlarnaCheckoutView have a property called eventHandler that should be set and it should implement the KlarnaEvenHandler protocol as follows:
This implementations remain practically the same, when doing a server-side call while the checkout is visible, the user interaction can be suspended and resumed as needed with the following methods:
For the behaviour the previous implementation presented a boolean variable that can be modified, as the following example:
In the new implementation checkout objects have a new property called checkoutOptions, where the user can set the values for the options enabled, for example:
Then the event listener will be notified with the corresponding event.