DocHub
Square API, n8n webhooks, Hostinger SMTP, Google APIs, PubSub, and Firebase Storage

External Integrations

Square API

Payment processing for invoices.

  • Base URL: https://connect.squareup.com/v2
  • API Version: 2023-10-17
  • Auth: Bearer token via process.env.SQUARE_ACCESS_TOKEN
  • Location ID: process.env.SQUARE_LOCATION_ID

Endpoints Used

Endpoint Method Used By Purpose
/orders POST sendInvoiceToSquare, processInvoiceInternal Create order with line items
/invoices POST sendInvoiceToSquare, processInvoiceInternal Create invoice attached to order
/customers/{id} DELETE deleteClientFromSquare Delete customer

Flow

  1. Build line items from invoice packages (item name, cost, dimensions, charges)
  2. Create Square Order with line items + idempotency key (UUID)
  3. Create Square Invoice linked to order + idempotency key
  4. Update Firestore invoice with Square order ID and invoice ID
  5. Log API call to squareAPILog collection

automaticallySent Status Codes

Code Meaning
0 Not yet sent / retry in progress
1 Auto-sent successfully via PubSub pipeline
2 Failed (max retries reached)
3 Manually sent via sendInvoiceToSquare callable
4 Failed during manual send

n8n Webhooks

Used for client management via Square. Migrated from Make.com (plan expired March 2026). n8n is self-hosted at http://worker1.ipnoelp.com.

Workflow n8n ID Webhook Path Full URL Used By Purpose
MaxForm (Create Customer) LdhHO7OJMFHANOXH /webhook/maxform-add-client http://worker1.ipnoelp.com/webhook/maxform-add-client addClientViaWebhook Creates new client in Square, returns squareCustomerId
Update Square Customer v1Ohl0pawAnTGHK3 /webhook/update-square-customer http://worker1.ipnoelp.com/webhook/update-square-customer updateClientInSquare Sends client data (email, phone, firstName, lastName, squareCustomerId, referenceId, location)
Welcome Email WKop8m43naRFZfxb /webhook/welcome-email http://worker1.ipnoelp.com/webhook/welcome-email (triggered by MaxForm workflow) Sends welcome email to new clients

n8n SMTP Credentials

  • Credential ID: g0OumJw1smloyrQ4
  • Credential Name: SMTP account 2
  • Used by: Welcome Email workflow

Hostinger SMTP (Nodemailer)

Two separate SMTP transporters for sending emails.

Transporter Host Port SSL Purpose
Primary (transporter) smtp.hostinger.com 465 Yes System alerts, reports, internal notifications
Formatted (formattedEmailTransporter) smtp.hostinger.com 465 Yes Client-facing branded emails, duplicate last name reports

From address: MAXSHIPPING <support@maxshipping.info>

Email Recipients by Type

Email Type Recipients
Invoice failures jaz@omelasai.com, info@omelasai.com, shipittomax@gmail.com, maxshippingroatan@gmail.com
Daily reports jaz@omelasai.com, log@omelasai.com, shipittomax@gmail.com, maxshippingroatan@gmail.com
Daily check results jaz@omelasai.com, log@omelasai.com
Unloaded alerts jaz@omelasai.com, shipittomax@gmail.com, maxshippingroatan@gmail.com
Force unload jaz@omelasai.com, shipittomax@gmail.com, maxshippingroatan@gmail.com
Bad scan alerts jaz@omelasai.com, log@omelasai.com
Container reports (JSON) jaz@omelasai.com, log@omelasai.com
Container reports (XLS) jaz@omelasai.com, shipittomax@gmail.com, maxshippingroatan@gmail.com
Prepaid reports jaz@omelasai.com, shipittomax@gmail.com, maxshippingroatan@gmail.com
Duplicate packages jaz@omelasai.com, shipittomax@gmail.com, maxshippingroatan@gmail.com
Duplicate last name shipittomax@gmail.com, maxshippingroatan@gmail.com, jaz@omelasai.com
Missing contacts jaz@omelasai.com, shipittomax@gmail.com, maxshippingroatan@gmail.com
Lost packages jaz@omelasai.com, shipittomax@gmail.com, maxshippingroatan@gmail.com
Client package status Client email (from Clients collection)

Google APIs (googleapis)

Authenticated via service account key (serviceAccountKey.json).

Scopes: drive, spreadsheets

Firestore Export API

Uses google.firestore(v1) for automated backups.

Backup Bucket Schedule Days
gs://maxproductionbackup/ 1pm and 8pm ET (weekdays), every 2hrs (weekends) All
gs://maxproductionbackup-weekly/ 1pm ET Mondays only
gs://maxproductionbackup-daily/ 1pm ET Tue-Sun

Google Cloud PubSub

Async message queue for decoupling heavy operations.

Topic Publisher Subscribers Purpose
process-invoice enqueueInvoiceForProcessing processInvoiceFromQueue (max 3 instances) Invoice processing pipeline to Square
process-container-tasks onContainerCreated (after 1-min delay) processContainerTaskJson, processContainerTaskXsl, processContainerTaskJsonForApp Container report generation (3 parallel consumers)

Firebase Cloud Storage

Bucket: Default project bucket (max-inventory-scanner-b0b53.appspot.com)

Path Content Written By
json/packages.json Combined package data for app processContainerTaskJsonForApp
excelsheets/{containerName}-loaded-packages.xlsx Loaded packages spreadsheet processContainerTaskXsl
excelsheets/{containerName}-prepaid-space-report.xlsx Prepaid space usage report prepaidSendEmail
loadedPackages/ Loaded package manifests External uploads (read by web app)
prepaid/ Prepaid shipment docs External uploads (read by web app)
Photo evidence URLs Bad scan photos Read by badScanAlert

Archive Database

Long-term data archival to a secondary Firestore instance.

  • Service account: serviceAccountKeyArchive.json
  • App name: db2
  • Trigger: copyDataOnNewContainer fires on container creation
  • Archive target: 8th-to-last container and all related data

Collections Archived

Collection Method
Containers Copy single container document
Packages Copy all packages for that container + child packages
Invoices Copy all invoices for that container
User Copy all, skip duplicates
Items Copy all, skip duplicates
Clients Copy all, skip duplicates