Receipt Correction Flow

If you would like your users to be able to correct receipt data (especially for purchase validation) after scanning you can achieve this using the Receipt Correction Flow.

Storing Receipt Data Locally

The BlinkReceipt SDK can store receipt data (scan results + images) locally for a certain amount of time so that if a user wants to edit it after the fact, the data will be immediately available.

Indicate how long you want receipt data to be stored with the following property:

[BRScanManager sharedManager].daysToStoreReceiptData = 7;

Retrieving Receipt Data Remotely

If you prefer not to store receipt data locally, we will attempt to fetch receipt data from our servers when you initiate the “Stock Receipt Correction UI” or when you explicitly request the results as described in “Custom Receipt Correction UI” below.

Stock Receipt Correction UI

To begin receipt correction for a given BlinkReceipt ID, use the following to show the initial controller:

[[BRScanManager sharedManager] startReceiptCorrection:@"DCA68D70-A4DD-4FE0-83D6-D4F6AE442777"
                                   fromViewController:self
                                       withCustomFont:nil
                                       withCompletion:^(BRScanResults * _Nullable results, NSError * _Nullable error) {
                                           [self dismissViewControllerAnimated:YES completion:nil];
                                       }];
  • You may pass your own UIFont instance to help style the receipt correction elements to look more like your own app. Don’t worry about the size of the font you pass; it will be ignored and all the elements will retain their original font sizes, but will use your font name.

The initial controller displays a list of the products and prices that were scanned. The user can touch any product to edit it, or can choose to add a new product that was missed entirely.

When a user edits a product or adds a new product, a modal controller is shown which prompts the user to scan the barcode of the item.

When a barcode is successfully scanned, if you participate in the purchase validation platform, the SDK will make a request to validate the UPC against your list of participating products.

If a matching product is found, the user will have the opportunity to adjust the quantity and price and save the record.

The callback from the method above passes back to you a fully populated BRScanResults object after the user’s corrections and the attempt to validate these results against promotions. See the section below for new fields to pay attention to specifically.

Custom Receipt Correction UI

You may create your own UI to capture user changes to an existing set of scan results.

The first step is to load the scan results and receipt images for a given Blink Receipt ID as follows:

[[BRScanManager sharedManager] getResultsForReceiptCorrection:@"blink_receipt_id"]
                                               withCompletion:(nonnull void(^)(BRScanResults* _Nullable results,
                                                                               NSArray<UIImage*> * _Nonnull images))completion {

                                                                               }

At this point you can display your own UI using these objects to show the user the old results and provide a way for them to modify certain properties (only a limited number of receipt properties and product properties are editable).

You may require a user to scan a product barcode (see section below on subclassing our barcode controller) to add or modify products or you may provide a different interface.

To modify an existing product, call:

- (void)userCorrectedBrand:(NSString*)brand
                       upc:(NSString*)upc
               productName:(NSString*)productName
                  imageUrl:(NSString*)imageUrl
                totalPrice:(float)totalPrice
                  quantity:(float)quantity;

on the existing BRProduct object with the new values for this product.

To add a new product call:

- (void)addUserCorrectedProductWithBrand:(NSString*)brand
                                     upc:(NSString*)upc
                             productName:(NSString*)productName
                                imageUrl:(NSString*)imgUrl
                              totalPrice:(float)totalPrice
                                quantity:(float)quantity;

on the BRScanResults object you obtained above.

To edit the receipt date call -[BRScanResults userCorrectedDate:]

Once the user has finished modifying the scan results, call -[BRScanManager submitUpdatedResultsForValidation:withCompletion:] and pass in the BRScanResults object that has been modified. The callback from this method will contain the BRScanResults object with an updated BRScanResults.qualifiedPromotions property reflecting user corrections.

Subclassing Barcode Scanning Controller

The SDK also provides a base class called BRMissedEarningsBaseViewController with barcode scanning capability that allows the user to scan the UPC from products they’ve purchased. To use this:

  1. Create your own view controller which is a subclass of this class to build your own UI on top of the basic barcode scanning experience.

  2. (optional) Set the BRMissedEarningsBaseViewController.scanningRegion property to indicate what portion of the screen should be used for detecting barcodes.

  3. Override the -[BRMissedEarningsBaseViewController didDetectBarcode:] method to be notified when a barcode is successfully captured

  4. Call the method -[BRMissedEarningsBaseViewController lookupUPC:withCompletion:] to make a network call which indicates whether the given UPC participates in your rewards program.

New Product Fields for Corrected Results

  1. BRProduct.userAdded - indicates that this product was added by the user during the receipt correction flow

  2. BRProduct.userModified - indicates that one or more properties of this product were modified by the user during the receipt correction flow