Skip to content

PhotoPay Dutch results

Nenad Mikša edited this page Oct 22, 2016 · 3 revisions

Dutch payment slip scanning results

Initializing the scanning of Dutch slips

To initialize the scanning of Dutch slips, use the following intialization code:

- (PPCameraCoordinator*)createCoordinator {

    // Check if photopay is supported
    NSError *error;
    if ([PPCameraCoordinator isScanningUnsupportedForCameraType:PPCameraTypeBack error:error]) {
        NSString *messageString = [error localizedDescription];
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Warning" message:messageString delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
        [alert show];

        return nil;
    }

    // 1. ******* Instantiate Scanning settings ********/
    PPSettings* settings = [[PPSettings alloc] init];


    // 2. ************* Setup UI Settings **************/

    // Instantiate PhotoPay UI settings. This allows more customization in the initialization process.
    PPPhotoPayUiSettings* photopayUiSettings = [[PPPhotoPayUiSettings alloc] init];
    settings.uiSettings = photopayUiSettings;

    // Use english language
    photopayUiSettings.language = @"en";


    // 3. ************* Setup Scan Settings **************/

    // Add recognizer for Dutch payslips
    [settings.scanSettings addRecognizerSettings:[[PPNedSlipRecognizerSettings alloc] init]];


    // 4. ************* Setup License Settings **************/

    // Set your license key here. This specific key is for demo purposes only!
    settings.licenseSettings.licenseKey = @"DBRWHNRH-YLGPHFUJ-Q7TGEPYE-G22L7IFY-2V2E7NTP-DB5I5T2P-WZXRQ6UO-Z5H56WZN";

    // Allocate the recognition coordinator object
    PPCameraCoordinator *coordinator = [[PPCameraCoordinator alloc] initWithSettings:settings];

    return coordinator;
}

- (IBAction)didTapScan:(id)sender {
    PPCameraCoordinator* coordinator = [self createCoordinator];
    if (coordinator == nil) {
        return;
    }

    // Create camera view controller
    UIViewController<PPScanningViewController> *cameraViewController = [PPViewControllerFactory cameraViewControllerWithDelegate:self overlayViewController:overlayVC coordinator:coordinator error:nil];

    cameraViewController.autorotate = YES;
    cameraViewController.supportedOrientations = UIInterfaceOrientationMaskLandscape;

    // present it
    cameraViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentViewController:cameraViewController animated:YES completion:nil];
}

Retrieving results

Scanning results for Dutch payslips are obtained as instances of a class PPNedSlipRecognizerResult. See the header files or sample below for all fields contained in these objects.

- (void)scanningViewController:(UIViewController<PPScanningViewController> *)scanningViewController
              didOutputResults:(NSArray *)results {

    // find the recognition result and process it

    for (PPRecognizerResult* result in results) {

        if ([result isKindOfClass:[PPNedSlipRecognizerResult class]]) {
            [self processNedSlipRecognizerResult:(PPNedSlipRecognizerResult*)result];
        }
    };
}

- (void)processNedSlipRecognizerResult:(PPNedSlipRecognizerResult*)nedSlipResult {

    // Here we log all field in PPNedSlipRecognizerResult object

    NSLog(@"Dutch payment slip results\n");

    NSLog(@"Amount is %@", [nedSlipResult amount]);
    NSLog(@"Currency is %@", [nedSlipResult currency]);

    NSLog(@"IBAN is %@", [nedSlipResult iban]);
    NSLog(@"Account number is %@", [nedSlipResult accountNumber]);
    NSLog(@"Reference number is %@", [nedSlipResult referenceNumber]);
}
Clone this wiki locally