How to use Scanner in pos.purchase.post.action.render

I am trying to use the scanner after checkout for identification purposes. However, the Scanner API is not available in the pos.purchase.post.action.render extension target.

I attempted to bridge this functionality in PostPurchaseActionModal.jsx as follows:

function openScanner() {
try {
const payload = await shopify.scanner.capture();
console.log(‘Scanner success’, payload);
} catch (error) {
console.log(‘Scanner error’, error);
}
}

return (

Scan


);

But when I pressed the button, I encountered the following error: