統合 · AIビルダー

ストアをvibe-codeしましたか?プロンプト1つでPeptide-Payを導入しましょう。

プロンプトをコピーしてLovable、Bolt、v0、Cursor、Replit、Claudeに貼り付けるだけ。AIがスタックを自動判別し、サーバーサイドのチェックアウト、ウェブフック、完了ページを追加してテストを実行します。テストに実際の支払いは不要です。

プロンプトを読む
対応ツールLovableBoltv0CursorReplitClaude

導入の3ステップ

  1. 1

    プロンプトをコピー

    ワンクリックで完了。AIツールは英語の仕様を最も正確に理解するため、プロンプトは意図的に英語にしています。AIからの回答は日本語のままで大丈夫です。

  2. 2

    AIツールに貼り付け

    Next.js、Vite + Supabase、Express、PHPなどのスタックを検出し、チェックアウト、署名検証付きウェブフック、完了ページを生成します。APIキーはサーバー側に安全に保持されます。

  3. 3

    テストして公開

    AIがテストセッションを作成し、支払いをせずに不正なウェブフックが拒否されることを確認します。その後、キーを追加し、ダッシュボードにウェブフックURLを貼り付けて「Send test webhook」をクリックするだけです。

AIが構築するもの

  • サーバーを呼び出し、カタログから合計金額を再計算して /api/v1/checkout/init を実行する購入ボタン。
  • Peptide-Payがホストするチェックアウトへのリダイレクト。サイト内にカード情報の入力フォームは不要です。
  • raw bodyの x-peptidepay-signature HMACを検証するウェブフックルート。
  • GET /api/v1/sessions/{id} による注文確認。金額と通貨が一致する場合のみ支払い済みと判定。
  • 確認を待機する完了ページ。ページ単独で注文を支払い済みとしてマークすることはありません。
  • テストと一般的なエラー処理。AIが「完了」と言う前に問題を修正します。

対応スタック

  • Next.js (App Router および Pages Router)
  • Vite / React + Supabase Edge Functions (Lovable, Bolt)
  • Express, Fastify, Hono, Remix, SvelteKit, Nuxt, Astro
  • PHP, Laravel, Django, Rails

WordPressをお使いですか?コードは不要です: WooCommerceプラグイン

プロンプト

コピーされる内容(プレーンテキスト)。ファイルとしてもダウンロード可能です: ai-prompt.txt

# TASK: add Peptide-Pay checkout to this project, end to end

You are a senior full-stack engineer working inside my project. Add Peptide-Pay (a hosted checkout for research-peptide stores, https://peptide-pay.com) so that a "Buy" / "Checkout" button takes the buyer to the Peptide-Pay payment page, and my order flips to "paid" automatically once the payment is confirmed.

Follow this spec exactly. Every endpoint, field, header and error below comes from the live API. Do not invent endpoints, fields or SDKs. Talk to me in the language I write to you in, but keep code, file names and env var names in English.

## 0. How it works (read once)

1. My server creates an order (status "pending") and calls POST https://peptide-pay.com/api/v1/checkout/init.
2. Peptide-Pay answers { id: "cs_…", url: "https://peptide-pay.com/session/cs_…", status: "pending", … }.
3. My site sends the buyer to that url (full-page redirect). The buyer pays there. My site never shows a card form.
4. When the payment is confirmed, Peptide-Pay:
   a. sends the buyer back to my success_url (after a 4-second countdown on its page), and
   b. POSTs an "order.paid" webhook to my webhook_url.
5. My server never trusts the redirect or the webhook body alone: it calls GET https://peptide-pay.com/api/v1/sessions/{id} and marks the order paid only if status === "paid" AND amount AND currency match my order.

Funds go straight to the merchant's own 0x wallet (most often on Ethereum as ETH or USDC, sometimes on Polygon). Peptide-Pay never holds a balance for the merchant.

## 1. Detect my stack first, then say it in ONE line

Look at package.json, lockfiles, folders (app/, pages/, src/, supabase/functions/, server/, api/, netlify/functions/), composer.json, requirements.txt. Then print one line, for example:
"Detected: Next.js 15 App Router + Prisma/Postgres. I will create: lib/peptidepay.ts, app/api/peptidepay/checkout/route.ts, app/api/peptidepay/webhook/route.ts, app/api/peptidepay/order-status/route.ts, app/checkout/success/page.tsx."

Pick the matching recipe:

- Next.js App Router → route handlers in app/api/peptidepay/{checkout,webhook,order-status}/route.ts (under src/ if the project has a src/ folder; import with the project's alias, e.g. "@/lib/peptidepay"). If next.config does NOT enable `cacheComponents`, add `export const runtime = "nodejs"` and `export const dynamic = "force-dynamic"` to each; if it does (default in new Next.js 16 apps), add NO route segment config: it breaks the build, and handlers that read the request are already dynamic. Read the webhook body with `await req.text()`. In pages, `searchParams` is a Promise (Next.js 15+): read it, or `useSearchParams()`, inside a `<Suspense>` boundary or `next build` fails.
- Next.js Pages Router → pages/api/peptidepay/*.ts. In the webhook file: `export const config = { api: { bodyParser: false } }` and read the raw body from the stream.
- Vite / React SPA with Supabase (typical Lovable, Bolt, v0 export) → three Supabase Edge Functions: peptidepay-checkout, peptidepay-webhook, peptidepay-order-status (Deno, `Deno.serve`). Put the helper in supabase/functions/_shared/peptidepay.ts. The browser calls them with `supabase.functions.invoke(...)`, so the checkout and order-status functions must answer the CORS preflight (OPTIONS) with Access-Control-Allow-Origin, Access-Control-Allow-Headers: authorization, x-client-info, apikey, content-type. The webhook function MUST run without JWT verification (Peptide-Pay sends no Supabase token): add `[functions.peptidepay-webhook]` + `verify_jwt = false` to supabase/config.toml, or deploy with `supabase functions deploy peptidepay-webhook --no-verify-jwt`. Set secrets with `supabase secrets set PEPTIDEPAY_API_KEY=… PEPTIDEPAY_WEBHOOK_SECRET=…` (in Lovable: Supabase → Edge Function secrets). Store orders in a Postgres table and write it with the service role key inside the functions only.
- Vite / React SPA with NO backend at all → stop and tell me: a payment needs a server. Propose the smallest option the host supports (Supabase Edge Functions, Netlify Functions, Vercel Functions, Cloudflare Workers) and use it. Never call Peptide-Pay from the browser with a key.
- Express / Fastify / Hono / Remix / SvelteKit / Nuxt / Astro SSR → the same three server routes in the framework's idiom. Express: mount `express.raw({ type: "application/json" })` on the webhook route BEFORE any `express.json()`.
- PHP / Laravel / Django / Rails → same three routes. Raw body: Laravel `$request->getContent()`, Django `request.body`, Rails `request.raw_post`, plain PHP `file_get_contents("php://input")`. HMAC: `hash_hmac("sha256", "$t.$raw", $secret)` + `hash_equals`, Python `hmac.new(...).hexdigest()` + `hmac.compare_digest`.
- WordPress / WooCommerce → STOP. Do not write code. Tell me to install the plugin: https://peptide-pay.com/integrate?stack=woocommerce

If the project already has another payment provider, keep it in place and add Peptide-Pay next to it (feature flag or second button). Do not delete working code.

## 2. Environment variables (server only)

PEPTIDEPAY_API_BASE=https://peptide-pay.com
PEPTIDEPAY_API_KEY=sk_live_...          # account mode (recommended once my account is active)
PEPTIDEPAY_WEBHOOK_SECRET=whsec_...     # account mode: verifies webhook signatures
PEPTIDEPAY_WALLET=0x...                 # wallet mode only, when there is no API key yet
APP_URL=https://my-domain.com           # public URL of THIS site, used to build return and webhook URLs (http://localhost:3000 in dev)

Rules:
- Never prefix them with NEXT_PUBLIC_, VITE_, PUBLIC_, REACT_APP_ or EXPO_PUBLIC_. They must never reach the browser bundle.
- Add them to .env.example (empty values) and to .env.local / the host's secret store. Never commit real values. If .gitignore ignores `.env*`, add the line `!.env.example` so the example is committed.

Two modes. The code supports both and picks automatically:
- Account mode: header `Authorization: Bearer <PEPTIDEPAY_API_KEY>`, no `wallet` in the body. Keys live at https://peptide-pay.com/app/api-keys after signing up at https://peptide-pay.com/signup. Webhooks are signed with PEPTIDEPAY_WEBHOOK_SECRET. A new account is reviewed before it can charge: until then checkout/init answers 403 "merchant_pending".
- Wallet mode: no key; send `"wallet": "0x…"` (0x + 40 hex, a personal EVM wallet that accepts Ethereum and Polygon, not an exchange deposit address) in the body. Works immediately, no account. Webhooks arrive UNSIGNED and carry `"unauthenticated_init": true`, which is why step 5 below (confirm with GET /sessions) is mandatory.

If I have neither yet and we are only developing: you may set PEPTIDEPAY_WALLET=0x7521d59b02e26e101abc98354e5c088bf449a157. That is Peptide-Pay's PUBLIC DEMO wallet: it lets you create test sessions, the API will return a warning saying so, and any real money sent to it is lost for me. Tell me loudly to replace it before going live, and never pay a session created with it.

## 3. The API (exact)

POST https://peptide-pay.com/api/v1/checkout/init
Headers: Content-Type: application/json
         Authorization: Bearer sk_live_…      (account mode only)
         Idempotency-Key: order-<my order id>  (recommended: a retry with the same key AND the same body returns the same session)
Body:
{
  "amount_cents": 4999,                 // REQUIRED. Integer, smallest currency unit. Min 100, max 100000000. 49.99 → 4999.
  "currency": "EUR",                    // REQUIRED. One of EUR, USD, GBP, CHF, CAD, AUD, TRY.
  "wallet": "0x…",                      // wallet mode only. Omit in account mode.
  "success_url": "https://my-domain.com/checkout/success?order=ORDER_ID",  // http(s). Peptide-Pay appends NOTHING, so put my order id in it.
  "cancel_url": "https://my-domain.com/cart",                              // http(s)
  "webhook_url": "https://my-domain.com/api/peptidepay/webhook",           // http(s), public. Overrides the dashboard setting for this session.
  "metadata": { "order_id": "ORDER_ID" },  // string values. Echoed back in the webhook.
  "customer_email": "buyer@example.com",   // optional, valid e-mail or omit
  "product_name": "Order #1042",           // optional, shown on the payment page
  "locale": "en"                           // optional: en fr de it es nl pt ru pl tr zh ja ko
}
200 response:
{ "id": "cs_…", "url": "https://peptide-pay.com/session/cs_…", "status": "pending", "amount": 4999, "currency": "EUR",
  "provider": "gateway", "expires_at": "<ISO date, 24 h later>", "tracking_number": "…", "warnings": ["…"] }
"warnings" is optional and non-fatal (e.g. "No webhook_url set", demo wallet). Log it on the server.

GET https://peptide-pay.com/api/v1/sessions/{id}
Headers: Authorization: Bearer sk_live_… (account mode; optional in wallet mode)
200 response: { "id", "status": "pending" | "paid" | "expired" | "failed", "amount", "currency", "paid_at", "paid_provider", "txid", "coin", "expires_at" }

Webhook that Peptide-Pay POSTs to webhook_url:
Headers: Content-Type: application/json
         x-peptidepay-signature: t=<unix seconds>,v1=<hex HMAC-SHA256>   (same value also in x-webhook-signature; absent in wallet mode)
Body: { "event": "order.paid", "session_id": "cs_…", "order_id": "ORDER_ID" | null, "address_in": "…", "status": "paid",
        "amount": 4999, "currency": "EUR", "txid": "0x…" | null, "paid_at": "<ISO>", "attempt": 1,
        "customer_email": "…" | null, "metadata": { … } | null, "unauthenticated_init": true (wallet mode only) }
Signature = hex(HMAC_SHA256(key = PEPTIDEPAY_WEBHOOK_SECRET, message = t + "." + rawBody)). Reject if |now - t| > 300 s.
The dashboard "Send test webhook" button and the test simulator send "event": "webhook.test" (status "test"): answer 200 and change nothing.
Delivery rules: 5-second timeout, redirects are NOT followed (a 301/302/307/308 counts as a failure), private/localhost hosts are refused. Failed deliveries are retried up to 6 attempts in total (after 5 min, 15 min, 1 h, 4 h, 12 h).

## 4. Files to create

### 4.1 Server helper (copy as is; TypeScript, works on Node 20+, Deno, Edge and Bun)
Put it at lib/peptidepay.ts (src/lib/peptidepay.ts if the project uses src/) or supabase/functions/_shared/peptidepay.ts (Supabase). Server-only.

```ts
/* eslint-disable @typescript-eslint/no-explicit-any */
// Peptide-Pay server helper. NEVER import this file from client/browser code.
const env = (k: string): string | undefined =>
  (globalThis as any).Deno?.env?.get(k) ?? (globalThis as any).process?.env?.[k];

export const PP_API_BASE = (env("PEPTIDEPAY_API_BASE") || "https://peptide-pay.com").replace(/\/+$/, "");

export class PeptidePayError extends Error {
  status: number; code: string;
  constructor(status: number, code: string, message: string) { super(message); this.status = status; this.code = code; }
}

function authHeader(): Record<string, string> {
  const key = env("PEPTIDEPAY_API_KEY");
  return key ? { Authorization: `Bearer ${key.trim()}` } : {};
}

export type PPSession = {
  id: string; url?: string; status: "pending" | "paid" | "expired" | "failed";
  amount: number; currency: string; expires_at: string;
  txid?: string | null; paid_at?: string | null; warnings?: string[];
};

export async function createPeptidePaySession(o: {
  orderId: string; amountCents: number; currency: string;
  successUrl: string; cancelUrl: string; webhookUrl?: string;
  customerEmail?: string; productName?: string; locale?: string;
}): Promise<PPSession> {
  const key = env("PEPTIDEPAY_API_KEY");
  const wallet = env("PEPTIDEPAY_WALLET");
  if (!key && !wallet) throw new PeptidePayError(500, "config", "Set PEPTIDEPAY_API_KEY or PEPTIDEPAY_WALLET");
  if (!Number.isInteger(o.amountCents) || o.amountCents < 100) throw new PeptidePayError(400, "amount", "amountCents must be an integer >= 100");
  const body: Record<string, unknown> = {
    amount_cents: o.amountCents,
    currency: o.currency.toUpperCase(),
    success_url: o.successUrl,
    cancel_url: o.cancelUrl,
    metadata: { order_id: String(o.orderId) },
  };
  if (!key) body.wallet = wallet!.trim();
  if (o.webhookUrl) body.webhook_url = o.webhookUrl;
  if (o.customerEmail) body.customer_email = o.customerEmail;
  if (o.productName) body.product_name = o.productName;
  if (o.locale) body.locale = o.locale;
  const res = await fetch(`${PP_API_BASE}/api/v1/checkout/init`, {
    method: "POST",
    headers: { "Content-Type": "application/json", "Idempotency-Key": `order-${o.orderId}`, ...authHeader() },
    body: JSON.stringify(body),
  });
  const data: any = await res.json().catch(() => ({}));
  if (!res.ok) throw new PeptidePayError(res.status, String(data.error ?? "http_" + res.status), String(data.message ?? data.error ?? "Peptide-Pay error"));
  if (Array.isArray(data.warnings) && data.warnings.length) console.warn("[peptide-pay] warnings:", data.warnings);
  return data as PPSession;
}

export async function getPeptidePaySession(id: string): Promise<PPSession> {
  const res = await fetch(`${PP_API_BASE}/api/v1/sessions/${encodeURIComponent(id)}`, {
    headers: { ...authHeader() },
  });
  const data: any = await res.json().catch(() => ({}));
  if (!res.ok) throw new PeptidePayError(res.status, String(data.error ?? "http_" + res.status), String(data.message ?? data.error ?? "Peptide-Pay error"));
  return data as PPSession;
}

/** True only if the session is paid for exactly this amount and currency. */
export function isPaidFor(s: PPSession, amountCents: number, currency: string): boolean {
  return s.status === "paid" && s.amount === amountCents && s.currency === currency.toUpperCase();
}

/** Verifies `x-peptidepay-signature: t=<ts>,v1=<hex>` against the RAW request body. */
export async function verifyPeptidePaySignature(rawBody: string, header: string | null, secret: string, toleranceSec = 300): Promise<boolean> {
  if (!header) return false;
  const parts = Object.fromEntries(header.split(",").map((p) => p.trim().split("=", 2) as [string, string]));
  const t = Number(parts.t);
  const v1 = (parts.v1 || "").toLowerCase();
  if (!Number.isFinite(t) || !/^[0-9a-f]{64}$/.test(v1)) return false;
  if (Math.abs(Math.floor(Date.now() / 1000) - t) > toleranceSec) return false;
  const enc = new TextEncoder();
  const key = await crypto.subtle.importKey("raw", enc.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
  const mac = new Uint8Array(await crypto.subtle.sign("HMAC", key, enc.encode(`${t}.${rawBody}`)));
  const expected = Array.from(mac, (b) => b.toString(16).padStart(2, "0")).join("");
  let diff = 0;
  for (let i = 0; i < 64; i++) diff |= expected.charCodeAt(i) ^ v1.charCodeAt(i);
  return diff === 0;
}

/** TESTS ONLY: builds a signature header the way Peptide-Pay does, to test the webhook locally. */
export async function signPeptidePayTestPayload(rawBody: string, secret: string, t = Math.floor(Date.now() / 1000)): Promise<string> {
  const enc = new TextEncoder();
  const key = await crypto.subtle.importKey("raw", enc.encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
  const mac = new Uint8Array(await crypto.subtle.sign("HMAC", key, enc.encode(`${t}.${rawBody}`)));
  return `t=${t},v1=${Array.from(mac, (b) => b.toString(16).padStart(2, "0")).join("")}`;
}
```

### 4.2 Orders storage
Use the project's existing database (Supabase table, Prisma model, Drizzle, SQL…). The order needs at least:
id, amount_cents (integer), currency, status ('pending' | 'paid' | 'expired' | 'failed'), peptidepay_session_id, paid_at, txid, created_at.
Write one shared function `syncOrderWithPeptidePay(order)`:
- if order.status is 'paid' or there is no peptidepay_session_id → return the order unchanged;
- s = await getPeptidePaySession(order.peptidepay_session_id);
- if isPaidFor(s, order.amount_cents, order.currency) → UPDATE … SET status='paid', paid_at, txid WHERE id = … AND status <> 'paid' (idempotent), then run the paid side effects (e-mail, stock) only if that UPDATE changed a row;
- if s.status is 'expired' or 'failed' → store it;
- if s.status is 'paid' but the amount or currency differs → do NOT mark paid; log it loudly for a human.
If the project has no database at all, tell me, and use the simplest persistence the host supports (a local JSON file is acceptable ONLY for local development).

### 4.3 Checkout endpoint (POST, server)
- Input from the browser: cart lines { productId, quantity } only. NEVER accept a price or total from the browser: recompute the total from the server-side catalog / database.
- Create the order (status 'pending') first, then call createPeptidePaySession with:
  successUrl = `${APP_URL}/checkout/success?order=${order.id}`
  cancelUrl  = `${APP_URL}/cart` if that page exists, otherwise the product page or home page (never a URL that 404s)
  webhookUrl = `${APP_URL}/api/peptidepay/webhook` (Supabase: `https://<project-ref>.supabase.co/functions/v1/peptidepay-webhook`), but ONLY when APP_URL starts with https:// and its host is not localhost / 127.0.0.1; otherwise omit it.
  productName = a short label such as `Order #${order.id}`; locale = the store's language if you know it, else omit.
- Save session.id on the order, return { url: session.url } as JSON.
- On PeptidePayError: log status + code + message on the server, return a short readable error to the browser: 502 if Peptide-Pay answered 5xx, 503 "please retry" if it answered 429, 500 for 401/403 (a configuration problem on my side, log it loudly), 400 otherwise. Never send the API key or the raw upstream response to the browser.

### 4.4 Webhook endpoint (POST, server, public)
1. Read the RAW body as text BEFORE any JSON parsing.
2. If PEPTIDEPAY_WEBHOOK_SECRET is set: verify with verifyPeptidePaySignature(raw, headers["x-peptidepay-signature"] ?? headers["x-webhook-signature"], secret). Invalid or missing → 401, do nothing else.
   If it is not set (wallet mode): continue, but treat the body as a hint only.
3. Parse JSON. If event !== "order.paid" (for example "webhook.test") → 200 { ok: true }.
4. Find the order by session_id (peptidepay_session_id), else by order_id. Unknown → 200 { ok: true, ignored: "unknown order" }.
5. Call syncOrderWithPeptidePay(order). This GET /sessions confirmation is what makes the order paid, never the webhook body itself.
   If Peptide-Pay cannot be reached (network error, 429, 5xx) → answer 500 so the webhook is retried later.
6. Answer 200 within 5 seconds. Send e-mails / heavy work after answering or in a queue.
The route must not redirect (no trailing-slash rewrite, no http→https or www/apex redirect in front of it) and must not require login, cookies or CSRF tokens.

### 4.5 Order-status endpoint (GET, server) + success page
- GET /api/peptidepay/order-status?order=<id> → loads the order; if it is 'pending', calls syncOrderWithPeptidePay(order) (wrap in try/catch: on 429 or network error just return the stored status); returns { status } only (no personal data).
  (Supabase: `supabase.functions.invoke` sends a POST, so let peptidepay-order-status also accept { order } in a JSON body.)
- /checkout/success page: reads ?order=, polls that endpoint every 5 seconds for up to 3 minutes. 'paid' → "Payment confirmed, thank you" + order number. 'pending' → "Waiting for payment confirmation…" with a spinner. After 3 minutes still pending → "Your payment is being confirmed. You will receive an e-mail; you can close this page." 'expired' / 'failed' → link back to the cart. In Next.js use `<Link>` from next/link for internal links, not `<a>`, or `next lint` fails.
- This page is a fallback for the webhook. It must never mark an order paid by itself: only syncOrderWithPeptidePay can.

### 4.6 Buy button (browser)
- On click: disable the button, POST { items } to the checkout endpoint, then `window.location.assign(url)` with the url you got back. Full-page redirect: no iframe, no popup window.
- On error: re-enable the button and show the message under it.
- Next to the button you may add a small line: "Secure checkout by Peptide-Pay".

## 5. Tests you MUST run before saying "done" (no payment needed)

1. Smoke test from a terminal (wallet mode shown; in account mode replace "wallet" with -H "Authorization: Bearer $PEPTIDEPAY_API_KEY"):
   curl -s -X POST https://peptide-pay.com/api/v1/checkout/init -H "Content-Type: application/json" -d '{"wallet":"<PEPTIDEPAY_WALLET>","amount_cents":100,"currency":"USD","success_url":"https://example.com/ok","cancel_url":"https://example.com/cancel"}'
   Expect HTTP 200 with "id": "cs_…" and "status": "pending".
   (On Windows run it from Git Bash or WSL, or use curl.exe with the JSON in a file: -d @body.json.)
2. Run the app (dev server on the port used in APP_URL, e.g. `next dev -p 3100`). Click Buy (or POST to your checkout endpoint with curl and open the returned url). You must land on https://peptide-pay.com/session/cs_… : the page answers 200 and shows the right amount and currency. Do NOT pay. Check the order row: status 'pending', peptidepay_session_id = that cs_ id.
3. curl -s https://peptide-pay.com/api/v1/sessions/<cs_id> → "status":"pending". Open /checkout/success?order=<id> → it shows the waiting state, not "paid".
4. Webhook security, locally (skip the signed part in wallet mode if no secret is set; set a dummy PEPTIDEPAY_WEBHOOK_SECRET=whsec_test_local in .env.local just for this test, restart the dev server, run the checks, then REMOVE it and restart again: in wallet mode real webhooks are unsigned and would be rejected):
   - Build a body {"event":"order.paid","session_id":"<cs_id>","order_id":"<id>","status":"paid","amount":<cents>,"currency":"<the order's currency>"}, sign it with signPeptidePayTestPayload (t = now; simplest: a small .mjs script that copies its 5 lines, since plain Node cannot import a .ts file) and POST it with the header x-peptidepay-signature to the local webhook → expect 200, and the order must STAY 'pending' because GET /sessions still says pending. This proves a forged "paid" webhook cannot mark an order paid.
   - Same body with one character changed after signing → 401.
   - Same body signed with t = now - 600 → 401.
   - {"event":"webhook.test"} correctly signed → 200, nothing changes.
5. Grep the client bundle / source for "sk_live_", "whsec_" and "PEPTIDEPAY_API_KEY": they must appear only in server files and .env files.
6. Run the project's type check, lint and build (e.g. `npx tsc --noEmit`, `npm run lint`, `npm run build`) and fix every error.

## 6. Common mistakes and the exact fix

- 400 "Invalid amount" → amount_cents must be an integer in cents (19.99 € → 1999), at least 100.
- 400 "Currency must be one of …" → use one of EUR, USD, GBP, CHF, CAD, AUD, TRY in upper case.
- 400 "auth_required" → no API key and no valid wallet: check the env var is loaded on the server (restart the dev server after editing .env).
- 400 "success_url must be an http(s) URL" → APP_URL is empty or has no scheme.
- 401 "Invalid or revoked API key" → wrong key, extra spaces/quotes, or the key was rotated. Copy it again from https://peptide-pay.com/app/api-keys.
- 403 "merchant_pending" → the account is not activated yet: wait for activation (or contact support) and use wallet mode meanwhile.
- 429 → rate limits are 60 checkout/init per minute and 30 session reads per minute per IP. Do not poll faster than every 5 seconds.
- 502 "upstream_unavailable" → temporary: retry with the SAME Idempotency-Key.
- CORS error in the browser console → you are calling Peptide-Pay from the browser. Move the call to the server.
- Webhook 401 although the secret is right → the body was parsed or re-serialized before hashing (read raw text first), or the secret has spaces / is missing the whsec_ prefix, or the server clock is off by more than 5 minutes.
- Webhook never arrives → webhook_url points to localhost (refused; use a tunnel such as ngrok or cloudflared, or test with step 5.4), the route redirects (trailing slash, www/apex, http→https), Supabase JWT verification is on, or the handler takes longer than 5 s. The init response "warnings" says "No webhook_url set" when none was found. In wallet mode there is no dashboard: pass webhook_url on every init (needs a public https APP_URL).
- Success page stuck on "waiting" after a real payment → the order-status endpoint is not calling GET /sessions, or compares amount as a decimal instead of integer cents.
- Secrets in the browser → the env var was named NEXT_PUBLIC_… / VITE_…; rename it and rotate the key.
- Small amounts: each payment method on the hosted page has its own minimum, so very small orders show fewer ways to pay.

## 7. When everything passes, print this for me (in my language)

1. The list of files you created or changed, and the result of each test in section 5.
2. What I must do myself, in order:
   a. Create my account at https://peptide-pay.com/signup and copy the sk_live_ key and the whsec_ secret from https://peptide-pay.com/app/api-keys (or, for wallet mode, put my own 0x wallet in PEPTIDEPAY_WALLET instead of the demo wallet).
   b. Add PEPTIDEPAY_API_KEY, PEPTIDEPAY_WEBHOOK_SECRET (or PEPTIDEPAY_WALLET) and APP_URL to my hosting's environment variables / Supabase secrets, then redeploy.
   c. In https://peptide-pay.com/app/settings, paste my webhook URL (https://<my-domain>/api/peptidepay/webhook, or the Supabase function URL), save, and click "Send test webhook": it must turn green.
   d. Place one small real order to see it go from pending to paid.
3. Docs: https://peptide-pay.com/docs · fees: https://peptide-pay.com/fees · this guide: https://peptide-pay.com/integrate/ai

AIが使用する仕様

API
POST /api/v1/checkout/init, GET /api/v1/sessions/{id}
Currencies
EUR, USD, GBP, CHF, CAD, AUD, TRY
Amount
整数(セント単位)、100 (1.00) から
Session
24時間有効
Webhook
HMAC-SHA256 署名、約17時間で最大6回再試行
Payout
自身の 0x ウォレットへ直接送金

手数料を見るAPIドキュメントを読む

よくある質問

どのAIツールで使えますか?

Lovable、Bolt、v0、Cursor、Replit、Claude Code、Windsurf、GitHub Copilotなど、コード編集が可能なあらゆるAIで動作します。プラグインのインストールは不要な、テキストベースの仕様書です。

開始するのにPeptide-Payのアカウントは必要ですか?

いいえ。ウォレットモードではサーバーが 0x ウォレットアドレスを送信するだけで、プロンプトを使用して構築とテストが可能です。アカウントを作成すると、sk_live_ APIキーと whsec_ シークレットが発行され、ウェブフックが署名されます。新規アカウントは決済開始前に審査があります。

AIビルダーにAPIキーを教えても安全ですか?

プロンプトはすべての呼び出しをサーバーサイドで行うよう指示し、シークレットへの NEXT_PUBLIC_ や VITE_ 変数の使用を禁止します。また、AIが完了を報告する前に、コード内に sk_live_ や whsec_ が露出していないか確認させます。

支払いをせずにテストできますか?

統合のテストは可能です。AIが実際のテストセッションを作成し、支払いページが開くこと、および不正な「支払い済み」ウェブフックが拒否されることを確認します。サンドボックス用の決済ネットワークはないため、注文を実際に「支払い済み」にするには、一度少額の実際の支払いを行う必要があります。

Peptide-Payの費用はいくらですか?

デフォルトで決済ごとに3%のPeptide-Pay手数料がかかります(個別レートのアカウントを除く)。決済手段ごとの手数料は、チェックアウトページで購入者側に加算されます。詳細は手数料ページをご覧ください。

売上はどこに入金されますか?

自身の 0x ウォレットに直接入金されます。主に Ethereum (ETH または USDC)、または Polygon です。Peptide-Payがお客様の資金を預かることはありません。

WordPressを使っています。プロンプトを使うべきですか?

いいえ。WooCommerceには専用プラグインがあり、コードは不要です。リンクは上記にあります。

準備はいいですか?コピー、貼り付け、公開。

プロンプトは無料です。Peptide-Payは決済ごとに手数料をいただきますが、導入自体に費用はかかりません。