-
Notifications
You must be signed in to change notification settings - Fork 3
PhotoPay Croatia results
Nenad Mikša edited this page Oct 22, 2016
·
4 revisions
To initialize the scanning of Croatian slips, use the following intialization code:
- (PPCameraCoordinator*)coordinatorWithError:(NSError **)error {
// Check if photopay is supported
if ([PPCameraCoordinator isScanningUnsupportedForCameraType:PPCameraTypeBack error:error]) {
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 croatian language
photopayUiSettings.language = @"hr";
// Help is available so present it just in the first app run
photopayUiSettings.helpDisplayMode = PPHelpDisplayModeFirstRun;
// Use Toast messages
photopayUiSettings.presentToast = YES;
// 3. ************* Setup Scan Settings **************/
// Add recognizer for Croatian payslips
PPCroSlipRecognizerSettings *croSlipRecognizer = [[PPCroSlipRecognizerSettings alloc] init];
[settings.scanSettings addRecognizerSettings:croSlipRecognizer];
// Read payment description always
croSlipRecognizer.readPaymentDescription = YES;
// Sanitize OCR output to be by the HUB standard
croSlipRecognizer.useSanitization = YES;
// Add PDF417 recognizer for Croatian payslips
PPCroPdf417RecognizerSettings *croPdf417Recognizer = [[PPCroPdf417RecognizerSettings alloc] init];
[settings.scanSettings addRecognizerSettings:croPdf417Recognizer];
// Sanitize PDF417 output to be by the HUB standard
croPdf417Recognizer.useSanitization = YES;
// Add QR code recognizer for Croatian payslips
PPCroQrRecognizerSettings *croQrRecognizer = [[PPCroQrRecognizerSettings alloc] init];
[settings.scanSettings addRecognizerSettings:croQrRecognizer];
// Sanitize QR output to be by the HUB standard
croQrRecognizer.useSanitization = YES;
// 4. ************* Setup License Settings **************/
// Set your license key here. This specific key is for demo purposes only!
settings.licenseSettings.licenseKey = @"X3YAC5EK-ASNYOJMC-XHD57SP4-NMPZAA5G-37E7Y2Y7-SAB2NX6J-7RVR7EAD-U3P2B7TC";
// Allocate the recognition coordinator object
PPCameraCoordinator *coordinator = [[PPCameraCoordinator alloc] initWithSettings:settings];
return coordinator;
}
- (void)showCoordinatorError:(NSError *)error {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Warning"
message:[error localizedDescription]
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* okAction = [UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:nil];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];
}
- (IBAction)didTapScan:(id)sender {
/** Instantiate the scanning coordinator */
NSError *error;
PPCameraCoordinator *coordinator = [self coordinatorWithError:&error];
/** If scanning isn't supported, show an error */
if (coordinator == nil) {
[self showCoordinatorError:error];
return;
}
/** Allocate and present the scanning view controller */
UIViewController<PPScanningViewController>* scanningViewController = [PPViewControllerFactory cameraViewControllerWithDelegate:self overlayViewController:overlayVC coordinator:coordinator error:nil];
scanningViewController.autorotate = YES;
scanningViewController.supportedOrientations = UIInterfaceOrientationMaskAll;
/** You can use other presentation methods as well */
[self presentViewController:scanningViewController animated:YES completion:nil];
}
Scanning results for Croatian payslips are obtained as instances of three possible classes PPCroSlipRecognizerResult
(if payment slip was scanned with OCR), PPCroPdf41RecognizerResult
(if PDF417 code was scanned), or PPCroQrRecognizerResult
(if QR code was scanned). See the header files or sample below for all fields contained in these objects. For easier implementation, both PPCroPdf41RecognizerResult
and PPCroQrRecognizerResult
inherit from PPCroBarcodeRecognizerResult
, so you just need to distinguish two cases - OCR result from barcode results.
- (void)scanningViewController:(UIViewController<PPScanningViewController> *)scanningViewController
didOutputResults:(NSArray *)results {
// find the recognition result and process it
for (PPRecognizerResult* result in results) {
if ([result isKindOfClass:[PPCroSlipRecognizerResult class]]) {
[self processCroSlipRecognizerResult:(PPCroSlipRecognizerResult*)result
scanningViewController:scanningViewController];
}
// this handles both QR code and PDF417 results as they both inherit from PPCroBarcodeRecognizerResult
if ([result isKindOfClass:[PPCroBarcodeRecognizerResult class]]) {
[self processCroBarcodeRecognizerResult:(PPCroBarcodeRecognizerResult*)result
scanningViewController:scanningViewController];
}
};
}
- (void)processCroSlipRecognizerResult:(PPCroSlipRecognizerResult*)croSlipResult
scanningViewController:(UIViewController<PPScanningViewController> *)scanningViewController {
// Here we log all fields in PPCroSlipRecognizerResult object
NSLog(@"Croatian payment slip results\n");
NSLog(@"Amount is %@", [croSlipResult amount]);
NSLog(@"Currency is %@", [croSlipResult currency]);
NSLog(@"Recipient name is %@", [croSlipResult recipientName]);
NSLog(@"IBAN is %@", [croSlipResult iban]);
NSLog(@"Bank code is %@", [croSlipResult bankCode]);
NSLog(@"Account number is %@", [croSlipResult accountNumber]);
NSLog(@"Reference number is %@", [croSlipResult referenceNumber]);
NSLog(@"Reference model is %@", [croSlipResult referenceModel]);
NSLog(@"Payment description is %@", [croSlipResult paymentDescription]);
NSLog(@"Payment description code is %@", [croSlipResult paymentDescriptionCode]);
NSLog(@"Purpose code is %@", [croSlipResult purposeCode]);
NSLog(@"Payer name is %@", [croSlipResult payerName]);
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Cro slip"
message:[croSlipResult description]
preferredStyle:UIAlertControllerStyleAlert];
// pause scanning until the user presses OK buttom
[scanningViewController pauseScanning];
UIAlertAction* okAction = [UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
// resume scanning when OK is pressed
[scanningViewController dismissViewControllerAnimated:YES completion:nil];
}];
[alertController addAction:okAction];
// present alert on top of scanning view controller
[scanningViewController presentViewController:alertController animated:YES completion:nil];
}
- (void)processCroBarcodeRecognizerResult:(PPCroBarcodeRecognizerResult*)croBarcodeResult scanningViewController:(UIViewController<PPScanningViewController> *)scanningViewController {
// Here we log all fields in PPCroBarcodeRecognizerResult object
NSLog(@"Croatian Barcode (PDF417 and QR code) results\n");
NSLog(@"Amount is %@", [croBarcodeResult amount]);
NSLog(@"Currency is %@", [croBarcodeResult currency]);
NSLog(@"Recipient name is %@", [croBarcodeResult recipientName]);
NSLog(@"IBAN is %@", [croBarcodeResult iban]);
NSLog(@"Bank code is %@", [croBarcodeResult bankCode]);
NSLog(@"Account number is %@", [croBarcodeResult accountNumber]);
NSLog(@"Reference number is %@", [croBarcodeResult referenceNumber]);
NSLog(@"Reference model is %@", [croBarcodeResult referenceModel]);
NSLog(@"Payment description is %@", [croBarcodeResult paymentDescription]);
NSLog(@"Payment description code is %@", [croBarcodeResult paymentDescriptionCode]);
NSLog(@"Due date is %@", [croBarcodeResult dueDate]);
NSLog(@"Recipient address is %@", [croBarcodeResult recipientAddress]);
NSLog(@"Detailed address is %@", [croBarcodeResult recipientDetailedAddress]);
NSLog(@"Optional data is %@", [croBarcodeResult optionalData]);
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Cro Barcode"
message:[croBarcodeResult description]
preferredStyle:UIAlertControllerStyleAlert];
// pause scanning until the user presses OK buttom
[scanningViewController pauseScanning];
UIAlertAction* okAction = [UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * _Nonnull action) {
// resume scanning when OK is pressed
[scanningViewController dismissViewControllerAnimated:YES completion:nil];
}];
[alertController addAction:okAction];
// present alert on top of scanning view controller
[scanningViewController presentViewController:alertController animated:YES completion:nil];
}
- Getting Started with PhotoPay SDK
-
Obtaining scanning results
- Scanning Austrian payslips
- Scanning Belgian payslips
- Scanning Croatian HUB payslips / barcodes
- Scanning Dutch Acceptgiros
- Scanning German payslips
- Scanning Hungarian payslips
- Scanning SEPA payment QR codes
- Scanning Slovenian payslips
- Using BlinkID recognizers
- Using MRTD Recognizer for scanning ID documents
- Using EUDL Recognizer
- Using USDL Recognizer
- Using MyKad recognizer
- Using PDF417 Recognizer
- Using BarDecoder Recognizer
- Using ZXing Recognizer
- Using Barcode Recognizer
- Using Templating API
- Using Detector Recognizer
- Using BlinkInput OCR Recognizer
- Troubleshoot
- Using Direct Processing API
- Customizing Camera UI
- Creating customized framework
- Upgrading from older versions