payfrit-works/api/beacons/getBusinessFromBeacon.cfm
John Mizerek 0765dc1e27 Add business portal, Stripe Connect, beacon APIs, and task system
Portal:
- New business portal UI (portal/index.html, portal.css, portal.js)
- Dashboard with real-time stats (orders today, revenue, pending, menu items)
- Business info endpoint (api/businesses/get.cfm)
- Portal stats endpoint (api/portal/stats.cfm)
- Menu page links to existing full-featured menu editor

Stripe Connect:
- Onboarding endpoint (api/stripe/onboard.cfm)
- Status check endpoint (api/stripe/status.cfm)
- Payment intent creation (api/stripe/createPaymentIntent.cfm)
- Webhook handler (api/stripe/webhook.cfm)

Beacon APIs:
- List all beacons (api/beacons/list_all.cfm)
- Get business from beacon (api/beacons/getBusinessFromBeacon.cfm)

Task System:
- List pending tasks (api/tasks/listPending.cfm)
- Accept task (api/tasks/accept.cfm)

Other:
- HUD interface for quick order status display
- KDS debug/test pages
- Updated Application.cfm with public endpoint allowlist
- Order status check improvements

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 23:38:26 -08:00

79 lines
2.2 KiB
Text

<cfsetting showdebugoutput="false">
<cfsetting enablecfoutputonly="true">
<cfcontent type="application/json; charset=utf-8" reset="true">
<cfheader name="Cache-Control" value="no-store">
<cfscript>
function apiAbort(obj) {
writeOutput(serializeJSON(obj));
abort;
}
function readJsonBody() {
raw = toString(getHttpRequestData().content);
if (isNull(raw) || len(trim(raw)) EQ 0) return {};
try {
parsed = deserializeJSON(raw);
} catch(any e) {
apiAbort({ OK=false, ERROR="bad_json", MESSAGE="Invalid JSON body" });
}
if (!isStruct(parsed)) return {};
return parsed;
}
data = readJsonBody();
if (!structKeyExists(data, "BeaconID") || !isNumeric(data.BeaconID) || int(data.BeaconID) LTE 0) {
apiAbort({ OK=false, ERROR="missing_beacon_id", MESSAGE="BeaconID is required" });
}
beaconId = int(data.BeaconID);
</cfscript>
<cfquery name="qAssignment" datasource="payfrit">
SELECT
lt.BusinessID,
lt.BeaconID,
lt.ServicePointID,
b.BeaconName,
b.BeaconUUID,
b.BeaconIsActive,
biz.BusinessName,
sp.ServicePointName,
sp.ServicePointIsActive
FROM lt_Beacon_Businesses_ServicePoints lt
INNER JOIN Beacons b ON b.BeaconID = lt.BeaconID
INNER JOIN Businesses biz ON biz.BusinessID = lt.BusinessID
INNER JOIN ServicePoints sp ON sp.ServicePointID = lt.ServicePointID
WHERE lt.BeaconID = <cfqueryparam cfsqltype="cf_sql_integer" value="#beaconId#">
AND b.BeaconIsActive = 1
AND sp.ServicePointIsActive = b'1'
LIMIT 1
</cfquery>
<cfif qAssignment.recordCount EQ 0>
<cfoutput>#serializeJSON({ OK=false, ERROR="not_found", MESSAGE="Beacon not found, inactive, or not assigned to an active service point" })#</cfoutput>
<cfabort>
</cfif>
<cfset response = {
"OK" = true,
"ERROR" = "",
"BEACON" = {
"BeaconID" = qAssignment.BeaconID,
"BeaconName" = qAssignment.BeaconName,
"UUID" = qAssignment.BeaconUUID
},
"BUSINESS" = {
"BusinessID" = qAssignment.BusinessID,
"BusinessName" = qAssignment.BusinessName
},
"SERVICEPOINT" = {
"ServicePointID" = qAssignment.ServicePointID,
"ServicePointName" = qAssignment.ServicePointName,
"ServicePointIsActive" = qAssignment.ServicePointIsActive
}
}>
<cfoutput>#serializeJSON(response)#</cfoutput>