---
title: "React Native flow'larında Stripe ödemelerini kabul etme"
description: "Bir flow'da Stripe fiyatlarını gösterin, React Native uygulamanızda Stripe'ın PaymentSheet'i ile ödeme alın ve Adapty'nin erişim sağlamasına ve geliri flow'a atamasına izin verin."
---

> For the complete documentation index, see [llms.txt](https://adapty.io/docs/tr/llms.txt).

> **AI agents**: to search Adapty docs faster and with fewer tokens, install the Adapty skills: `npx adapty skills install --yes`

Flow & Paywall Builder'da oluşturduğunuz bir flow'dan Stripe abonelikleri satabilirsiniz. Flow, Stripe fiyatlarınızı gösterir ve düğmeleri, flow üzerinde Stripe'ın [PaymentSheet](https://docs.stripe.com/payments/accept-a-payment?platform=react-native) ekranını açar. Ödemenin ardından Stripe, Adapty'yi bilgilendirir. Adapty, kullanıcıya access level tanır ve geliri flow'a, placement'ına ve A/B testi varyantına atar. Bu kurulumu, kullanıcıların uygulama dışında tükettiği hizmetlere yönelik abonelikler satmak için kullanın; örneğin yüz yüze etkinlik üyelikleri, ders kartları veya düzenli teslimatlar gibi. Gerçek dünyaya ait bir hizmeti App Store ürünü olarak da satıyorsanız, Stripe'ı aynı flow'a ek bir ödeme yöntemi olarak ekleyebilirsiniz.

:::important
App Store, dijital içerik ve özellikler için uygulama içi satın almaları zorunlu kılar ([3.1.1 yönergesi](https://developer.apple.com/app-store/review/guidelines/#in-app-purchase)), Google Play ise bunlar için kendi ödeme sistemini kullanmanızı şart koşar ([Ödeme politikası](https://support.google.com/googleplay/android-developer/answer/9858738)). Stripe üzerinden yapılan uygulama içi ödeme, fiziksel ürünler ve kullanıcıların uygulama dışında tükettiği hizmetler içindir ([3.1.3(e) yönergesi](https://developer.apple.com/app-store/review/guidelines/#other-purchase-methods)). Google Play, spor salonu üyelikleri ve canlı etkinlik biletleri gibi bu tür satın almalar için kendi ödeme sistemine izin vermez.
:::

## Nasıl çalışır \{#how-it-works\}

1. Uygulamanız Stripe fiyatlarını backend'inizden alır. Ardından bunları [custom tag](react-native-flow-custom-tags) olarak flow'a iletir ve flow'u gösterir.
2. Kullanıcı flow'daki bir butona dokunur. Buton bir custom action tetikler ve uygulamanız action ID'yi alır.
3. Uygulamanız backend'inizden bir Stripe aboneliği oluşturmasını ister. Backend'iniz, kullanıcının ID'sini ve flow'un variation ID'sini aboneliğin metadata'sına ekler.
4. Uygulamanız flow'un üzerine PaymentSheet açar ve kullanıcı aboneliğin ilk faturasını öder.
5. Stripe, Adapty'ye bir webhook gönderir. Adapty, access level'ı kullanıcının ID'sine sahip profile atar ve satın almayı flow varyantına bağlar.
6. Uygulamanız flow'u kapatır ve profilde access level oluşana kadar bekler.

## Başlamadan önce \{#before-you-start\}

Şunlara sahip olduğunuzdan emin olun:

1. **Adapty uygulamanıza bağlı Stripe**: Test modu ve canlı mod için [Stripe'ı Adapty'e bağlama](stripe#1-connect-stripe-to-adapty) adımlarını izleyin. [**Profile creation behavior**](stripe#profile-creation-behavior) ayarını **Use customer_user_id from metadata (default)** olarak bırakın.
2. **Her plan için bir Stripe ürünü ve fiyatı**: Aylık veya yıllık gibi yinelenen fiyatlarla [Stripe'ta ürünler oluşturun](stripe#2-create-products-on-stripe).
3. **Her Stripe fiyatı için bir Adapty ürünü**: [Adapty ürününe Stripe ürün ID'si ve fiyat ID'si ekleyin](stripe#3-add-stripe-products-to-adapty) ve planın kilidini açacak access level'ı atayın. Access level, uygulamanızdaki dijital özellikleri değil; aktif üyelik gibi hizmet erişim hakkını temsil eder. Adapty ürünü olmadan Adapty satın almayı kaydetmez.
4. **Adapty React Native SDK 4.0.0 veya üzeri**: SDK'yı Stripe'a bağladığınız Adapty uygulamasının anahtarıyla etkinleştirin. Adapty, Stripe webhook'larını yalnızca o uygulama için alır. Kullanıcıları bir müşteri kullanıcı ID'siyle [tanımlayın](react-native-identifying-users) ve bu flow'u yalnızca giriş yapmış ve tanımlanmış kullanıcılara gösterin. Adapty, access level atanacak profili bulmak için bu ID'yi kullanır.

   SDK 4.4'ten itibaren, flow'lar iOS 16 veya üzerini gerektirmektedir. iOS 15'te `createFlowView` ve `AdaptyFlowView`, `platformNotSupported` koduyla bir hata bildirir. Uygulamanız bu hatayı aldığında, flow yerine [özel bir paywall](react-native-implement-paywalls-manually) gibi kendi içeriğinizi gösterin.
5. **Stripe React Native SDK** (`@stripe/stripe-react-native`) uygulamanızda yüklü olmalıdır. Daha fazla bilgi için Stripe belgelerindeki [Ödeme kabul etme](https://docs.stripe.com/payments/accept-a-payment?platform=react-native) sayfasına bakın.
6. **Stripe API'sini çağırabilen bir backend**, Stripe [gizli anahtarınızla](https://docs.stripe.com/keys) veya Müşteri ve Abonelik yazma iznine sahip kısıtlı bir anahtarla çalışmalıdır. Adapty için oluşturduğunuz kısıtlı anahtarı yeniden kullanmayın: bu anahtar Adapty'ye aittir ve backend'inizin ihtiyaç duyduğu yazma izinlerine sahip değildir. Anahtarı sunucunuzda saklayın.

## Flow'da Stripe fiyatlarını gösterme \{#show-stripe-prices-in-the-flow\}

Flow, Stripe fiyatlarını özel etiketler aracılığıyla gösterir. Özel etiket, uygulamanızın flow'u yüklerken flow'a ilettiği bir metin değeridir. Adapty, özel etiket değerini biçimlendirmez; bu nedenle her fiyatı kullanıcıların gördüğü biçimde iletin; örneğin "$29.00".

1. Flow & Paywall Builder'da her fiyat için [bir **String** değişkeni oluşturun](flow-custom-tags#create-a-custom-tag) (örneğin `stripe_monthly_price` ve `stripe_annual_price`) ve **Value comes from outside the app** seçeneğini belirleyin. Her değişkenin **Initial value** alanını mevcut fiyatınıza ayarlayın. Uygulamanız fiyatları yükleyemezse kullanıcılar bu başlangıç değerini görür; bu nedenle başlangıç değerlerini Stripe fiyatlarınızla aynı tutun.
2. [Her etiketi bir metin öğesine ekleyin](flow-custom-tags#add-a-custom-tag-to-a-text-element); örneğin bir plan düğmesinin etiketine.
3. Uygulamanızda, flow'u yüklemeden önce fiyatları backend'inizden alın.
4. Fiyatları, görünüm parametrelerinin `customTags` alanına aktarın.

Aşağıdaki fonksiyon flow'u yükler ve Stripe fiyatlarınızla birlikte view parametrelerini oluşturur. Aynı zamanda flow'u da döndürür; çünkü backend'iniz flow'un `variationId` değerini Stripe aboneliğine yazar. Flow'u [Flow'dan PaymentSheet'i açın](#open-paymentsheet-from-the-flow) bölümünde sunarsınız.

```typescript showLineNumbers title="React Native"

export type StripeFlow = {
  flow: AdaptyFlow;
  params: CreateFlowViewParamsInput;
};

export async function loadStripeFlow(): Promise<StripeFlow> {
  // If the prices fail to load, the flow shows the tags' initial values
  const prices = await Backend.fetchPrices().catch((): Record<string, string> => ({}));

  const flow = await adapty.getFlow('YOUR_PLACEMENT_ID');
  const customTags: Record<string, string> = {};
  if (prices.monthly) customTags.stripe_monthly_price = prices.monthly;
  if (prices.annual) customTags.stripe_annual_price = prices.annual;

  return { flow, params: { customTags } };
}
```

`Backend`, [arka ucunuzda abonelik oluşturma](#create-the-subscription-on-your-backend) bölümünde oluşturduğunuz arka uç endpoint'lerinizin istemcisidir.

## PaymentSheet'i açan butonlar ekleyin \{#add-buttons-that-open-paymentsheet\}

Bir Stripe planı satan her buton, özel bir aksiyon tetikler. Uygulamanız aksiyon ID'sini alarak ilgili plan için PaymentSheet'i açar.

1. Flow & Paywall Builder'da her Stripe planı için [bir buton ekleyin](paywall-buttons).
2. Her butona **Custom Action** aksiyonunu atayın ve `buy_stripe_monthly` ile `buy_stripe_annual` gibi bir aksiyon ID'si girin.
3. Flow'u yayınlayın ve [bir placement'a ekleyin](create-placement).

Uygulamanız her aksiyon ID'sini bir plana eşler. Flow, aksiyonla birlikte uygulamanıza herhangi bir veri göndermez; bu nedenle planı tanımlamak için aksiyon ID'si kullanılmalıdır.

### Uygulama İçi Satın Almalara Alternatif Ödeme Yöntemi Olarak Stripe Ekleme \{#add-stripe-as-another-way-to-pay-for-app-store-products\}

Bu kurulumu yalnızca kullanıcıların uygulama dışında tükettiği fiziksel ürün veya hizmetler ([kural 3.1.3(e)](https://developer.apple.com/app-store/review/guidelines/#other-purchase-methods)) için kullanın; örneğin yüz yüze etkinliklere üyelikler gibi. Dijital içerik veya özellikler için ödeme alternatifi sunmak istiyorsanız [web paywall](react-native-web-paywall) kullanın.

Bu kurulum yalnızca iOS içindir. Google Play, fiziksel mal ve hizmetler için kendi ödeme sistemine izin vermez ([Ödeme politikası](https://support.google.com/googleplay/android-developer/answer/9858738)), bu nedenle Android'de bu planları yalnızca Stripe aracılığıyla satın.

Flow, App Store ürünlerinizi her zamanki gibi gösterir ve "Başka bir yolla öde" gibi bir bağlantı PaymentSheet'i açar. App Store satın alma düğmeleri değişiklik yapılmadan çalışmaya devam eder.

1. Bağlantıya **Custom Action** eylemini atayın ve `pay_with_stripe` gibi bir eylem ID'si verin.
2. Flow'daki her App Store ürünü için aynı plan adına karşılık gelen bir Stripe fiyatı oluşturun.
3. Uygulamanızda her App Store ürün ID'sini ilgili Stripe planıyla eşleştirin.
4. Kullanıcının seçtiği ürünü saklayın. Flow, her seçimi `onProductSelected` işleyicisine bildirir. Flow & Paywall Builder ile oluşturulan bir flow, varsayılan olarak seçilen ürünü bildirmez; bu nedenle builder'da seçili olarak ayarladığınız ürünü başlangıç değeri olarak kullanın. Bir A/B testinin varyantları farklı ürünler seçiyorsa, her varyant için varsayılan ürünü ayrı ayrı saklayın.
5. Uygulama `pay_with_stripe` eylemini aldığında, [Flow'dan PaymentSheet'i açma](#open-paymentsheet-from-the-flow) bölümündeki `StripeCheckout` nesnesinin `pay` metodunu, saklanan ürünün Stripe planıyla çağırın.

Flow, bu ürünlerin mağazaya göre değişen App Store fiyatlarını gösterir. PaymentSheet ise Stripe fiyatını uygular. Kullanıcılar bir seçeneğe dokunmadan önce Stripe fiyatını görmek istiyorsanız, [bunu özel bir etiket olarak geçirin](#show-stripe-prices-in-the-flow) ve her plan kartında gösterin; örneğin "ya da aylık 29,00 $ kartla". Özel etiket değerleri flow açıkken değişmez, bu nedenle tek bir bağlantıyla seçili planın fiyatı gösterilemez.

## Backend'inizde aboneliği oluşturun \{#create-the-subscription-on-your-backend\}

PaymentSheet, backend'inizin oluşturduğu bir Stripe nesnesinin ödemesini yapar. Bu kılavuzda, backend'iniz bir Stripe [aboneliği](https://docs.stripe.com/billing/subscriptions/overview) oluşturur ve PaymentSheet bu aboneliğin ilk faturasını öder. Backend'iniz aboneliğin [metadata](https://docs.stripe.com/metadata) alanına iki anahtar ekler:

- `customer_user_id`: Adapty'deki kullanıcının müşteri kullanıcı kimliği. Adapty, access level'ı bu kimliğe sahip profile verir.
- `variation_id`: Uygulamanızın backend'e gönderdiği flow'un varyasyon kimliği. Adapty, geliri bu flow varyantına, ilgili placement'ına ve A/B testine atar.

:::warning
Adapty, abonelik veya fatura olmaksızın tek başına oluşturduğunuz bir PaymentIntent için ödeme kaydetmez. Kullanıcı ödeme yapar, ancak access level almaz.
:::

Create two endpoints. The first returns the formatted prices for the custom tags. The second creates the subscription and returns the values that PaymentSheet needs. Before it creates a subscription, the second endpoint verifies that the user has no active one, so a user can't pay twice for the same plan.

This example uses Node.js with ES modules (`"type": "module"` in `package.json`), Express, and the [`stripe` library](https://github.com/stripe/stripe-node) version 18 or later. Replace `db` with your own database:

```javascript showLineNumbers title="Node.js"

const app = express();
app.use(express.json());

const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

const prices = {
  monthly: 'price_...', // your Stripe price IDs
  annual: 'price_...',
};

// Prices for the custom tags, such as { "monthly": "$29.00", "annual": "$249.00" }.
// You can cache the response.
app.get('/prices', async (req, res) => {
  try {
    const result = {};
    for (const [plan, priceId] of Object.entries(prices)) {
      const price = await stripe.prices.retrieve(priceId);
      // Assumes a currency with two decimal places. Format for your users' locale.
      result[plan] = new Intl.NumberFormat('en-US', {
        style: 'currency',
        currency: price.currency.toUpperCase(),
      }).format(price.unit_amount / 100);
    }
    res.json(result);
  } catch (error) {
    console.error(error);
    res.status(500).json({ error: 'Could not load prices' });
  }
});

app.post('/subscriptions', async (req, res) => {
  // req.user comes from your authentication middleware. Its ID is the same
  // customer user ID that your app passes to adapty.identify().
  const customerUserId = req.user.id;
  // variationId affects only attribution, so the backend doesn't need to trust it
  const { plan, variationId } = req.body;
  if (!prices[plan]) {
    return res.status(400).json({ error: 'Unknown plan' });
  }

  try {
    // One Stripe customer per user, stored in your database
    let customerId = await db.getStripeCustomerId(customerUserId);
    if (!customerId) {
      const customer = await stripe.customers.create({ metadata: { customer_user_id: customerUserId } });
      customerId = customer.id;
      await db.saveStripeCustomerId(customerUserId, customerId);
    }

    // Don't sell a second subscription to a user who already has one
    for (const status of ['active', 'trialing', 'past_due']) {
      const existing = await stripe.subscriptions.list({ customer: customerId, status, limit: 1 });
      if (existing.data.length > 0) {
        return res.status(409).json({ error: 'You already have a subscription' });
      }
    }

    const subscription = await stripe.subscriptions.create({
      customer: customerId,
      items: [{ price: prices[plan] }],
      payment_behavior: 'default_incomplete',
      payment_settings: { save_default_payment_method: 'on_subscription' },
      metadata: {
        customer_user_id: customerUserId,
        variation_id: variationId,
      },
      expand: ['latest_invoice.confirmation_secret'],
    });

    res.json({
      subscriptionId: subscription.id,
      clientSecret: subscription.latest_invoice.confirmation_secret.client_secret,
      publishableKey: process.env.STRIPE_PUBLISHABLE_KEY,
    });
  } catch (error) {
    console.error(error);
    res.status(500).json({ error: 'Could not create the subscription' });
  }
});

app.listen(process.env.PORT ?? 3000);
```

`payment_behavior: 'default_incomplete'` ile abonelik, ilk ödeme beklenene kadar beklemede kalır. Kullanıcı PaymentSheet'te ödeme yaptığında Stripe aboneliği etkinleştirir. Kullanıcı ödeme yapmadan PaymentSheet'i kapatırsa Stripe aboneliği yaklaşık 23 saat sonra sona erdirir ve Adapty bunu kaydetmez. Stripe kurulumunun tamamı için Stripe dokümanlarındaki [Build a subscriptions integration](https://docs.stripe.com/billing/subscriptions/build-subscriptions?platform=react-native) sayfasına bakın.

Kodunuz, `latest_invoice.confirmation_secret` alanından client secret'ı okur; bunun için Stripe API sürümü `2025-03-31.basil` veya daha yenisi gereklidir. `stripe` kütüphanesi bu sürümü 18. sürümden itibaren kullanmaktadır. Stripe API'sini kütüphane olmadan çağırıyorsanız `Stripe-Version` başlığını ayarlayın. Daha eski bir API sürümünde `latest_invoice.payment_intent` alanını genişletin ve bunun yerine `payment_intent.client_secret` değerini okuyun.

Uygulamanızda iki endpoint'i çağırın. Backend'inizin gerektirdiği şekilde her istekle birlikte kullanıcınızın kimlik doğrulama bilgilerini gönderin:

```typescript showLineNumbers title="React Native"
const BASE_URL = 'https://YOUR_BACKEND';

export type Subscription = {
  subscriptionId: string;
  clientSecret: string;
  publishableKey: string;
};

async function send<T>(path: string, init?: RequestInit): Promise<T> {
  const response = await fetch(`${BASE_URL}/${path}`, init);
  if (response.status !== 200) {
    // Use the backend's message when the response has one
    const body = await response.json().catch(() => null);
    throw new Error(body?.error ?? `The server returned HTTP ${response.status}.`);
  }
  return response.json();
}

export const Backend = {
  fetchPrices: () => send<Record<string, string>>('prices'),

  createSubscription: (plan: string, variationId: string) =>
    send<Subscription>('subscriptions', {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        // add your authentication header
      },
      body: JSON.stringify({ plan, variationId }),
    }),
};
```

## Flow içindeki PaymentSheet'i açma \{#open-paymentsheet-from-the-flow\}

Uygulamanız, flow içindeki bir düğme özel bir eylem tetiklediğinde PaymentSheet'i açar ve ödeme başarılı olduğunda flow'u kapatır:

1. Özel action ID'sini bir plana eşleyin. Uygulamanız backend'i beklerken veya PaymentSheet gösterilirken dokunmalar, bağlantılar ve flow'un kapat düğmesi yoksayılır. Böylece tek bir dokunuş tek bir abonelik oluşturur.
2. Backend'inizden bir abonelik isteyin ve planı ile flow'un `variationId` değerini gönderin.
3. PaymentSheet'i flow'un üzerinde gösterin ve sonucunu işleyin:
   - **Completed**: Flow'u kapatın. Kapandıktan sonra [access level'ın açılmasını bekleyin](#unlock-access-after-the-payment).
   - **Canceled**: Hiçbir şey yapmayın. Kullanıcı flow'da kalır ve başka bir plan seçebilir.
   - **Failed**: Hatayı gösterin. Kullanıcı flow'da kalır ve tekrar deneyebilir.
4. Flow'un kapat düğmesini, bağlantıları ve hataları işleyin. Ayarladığınız handler, o olay için SDK'nın varsayılan handler'ının yerini alır. Varsayılan handler'lar bağlantıları açar; modal sunumda ise kapat düğmesine ve hatalara karşılık flow'u kapatır.
5. Özel action handler'ında ödemeyi beklemeyin ve handler'dan `false` döndürün. Modal sunumda, `true` döndüren bir handler flow'u kapatır; `async` bir handler da promise döndürdüğü için flow'u kapatır.

2. ve 3. adımlar React bileşeni ve modal sunum için aynıdır, bu nedenle bu kılavuz bunları tek bir sınıfta ele alır:

```typescript showLineNumbers title="React Native"
  initPaymentSheet,
  initStripe,
  PaymentSheetError,
  presentPaymentSheet,
} from '@stripe/stripe-react-native';

/** What the checkout needs from the screen that shows the flow */
export type CheckoutHost = {
  isFlowOpen: () => boolean;
  showError: (message: string) => void;
};

export class StripeCheckout {
  // Custom action IDs from the flow, mapped to your backend's plan keys
  static readonly plans: Record<string, string> = {
    buy_stripe_monthly: 'monthly',
    buy_stripe_annual: 'annual',
  };

  private paying = false;

  get isPaying(): boolean {
    return this.paying;
  }

  /** Opens PaymentSheet for a plan over the flow. Resolves to `true` when the user paid. */
  async pay(plan: string, variationId: string, host: CheckoutHost): Promise<boolean> {
    if (this.paying) return false;
    this.paying = true;

    try {
      const subscription = await Backend.createSubscription(plan, variationId);
      // The flow may have closed while the backend responded
      if (!host.isFlowOpen()) return false;

      await initStripe({ publishableKey: subscription.publishableKey });
      const { error: initError } = await initPaymentSheet({
        paymentIntentClientSecret: subscription.clientSecret,
        merchantDisplayName: 'YOUR_BUSINESS_NAME',
        // iOS: for payment methods that redirect to another app, such as bank apps
        returnURL: 'your-app://stripe-redirect',
      });
      if (initError) {
        host.showError(initError.message);
        return false;
      }

      const { error } = await presentPaymentSheet();
      if (!error) {
        return true;
      }
      if (error.code !== PaymentSheetError.Canceled) {
        host.showError(error.message);
      }
      return false; // the user stays on the flow
    } catch (error) {
      host.showError(error instanceof Error ? error.message : String(error));
      return false;
    } finally {
      this.paying = false;
    }
  }
}
```

iOS'ta PaymentSheet, ödeme yöntemleri başka bir uygulama açtıktan sonra dönüş URL'si aracılığıyla uygulamanıza geri döner. URL şemasını uygulamanıza kaydedin; bunun için Stripe belgelerindeki [Dönüş URL'si ayarlama](https://docs.stripe.com/payments/accept-a-payment?platform=react-native#react-native-set-up-return-url) bölümüne bakın ve uygulama bu URL ile açıldığında URL'yi Stripe'a iletin. Android'de dönüş URL'sine gerek yoktur.

```typescript showLineNumbers title="React Native"

// Call this hook in your root component
export function useStripeReturnURL() {
  useEffect(() => {
    const forward = (url: string | null) => {
      if (url) void handleURLCallback(url);
    };
    void Linking.getInitialURL().then(forward);
    const subscription = Linking.addEventListener('url', ({ url }) => forward(url));
    return () => subscription.remove();
  }, []);
}
```

Ardından flow'u sunun ve aksiyonlarını `StripeCheckout`'a aktarın:

<Tabs groupId="presentation-method" queryString>
<TabItem value="platform" label="React component" default>

Flow'u [`AdaptyFlowView` bileşeni](react-native-present-paywalls#react-component) ile render edin ve handler'ları prop olarak geçirin. Bileşen, handler'ların döndürdüğü değerleri dikkate almaz; bu nedenle flow'u kapatmak için bileşeni render etmeyi durdurun:

```typescript showLineNumbers title="React Native (TSX)"

export function MembershipScreen() {
  const [stripeFlow, setStripeFlow] = useState<StripeFlow | null>(null);
  const [checkout] = useState(() => new StripeCheckout());
  const isLoadingFlow = useRef(false);
  const isFlowOpen = useRef(false);

  // The screen can close while the backend responds, for example on Android back navigation
  useEffect(() => () => {
    isFlowOpen.current = false;
  }, []);

  const host: CheckoutHost = {
    isFlowOpen: () => isFlowOpen.current,
    showError: (message) => Alert.alert("The payment didn't go through", message),
  };

  function closeFlow() {
    isFlowOpen.current = false;
    setStripeFlow(null);
  }

  async function showStripeFlow() {
    if (isLoadingFlow.current) return;
    isLoadingFlow.current = true;

    try {
      const loadedFlow = await loadStripeFlow();
      isFlowOpen.current = true;
      setStripeFlow(loadedFlow);
    } catch (error) {
      // handle the error
    } finally {
      isLoadingFlow.current = false;
    }
  }

  async function payAndClose(plan: string, variationId: string) {
    if (!(await checkout.pay(plan, variationId, host))) return;
    closeFlow();
    await unlockAfterPayment();
  }

  if (!stripeFlow) {
    return <Button title="Become a member" onPress={() => void showStripeFlow()} />;
  }

  return (
    <AdaptyFlowView
      flow={stripeFlow.flow}
      params={stripeFlow.params}
      style={{ flex: 1 }}
      onCloseButtonPress={() => {
        if (!checkout.isPaying) closeFlow();
      }}
      onUrlPress={(url, openIn) => {
        if (checkout.isPaying) return;
        adapty.openWebUrl(url, openIn).catch(() => {
          // handle the error
        });
      }}
      onError={() => {
        // Keep the flow, and PaymentSheet over it, while the user pays.
        // Otherwise stop rendering the flow, and show your own content.
        if (!checkout.isPaying) closeFlow();
      }}
      onCustomAction={(actionId) => {
        const plan = StripeCheckout.plans[actionId];
        if (!plan) return;
        payAndClose(plan, stripeFlow.flow.variationId).catch(() => {
          // handle the error
        });
      }}
    />
  );
}

async function unlockAfterPayment() {
  if (await waitForAccess()) {
    // unlock the service
  } else {
    // tell the user that the payment is processing, and how to reach your support
  }
}
```

</TabItem>
<TabItem value="standalone" label="Modal presentation">

[`createFlowView`](react-native-present-paywalls#modal-presentation) ile view'i oluşturun, olay işleyicilerini ayarlayın ve sunun. Hataları, view'in iOS ve Android'de flow'un üzerinde diyalog açan [`showDialog`](react-native-present-paywalls#show-dialog) metoduyla gösterin. Android'de SDK 4.3.0'dan önceki sürümlerde bir React Native uyarısı flow'un arkasında açılır.

```typescript showLineNumbers title="React Native"

const checkout = new StripeCheckout();
let isLoadingFlow = false;

export async function showStripeFlow() {
  if (isLoadingFlow) return;
  isLoadingFlow = true;

  try {
    const { flow, params } = await loadStripeFlow();
    const view = await createFlowView(flow, params);

    const host: CheckoutHost = {
      // The handlers below don't close the flow while the user pays
      isFlowOpen: () => true,
      showError: (message) => {
        view
          .showDialog({
            title: "The payment didn't go through",
            content: message,
            primaryActionTitle: 'OK',
          })
          .catch(() => {
            // handle the error
          });
      },
    };

    async function payAndClose(plan: string) {
      if (!(await checkout.pay(plan, flow.variationId, host))) return;
      try {
        await view.dismiss();
      } finally {
        // The user paid, so unlock even if the flow fails to close
        await unlockAfterPayment();
      }
    }

    view.setEventHandlers({
      onCloseButtonPress: () => !checkout.isPaying,
      onUrlPress(url, openIn) {
        if (!checkout.isPaying) {
          adapty.openWebUrl(url, openIn).catch(() => {
            // handle the error
          });
        }
        return false;
      },
      // Keep the flow, and PaymentSheet over it, while the user pays
      onError: () => !checkout.isPaying,
      onCustomAction(actionId) {
        const plan = StripeCheckout.plans[actionId];
        if (plan) {
          payAndClose(plan).catch(() => {
            // handle the error
          });
        }
        return false;
      },
    });

    await view.present();
  } catch (error) {
    // handle the error
  } finally {
    isLoadingFlow = false;
  }
}

async function unlockAfterPayment() {
  if (await waitForAccess()) {
    // unlock the service
  } else {
    // tell the user that the payment is processing, and how to reach your support
  }
}
```

</TabItem>
</Tabs>

Flow'unuz aynı zamanda App Store ürünleri de satıyorsa, satın alma işlemlerini [Flow olaylarını yönetme](react-native-handling-events-1) bölümünde açıklandığı gibi satın alma işleyicilerinde ele alın.

## Ödeme sonrası erişimi açma \{#unlock-access-after-the-payment\}

Ödeme sonrasında Adapty, Stripe'ın webhook'unu alır ve birkaç saniye içinde access level'ı tanımlar. SDK, profili dakikada bir yeniler; bu nedenle access level etkin olana kadar profili sorgulamaya devam edin:

```typescript showLineNumbers title="React Native"

export async function waitForAccess(): Promise<boolean> {
  for (let attempt = 1; attempt <= 20; attempt++) {
    try {
      const profile = await adapty.getProfile();
      if (profile.accessLevels?.['YOUR_ACCESS_LEVEL']?.isActive) {
        return true;
      }
    } catch {
      // try again
    }
    await new Promise<void>((resolve) => setTimeout(resolve, 3000));
  }
  return false;
}
```

Access level genellikle birkaç saniye içinde aktif olur. 60 saniye sonra hâlâ aktif değilse, [Stripe'ın webhook ayarları](https://dashboard.stripe.com/webhooks) üzerinden Adapty webhook endpoint'ine yapılan teslimatları kontrol edin.

Ödeme sonrası bir karşılama ekranı gibi bir onay göstermek istiyorsanız, bunu access level aktif olduğunda uygulamanızdan gösterin. Ekranı ayrı bir flow olarak da oluşturabilir, kendi placement'ına ekleyebilir ve ilk flow kapandıktan sonra gösterebilirsiniz. Bunun nasıl yapıldığını [Satın alma sonuçlarına yanıt verme](respond-to-purchase-outcomes) bölümünde bulabilirsiniz.

## Kullanıcıların aboneliği yönetmesine izin verin \{#let-users-manage-the-subscription\}

Stripe aboneliği, iOS Ayarları'ndaki kullanıcının App Store abonelikleri arasında veya Google Play aboneliklerinde görünmez. Kullanıcıların iptal etmesine veya ödeme yöntemini değiştirmesine izin vermek için uygulamanıza, örneğin hesap ekranına, [Stripe müşteri portalı](https://docs.stripe.com/customer-management)'nı açan bir düğme ekleyin. Backend'iniz, kullanıcının Stripe müşterisi için bir portal oturumu oluşturur ve URL'sini döndürür.

Bir kullanıcı iptal ettiğinde, Stripe Adapty'ye bildirim gönderir ve Adapty access level'ı günceller. Adapty'nin anlık ve dönem sonu iptallerini nasıl ele aldığı hakkında bilgi için [İptaller](stripe#cancellations) bölümüne bakın.

## Entegrasyonu test edin \{#test-the-integration\}

Adapty uygulamanıza bağlı Stripe'ın test modunu kullanın:

1. Uygulamanızı iOS ve Android'de, Stripe'a bağladığınız Adapty uygulamasının Adapty SDK anahtarıyla çalıştırın.
2. Flow'u açın. Butonlar, özel etiketlerin başlangıç değerlerini değil, uygulamanızın ilettiği fiyatları göstermelidir.
3. Bir Stripe plan butonuna dokunun. PaymentSheet'te Stripe [test kartıyla](https://docs.stripe.com/testing) `4242 4242 4242 4242`, gelecekte herhangi bir son kullanma tarihi ve herhangi bir CVC ile ödeme yapın.
4. Flow'un kapandığını ve profilin access level'ının birkaç saniye içinde aktif hale geldiğini doğrulayın.
5. Adapty Kontrol Paneli'nde [**Event Feed**](event-feed) sayfasını açın. Satın alma olayında `store`: `stripe`, flow'unuzun `flow_id` ve `flow_name` değerleri, uygulamanızın gönderdiği `variationId`'ye eşit bir `flow_variation_id` ve `developer_id` alanında placement ID'niz yer almalıdır. Stripe satın alımlarında `variation_id`, `flow_variation_id` ile aynı değere sahiptir.

Test modu satın almaları `Sandbox` ortamına sahiptir. Bunlar Event Feed'de ve profilde görünür, ancak yalnızca üretim satın almalarını sayan analizlerde veya flow'un metriklerinde görünmez.

Satın alma Adapty'de görünmüyorsa, uygulamanızın Stripe'a bağlı Adapty uygulamasının SDK anahtarını kullandığını, Stripe fiyatı için bir Adapty ürününün mevcut olduğunu ve aboneliğin meta verilerinde `customer_user_id` bulunduğunu doğrulayın. Ayrıca Stripe entegrasyon kılavuzundaki [Sorun Giderme](stripe#troubleshooting) bölümüne bakın.

## Sınırlamalar \{#limitations\}

- **Flow, Stripe sonucunu almaz**: Flow, başarılı, iptal edilmiş veya başarısız bir Stripe ödemesinin ardından başka bir ekrana geçemez. Uygulamanız flow'u kapatır ve sıradaki içeriği gösterir.
- **Özel etiketlerdeki fiyatlar metindir**: Flow, özel etiket değerini uygulamanızın ilettiği şekilde gösterir; haftaya düşen fiyat veya indirim gibi başka değerleri bu değerden hesaplamaz. Bu değerlerin her birini ayrı bir etiket olarak iletin.
- **Özel etiket değerleri flow açıkken sabit kalır**: Yeni fiyatları göstermek için flow'u yeniden yükleyin.