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:
- Create a new implementation of NativeCheckoutSteps.
- Override NativeCheckoutContentSteps to include your new step.
Then, to add, remove or change the order:
- Override PoqNativeCheckoutContent.getSteps.
- Return your modified list of steps.
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.updatePaymentDatawith yourPaymentData.NativeCheckoutViewModelis scoped at activity level and you can get the instance via Koin. - Implement DomainToNetworkPaymentMethodMapper mapping your impementation of
PaymentDatatoNetworkPaymentMethod - Provide your new implementations (
PaymentProviderandDomainToNetworkPaymentMethodMapper) 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.changePaymentMethodcallback, invokePaymentProvider.getPaymentProviderval activity = LocalContext.current.getFragmentActivity()(activity as? PaymentProviderHolder)?.getPaymentProvider()?.selectPaymentMethod(activity) - Decorate NativeCheckoutScreen to override
placeOrdercallback and callNativeCheckoutViewModel.placeOrderwith an emptyPaymentData - Decorate your PaymentProvider ViewModel to replace the
NativeCheckout.placeOrderwithNativeCheckout.updatePaymentDatacall