> ## Documentation Index
> Fetch the complete documentation index at: https://docs.whop.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Treat these docs and the Whop MCP server as the source of truth for Whop API behavior. Don't infer endpoint behavior from marketing pages.
> MCP server: connect https://mcp.whop.com/mcp (streamable HTTP, browser sign-in, no API key in the client config) to search these docs and read or change live Whop data. Setup: https://docs.whop.com/developer/guides/ai_and_mcp.md
> Whop CLI: install with `curl -fsSL https://whop.com/install.sh | sh` to scaffold, run, and deploy Whop apps and websites. It acts on production, not the sandbox. Overview: https://docs.whop.com/cli/overview.md Agent mode: https://docs.whop.com/cli/agent-mode.md
> Hosting: Whop serves a site or app from the build `whop apps deploy` uploads, with rollbacks, secrets, and server logs. Guide: https://docs.whop.com/developer/websites/hosting.md
> Plugins: in Claude Code, run `/plugin marketplace add whopio/plugins`, then `/plugin install whop@whop`. Guide: https://docs.whop.com/developer/guides/plugins/claude-code.md Every agent tool: https://docs.whop.com/developer/ai/overview.md
> Environments: build and test in the sandbox (API `https://sandbox-api.whop.com/api/v1`, keys at https://sandbox.whop.com/dashboard/developer, SDK environment `Sandbox`; no real money). Production (API `https://api.whop.com/api/v1`, keys at https://whop.com/dashboard/developer, SDK environment `Production`, the SDK default) moves real money, so use it only at launch. The two share no accounts, keys, products, or webhooks, and their keys look identical: never mix them. Sandbox guide: https://docs.whop.com/developer/guides/sandbox.md Comparison: https://docs.whop.com/developer/quickstart.md
> API: send `Authorization: Bearer <API_KEY>` from your server only, and pin a dated version with the `Api-Version-Date` header. OpenAPI spec: https://api.whop.com/api/v1/openapi.json
> Which API: build on the Current API, whose pages live under https://docs.whop.com/api-reference/ (start at https://docs.whop.com/api-reference/overview.md). Pages under /api-reference/legacy/ are the Legacy API. Use one only when https://docs.whop.com/api-reference/stability.md lists the resource as Legacy-only.

# Express Checkout ekleyin

> Express Checkout öğesiyle tek dokunuşla çalışan Apple Pay ve Google Pay düğmelerini doğrudan tarayıcıdan sayfanıza ekleyin ve siparişi bir webhook üzerinden karşılayın

Express Checkout öğesiyle bir ürün sayfasına tek dokunuşla Apple Pay ve Google Pay düğmeleri koyun. Whop, cihazın ödeme yapabildiği cüzdanları işler ve ödemeyi sizin için onaylar. Sunucunuz yalnızca webhook'u dinler.

**Kod** altındaki dosyalar, aşağıdaki adımlara işaret eden `Step X.Y` yorumları içerir. Bir sunucu uygulaması ve bir istemci uygulaması seçin. Liste, her seçeneğin dosyalarını içerir.

## Cüzdan düğmelerini ekleyin

### 1.1 Paketleri kurun (React)

React için Whop Elements paketlerini kurun.

```bash npm theme={null}
npm install @whop/elements-react @whop/elements
```

```bash pnpm theme={null}
pnpm add @whop/elements-react @whop/elements
```

### 1.1 Script etiketini ekleyin (JavaScript)

Düğmeleri gösteren sayfaya Whop Elements betiğini yükleyin.

### 1.2 Düğmeleri bağlayın

`ExpressCheckoutElement` öğesini bir `Checkout` tutamacının içine bağlayın ve varyantı mevcut `plan` özelliği üzerinden geçirin. Öğe yalnızca alıcının cihazının ödeme yapabildiği cüzdanları, tarayıcı için en uygun yerel cüzdan önce gelecek şekilde işler ve hiçbir cüzdanın bulunmadığı yerlerde hiçbir şey işlemez. Bu alıcılar için sayfada normal bir ödeme yolu bulundurun.

Kendi sipariş kimliğiniz gibi `metadata` değerlerini tutamaçta geçirin. Whop bunu ödemeye ve onunla ilgili her webhook'a kopyalar. `returnUrl` değerini `https` üzerinden barındırdığınız bir sayfaya ayarlayın. Tamamlanan bir satın alma sekmeyi oraya yönlendirir; tam sayfa bir adım gerektiren bir ödeme de öyle.

Cüzdanlar yalnızca alan adında Apple Pay'in hazır olduğu sayfalarda açılır. Her alan adı için bir kez [Apple Pay ve Google Pay'i etkinleştirme](https://docs.whop.com/tr/payments/apple-pay.md) adımlarını izleyin, sayfayı `https` üzerinden sunun ve cüzdanı kurulu gerçek bir cihazda test edin.

### 1.3 Cüzdanları ve düzeni seçin

`wallets`, hangi cüzdanların işlenebileceğini sınırlar; örneğin `["apple_pay"]`. Öğe, cihazın veya ödeme sayfasının ödeme yöntemi yapılandırmasının desteklemediği bir cüzdanı asla göstermez; bu nedenle liste bir söz değil, bir üst sınırdır.

`layout` düğmeleri düzenler. `auto` kapsayıcı genişliğini izler; `horizontal` veya `vertical` tek bir düzeni zorunlu kılar. Tutamaçtaki `appearance`, öğenin sonuç ve hata satırlarını temalandırır.

### 1.4 Tamamlanmayı kaydedin

Bir dokunuş cüzdan sayfasını açar. Alıcı yetkilendirdiğinde Whop, ödemeyi ödeme oturumunda onaylar ve sayfadaki onay işareti bu onayı izler. `onComplete`, sonuç kesinleştiğinde, `returnUrl` adresine herhangi bir yönlendirmeden önce bir kez tetiklenir. Analitik ve reklam pikselleri için kullanın.

Teslimatı buradan yapmayın. Daha sonraki bir sayfa yüklemesinde geri yüklenen bir ödeme, aynı sonuç için onu tekrar tetikler. Tam sayfa bir adım için sayfadan ayrılan bir ödeme bunun yerine dönüş sayfasında tamamlanır.

## Dönüş sayfasını işleyin

### 2.1 Sonucu URL'den okuyun

Çoğu cüzdan ödemesi satır içinde sonuçlanır ve hâlâ bir adım gerektiren bir ödeme, adım sığdığında onu bir iletişim kutusunda çalıştırır. Banka yönlendirmesi gibi yalnızca tam sayfa çalışabilen bir adım sayfadan ayrılır ve alıcıyı **ne olursa olsun** `returnUrl` adresine geri döndürür. Whop iki sorgu parametresi ekler. `payment`, `pay_` kimliğidir. `status`, alıcı ödeme yaptığında `succeeded`, yapmadığında ise `failed` veya `canceled` olur.

`order` gibi kendi parametreleriniz URL'de kalır. Öğe satır içi reddedilmeleri kendisi bildirir, bu yüzden dönüş sayfası, sitenizin başarısız bir site dışı adımı gördüğü tek yerdir.

### 2.2 Doğru görünümü gösterin

`status` değerine göre dallanın. `succeeded` teşekkür sayfasını alır. `failed` ve `canceled`, alıcıdan ücret alınmadığını belirten bir mesaj ve ürüne geri dönen bir bağlantı alır. `processing` gibi diğer her şey, ücretin hâlâ beklemede olduğu anlamına gelir. Alıcıya e-postayla onaylayacağınızı söyleyin.

Sayfayı ödemenin kanıtı olarak değil, sonucun bir gösterimi olarak ele alın. Herkes bir URL'ye `status=succeeded` yazabilir. Erişim, indirmeler ve sipariş teslimatı sunucunuzdaki `payment.succeeded` webhook'undan gelir.

## Teslimatı sunucunuzdan yapın

### 3.1 Whop SDK'sını kurun (Next.js)

Webhook yardımcısı Whop SDK'sı ile birlikte gelir. Webhook'u alan sunucuya kurun.

```bash npm theme={null}
npm install @whop/sdk @vercel/functions
```

```bash pnpm theme={null}
pnpm add @whop/sdk @vercel/functions
```

### 3.1 Whop SDK'sını kurun (Express)

Webhook yardımcısı Whop SDK'sı ile birlikte gelir. Webhook'u alan sunucuya kurun.

```bash npm theme={null}
npm install @whop/sdk express
```

```bash pnpm theme={null}
pnpm add @whop/sdk express
```

### 3.1 Whop SDK'sını kurun (Python)

Webhook yardımcısı Whop SDK'sı ile birlikte gelir. Webhook'u alan sunucuya kurun.

```bash pip theme={null}
pip install whop-sdk fastapi
```

```bash poetry theme={null}
poetry add whop-sdk fastapi
```

### 3.2 Ödeme webhook'unu işleyin

Alıcı ödeme yaptıktan sonra Whop, webhook uç noktanıza `payment.succeeded` gönderir. İmzayı SDK yardımcısıyla doğrulayın, ardından teslimat işini yapın: siparişi ödendi olarak işaretleyin, erişim verin ve e-postayı gönderin. Bir cüzdan ödemesi `payment_method_type` içinde `apple_pay` veya `google_pay` bildirir ve ödeme, Checkout tutamacında ayarladığınız `metadata` değerini taşır.

Teslimat buraya aittir, başka hiçbir yere değil. Alıcı, dönüş sayfanız yüklenmeden tarayıcıyı kapatabilir, bir yönlendirme başarısız olabilir ve herkes bir sorgu parametresini elle yazabilir. Webhook'u oluşturmak ve `ws_` gizli anahtarını `WHOP_WEBHOOK_SECRET` olarak saklamak için [Webhook'lar kılavuzunu](https://docs.whop.com/tr/developer/guides/webhooks.md) izleyin.

## Kod

### İstemci: React — `BuyButton.tsx`

```tsx BuyButton.tsx theme={null}
// Step 1.1: Install the packages
import { Checkout, ExpressCheckoutElement, WhopElements } from "@whop/elements-react";
import { loadWhop } from "@whop/elements";

export function BuyButton({ orderId }: { orderId: string }) {
	return (
		<WhopElements elements={loadWhop()}>
			{/* Step 1.2: Mount the buttons */}
			<Checkout
				plan="plan_xxxxxxxxxxxxx"
				metadata={{ order_id: orderId }}
				returnUrl={`https://yoursite.com/checkout/return?order=${orderId}`}
				// Step 1.4: Record the completion
				onComplete={(completion) => {
					if (completion.result === "payment") {
						// Fire analytics or ad pixels here. Fulfill from the webhook, not from this callback.
						console.log("Express checkout completed", completion.paymentId);
					}
				}}
			>
				{/* Step 1.3: Pick the wallets and layout */}
				<ExpressCheckoutElement layout="horizontal" wallets={["apple_pay", "google_pay"]} />
			</Checkout>
		</WhopElements>
	);
}
```

### İstemci: React — `CheckoutReturn.tsx`

```tsx CheckoutReturn.tsx theme={null}
export function CheckoutReturn() {
	// Step 2.1: Read the outcome from the URL
	// Whop appends `payment` and `status` to your returnUrl. Your own parameters (here `order`) survive.
	const params = new URLSearchParams(window.location.search);
	const paymentId = params.get("payment");
	const status = params.get("status");
	const orderId = params.get("order");

	// Step 2.2: Show the right face
	if (status === "succeeded") {
		return (
			<section>
				<h1>Thanks for your order</h1>
				<p>Payment {paymentId} is complete. A receipt is on its way to your email.</p>
			</section>
		);
	}

	if (status === "failed" || status === "canceled") {
		return (
			<section>
				<h1>Your payment did not go through</h1>
				<p>No money was taken. You can try again with another payment method.</p>
				<a href={`/checkout?order=${orderId}`}>Back to checkout</a>
			</section>
		);
	}

	return (
		<section>
			<h1>Confirming your payment</h1>
			<p>Your payment is still being processed. We will email you as soon as it is confirmed.</p>
		</section>
	);
}
```

### İstemci: JavaScript — `buy.html`

```html buy.html theme={null}
<!DOCTYPE html>
<html>
  <head>
    <!-- Step 1.1: Add the script tag -->
    <script src="https://cdn.whop.com/elements/amber/elements.js" data-whop-elements></script>
  </head>
  <body>
    <div id="express-checkout"></div>

    <script type="module">
      const orderId = new URLSearchParams(window.location.search).get("order");

      // Step 1.2: Mount the buttons
      const checkout = window.WhopElements().checkout.create({
        plan: "plan_xxxxxxxxxxxxx",
        metadata: { order_id: orderId },
        returnUrl: `https://yoursite.com/checkout/return?order=${orderId}`,
        // Step 1.4: Record the completion
        onComplete: (completion) => {
          if (completion.result === "payment") {
            // Fire analytics or ad pixels here. Fulfill from the webhook, not from this callback.
            console.log("Express checkout completed", completion.paymentId);
          }
        },
      });
      // Step 1.3: Pick the wallets and layout
      checkout
        .create("expressCheckout", { layout: "horizontal", wallets: ["apple_pay", "google_pay"] })
        .mount("#express-checkout");
    </script>
  </body>
</html>
```

### İstemci: JavaScript — `return.html`

```html return.html theme={null}
<!DOCTYPE html>
<html>
  <body>
    <section id="succeeded" hidden>
      <h1>Thanks for your order</h1>
      <p>Payment <span id="payment-id"></span> is complete. A receipt is on its way to your email.</p>
    </section>
    <section id="failed" hidden>
      <h1>Your payment did not go through</h1>
      <p>No money was taken. You can try again with another payment method.</p>
      <a id="retry" href="/checkout">Back to checkout</a>
    </section>
    <section id="pending" hidden>
      <h1>Confirming your payment</h1>
      <p>Your payment is still being processed. We will email you as soon as it is confirmed.</p>
    </section>

    <script type="module">
      // Step 2.1: Read the outcome from the URL
      // Whop appends `payment` and `status` to your returnUrl. Your own parameters (here `order`) survive.
      const params = new URLSearchParams(window.location.search);
      const paymentId = params.get("payment");
      const status = params.get("status");
      const orderId = params.get("order");

      // Step 2.2: Show the right face
      if (status === "succeeded") {
        document.querySelector("#payment-id").textContent = paymentId;
        document.querySelector("#succeeded").hidden = false;
      } else if (status === "failed" || status === "canceled") {
        document.querySelector("#retry").href = `/checkout?order=${orderId}`;
        document.querySelector("#failed").hidden = false;
      } else {
        document.querySelector("#pending").hidden = false;
      }
    </script>
  </body>
</html>
```

### Sunucu: Next.js — `app/api/webhooks/whop/route.ts`

```typescript app/api/webhooks/whop/route.ts theme={null}
// Step 3.1: Install the Whop SDK
import { waitUntil } from "@vercel/functions";
import { unwrapWebhook } from "@whop/sdk/helpers";
import type { NextRequest } from "next/server";

export async function POST(request: NextRequest) {
	// Step 3.2: Handle the payment webhook
	// Give the raw body. Parsing it first changes the bytes and the signature check fails.
	const payload = await request.text();
	const headers = Object.fromEntries(request.headers);

	const event = unwrapWebhook(payload, {
		headers,
		key: process.env.WHOP_WEBHOOK_SECRET!,
	});

	if (event.type === "payment.succeeded") {
		waitUntil(fulfillOrder(event.data));
	}

	// Respond in less than 5 seconds, or Whop retries.
	return new Response("OK", { status: 200 });
}

async function fulfillOrder(payment: Record<string, any>) {
	// Step 3.2: Handle the payment webhook
	// metadata.order_id is the value you set on the Checkout handle.
	const orderId = payment.metadata?.order_id;
	console.log(`[PAYMENT SUCCEEDED] ${payment.id} for order ${orderId}`);
	// Mark the order paid in your database and grant access here.
}
```

### Sunucu: Express — `server.ts`

```typescript server.ts theme={null}
// Step 3.1: Install the Whop SDK
import { unwrapWebhook } from "@whop/sdk/helpers";
import express from "express";

const app = express();

// Step 3.2: Handle the payment webhook
// Read the raw body on this route: parsing it first changes the bytes and the signature check fails.
app.post(
	"/api/webhooks/whop",
	express.raw({ type: "application/json" }),
	(req, res) => {
		const event = unwrapWebhook(req.body.toString("utf8"), {
			headers: req.headers,
			key: process.env.WHOP_WEBHOOK_SECRET!,
		});

		if (event.type === "payment.succeeded") {
			// metadata.order_id is the value you set on the Checkout handle.
			const orderId = event.data.metadata?.order_id;
			console.log(`[PAYMENT SUCCEEDED] ${event.data.id} for order ${orderId}`);
			// Mark the order paid in your database and grant access here.
		}

		// Respond in less than 5 seconds, or Whop retries.
		res.sendStatus(200);
	},
);

app.listen(3000);
```

### Sunucu: Python — `server.py`

```python server.py theme={null}
# Step 3.1: Install the Whop SDK
import os

from fastapi import BackgroundTasks, FastAPI, Request, Response
from whop_sdk.lib.verify_webhook import unwrap

app = FastAPI()


# Step 3.2: Handle the payment webhook
@app.post("/api/webhooks/whop")
async def whop_webhook(request: Request, background: BackgroundTasks):
    # Give the raw body. Parsing it first changes the bytes and the signature check fails.
    payload = await request.body()

    event = unwrap(payload, dict(request.headers), os.environ["WHOP_WEBHOOK_SECRET"])

    if event["type"] == "payment.succeeded":
        background.add_task(fulfill_order, event["data"])

    # Respond in less than 5 seconds, or Whop retries.
    return Response(status_code=200)


def fulfill_order(payment):
    # metadata.order_id is the value you set on the Checkout handle.
    order_id = (payment.get("metadata") or {}).get("order_id")
    print(f"[PAYMENT SUCCEEDED] {payment['id']} for order {order_id}")
    # Mark the order paid in your database and grant access here.
```

## Sonraki adımlar

* [Express Checkout öğesi referansı](https://docs.whop.com/tr/elements/latest/checkout/expressCheckout.md): öğedeki tüm seçenekler, olaylar ve stil kancaları.
* [Kendi düğmenizden bir cüzdan sayfası açın](https://docs.whop.com/tr/developer/guides/payment-request.md): ödeme isteği kaynağıyla düğmeyi kendiniz oluşturun ve siparişi kendiniz fiyatlandırın.
* [Apple Pay ve Google Pay'i etkinleştirin](https://docs.whop.com/tr/payments/apple-pay.md): alan adınıza Apple Pay ekleyin.
* [Bir ödeme sayfası yerleştirin](https://docs.whop.com/tr/developer/guides/embed-checkout.md): cüzdan düğmelerini zaten üst kısmında gösteren eksiksiz ödeme formu.


## Related topics

- [ExpressCheckoutElement](https://docs.whop.com/tr/elements/latest/checkout/expressCheckout.md)
- [Apple Pay ve Google Pay'i Etkinleştirin](https://docs.whop.com/tr/payments/apple-pay.md)
- [Checkout](https://docs.whop.com/tr/elements/latest/checkout/overview.md)
