CodeService
IAPMiniProgram SDK calls the CodeService SPI to provide QR code or barcode.
scan
Method signature
Call the scan method to launch the QR code or barcode scanner, and return the code.
void scan(ScannerOption scannerOption, APIContext apiContext, Callback<ScannerResult> callback)Request parameters
| Field | Data type | Description | Required | 
| scannerOption | The properties that a wallet scanner supports, including compatibility for QR code and barcode, and so on. When this parameter is not specified, the default values of this parameter are used. | No | |
| apiContext | APIContext | A context object, which carries the mini program runtime metadata. | Yes | 
| callback | Callback (For details, see the following section) | The callback that is executed when request processing is completed. | Yes | 
Callback
| Field | Data type | Description | Required | 
| result | The result of the  | Yes | 
Response parameters
N/A
Error codes
| Error code | Error message | |
| 10 | ERROR_USER_CANCEL | Users cancel the scan action. | 
| 2001 | ERROR_OPERATION_FAILED | Failed to scan the code. | 
Samples
The following samples show how to call the scan method to launch the QR code or barcode scanner and return the code.
Java
public class CodeServiceImpl implements CodeService {
    @Override
    public void scan(ScannerOption scannerOption, APIContext apiContext, final Callback<ScannerResult> callback) {
        // to scan code
        callback.result(new ScannerResult(codeValue));
    }
}Kotlin
class CodeServiceImpl : CodeService {
    override fun scan(scannerOption: ScannerOption?, apiContext: APIContext?, callback: Callback<ScannerResult?>
            ) {
        // to scan code
        callback.result(ScannerResult(codeValue))
    }
}