Card Element
Learn how to integrate the Card Element widget for accepting card payments in your Android app using Juspay Hyperswitch SDK.
Purpose: Card payments with Juspay Hyperswitch
Add Card Widget to Layout
<io.hyperswitch.view.BasePaymentWidget
android:id="@+id/cardElement"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:paymentMethod="card" />
<Button
android:id="@+id/confirmButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Pay with Card" />Initialize Card Launcher
private lateinit var cardPaymentLauncher: UnifiedPaymentLauncher
private fun setupCardPayment() {
cardPaymentLauncher = UnifiedPaymentLauncher.createCardLauncher(
activity = this,
resultCallback = ::onPaymentResult
)
}Handle Card Payment
Best Practices
Error Handling
Always check if launchers are initialized before using them:
Last updated
Was this helpful?

