Home>Catalyst 101>Exploring Catalyst function types through E- commerce order processing
Exploring Catalyst function types through E- commerce order processing
Srilakshmi | Technical writer
October 15, 2025
Inside the Cookbook
Basic I/O function — Receive new orders
Advanced I/O function - Generate invoice PDFs on demand
Event function - Trigger fulfillment on new orders
Browser Logic function - Scrape low-rated product reviews
Integration function
Job function — Batch process refund requests
Wrapping up
Building a full-fledged ecommerce backend is no small feat. You need to handle everything from capturing customer orders and managing inventory to processing payments and generating detailed reports, all while ensuring your app is fast, reliable, and scalable.
Whether you want to quickly expose a REST API for new orders, automate complex fulfillment workflows, or run batch jobs during off-peak hours, Catalyst offers a tailored function type for every need.
In this article, we’ll walk through how each Catalyst function type fits perfectly into a typical ecommerce order processing app.
Basic I/O function - Receive new orders
Your customers place orders through an API endpoint, the critical gateway that kicks off the entire order processing flow.
Basic I/O functions are designed exactly for this. They provide a lightweight, efficient way to accept incoming requests and validate order details without worrying about managing servers.
This means you can rapidly build and deploy your order intake logic, ensuring every customer’s purchase is recorded instantly and reliably.
Plus, Basic I/O functions scale automatically to handle traffic spikes during flash sales or holiday rushes, so your backend never misses a beat.
module.exports = async function(context, basicIO) {
try {
// 1. Ensure body exists
if (!context.body) {
basicIO.write(JSON.stringify({ status: 'error', message: 'No request body provided.' }));
context.close();
return;
}
// 2. Parse JSON safely
const requestBody = JSON.parse(context.body);
const order = requestBody.order;
// 3. Validate order
if (!order || !order.items || order.items.length === 0) {
basicIO.write(JSON.stringify({ status: 'error', message: 'Invalid order data.' }));
context.close();
return;
}
let totalAmount = 0;
order.items.forEach(item => {
if (item.price && item.quantity) totalAmount += item.price * item.quantity;
});
// 5. Generate order ID
const orderId = `ORD-${Date.now()}`;
// 6. Prepare record for NoSQL
const orderRecord = {
orderId, // Partition key in NoSQL table
order,
totalAmount,
date: Date.now()
};
// 7. Insert into NoSQL table
const noSQL = context.getNoSQL();
const table = noSQL.table('orders'); // Use your **exact table name** here
await table.insert(orderRecord);
// 8. Return success
basicIO.write(JSON.stringify({
status: 'success',
message: 'Order received successfully.',
orderId,
totalAmount
}));
context.close();
} catch (err) {
console.error('Error inserting order:', err);
basicIO.write(JSON.stringify({ status: 'error', message: 'Internal server error.' }));
context.close();
}
Advanced I/O function - Generate invoice PDFs on demand
Generate dynamic invoices as downloadable PDFs using Advanced I/O functions and Puppeteer. This lets you create fast, customizable invoices server-side with full control over design no extra dependencies needed.
const puppeteer = require('puppeteer');
exports.handler = async function(context, req) {
// Extract orderId from query parameters
const orderId = req.query.orderId;
// Fetch the order document from the 'orders' collection by _id
const order = await context.db.collection('orders').findOne({ _id: orderId });
// If order not found, return 404 error response
if (!order) return { statusCode: 404, body: "Order not found." };
// Launch a headless browser instance
const browser = await puppeteer.launch();
// Open a new page/tab in the browser
const page = await browser.newPage();
// Prepare simple HTML content for the invoice
const html = `Invoice for Order ${orderId}Items: ${order.order.items.length}`;
// Set the HTML content into the page
await page.setContent(html);
// Generate a PDF from the page content and store it in a buffer
const pdfBuffer = await page.pdf();
// Close the browser to free resources
await browser.close();
// Return the PDF as a base64-encoded string with appropriate headers
return {
statusCode: 200,
headers: { 'Content-Type': 'application/pdf' },
body: pdfBuffer.toString('base64'),
isBase64Encoded: true
};
};
Event function - Trigger fulfillment on new orders
When a new order is placed, you want to start the fulfillment process immediately whether that means notifying your warehouse, updating inventory, or initiating shipping. Event functions in Catalyst let you hook directly into system events (like a new order inserted into your database) so your backend can respond automatically, in real time, without polling or manual triggers. This reactive approach ensures faster order processing and a smoother customer experience.
Here’s an example where an Event function listens for new orders and triggers fulfillment logic:
exports.handler = async function(event) {
// Get the action that triggered the event (e.g., insert, update)
const action = event.getAction();
// Get the ID of the source entity where the event occurred (e.g., table ID)
const sourceEntityId = event.getSourceEntityId();
// Get project details like ID and name
const projectDetails = event.getProjectDetails();
// Get the event data (e.g., order details)
const data = event.getData();
// Get the time when the event occurred
const eventTime = event.getTime();
// Get the source name that triggered the event (e.g., Data Store)
const source = event.getSource();
// Get event bus details like configured actions and rules
const eventBusDetails = event.getEventBusDetails();
// Example: Proceed if action is 'INSERT' and source is 'Data Store'
if (action === 'INSERT' && source === 'Data Store') {
const order = data.order;
// Trigger order fulfillment logic
await triggerFulfillment(order);
console.log(`Order fulfillment triggered for order ID: ${order.id}`);
} else {
console.log('Event not related to new order insertion, no action taken.');
}
};
async function triggerFulfillment(order) {
// Fulfillment logic here: notify warehouse, update inventory, etc.
)
}
Browser Logic function - Scrape low-rated product reviews
Let’s say you want to fetch negative reviews from a product page using a headless browser and analyze customer satisfaction, all triggered from your web app.
Here’s a Browser Logic function that uses SmartBrowz:
This code opens a product page using SmartBrowz, scrapes all one-star customer reviews, and returns them. It runs securely as a Browser Logic function, triggered directly from the frontend.
Catalyst supports integration with Zoho Cliq and other services of Catalyst via Integration functions, enabling seamless team collaboration and automation. Developers can build backend services for Cliq extensions like:
Refund processing can involve multiple steps like validating transactions, updating databases, and notifying customers. Running these tasks synchronously can slow down your app and frustrate users.
Job functions let you offload such resource-intensive or time-consuming processes to run asynchronously, improving your app’s responsiveness.
They receive two arguments: job_details, which provides metadata and parameters about the job, and context, which lets you monitor execution time and signal success or failure. Using these, you can manage batch jobs like data imports, refunds, or report generation efficiently.
Catalyst gives you the flexibility to build your apps using the right function type for each job from quick APIs and event-driven workflows to scheduled tasks and complex integrations.