import { Client, type Delivery, type Order, type Product } from "@spxrk/sdk"; /** Load input fields and bounds for the selected Telegram SKU in the sandbox. */ export async function inspectTelegramSku(client: Client, sku: string): Promise { const product = await client.product(sku); if (product.attributes.group !== "telegram") throw new Error("Select a Telegram product"); return product; } /** Supply an explicitly chosen sandbox SKU, quantity, recipient, and a durable cart ID. */ export async function submitTestOrder(key: string, product: Product, quantity: number, username: string, checkoutId: string): Promise { if (!key.startsWith("spk_test_")) throw new Error("Use a sandbox key"); if (product.attributes.group !== "telegram") throw new Error("Select a Telegram product"); const client = new Client(key); const delivery: Delivery = { telegram_username: username }; if (product.attributes.validate) { const check = await client.validate(product.sku, delivery); if (check.valid !== true) throw new Error("Recipient verification requires review"); } return client.createOrder({ items: [{ sku: product.sku, quantity }], delivery }, checkoutId); }