feat: beta promo, zero fee, scout bot, and LLM SEO
Some checks failed
Deploy to 110 WOOO Server / deploy (push) Failing after 7s
Some checks failed
Deploy to 110 WOOO Server / deploy (push) Failing after 7s
This commit is contained in:
@@ -3,9 +3,9 @@ import { ScoutDraftRequestSchema, ScoutDraftResponseSchema, TaskStatus } from "@
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import Stripe from "stripe";
|
||||
|
||||
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", {
|
||||
const stripe = process.env.STRIPE_SECRET_KEY ? new Stripe(process.env.STRIPE_SECRET_KEY, {
|
||||
apiVersion: "2026-05-27.dahlia",
|
||||
});
|
||||
}) : null;
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
const authHeader = request.headers.get("Authorization");
|
||||
@@ -51,7 +51,28 @@ export async function POST(request: NextRequest) {
|
||||
});
|
||||
|
||||
// Create Stripe Checkout Session
|
||||
// We do a manual capture session so the funds are only captured when Judge passes
|
||||
// 試營運期間:如果賞金小於等於 20 美元 ($20.00 = 2000 cents),則由官方贊助(免刷卡直接 OPEN)
|
||||
if (parsed.reward_amount <= 2000) {
|
||||
await prisma.task.update({
|
||||
where: { id: task.id },
|
||||
data: {
|
||||
status: TaskStatus.OPEN,
|
||||
stripe_checkout_session_id: "promo_free_bounty",
|
||||
stripe_payment_intent_id: "promo_free_bounty_intent" // Skip auth hold
|
||||
}
|
||||
});
|
||||
|
||||
const responseData = {
|
||||
task_id: task.id,
|
||||
checkout_url: `${process.env.NEXT_PUBLIC_SITE_URL || 'https://agent.wooo.work'}/tasks/${task.id}`,
|
||||
status: TaskStatus.OPEN,
|
||||
};
|
||||
|
||||
ScoutDraftResponseSchema.parse(responseData);
|
||||
return NextResponse.json(responseData);
|
||||
}
|
||||
|
||||
if (!stripe) throw new Error("Stripe is not initialized");
|
||||
const session = await stripe.checkout.sessions.create({
|
||||
payment_method_types: ["card"],
|
||||
mode: "payment",
|
||||
@@ -76,8 +97,8 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
},
|
||||
// You should set these to actual frontend URLs
|
||||
success_url: `${process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3000'}/tasks/${task.id}?success=true`,
|
||||
cancel_url: `${process.env.NEXT_PUBLIC_SITE_URL || 'http://localhost:3000'}/tasks/create`,
|
||||
success_url: `${process.env.NEXT_PUBLIC_SITE_URL || 'https://agent.wooo.work'}/tasks/${task.id}?success=true`,
|
||||
cancel_url: `${process.env.NEXT_PUBLIC_SITE_URL || 'https://agent.wooo.work'}/tasks/create`,
|
||||
});
|
||||
|
||||
// Save session ID so webhook can find it
|
||||
|
||||
@@ -3,9 +3,9 @@ import { prisma } from "@/lib/prisma";
|
||||
import Stripe from "stripe";
|
||||
import { TaskStatus } from "@agent-bounty/contracts";
|
||||
|
||||
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY || "", {
|
||||
const stripe = process.env.STRIPE_SECRET_KEY ? new Stripe(process.env.STRIPE_SECRET_KEY, {
|
||||
apiVersion: "2026-05-27.dahlia",
|
||||
});
|
||||
}) : null;
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
const payload = await request.text();
|
||||
@@ -18,6 +18,9 @@ export async function POST(request: NextRequest) {
|
||||
let event: Stripe.Event;
|
||||
|
||||
try {
|
||||
if (!stripe) {
|
||||
throw new Error("Stripe SDK is not initialized");
|
||||
}
|
||||
event = stripe.webhooks.constructEvent(
|
||||
payload,
|
||||
signature,
|
||||
|
||||
Reference in New Issue
Block a user