Update all SQL queries, query result references, and ColdFusion code to match
the renamed database schema. Tables use plural CamelCase, PKs are all `ID`,
column prefixes stripped (e.g. BusinessName→Name, UserFirstName→FirstName).
Key changes:
- Strip table-name prefixes from all column references (Businesses, Users,
Addresses, Hours, Menus, Categories, Items, Stations, Orders,
OrderLineItems, Tasks, TaskCategories, TaskRatings, QuickTaskTemplates,
ScheduledTaskDefinitions, ChatMessages, Beacons, ServicePoints, Employees,
VisitorTrackings, ApiPerfLogs, tt_States, tt_Days, tt_AddressTypes,
tt_OrderTypes, tt_TaskTypes)
- Rename PK references from {TableName}ID to ID in all queries
- Rewrite 7 admin beacon files to use ServicePoints.BeaconID instead of
dropped lt_Beacon_Businesses_ServicePoints link table
- Rewrite beacon assignment files (list, save, delete) for new schema
- Fix FK references incorrectly changed to ID (OrderLineItems.OrderID,
Categories.MenuID, Tasks.CategoryID, ServicePoints.BeaconID)
- Update Addresses: AddressLat→Latitude, AddressLng→Longitude
- Update Users: UserPassword→Password, UserIsEmailVerified→IsEmailVerified,
UserIsActive→IsActive, UserBalance→Balance, etc.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
85 lines
3 KiB
Text
85 lines
3 KiB
Text
<cfsetting showdebugoutput="false">
|
|
<cfsetting enablecfoutputonly="true">
|
|
<cfcontent type="application/json; charset=utf-8" reset="true">
|
|
|
|
<cfscript>
|
|
/**
|
|
* Create Stripe Checkout Session for activation early unlock.
|
|
* Worker pays remaining activation balance via card.
|
|
*/
|
|
|
|
response = { "OK": false };
|
|
|
|
try {
|
|
requestData = deserializeJSON(toString(getHttpRequestData().content));
|
|
userID = val(requestData.UserID ?: 0);
|
|
|
|
if (userID == 0 && structKeyExists(request, "UserID")) {
|
|
userID = val(request.UserID);
|
|
}
|
|
|
|
if (userID == 0) {
|
|
response["ERROR"] = "missing_params";
|
|
response["MESSAGE"] = "UserID is required.";
|
|
writeOutput(serializeJSON(response));
|
|
abort;
|
|
}
|
|
|
|
qUser = queryExecute("
|
|
SELECT ActivationBalanceCents, ActivationCapCents
|
|
FROM Users WHERE ID = :userID
|
|
", { userID: userID }, { datasource: "payfrit" });
|
|
|
|
if (qUser.recordCount == 0) {
|
|
response["ERROR"] = "user_not_found";
|
|
writeOutput(serializeJSON(response));
|
|
abort;
|
|
}
|
|
|
|
remainingCents = val(qUser.ActivationCapCents) - val(qUser.ActivationBalanceCents);
|
|
|
|
if (remainingCents <= 0) {
|
|
response["OK"] = true;
|
|
response["ALREADY_COMPLETE"] = true;
|
|
writeOutput(serializeJSON(response));
|
|
abort;
|
|
}
|
|
|
|
// Create Stripe Checkout Session
|
|
stripeSecretKey = application.stripeSecretKey ?: "";
|
|
|
|
httpService = new http();
|
|
httpService.setMethod("POST");
|
|
httpService.setUrl("https://api.stripe.com/v1/checkout/sessions");
|
|
httpService.setUsername(stripeSecretKey);
|
|
httpService.setPassword("");
|
|
|
|
httpService.addParam(type="formfield", name="mode", value="payment");
|
|
httpService.addParam(type="formfield", name="line_items[0][price_data][unit_amount]", value=remainingCents);
|
|
httpService.addParam(type="formfield", name="line_items[0][price_data][currency]", value="usd");
|
|
httpService.addParam(type="formfield", name="line_items[0][price_data][product_data][name]", value="Payfrit Activation");
|
|
httpService.addParam(type="formfield", name="line_items[0][quantity]", value="1");
|
|
httpService.addParam(type="formfield", name="success_url", value="https://biz.payfrit.com/works/activation?success=1");
|
|
httpService.addParam(type="formfield", name="cancel_url", value="https://biz.payfrit.com/works/activation?cancel=1");
|
|
httpService.addParam(type="formfield", name="metadata[user_id]", value=userID);
|
|
httpService.addParam(type="formfield", name="metadata[type]", value="activation_unlock");
|
|
|
|
result = httpService.send().getPrefix();
|
|
sessionData = deserializeJSON(result.fileContent);
|
|
|
|
if (structKeyExists(sessionData, "error")) {
|
|
response["ERROR"] = sessionData.error.message;
|
|
writeOutput(serializeJSON(response));
|
|
abort;
|
|
}
|
|
|
|
response["OK"] = true;
|
|
response["CHECKOUT_URL"] = sessionData.url;
|
|
response["AMOUNT_DUE_CENTS"] = remainingCents;
|
|
|
|
} catch (any e) {
|
|
response["ERROR"] = e.message;
|
|
}
|
|
|
|
writeOutput(serializeJSON(response));
|
|
</cfscript>
|