Common customisations

Add or modify Native Checkout steps

Native checkout steps represents the actions the user needs to do to complete the checkout process. These steps are visually represented via NativeCheckoutStepsBar. You can add, remove or change the order of these steps.

To add a new step, you first need to:

Then, to add, remove or change the order:

Implement a new Payment provider

Native checkout SDK requires the implementation of a Payment provider. To implement your own Payment provider, you need to:

  • Implement PaymentProvider interface adding your logic to initiate the payment provider and select a payment method.
  • Create a new class that implements PaymentData representing the selected payment method.
  • After selecting a payment method, call NativeCheckoutViewModel.updatePaymentData with your PaymentData. NativeCheckoutViewModel is scoped at activity level and you can get the instance via Koin.
  • Implement DomainToNetworkPaymentMethodMapper mapping your impementation of PaymentData to NetworkPaymentMethod
  • Provide your new implementations (PaymentProvider and DomainToNetworkPaymentMethodMapper) via Koin.

Add Payment selection section

Native checkout SDK allows to select the payment method before the user clicks on pay. To do so:

  • Decorate NativeCheckoutContentSteps to include as last step NativeCheckoutPayment
  • On NativeCheckoutPayment.changePaymentMethod callback, invoke PaymentProvider.getPaymentProvider
    val activity = LocalContext.current.getFragmentActivity()
    (activity as? PaymentProviderHolder)?.getPaymentProvider()?.selectPaymentMethod(activity)
  • Decorate NativeCheckoutScreen to override placeOrder callback and call NativeCheckoutViewModel.placeOrder with an empty PaymentData
  • Decorate your PaymentProvider ViewModel to replace the NativeCheckout.placeOrder with NativeCheckout.updatePaymentData call