mirror of
https://github.com/profullstack/logicsrc.git
synced 2026-12-01 09:24:46 +00:00
feat(web): move Hire Us pricing to $400/hour metered billing (PRD 0002) (#102)
* feat(web): move Hire Us pricing to $400/hour metered billing (PRD 0002) Replaces the $250/week retainer with a $400/hour rate billed against actual hours, invoiced through CoinPay after the client approves them. A 10-hour minimum engagement replaces the week as the unit of commitment. The weekly price lived in 12 places, not the 3 the PRD listed: the front-page Hire Us section, the Top-Level Pages list, /hire-us metadata, /pricing (metadata, two FAQ answers, rate bullet), /about, llms.txt, skill.md, and the Hire Us form success message. Metered billing rather than a committed weekly block, because the old "recurring CoinPay invoice" copy documented a mechanic that never existed: /api/payments/create makes a single one-shot payment, not a subscription. - coinpay-checkout derives amount_usd from hours x 400 instead of a hardcoded 250, validates hours as quarter-hour increments at or above the minimum, and returns 422 before calling CoinPay on bad input. Payment metadata carries billing/hours/rate_usd_per_hour in place of interval. - project-request returns a rate, billing mode, and minimum; no amount exists until hours are approved. - CoinPay config block documents COINPAY_RATE_USD_PER_HOUR / COINPAY_BILLING / COINPAY_MINIMUM_HOURS instead of a weekly amount and interval. - New real /terms route replacing the SPA stub: what is billable, the approve-then-invoice flow, the minimum, cancellation on one week's notice, and an explicit clause that existing engagements keep their terms until both sides agree in writing. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(mcp): advance prd_next_id expectation to 0003 for PRD 0002 The standards test asserts prd_next_id against the live prd/ directory, so adding prd/0002-hourly-hire-us-rate.md moves the next free id to 0003. This assertion advances with every PRD added to the repo. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
da5f6f8381
commit
eaf0a6162b
16 changed files with 446 additions and 43 deletions
|
|
@ -4,8 +4,23 @@ import { choosePaymentRail, fetchMerchantEligibility, parseJson } from "@/lib/co
|
|||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
// POST /api/hire-us/coinpay-checkout — create a $250/week CoinPay checkout for
|
||||
// the Hire Us plan, choosing card/crypto/both based on merchant eligibility.
|
||||
// POST /api/hire-us/coinpay-checkout — create a CoinPay checkout for approved
|
||||
// Hire Us hours at $400/hour, choosing card/crypto/both based on merchant
|
||||
// eligibility. Billing is metered: the caller supplies the approved hours and the
|
||||
// amount is derived from them, never a fixed recurring figure.
|
||||
const RATE_USD_PER_HOUR = 400;
|
||||
const MINIMUM_HOURS = 10;
|
||||
|
||||
// Hours are quoted in quarter-hour increments; anything finer is a rounding
|
||||
// artifact rather than a real billing unit.
|
||||
function parseHours(value: unknown): number | null {
|
||||
const hours = typeof value === "number" ? value : Number(value);
|
||||
if (!Number.isFinite(hours) || hours < MINIMUM_HOURS) return null;
|
||||
const quarters = Math.round(hours * 4);
|
||||
if (Math.abs(hours * 4 - quarters) > 1e-9) return null;
|
||||
return quarters / 4;
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
const apiKey = process.env.COINPAY_API_KEY;
|
||||
const eligibilityApiKey = process.env.COINPAY_ELIGIBILITY_API_KEY || process.env.COINPAY_AGENT_API_KEY || apiKey;
|
||||
|
|
@ -22,6 +37,19 @@ export async function POST(request: NextRequest) {
|
|||
try {
|
||||
const body = (await request.json().catch(() => ({}))) as Record<string, unknown>;
|
||||
const buyerEmail = typeof body.email === "string" ? body.email.trim().slice(0, 160) : "";
|
||||
const hours = body.hours === undefined ? MINIMUM_HOURS : parseHours(body.hours);
|
||||
|
||||
if (hours === null) {
|
||||
return json(
|
||||
{
|
||||
success: false,
|
||||
error: `Approved hours must be a quarter-hour increment of at least ${MINIMUM_HOURS}`
|
||||
},
|
||||
422
|
||||
);
|
||||
}
|
||||
|
||||
const amountUsdDue = Math.round(hours * RATE_USD_PER_HOUR * 100) / 100;
|
||||
const eligibility = await fetchMerchantEligibility(apiUrl, eligibilityApiKey, eligibilityMerchantId);
|
||||
const paymentRail = choosePaymentRail(eligibility, blockchain);
|
||||
|
||||
|
|
@ -37,18 +65,20 @@ export async function POST(request: NextRequest) {
|
|||
},
|
||||
body: JSON.stringify({
|
||||
business_id: businessId,
|
||||
amount_usd: 250,
|
||||
amount_usd: amountUsdDue,
|
||||
payment_method: paymentRail.method,
|
||||
currency: paymentRail.currency,
|
||||
...(paymentRail.blockchain ? { blockchain: paymentRail.blockchain } : {}),
|
||||
description: "LogicSRC Hire Us - $250/week",
|
||||
description: `LogicSRC Hire Us - ${hours}h @ $${RATE_USD_PER_HOUR}/hour`,
|
||||
success_url: `${publicUrl}/hire-us?payment=success`,
|
||||
cancel_url: `${publicUrl}/hire-us?payment=cancelled`,
|
||||
redirect_url: `${publicUrl}/hire-us?payment=coinpay`,
|
||||
webhook_url: `${publicUrl}/api/webhooks/coinpay`,
|
||||
metadata: {
|
||||
product: "logicsrc-hire-us",
|
||||
interval: "week",
|
||||
billing: "metered_hours",
|
||||
hours,
|
||||
rate_usd_per_hour: RATE_USD_PER_HOUR,
|
||||
source: "logicsrc.com/hire-us",
|
||||
...(buyerEmail ? { buyer_email: buyerEmail } : {})
|
||||
}
|
||||
|
|
@ -70,13 +100,15 @@ export async function POST(request: NextRequest) {
|
|||
}
|
||||
|
||||
const payment = (payload.payment as Record<string, unknown>) || {};
|
||||
const amountUsd = Number(payment.amount_usd ?? payment.amount ?? 250);
|
||||
const amountUsd = Number(payment.amount_usd ?? payment.amount ?? amountUsdDue);
|
||||
return json(
|
||||
{
|
||||
success: true,
|
||||
payment: {
|
||||
id: payment.id,
|
||||
amount_usd: Number.isFinite(amountUsd) ? amountUsd : 250,
|
||||
amount_usd: Number.isFinite(amountUsd) ? amountUsd : amountUsdDue,
|
||||
hours,
|
||||
rate_usd_per_hour: RATE_USD_PER_HOUR,
|
||||
payment_method: payment.stripe_checkout_url ? "card" : paymentRail.method,
|
||||
currency: payment.currency ?? payment.blockchain ?? paymentRail.blockchain ?? paymentRail.currency,
|
||||
crypto_amount: payment.amount_crypto ?? payment.crypto_amount ?? null,
|
||||
|
|
|
|||
|
|
@ -3,8 +3,12 @@ import { json } from "@/lib/http";
|
|||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
// POST /api/hire-us/project-request — accept a Hire Us project request before a
|
||||
// recurring CoinPay invoice is created (invoice is created after acceptance).
|
||||
// POST /api/hire-us/project-request — accept a Hire Us project request before any
|
||||
// CoinPay invoice is created. Hire Us bills metered hours at $400/hour, so there is
|
||||
// no amount until we accept the project and hours are approved.
|
||||
const RATE_USD_PER_HOUR = 400;
|
||||
const MINIMUM_HOURS = 10;
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const body = (await request.json().catch(() => ({}))) as Record<string, unknown>;
|
||||
|
|
@ -20,7 +24,7 @@ export async function POST(request: NextRequest) {
|
|||
id: requestId,
|
||||
contact,
|
||||
project_length: project.length,
|
||||
plan: "250/week",
|
||||
plan: "400/hour",
|
||||
invoice: "pending_acceptance"
|
||||
});
|
||||
|
||||
|
|
@ -30,8 +34,9 @@ export async function POST(request: NextRequest) {
|
|||
request: {
|
||||
id: requestId,
|
||||
status: "pending_acceptance",
|
||||
amount_usd: 250,
|
||||
interval: "week",
|
||||
rate_usd_per_hour: RATE_USD_PER_HOUR,
|
||||
billing: "metered_hours",
|
||||
minimum_hours: MINIMUM_HOURS,
|
||||
invoice: "created_after_acceptance"
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue