Bank Account Token UI Component

Bank Account Token UI Component

The Bank Account Token UI Component is intended to display stored bank account details like account holder and IBAN.

Basic implementation

This code sample demonstrates a basic implementation of Bank Account Token UI Component.

Implementation
Layout

public class BankAccountUiComponentFragment 
        extends Fragment 
        implements BankAccountTokenUiComponent {

    private BankAccountTokenUiComponentFragmentBinding binding;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater,
                             @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        binding = BankAccountTokenUiComponentFragmentBinding.inflate(inflater, container, false);
            
        return binding.getRoot();
    }

    @Override
    public void onUiComponentCreated(@NonNull BankAccountTokenUiComponentInteraction interaction) {
        // this method will be called after onViewCreated() and before onStart(),
        // it provides the link to the UI Component interaction, use it to initialize your UI

        // use interaction to get BankAccount
	BankAccount bankAccount = interaction.getBankAccount();
			
	binding.bankAccountDetails.setText(bankAccount.getIban());
        binding.payButton.setOnClickListener(view -> interaction.submitPaymentDetails());
    }
}
class BankAccountUiComponentFragment : Fragment(), BankAccountTokenUiComponent {

    private var _binding: BankAccountTokenUiComponentFragmentBinding? = null
    private val binding get() = _binding!!

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {
        _binding = BankAccountTokenUiComponentFragmentBinding.inflate(
            inflater, container, false)

        return binding.root
    }

    override fun onUiComponentCreated(interaction: BankAccountTokenUiComponentInteraction) {
        // this method will be called after onViewCreated() and before onStart(),
        // it provides the link to the UI Component interaction, use it to initialize your UI
		
	// use interaction to get BankAccount
	BankAccount bankAccount = interaction.bankAccount
			
	binding.bankAccountDetails.text = bankAccount.iban
        binding.payButton.setOnClickListener { interaction.submitPaymentDetails() }
    }
}