1926 lines
36 KiB
HTML
Raw Normal View History

<!doctype html>
<html lang="en" class="no-js">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="prev" href="../../Examples/05CryptoProcessor/">
<link rel="next" href="../database/">
<link rel="icon" href="../../assets/external/postalpoint.app/images/favicon-voxel.png">
<meta name="generator" content="mkdocs-1.6.1, mkdocs-material-9.7.1">
<title>Barcode - PostalPoint Plugin Development</title>
<link rel="stylesheet" href="../../assets/stylesheets/main.484c7ddc.min.css">
<link rel="stylesheet" href="../../assets/stylesheets/palette.ab4e12ef.min.css">
<link rel="stylesheet" href="../../assets/external/fonts.googleapis.com/css.49ea35f2.css">
<style>:root{--md-text-font:"Roboto";--md-code-font:"Roboto Mono"}</style>
<link rel="stylesheet" href="../../assets/styles.css">
<script>__md_scope=new URL("../..",location),__md_hash=e=>[...e].reduce(((e,_)=>(e<<5)-e+_.charCodeAt(0)),0),__md_get=(e,_=localStorage,t=__md_scope)=>JSON.parse(_.getItem(t.pathname+"."+e)),__md_set=(e,_,t=localStorage,a=__md_scope)=>{try{t.setItem(a.pathname+"."+e,JSON.stringify(_))}catch(e){}}</script>
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.netsyms.net/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '57']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
<script>"undefined"!=typeof __md_analytics&&__md_analytics()</script>
</head>
<body dir="ltr" data-md-color-scheme="default" data-md-color-primary="blue" data-md-color-accent="indigo">
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
<label class="md-overlay" for="__drawer"></label>
<div data-md-component="skip">
<a href="#barcode-object" class="md-skip">
Skip to content
</a>
</div>
<div data-md-component="announce">
</div>
<div data-md-color-scheme="default" data-md-component="outdated" hidden>
</div>
<header class="md-header md-header--shadow" data-md-component="header">
<nav class="md-header__inner md-grid" aria-label="Header">
<a href="https://postalpoint.app" title="PostalPoint Plugin Development" class="md-header__button md-logo" aria-label="PostalPoint Plugin Development" data-md-component="logo">
<img src="../../assets/logo.svg" alt="logo">
</a>
<label class="md-header__button md-icon" for="__drawer">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M3 6h18v2H3zm0 5h18v2H3zm0 5h18v2H3z"/></svg>
</label>
<div class="md-header__title" data-md-component="header-title">
<div class="md-header__ellipsis">
<div class="md-header__topic">
<span class="md-ellipsis">
PostalPoint Plugin Development
</span>
</div>
<div class="md-header__topic" data-md-component="header-topic">
<span class="md-ellipsis">
Barcode
</span>
</div>
</div>
</div>
<label class="md-header__button md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
</label>
<div class="md-search" data-md-component="search" role="dialog">
<label class="md-search__overlay" for="__search"></label>
<div class="md-search__inner" role="search">
<form class="md-search__form" name="search">
<input type="text" class="md-search__input" name="query" aria-label="Search" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="search-query" required>
<label class="md-search__icon md-icon" for="__search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M9.5 3A6.5 6.5 0 0 1 16 9.5c0 1.61-.59 3.09-1.56 4.23l.27.27h.79l5 5-1.5 1.5-5-5v-.79l-.27-.27A6.52 6.52 0 0 1 9.5 16 6.5 6.5 0 0 1 3 9.5 6.5 6.5 0 0 1 9.5 3m0 2C7 5 5 7 5 9.5S7 14 9.5 14 14 12 14 9.5 12 5 9.5 5"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 11v2H8l5.5 5.5-1.42 1.42L4.16 12l7.92-7.92L13.5 5.5 8 11z"/></svg>
</label>
<nav class="md-search__options" aria-label="Search">
<button type="reset" class="md-search__icon md-icon" title="Clear" aria-label="Clear" tabindex="-1">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>
</button>
</nav>
</form>
<div class="md-search__output">
<div class="md-search__scrollwrap" tabindex="0" data-md-scrollfix>
<div class="md-search-result" data-md-component="search-result">
<div class="md-search-result__meta">
Initializing search
</div>
<ol class="md-search-result__list" role="presentation"></ol>
</div>
</div>
</div>
</div>
</div>
</nav>
</header>
<div class="md-container" data-md-component="container">
<main class="md-main" data-md-component="main">
<div class="md-main__inner md-grid">
<div class="md-sidebar md-sidebar--primary" data-md-component="sidebar" data-md-type="navigation" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--primary" aria-label="Navigation" data-md-level="0">
<label class="md-nav__title" for="__drawer">
<a href="https://postalpoint.app" title="PostalPoint Plugin Development" class="md-nav__button md-logo" aria-label="PostalPoint Plugin Development" data-md-component="logo">
<img src="../../assets/logo.svg" alt="logo">
</a>
PostalPoint Plugin Development
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../.." class="md-nav__link">
<span class="md-ellipsis">
Overview
</span>
</a>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_2" >
<label class="md-nav__link" for="__nav_2" id="__nav_2_label" tabindex="0">
<span class="md-ellipsis">
Docs
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_2_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_2">
<span class="md-nav__icon md-icon"></span>
Docs
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../Docs/Address/" class="md-nav__link">
<span class="md-ellipsis">
Address object
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../Docs/Carrier_Service/" class="md-nav__link">
<span class="md-ellipsis">
getCarrierName and getServiceName
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../Docs/Database/" class="md-nav__link">
<span class="md-ellipsis">
Database Drivers
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../Docs/Events/" class="md-nav__link">
<span class="md-ellipsis">
Event Bus
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../Docs/FormPS1583/" class="md-nav__link">
<span class="md-ellipsis">
FormPS1583 object
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../Docs/HTTP_API_Server/" class="md-nav__link">
<span class="md-ellipsis">
HTTP API Server
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../Docs/HiddenConfigs/" class="md-nav__link">
<span class="md-ellipsis">
Configuration Flags
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../Docs/Parcel/" class="md-nav__link">
<span class="md-ellipsis">
Parcel/Package Object
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../Docs/Receipt/" class="md-nav__link">
<span class="md-ellipsis">
Receipt Objects
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../Docs/ReceiptPrinter/" class="md-nav__link">
<span class="md-ellipsis">
Receipt Printer driver functions
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../Docs/TrackingBarcode/" class="md-nav__link">
<span class="md-ellipsis">
TrackingBarcode class
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_3" >
<label class="md-nav__link" for="__nav_3" id="__nav_3_label" tabindex="0">
<span class="md-ellipsis">
Examples
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_3_label" aria-expanded="false">
<label class="md-nav__title" for="__nav_3">
<span class="md-nav__icon md-icon"></span>
Examples
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item">
<a href="../../Examples/01Minimal/" class="md-nav__link">
<span class="md-ellipsis">
Minimal Plugin
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../Examples/02Basic/" class="md-nav__link">
<span class="md-ellipsis">
Basic Plugin
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../Examples/03Shipping/" class="md-nav__link">
<span class="md-ellipsis">
Shipping Plugin
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../Examples/04CardProcessor/" class="md-nav__link">
<span class="md-ellipsis">
Card Payments
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../../Examples/05CryptoProcessor/" class="md-nav__link">
<span class="md-ellipsis">
Cryptocurrency Payments
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item md-nav__item--active md-nav__item--nested">
<input class="md-nav__toggle md-toggle " type="checkbox" id="__nav_4" checked>
<label class="md-nav__link" for="__nav_4" id="__nav_4_label" tabindex="0">
<span class="md-ellipsis">
Plugin API
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<nav class="md-nav" data-md-level="1" aria-labelledby="__nav_4_label" aria-expanded="true">
<label class="md-nav__title" for="__nav_4">
<span class="md-nav__icon md-icon"></span>
Plugin API
</label>
<ul class="md-nav__list" data-md-scrollfix>
<li class="md-nav__item md-nav__item--active">
<input class="md-nav__toggle md-toggle" type="checkbox" id="__toc">
<label class="md-nav__link md-nav__link--active" for="__toc">
<span class="md-ellipsis">
Barcode
</span>
<span class="md-nav__icon md-icon"></span>
</label>
<a href="./" class="md-nav__link md-nav__link--active">
<span class="md-ellipsis">
Barcode
</span>
</a>
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#barcode-object" class="md-nav__link">
<span class="md-ellipsis">
barcode : object
</span>
</a>
<nav class="md-nav" aria-label="barcode : object">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#barcodetrackingbarcode" class="md-nav__link">
<span class="md-ellipsis">
barcode.TrackingBarcode
</span>
</a>
<nav class="md-nav" aria-label="barcode.TrackingBarcode">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#new-trackingbarcodecode" class="md-nav__link">
<span class="md-ellipsis">
new TrackingBarcode(code)
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#barcodeaddprepaidbarcodetrackingbarcodedata" class="md-nav__link">
<span class="md-ellipsis">
barcode.addPrepaidBarcode(trackingBarcodeData)
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#barcodeinjectbarcodedata" class="md-nav__link">
<span class="md-ellipsis">
barcode.inject(barcodeData)
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#barcodeonprepaidscanf" class="md-nav__link">
<span class="md-ellipsis">
barcode.onPrepaidScan(f)
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#barcoderegisterdropoffcarrierscanhandlercarrier-fn" class="md-nav__link">
<span class="md-ellipsis">
barcode.registerDropOffCarrierScanHandler(carrier, fn)
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="../database/" class="md-nav__link">
<span class="md-ellipsis">
Database
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../fs/" class="md-nav__link">
<span class="md-ellipsis">
Fs
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../global%20functions/" class="md-nav__link">
<span class="md-ellipsis">
Global functions
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../graphics/" class="md-nav__link">
<span class="md-ellipsis">
Graphics
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../httpserver/" class="md-nav__link">
<span class="md-ellipsis">
Httpserver
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../i18n/" class="md-nav__link">
<span class="md-ellipsis">
I18n
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../kiosk/" class="md-nav__link">
<span class="md-ellipsis">
Kiosk
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../mailboxes/" class="md-nav__link">
<span class="md-ellipsis">
Mailboxes
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../pos/" class="md-nav__link">
<span class="md-ellipsis">
Pos
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../print/" class="md-nav__link">
<span class="md-ellipsis">
Print
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../reports/" class="md-nav__link">
<span class="md-ellipsis">
Reports
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../settings/" class="md-nav__link">
<span class="md-ellipsis">
Settings
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../shipping/" class="md-nav__link">
<span class="md-ellipsis">
Shipping
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../storage/" class="md-nav__link">
<span class="md-ellipsis">
Storage
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../ui/" class="md-nav__link">
<span class="md-ellipsis">
Ui
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../user/" class="md-nav__link">
<span class="md-ellipsis">
User
</span>
</a>
</li>
<li class="md-nav__item">
<a href="../util/" class="md-nav__link">
<span class="md-ellipsis">
Util
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-sidebar md-sidebar--secondary" data-md-component="sidebar" data-md-type="toc" >
<div class="md-sidebar__scrollwrap">
<div class="md-sidebar__inner">
<nav class="md-nav md-nav--secondary" aria-label="Table of contents">
<label class="md-nav__title" for="__toc">
<span class="md-nav__icon md-icon"></span>
Table of contents
</label>
<ul class="md-nav__list" data-md-component="toc" data-md-scrollfix>
<li class="md-nav__item">
<a href="#barcode-object" class="md-nav__link">
<span class="md-ellipsis">
barcode : object
</span>
</a>
<nav class="md-nav" aria-label="barcode : object">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#barcodetrackingbarcode" class="md-nav__link">
<span class="md-ellipsis">
barcode.TrackingBarcode
</span>
</a>
<nav class="md-nav" aria-label="barcode.TrackingBarcode">
<ul class="md-nav__list">
<li class="md-nav__item">
<a href="#new-trackingbarcodecode" class="md-nav__link">
<span class="md-ellipsis">
new TrackingBarcode(code)
</span>
</a>
</li>
</ul>
</nav>
</li>
<li class="md-nav__item">
<a href="#barcodeaddprepaidbarcodetrackingbarcodedata" class="md-nav__link">
<span class="md-ellipsis">
barcode.addPrepaidBarcode(trackingBarcodeData)
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#barcodeinjectbarcodedata" class="md-nav__link">
<span class="md-ellipsis">
barcode.inject(barcodeData)
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#barcodeonprepaidscanf" class="md-nav__link">
<span class="md-ellipsis">
barcode.onPrepaidScan(f)
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#barcoderegisterdropoffcarrierscanhandlercarrier-fn" class="md-nav__link">
<span class="md-ellipsis">
barcode.registerDropOffCarrierScanHandler(carrier, fn)
</span>
</a>
</li>
</ul>
</nav>
</li>
</ul>
</nav>
</div>
</div>
</div>
<div class="md-content" data-md-component="content">
<article class="md-content__inner md-typeset">
<h1>Barcode</h1>
<p><a name="barcode"></a></p>
<h2 id="barcode-object">barcode : <code>object</code></h2>
<p>Handle tracking barcodes</p>
<p><strong>Kind</strong>: global namespace </p>
<ul>
<li><a href="#barcode">barcode</a> : <code>object</code><ul>
<li><a href="#barcode.TrackingBarcode">.TrackingBarcode</a><ul>
<li><a href="#new_barcode.TrackingBarcode_new">new TrackingBarcode(code)</a></li>
</ul>
</li>
<li><a href="#barcode.addPrepaidBarcode">.addPrepaidBarcode(trackingBarcodeData)</a></li>
<li><a href="#barcode.inject">.inject(barcodeData)</a></li>
<li><a href="#barcode.onPrepaidScan">.onPrepaidScan(f)</a></li>
<li><a href="#barcode.registerDropOffCarrierScanHandler">.registerDropOffCarrierScanHandler(carrier, fn)</a></li>
</ul>
</li>
</ul>
<p><a name="barcode.TrackingBarcode"></a></p>
<h3 id="barcodetrackingbarcode">barcode.TrackingBarcode</h3>
<p><strong>Kind</strong>: static class of <a href="#barcode"><code>barcode</code></a><br />
<strong>Properties</strong></p>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>tracking</td>
<td><code>string</code></td>
<td>Tracking number</td>
</tr>
<tr>
<td>barcode</td>
<td><code>string</code></td>
<td>Original barcode data this was created from</td>
</tr>
<tr>
<td>toZip</td>
<td><code>string</code></td>
<td>Destination ZIP Code, for domestic shipments. The city and state are automatically added. If toAddress is specified, toZip is ignored in favor of it.</td>
</tr>
<tr>
<td>toCountry</td>
<td><code>string</code></td>
<td>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.</td>
</tr>
<tr>
<td>toAddress</td>
<td><code>string</code></td>
<td>Destination mailing/shipping address.</td>
</tr>
<tr>
<td>carrier</td>
<td><code>string</code></td>
<td>Shipping carrier name.</td>
</tr>
<tr>
<td>service</td>
<td><code>string</code></td>
<td>Shipping service/mail class name. Example: "Priority Mail".</td>
</tr>
<tr>
<td>dropoff</td>
<td><code>boolean</code></td>
<td>If set to false, the barcode will be rejected with a suitable message when PostalPoint is running in self-serve kiosk mode.</td>
</tr>
<tr>
<td>confidentCarrier</td>
<td><code>boolean</code></td>
<td>If false, PostalPoint may prompt user to specify the shipping carrier.</td>
</tr>
<tr>
<td>extraInfo</td>
<td><code>Array.&lt;string&gt;</code></td>
<td>Extra description strings, like "Signature Required".</td>
</tr>
<tr>
<td>message</td>
<td><code>string</code></td>
<td>If not empty, the barcode will NOT be added and the contents of <code>message</code> will be displayed to the user.</td>
</tr>
<tr>
<td>warning</td>
<td><code>string</code></td>
<td>If not empty, the barcode WILL be added and the contents of <code>warning</code> will be displayed to the user.</td>
</tr>
<tr>
<td>destString</td>
<td><code>string</code></td>
<td>(read only) Get the destination information as a human-presentable multiline string.</td>
</tr>
<tr>
<td>serviceString</td>
<td><code>string</code></td>
<td>(read only) Get the carrier and service.</td>
</tr>
<tr>
<td>toString()</td>
<td><code>function</code></td>
<td>Get the package information in a format suitable for display on a receipt.</td>
</tr>
<tr>
<td>toString(false)</td>
<td><code>function</code></td>
<td>Get the package information in a format suitable for display on a receipt, suppressing the tracking number.</td>
</tr>
</tbody>
</table>
<p><a name="new_barcode.TrackingBarcode_new"></a></p>
<h4 id="new-trackingbarcodecode">new TrackingBarcode(code)</h4>
<p>A Tracking barcode object.</p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>code</td>
<td><code>string</code></td>
<td>Barcode data</td>
</tr>
</tbody>
</table>
<p><a name="barcode.addPrepaidBarcode"></a></p>
<h3 id="barcodeaddprepaidbarcodetrackingbarcodedata">barcode.addPrepaidBarcode(trackingBarcodeData)</h3>
<p>Add a TrackingBarcode object to the transaction receipt at any time other than <code>onPrepaidScan</code>.</p>
<p><strong>Kind</strong>: static method of <a href="#barcode"><code>barcode</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>trackingBarcodeData</td>
<td><code>TrackingBarcode</code></td>
</tr>
</tbody>
</table>
<p><a name="barcode.inject"></a></p>
<h3 id="barcodeinjectbarcodedata">barcode.inject(barcodeData)</h3>
<p>Pass data to the internal barcode event subsystem. The data is handled as if it
were just received from a physical barcode scanner.</p>
<p><strong>Kind</strong>: static method of <a href="#barcode"><code>barcode</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>barcodeData</td>
<td><code>string</code></td>
</tr>
</tbody>
</table>
<p><a name="barcode.onPrepaidScan"></a></p>
<h3 id="barcodeonprepaidscanf">barcode.onPrepaidScan(f)</h3>
<p>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.</p>
<p><strong>Kind</strong>: static method of <a href="#barcode"><code>barcode</code></a> </p>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
</tr>
</thead>
<tbody>
<tr>
<td>f</td>
<td><code>function</code></td>
</tr>
</tbody>
</table>
<p><a name="barcode.registerDropOffCarrierScanHandler"></a></p>
<h3 id="barcoderegisterdropoffcarrierscanhandlercarrier-fn">barcode.registerDropOffCarrierScanHandler(carrier, fn)</h3>
<p>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.</p>
<p><strong>Kind</strong>: static method of <a href="#barcode"><code>barcode</code></a><br />
<strong>Throws</strong>:</p>
<ul>
<li><code>Error</code> - Only one plugin may register a particular carrier with this function;
any subsequent attempts to register to handle that carrier will throw an Error.</li>
</ul>
<table>
<thead>
<tr>
<th>Param</th>
<th>Type</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>carrier</td>
<td><code>string</code></td>
<td>Carrier name to register for.</td>
</tr>
<tr>
<td>fn</td>
<td><code>function</code></td>
<td>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.</td>
</tr>
</tbody>
</table>
<p><strong>Example</strong><br />
<div class="language-js highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="nb">global</span><span class="p">.</span><span class="nx">apis</span><span class="p">.</span><span class="nx">barcode</span><span class="p">.</span><span class="nx">registerDropOffCarrierScanHandler</span><span class="p">(</span><span class="s2">&quot;FedEx&quot;</span><span class="p">,</span><span class="w"> </span><span class="kd">function</span><span class="w"> </span><span class="p">(</span><span class="nx">data</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a><span class="w"> </span><span class="nb">global</span><span class="p">.</span><span class="nx">apis</span><span class="p">.</span><span class="nx">alert</span><span class="p">(</span><span class="sb">`Carrier: </span><span class="si">${</span><span class="nx">data</span><span class="p">.</span><span class="nx">carrier</span><span class="si">}</span><span class="sb">, Tracking number: </span><span class="si">${</span><span class="nx">data</span><span class="p">.</span><span class="nx">tracking</span><span class="si">}</span><span class="sb">, `</span>
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="sb">`Raw scanned barcode: </span><span class="si">${</span><span class="nx">data</span><span class="p">.</span><span class="nx">barcode</span><span class="si">}</span><span class="sb">, `</span>
</span><span id="__span-0-4"><a id="__codelineno-0-4" name="__codelineno-0-4" href="#__codelineno-0-4"></a><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="sb">`UNIX timestamp of scan: </span><span class="si">${</span><span class="nx">data</span><span class="p">.</span><span class="nx">timestamp</span><span class="si">}</span><span class="sb">, Scan UUID: </span><span class="si">${</span><span class="nx">data</span><span class="p">.</span><span class="nx">uuid</span><span class="si">}</span><span class="sb">`</span><span class="p">,</span>
</span><span id="__span-0-5"><a id="__codelineno-0-5" name="__codelineno-0-5" href="#__codelineno-0-5"></a><span class="w"> </span><span class="s2">&quot;Processing DropOffCarrierScan data&quot;</span><span class="p">);</span>
</span><span id="__span-0-6"><a id="__codelineno-0-6" name="__codelineno-0-6" href="#__codelineno-0-6"></a>
</span><span id="__span-0-7"><a id="__codelineno-0-7" name="__codelineno-0-7" href="#__codelineno-0-7"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="kc">false</span><span class="p">;</span><span class="w"> </span><span class="c1">// Not processed but should be discarded</span>
</span><span id="__span-0-8"><a id="__codelineno-0-8" name="__codelineno-0-8" href="#__codelineno-0-8"></a><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span><span class="w"> </span><span class="c1">// Processed, discard from queue</span>
</span><span id="__span-0-9"><a id="__codelineno-0-9" name="__codelineno-0-9" href="#__codelineno-0-9"></a><span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="ow">new</span><span class="w"> </span><span class="ne">Error</span><span class="p">(</span><span class="s2">&quot;Failed to process, try again later&quot;</span><span class="p">);</span>
</span><span id="__span-0-10"><a id="__codelineno-0-10" name="__codelineno-0-10" href="#__codelineno-0-10"></a><span class="p">});</span>
</span></code></pre></div></p>
</article>
</div>
<script>var target=document.getElementById(location.hash.slice(1));target&&target.name&&(target.checked=target.name.startsWith("__tabbed_"))</script>
</div>
</main>
<footer class="md-footer">
<div class="md-footer-meta md-typeset">
<div class="md-footer-meta__inner md-grid">
<div class="md-copyright">
Made with
<a href="https://squidfunk.github.io/mkdocs-material/" target="_blank" rel="noopener">
Material for MkDocs
</a>
</div>
</div>
</div>
</footer>
</div>
<div class="md-dialog" data-md-component="dialog">
<div class="md-dialog__inner md-typeset"></div>
</div>
<script id="__config" type="application/json">{"annotate": null, "base": "../..", "features": ["content.code.copy"], "search": "../../assets/javascripts/workers/search.2c215733.min.js", "tags": null, "translations": {"clipboard.copied": "Copied to clipboard", "clipboard.copy": "Copy to clipboard", "search.result.more.one": "1 more on this page", "search.result.more.other": "# more on this page", "search.result.none": "No matching documents", "search.result.one": "1 matching document", "search.result.other": "# matching documents", "search.result.placeholder": "Type to start searching", "search.result.term.missing": "Missing", "select.version": "Select version"}, "version": {"alias": true, "provider": "mike"}}</script>
<script src="../../assets/javascripts/bundle.79ae519e.min.js"></script>
<script src="../../assets/external/unpkg.com/mermaid@11/dist/mermaid.min.js"></script>
</body>
</html>