> ## 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.

# Iframe SDK

> Gömülü uygulamanızdan Whop ile iletişim kurmak, örneğin bir bağlantı açmak veya uygulama içi satın alma başlatmak için @whop/iframe SDK'sını kullanın.

Whop, uygulamaları siteye iframe'ler kullanarak yerleştirir. Bu SDK, `window.postMessage` kullanan bir istek-yanıt API'si aracılığıyla Whop uygulamasıyla tür güvenli bir şekilde iletişim kurmanızı sağlar.

Bu paket `window.postMessage`'a dayandığından yalnızca **Client Components** içinde veya istemci tarafı JavaScript'te çalışır.

### İlgili paketler

* `@whop/iframe` - iframe SDK'sının ana paketi.
* `@whop/react` - iframe SDK'sı için yardımcılar içeren, Whop uygulamalarına yönelik bir React sarmalayıcısı.

***

## Kurulum

`@whop/iframe` paketinden dışa aktarılan ana fonksiyon `createSdk` fonksiyonudur. Bu fonksiyon çağrıldığında, `window.on('message', ...)` kullanarak ana Whop sitesinden gelen mesajlar için bir dinleyici kurar. Ayrıca `@whop/react` paketindeki `WhopIframeSdkProvider` bileşeni aracılığıyla da sunulur.

### React

React kullanıyorsanız, iframe SDK'sını tüm alt bileşenlere sağlamak için `@whop/react` paketindeki `WhopIframeSdkProvider` bileşenini ekleyin.

**1. Sağlayıcıyı kök düzende bağlayın**

```javascript theme={null}
// app/layout.tsx
import { WhopIframeSdkProvider } from "@whop/react";

export default function RootLayout({
  children,
}: {
  children: React.ReactNode,
}) {
  return (
    <html lang="en">
      <body>
        <WhopIframeSdkProvider>{children}</WhopIframeSdkProvider>
      </body>
    </html>
  );
}
```

**2. iframe SDK'sını bir bileşende kullanın**

```javascript theme={null}
// components/example.tsx
import { useIframeSdk } from "@whop/react";

export const Example = () => {
  const iframeSdk = useIframeSdk();

  return (
    <button
      onClick={() => iframeSdk.openExternalUrl({ url: "https://example.com" })}
    >
      Open External URL
    </button>
  );
};
```

### Diğer çatılar

Diğer çatılarda, iframe SDK'sının bir örneğini oluşturmak için `@whop/iframe` paketindeki `createSdk` fonksiyonunu kullanabilirsiniz.

**1. iframe SDK örneğini oluşturun**

```javascript theme={null}
// lib/iframe-sdk.ts
import { createSdk } from "@whop/iframe";

export const iframeSdk = createSdk({
  appId: process.env.NEXT_PUBLIC_WHOP_APP_ID,
});
```

**2. iframe SDK örneğini kullanın**

```javascript theme={null}
// index.ts
import { iframeSdk } from "@/lib/iframe-sdk";

const navigationButtonElement = document.querySelector("button");

if (navigationButtonElement) {
  navigationButtonElement.addEventListener("click", () => {
    iframeSdk.openExternalUrl({ url: "https://example.com" });
  });
}
```

> [!TIP]
>
> SDK ve iframe artık kuruldu.

## Harici bağlantıları açma

iframe SDK'sını başlattıktan sonra harici bağlantıları açmak için kullanabilirsiniz. Bu, uygulamanızı kapatır ve yeni bir web sitesine gider.

```javascript React theme={null}
"use client";
import { useIframeSdk } from "@whop/react";

export default function Home() {
	const iframeSdk = useIframeSdk();

    function openLink() {
    	iframeSdk.openExternalUrl({ url: "https://google.com" });
    }

    return <button onClick={openLink}>Click me to open Google</button>;

}

```

```javascript Vanilla JS theme={null}
import { iframeSdk } from "@/lib/iframe-sdk";

const navigationButtonElement = document.querySelector("button");

if (navigationButtonElement) {
  navigationButtonElement.addEventListener("click", () => {
    iframeSdk.openExternalUrl({ url: "https://google.com" });
  });
}
```

### Kullanıcı profillerini açma

Bir Whop kullanıcı profilini göstermek istiyorsanız `openExternalUrl` yöntemini kullanabilir ve `https://whop.com/@username` biçimindeki profil sayfası bağlantısını iletebilirsiniz.

Whop uygulaması bunu yakalar ve sayfadan ayrılmak yerine kullanıcının profilini içeren bir modal gösterir.

```javascript React theme={null}
"use client";
import { useIframeSdk } from "@whop/react";

export default function Home() {
	const iframeSdk = useIframeSdk();

    function openProfile() {
    	iframeSdk.openExternalUrl({ url: "https://whop.com/@j" });
    }

    return <button onClick={openProfile}>View Profile</button>;

}

```

```javascript Vanilla JS theme={null}
import { iframeSdk } from "@/lib/iframe-sdk";

const profileButtonElement = document.querySelector("button");

if (profileButtonElement) {
  profileButtonElement.addEventListener("click", () => {
    iframeSdk.openExternalUrl({ url: "https://whop.com/@j" });
  });
}
```

> [!NOTE]
>
> Kullanıcı adı yerine bir kullanıcı kimliği de kullanabilirsiniz. Son bağlantı
> şu şekilde görünmelidir: `https://whop.com/@user_XXXXXXXX`

## Uygulama içi satın almalar

iframe SDK'sı, uygulama içi satın almaları doğrudan uygulamanızın içinden tetiklemek için bir yöntem sunar. Bu sayede Whop'un ödeme sayfasını kullanarak tek seferlik satın almalar veya abonelikler için ödeme alabilirsiniz.

Uygulama içi satın almaları işlemek için şunları yapmanız gerekir:

1. Sunucunuzda bir checkout yapılandırması oluşturun (varyant ayrıntıları uyumluluk alanı olan `plan` içinde ve meta verilerinizle birlikte)
2. Ödeme modalını açmak için iframe SDK'sındaki `inAppPurchase` yöntemini kullanın
3. Yanıtı işleyin ve ödemeyi webhook'lar aracılığıyla doğrulayın

```tsx React theme={null}
"use client";
import { useIframeSdk } from "@whop/react";
import { useState } from "react";

export default function PaymentButton() {
    const iframeSdk = useIframeSdk();
    const [paymentId, setPaymentId] = useState<string>();

    async function handlePurchase() {
        // 1. Create checkout configuration on server
        //    (in this example this is a nextjs server action, but it could also be a plain API route)
        const checkoutConfiguration = await createCheckoutConfiguration(/* can pass options here */);

        // 2. Open payment modal
        const res = await iframeSdk.inAppPurchase({
            planId: checkoutConfiguration.plan.id,
            id: checkoutConfiguration.id
        });

        if (res.status === "ok") {
            setPaymentId(res.data.receipt_id);
        } else {
            // handle errors
        }
    }

    return <button onClick={handlePurchase}>Purchase</button>;

}

```

```javascript Vanilla JS theme={null}
import { iframeSdk } from "@/lib/iframe-sdk";

const paymentButton = document.querySelector("button#payment-button");

paymentButton.addEventListener(
    "click",
    async function onPaymentButtonClick() {
        // 1. Create checkout configuration on server
        const checkoutConfiguration = await createCheckoutConfiguration(/* can pass options here */);

        // 2. Open payment modal
        const res = await iframeSdk.inAppPurchase({
            planId: checkoutConfiguration.plan.id,
            id: checkoutConfiguration.id
        });

        if (res.status === "ok") {
            const paymentId = res.data.receipt_id;
            // Send this id to your backend to validate, or rely on webhooks.
            // User has purchased the item, and it can be unlocked.
        } else {
            // handle errors
        }
    }
);
```

> [!NOTE]
>
> Checkout yapılandırmaları oluşturma, webhook'ları işleme ve ödemeleri doğrulama
> dahil olmak üzere uygulama içi satın almaları kurmaya yönelik eksiksiz bir kılavuz
> için [Ödeme alma belgelerine](https://docs.whop.com/tr/developer/guides/accept-payments.md) bakın.


## Related topics

- [Frosted UI](https://docs.whop.com/tr/developer/guides/frosted_ui.md)
- [Stil Başvurusu](https://docs.whop.com/tr/sdk/elements/styling-reference.md)
- [Whop Uygulamalarında Kullanıcıların Kimliğini Doğrulayın](https://docs.whop.com/tr/developer/guides/authentication.md)
