Overview
To simplify your application logic and integration with the Knot Android SDK, Version 2.0 includes a number of breaking changes that may affect the way your integration works or behaves. The new version includes a number of significant improvements:- Enhanced speed and stability in loading merchant flows.
- More streamlined initialization of the SDK.
- Simplified event handling, more informative event messaging, and uniform naming conventions for easier debugging.
- Improved maintainability and foundations for new feature compatibility.
Breaking Changes
Configuring and opening the Knot SDK has changed significantly in Android Version 2.0 and requires some refactoring in order to initialize the SDK with a session. Errors are now encapsulated in aKnotError object which provides an enumerated value to debug with.
Session Initialization
ChangesCardOnFileSwitcher.getInstance();andConfiguration(environment, clientId, sessionId);are replaced with a more flexibleKnotConfiguration.- The new interface allows configuration of additional properties such as
useCategories,useSearch, andmerchantIds. - The
openaction now requires aKnotConfigurationand an optionalKnotEventDelegatewhich is nowKnot.open(context, knotConfiguration, knotEventDelegate).
Event Handling
Changes- Event handling is now managed through
KnotEventDelegateinstead of closures. - Events like
onSuccess,onError, andonExitare now explicit methods inside a delegate. - The
onEventmethod introduces theKnotEventobject to better handle Knot emitted events. - The
KnotErrortype provides improved error descriptions. - The
sendCardparameter is deprecated and its functionality incorporated into themetaDatadictionary withinKnotEventwhenKnotEvent.eventequalsAUTHENTICATED.
Most apps do not use the explicit
sendCard method, as it is rarely applicable to the integration with the Knot SDK.sendCard parameter has been deprecated and its functionality is incorporated into the metaData object within KnotEvent when the KnotEvent.event equals AUTHENTICATED. This change enhances flexibility by allowing additional contextual data to be included in events without requiring separate parameters. Previously, sendCard was accessed as a standalone value, but now developers can retrieve it from the metaData object in the event callback. This approach ensures better extensibility and consistency across different event types. To access the sendCard value, simply extract it from the event’s metaData object.
| Event Name Prior to 2.0 | 2.0 Event Name |
|---|---|
| refresh session request | REFRESH_SESSION_REQUEST |
| merchant clicked | MERCHANT_CLICKED |
| login started | LOGIN_STARTED |
| authenticated | AUTHENTICATED |
| otp required | OTP_REQUIRED |
| security questions required | SECURITY_QUESTIONS_REQUIRED |
| approval required | APPROVAL_REQUIRED |
Error Handling
Error handling has been improved with more structured and meaningful error messages. Changes- Errors are now encapsulated in the
KnotErrorenum. - Each error has a human-readable description (
errorDescription) and a unique error code (errorCode). - Improved clarity and consistency across error messages.
| Error Case | Description |
|---|---|
| INVALID_SESSION | The session is invalid. |
| EXPIRED_SESSION | The session has expired. |
| INVALID_CLIENT_ID | The client ID is invalid. |
| INTERNAL_ERROR | An internal error occurred. |
Closing the SDK
Most apps do not use the explicit
close method, as it is infrequently applicable to the integration with the Knot SDK.- Closing the SDK is now statically accessed via
Knot.close()as opposed to being bound to the session object.