1 min read

Customisations

Add custom WebCheckout JS bridge event

To add extra events to the WebCheckout JS bridge:

  1. Define a new model CustomWebCheckoutEvent that represents your new event.
  2. Provide new implementation of Mapper<Any, WebViewEvent>
    class CustomWebCheckoutEventMapper: Mapper<Any, WebViewEvent> {
    override fun map(origin: WebViewEvent): Any {
    return CustomWebCheckoutEvent(...)
    }
    }
  3. Provide your new mapper via Koin using the name customEventMapperName
  4. 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:

  1. Receive your custom data in the network model NetworkWebCheckout.
  2. Create a new implementation of Mapper<Any, Map<String, Any>>.
  3. 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:

  1. Receive your custom data in the network model NetworkWebCheckoutOrder.
  2. Create a new implementation of Mapper<Any, Map<String, Any>>.
  3. Provide your new mapper via Koin using the name webCheckoutOrderCustomMapToAnyMapperName.
  4. 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:

  1. Receive your custom data in the web view model WebViewData.
  2. Create a new implementation of Mapper<Any, Map<String, Any>>.
  3. Provide your new mapper via Koin using the name webCheckoutOrderCompletedCustomMapToAnyMapperName.
  4. 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:

  1. Receive your custom data in the network model NetworkWebCheckoutOrderItem.
  2. Create a new implementation of Mapper<Any, Map<String, Any>>.
  3. Provide your new mapper via Koin using the name webCheckoutOrderItemCustomMapToAnyMapperName