Skip to content

UI Components Implementation

Mohamed Osman edited this page Oct 1, 2019 · 1 revision

UI Components are implemented in both core and PSP modules. core provides the host activity and payment chooser fragment, and is responsible for orchestrating the flow between the fragments. The PSP integration modules are responsible for providing fragments that implement specific data entry for specific payment methods. Once the payment data has been entered by user it is delivered back to PspCoordinator class of core module and is then processed as if it was supplied by 3rd party developer.

Core

The core provides the following public API

registerPaymentMehodUsingUi(activity : Activity? = null, 
			specificPaymentMethodType: PaymentMethodType? = null
			) : Pair<String, PaymentMethodType>

which offers two optional parameters. The activity parameter is used whn 3rd party developer wants to keep new activities in existing activity stack. If the activity is not present a new task will be started by the SDK. In any case the host activity is created by the core module.

Parameter specificPaymentMethodType offers the ability to skip a payment method chooser, and directly ask the user for specific payment method data, if this paramter is ommited, a payment method chooser will be shown.

The request is then handled in PspCoordinator class, which will resolve which PSP module should handle the UI request and through UiRequestHandler class forward the host activity so that the module can show it's specific fragment. Once the entry is complete the data is returned to the `PspCoordinator, which then invokes registration request with user entered data as if it was invoked by the 3rd party developer.

PSP Integration Module

The responsibility of the PSP integration module is to provide UI entry fragments for all payment method types that the module supports.

Fragment needs to collect the least amount of required data for successful payment method registration, or to provide redirection to registration flow (i.e. PayPal flow). Once the data is obtained, it is returned to the core module in form of Observable<AdditionalRegistrationData>, where AdditionalRegistrationData is just a wrapper around a <String, String> map.

The integration will be supplied with resultObservable which is used to cummincate that the entered data is being processed, has failed processing, or was successful.

If the user decideds to abandon payment method registration, Fragment needs to return a EntryCancelled exception.