Rebrand to Waseel, swap Stripe for Areeba, add phone-ready auth and DB seed
- Rename app: Waseel (name, slug, scheme waseel://, com.waseel.app ids, splash) - Payments: replace Stripe with Areeba hosted checkout (create/verify API routes, lib/areeba.ts, WebBrowser-based payment flow) - Maps: migrate address autocomplete to Places API (New), drop legacy library - Web support: map stub for web (native maps are iOS/Android only) - Auth: keep email + Google OAuth; fix OAuth redirect for Expo Go - Add scripts/seed-db.mjs (schema + Lebanese driver seed) - Pin Expo SDK 51 compatible package versions
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import { createCheckoutSession } from "@/lib/areeba";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
const body = await req.json();
|
||||
const { name, email, amount, returnUrl } = body;
|
||||
|
||||
if (!name || !email || !amount)
|
||||
return new Response(
|
||||
JSON.stringify({ error: "Missing required payment information." }),
|
||||
{ status: 400 },
|
||||
);
|
||||
|
||||
try {
|
||||
const orderId = `waseel-${Date.now()}`;
|
||||
|
||||
const session = await createCheckoutSession({
|
||||
orderId,
|
||||
amount: parseFloat(amount),
|
||||
currency: "USD",
|
||||
description: `Waseel ride payment for ${name}`,
|
||||
returnUrl: returnUrl || "waseel://book-ride",
|
||||
});
|
||||
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
orderId,
|
||||
checkoutUrl: session.checkoutUrl,
|
||||
successIndicator: session.successIndicator,
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
console.log("[AREEBA_PAYMENT_CREATE]: ", err);
|
||||
|
||||
return new Response(JSON.stringify({ error: "Internal Server Error" }), {
|
||||
status: 500,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { retrieveOrder } from "@/lib/areeba";
|
||||
|
||||
export async function POST(req: Request) {
|
||||
const body = await req.json();
|
||||
const { orderId, resultIndicator, successIndicator } = body;
|
||||
|
||||
if (!orderId)
|
||||
return new Response(JSON.stringify({ error: "Missing order id." }), {
|
||||
status: 400,
|
||||
});
|
||||
|
||||
try {
|
||||
const order = await retrieveOrder(orderId);
|
||||
|
||||
// The gateway appends resultIndicator to the return URL after payment;
|
||||
// it must match the successIndicator issued when the session was created.
|
||||
const indicatorMatches =
|
||||
!successIndicator || resultIndicator === successIndicator;
|
||||
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
success: order.paid && indicatorMatches,
|
||||
status: order.status,
|
||||
amount: order.amount,
|
||||
currency: order.currency,
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
console.log("[AREEBA_PAYMENT_VERIFY]: ", err);
|
||||
|
||||
return new Response(JSON.stringify({ error: "Internal Server Error" }), {
|
||||
status: 500,
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user