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() }
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/bank_account_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/pay_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>