Add custom communication to the web checkout bridge

Out of date

You payment website communicates with your App via a Javascript bridge.

The CheckoutBridgeMessageDomainModelMapper object maps the web messages into domain messages and vice versa. If you need to customise any communication between the web and the App, this is where you should do it.

Use this code to provide a different message domain mapper into the WebCheckoutBuilder:

import PoqWebCheckout
import PoqFoundation
import PoqPlatform
class ClientModule: PoqModule {
func didAddToPlatform() {
// Override platform's deeplink logic.
let navigator = NavigationHelper.sharedInstance
navigator.mapRoute(navigator.cartTransferURL, toDestination: { _ in
navigator.openController(ClientModule.createWebCheckoutViewController())
})
}
static func createWebCheckoutViewController() -> UIViewController {
let router = CheckoutRouter(navigator: NavigationHelper.sharedInstance)
let supportedLocations = [CheckoutLocationDomainModel(host: "poq-web-carttransferdemo.azurewebsites.net", port: nil), CheckoutLocationDomainModel(host: "poq-web-carttransferdemo-uat.azurewebsites.net", port: nil)]
let checkoutBridgeConfiguration = CheckoutBridgeConfiguration(supportedLocations: supportedLocations, checkoutPaymentConfiguration: nil)
let checkoutType: CheckoutWebViewType = .bridge(configuration: checkoutBridgeConfiguration)
let messageDataMapper = CustomCheckoutBridgeMessageDomainModelMapper()
return WebCheckoutBuilder<PoqCheckoutState>(router: router, type: checkoutType)
.withBridgeMessageDomainModelMapper(messageDataMapper)
.build()
}
}
public class CustomCheckoutBridgeMessageDomainModelMapper: CheckoutBridgeMessageDomainModelMapper {
public func map(from bridgeMessage: BridgeScriptMessage) -> CheckoutBridgeMessageDomainModel? {
// Your custom implementation goes here.
}
public func map(from domainMessage: CheckoutBridgeRequestDomainModel) -> String {
// Your custom implementation goes here.
}
}