acp-handler
Version:
Vercel handler for Agentic Commerce Protocol (ACP) - Build checkout APIs that AI agents like ChatGPT can use to complete purchases
114 lines (112 loc) • 2.38 kB
TypeScript
import { CheckoutSession, KV, Message } from "../index-COuZpx6k.js";
//#region src/test/index.d.ts
/**
* In-memory KV store for testing
*/
declare function createMemoryStore(): KV;
/**
* Mock products handler that returns configurable pricing
*/
declare function createMockProducts(config?: {
pricePerItem?: number;
ready?: boolean;
messages?: CheckoutSession["messages"];
}): {
price: (input: {
items: Array<{
id: string;
quantity: number;
}>;
customer?: any;
fulfillment?: any;
}) => Promise<{
items: {
id: string;
title: string;
quantity: number;
unit_price: {
amount: number;
currency: string;
};
}[];
totals: {
subtotal: {
amount: number;
currency: string;
};
grand_total: {
amount: number;
currency: string;
};
};
fulfillment: {
options: {
id: string;
label: string;
price: {
amount: number;
currency: string;
};
}[];
selected_id: string;
};
messages: Message[];
ready: boolean;
}>;
};
/**
* Mock payments handler with configurable behavior
*/
declare function createMockPayments(config?: {
shouldAuthorizeSucceed?: boolean;
shouldCaptureSucceed?: boolean;
authorizeReason?: string;
captureReason?: string;
}): {
authorize: () => Promise<{
ok: false;
reason: string;
intent_id?: undefined;
} | {
ok: true;
intent_id: string;
reason?: undefined;
}>;
capture: (_intentId: string) => Promise<{
ok: false;
reason: string;
} | {
ok: true;
reason?: undefined;
}>;
_calls: {
authorize: number;
capture: number;
};
};
/**
* Mock webhooks handler that tracks calls
*/
declare function createMockWebhooks(): {
orderUpdated: (evt: {
checkout_session_id: string;
status: string;
order?: any;
}) => Promise<void>;
_calls: {
checkout_session_id: string;
status: string;
order?: any;
}[];
};
/**
* Helper to create a mock Request object
*/
declare function createRequest(url: string, options?: {
method?: string;
body?: any;
headers?: Record<string, string>;
}): Request;
//#endregion
export { createMemoryStore, createMockPayments, createMockProducts, createMockWebhooks, createRequest };
//# sourceMappingURL=index.d.ts.map