# Card Scanner

The Android Payment Sheet SDK includes built-in card scanning powered by the device camera and on-device ML Kit text recognition. When a user taps the scan button in the payment sheet, the SDK requests camera access, scans the card, and automatically populates the card number and expiry fields. No additional configuration is required.

## Camera Permission

Add the following permission to your app's `AndroidManifest.xml`. The SDK handles the runtime permission request automatically, but the permission must be declared in your manifest or the OS will not grant access.


```xml
<uses-permission android:name="android.permission.CAMERA" />
```

## onScanCard Callback

All payment sheet composables include an optional `onScanCard` callback. It is called when the user taps the scan button, before the scanner opens. Use it for analytics or logging — it does not affect scanning behavior.

| Parameter | Type | Required | Description |
|  --- | --- | --- | --- |
| `onScanCard` | `() -> Unit` | No | Called when the user initiates a card scan. Defaults to `{}`. |


Scanned card details are populated automatically. Results are returned through the existing `onTokenized` callback, the same as manual entry.