Skip to content

Barcode

barcode : object

Handle tracking barcodes

Kind: global namespace

barcode.TrackingBarcode

Kind: static class of barcode
Properties

Name Type Description
tracking string Tracking number
barcode string Original barcode data this was created from
toZip string Destination ZIP Code, for domestic shipments. The city and state are automatically added. If toAddress is specified, toZip is ignored in favor of it.
toCountry string Two-letter destination country code. If it doesn't match the country PostalPoint is running in, the full country name is appended to the displayed address information.
toAddress string Destination mailing/shipping address.
carrier string Shipping carrier name.
service string Shipping service/mail class name. Example: "Priority Mail".
dropoff boolean If set to false, the barcode will be rejected with a suitable message when PostalPoint is running in self-serve kiosk mode.
confidentCarrier boolean If false, PostalPoint may prompt user to specify the shipping carrier.
extraInfo Array.<string> Extra description strings, like "Signature Required".
message string If not empty, the barcode will NOT be added and the contents of message will be displayed to the user.
warning string If not empty, the barcode WILL be added and the contents of warning will be displayed to the user.
destString string (read only) Get the destination information as a human-presentable multiline string.
serviceString string (read only) Get the carrier and service.
toString() function Get the package information in a format suitable for display on a receipt.
toString(false) function Get the package information in a format suitable for display on a receipt, suppressing the tracking number.

new TrackingBarcode(code)

A Tracking barcode object.

Param Type Description
code string Barcode data

barcode.addPrepaidBarcode(trackingBarcodeData)

Add a TrackingBarcode object to the transaction receipt at any time other than onPrepaidScan.

Kind: static method of barcode

Param Type
trackingBarcodeData TrackingBarcode

barcode.inject(barcodeData)

Pass data to the internal barcode event subsystem. The data is handled as if it were just received from a physical barcode scanner.

Kind: static method of barcode

Param Type
barcodeData string

barcode.onPrepaidScan(f)

The function passed to onPrepaidScan is run when a barcode is scanned on the Prepaid page. The function is passed one argument, a string containing the raw barcode data. The function shall return boolean false if unable or unwilling to handle the barcode. If the barcode is handled by this function, it shall return a TrackingBarcode object.

Kind: static method of barcode

Param Type
f function

barcode.registerDropOffCarrierScanHandler(carrier, fn)

Register to handle prepaid drop off scans for a particular shipping carrier. Scans are kept in a local, disk-backed queue and the function registered here will be called when a queued barcode is processed for the provided carrier. This function is intended for carrier drop-off reimbursement programs such as ASO and FASC.

Kind: static method of barcode
Throws:

  • Error - Only one plugin may register a particular carrier with this function; any subsequent attempts to register to handle that carrier will throw an Error.
Param Type Description
carrier string Carrier name to register for.
fn function Async function to pass scan details to. Returns true if processed, false if not processed (but the barcode should be removed from queue), or throws an Error if it should be retried later. See example for data and usage.

Example

global.apis.barcode.registerDropOffCarrierScanHandler("FedEx", function (data) {
    global.apis.alert(`Carrier: ${data.carrier}, Tracking number: ${data.tracking}, `
        + `Raw scanned barcode: ${data.barcode}, `
        + `UNIX timestamp of scan: ${data.timestamp}, Scan UUID: ${data.uuid}`,
        "Processing DropOffCarrierScan data");

    return false; // Not processed but should be discarded
    return true; // Processed, discard from queue
    throw new Error("Failed to process, try again later");
});