feat: add customer cart with expiry, shipping addresses with USPS validation, and multi-item PayPal checkout
This commit is contained in:
+1
-31
@@ -1,15 +1,9 @@
|
||||
export interface ItemImage {
|
||||
id: number;
|
||||
image_path: string;
|
||||
sort_order: number;
|
||||
}
|
||||
|
||||
export interface Item {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string | null;
|
||||
price_cents: number;
|
||||
images: ItemImage[];
|
||||
images: { id: number; image_path: string; sort_order: number }[];
|
||||
status: 'available' | 'reserved' | 'sold';
|
||||
}
|
||||
|
||||
@@ -57,27 +51,3 @@ export async function markAvailable(id: number): Promise<Item> {
|
||||
const res = await fetch(`/api/admin/items/${id}/mark-available`, { method: 'POST' });
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export async function createPaypalOrder(itemId: number): Promise<string> {
|
||||
const res = await fetch(`/api/checkout/paypal/${itemId}/create`, { method: 'POST' });
|
||||
const data = await res.json();
|
||||
if (!res.ok) throw new Error(data.error || 'Could not start checkout');
|
||||
return data.orderID;
|
||||
}
|
||||
|
||||
export async function capturePaypalOrder(itemId: number, orderID: string): Promise<void> {
|
||||
const res = await fetch(`/api/checkout/paypal/${itemId}/capture`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ orderID })
|
||||
});
|
||||
if (!res.ok) throw new Error('Payment captured but confirmation failed — contact the seller.');
|
||||
}
|
||||
|
||||
export async function demoPurchase(itemId: number): Promise<void> {
|
||||
const res = await fetch(`/api/checkout/demo/${itemId}/purchase`, { method: 'POST' });
|
||||
if (!res.ok) {
|
||||
const data = await res.json().catch(() => ({}));
|
||||
throw new Error(data.error || 'Demo purchase failed');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user