Pay by Card button
Drop-in button view that launches the Lib Lite payment activity — minimal code, consistent UX.
The PayByCard button is a pre-built View subclass you can drop into your XML layout. When tapped, it launches the standard LibLiteActivity payment flow. Use it whenever you want a consistent Scan to Pay button without designing your own.
For the underlying flow it triggers, see Payments.
What it looks like
A flat, brand-themed button labelled with the Scan to Pay payment mark. It supports light and dark themes from Lib Lite 1.2.0 onwards.
Step 1 — Add the button to your layout
In your activity / fragment XML layout:
<com.eftcorp.liblite.paybycard.PayByCardButton
android:id="@+id/payByCard"
android:layout_width="match_parent"
android:layout_height="wrap_content" />Step 2 — Register the result launcher
In your activity, register an ActivityResultLauncher exactly as you would for the standard payment activity:
private final ActivityResultLauncher<Intent> libLiteActivityLauncher =
registerForActivityResult(
new ActivityResultContracts.StartActivityForResult(),
result -> handleLibLiteResult(result.getResultCode(), result.getData())
);Step 3 — Wire the click handler
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
PayByCardButton payByCardButton = findViewById(R.id.payByCard);
payByCardButton.setOnClickListener(v -> {
Intent intent = new Intent(this, LibLiteActivity.class);
intent.putExtra(LibLiteActivity.IN_CODE, "1234567890");
intent.putExtra(LibLiteActivity.IN_API_KEY, "YOUR_API_KEY");
intent.putExtra(LibLiteActivity.IN_HASH, "YOUR_SMS_HASH");
intent.putExtra(LibLiteActivity.IN_SYSTEM, "LIVE");
libLiteActivityLauncher.launch(intent);
});
}The button is otherwise a plain View — onClick, accessibility actions, etc. work as usual.
Result handling
Identical to the standalone LibLiteActivity launch — five possible result codes, parsed the same way. See Payments for the full result-handling block.
Styling
The button's appearance is locked for brand consistency. You can resize, reposition, and adjust margins around it, but you can't change its colours, fonts, or label text. If you need a fully custom button, launch LibLiteActivity from your own View instead — see Payments for the direct invocation pattern.
What's next
- Hand off to a bank app instead → Pay-by-App button
- Underlying payment activity → Payments
- Result codes and errors → Errors
Updated 2 days ago
