Good to know: Payment Initiation is responsible for handling bank payments.
Firstly, you will need to integrate kevin. API and fetch payment ID. Instructions on how to do it can be found here:
Basic flow
Customise payment flow by tweaking our configuration:
// initialize configuration with paymentId fetched from the API let configuration = KevinPaymentSessionConfiguration.Builder(paymentId: paymentId) .setPreselectedCountry(.lithuania) .setCountryFilter([.lithuania, .latvia, .estonia]) .setDisableCountrySelection(false) .setPreselectedBank("SOME_BANK_ID") .setSkipBankSelection(false) .setSkipAuthentication(false) .build()
Implement KevinPaymentSessionDelegate protocol. Make sure that in onKevinPaymentInitiationStarted you present returned UINavigationController:
Define your ViewModel which will subscribe to KevinPaymentSessionDelegate and invoke the SDK:
importUIKitimportKevinclassSampleViewModel:ObservableObject, KevinPaymentSessionDelegate {@Publishedvar viewState =SampleViewState()var kevinController: UIViewController?=nilprivatelet apiClient =ApiClient()funcinvokeBankPaymentInitiationSession() { apiClient.initializeBankPayment().done { state indo { KevinPaymentSession.shared.delegate = selftry KevinPaymentSession.shared.initiatePayment( configuration: KevinPaymentSessionConfiguration.Builder( paymentId: state.id) .setPreselectedCountry(.lithuania) .setSkipBankSelection(false) .build()) } catch {// do something } }.catch { error in// do something } }//MARK: KevinPaymentSessionDelegatefunconKevinPaymentInitiationStarted(controller: UINavigationController) { self.kevinController = controller self.viewState =MainViewState(openKevin:true) }funconKevinPaymentCanceled(error: Error?) {// notify user if error has been returned }funconKevinPaymentSucceeded(paymentId: String) {// notify user }}
Customise session configuration
KevinPaymentSessionConfiguration can be configured with following properties:
setPreselectedCountry - allows to set a default country to be selected in the bank selection screen. If this parameter is not specified, the selection will be based on the SIM card information. In case the SIM card information is not available, the SDK will use the device locale. If the SIM card information and device locale are unavailable, the SDK will select the first country from the country filter (or fall back to the first bank on the list).
setPreselectedBank - allows to specify a default bank that will be preselected in the bank selection screen.
setCountryFilter - allows only certain countries to be supported.
setBankFilter - allows to filter banks and show only selected ones to the user. It requires a list of bank IDs that should be shown.
setDisableCountrySelection - if set to true, country selection will be disabled, and only preselected country banks will be available to choose from.
setSkipBankSelection - if set to true country, and bank selection step will be skipped, and the user will be redirected to the bank SCA immediately.
setSkipAuthentication - allows users to skip the SCA bank step and proceed directly to the payment confirmation. Bank payment needs to be initialised with an account access token. See reference here.