Print Receipt In-App Integration
Processing a Print Receipt Request
// Function to print receipt using In-App Integration
async function printReceiptInApp(base64Receipt) {
// Check if the PrintImage handler is available
if (window.PrintImage) {
const printRequest = {
method: "PrintImage",
data: base64Receipt, // Base64-encoded receipt image
};
// Convert the request to JSON
const message = JSON.stringify(printRequest);
try {
// Send the print request to Easypay's PrintImage handler
await window.PrintImage.postMessage(message);
console.log("Print request sent (In-App):", printRequest);
} catch (error) {
console.error("Failed to send print request (In-App):", error);
// Optionally, notify the user or implement fallback logic
}
} else {
console.error("PrintImage handler is not available.");
// Optionally, fallback to WebSocket Integration or notify the user
}
}
// Example usage:
const base64Receipt = "your_base64_receipt_here"; // Replace with your base64 receipt
printReceiptInApp(base64Receipt);Processing Open Cash Drawer Request
Last updated