1 min read
Customisations
Add custom WebCheckout JS bridge event
To add extra events to the WebCheckout JS bridge:
- Define a new model
CustomWebCheckoutEvent
that represents your new event. - Provide new implementation of
Mapper<Any, WebViewEvent>
class CustomWebCheckoutEventMapper: Mapper<Any, WebViewEvent> {override fun map(origin: WebViewEvent): Any {return CustomWebCheckoutEvent(...)}} - Provide your new mapper via Koin using the name
customEventMapperName
- Your new event is available in
WebCheckoutViewModel.customEvent
You have added a custom JS bridge event.
Add custom data to the WebCheckout model
To add custom data to the WebCheckout
model you need to:
- Receive your custom data in the network model
NetworkWebCheckout
. - Create a new implementation of
Mapper<Any, Map<String, Any>>
. - Provide your new mapper via Koin using the name
webCheckoutCustomMapToAnyMapperName
.
Add custom data to the WebCheckoutOrder model
WebCheckoutOrder
model is built from two different sources: from a network call and from the WebView through the Javascript bridge. You can add custom data to this model from both sources.
From the Network call
To add custom data to the WebCheckoutOrder
model from the network call you need to:
- Receive your custom data in the network model
NetworkWebCheckoutOrder
. - Create a new implementation of
Mapper<Any, Map<String, Any>>
. - Provide your new mapper via Koin using the name
webCheckoutOrderCustomMapToAnyMapperName
. - Your custom data is available in the field
WebCheckoutOrder.customData
From the WebView
To add custom data to the WebCheckoutOrder
model from the WebView you need to:
- Receive your custom data in the web view model
WebViewData
. - Create a new implementation of
Mapper<Any, Map<String, Any>>
. - Provide your new mapper via Koin using the name
webCheckoutOrderCompletedCustomMapToAnyMapperName
. - Your custom data is available in the field
WebCheckoutOrder.customDataOrderCompleted
Add custom data to the WebCheckoutOrderItem model
To add custom data to the WebCheckoutOrderItem
model you need to:
- Receive your custom data in the network model
NetworkWebCheckoutOrderItem
. - Create a new implementation of
Mapper<Any, Map<String, Any>>
. - Provide your new mapper via Koin using the name
webCheckoutOrderItemCustomMapToAnyMapperName