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

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# Recursos avançados

> Otimização de desempenho, deep linking e configurações específicas de cada plataforma para React Native.

> [!NOTE]
>
> **Esta página documenta um SDK legado.** Vai começar uma nova integração? Use o [Yuno SDK](https://docs.y.uno/pt-br/docs/yuno-sdk/get-started.md). Já usa um SDK legado? Siga o [guia de migração](https://docs.y.uno/pt-br/docs/yuno-sdk/migration/overview.md).
>
> O novo **Yuno SDK** (Web v2.x, iOS v3.x, Android v3.x, React Native v2.x) substitui os SDKs Full, Lite, Seamless, Render, Headless e Secure Fields por uma única API em todas as plataformas. Os SDKs legados continuam com suporte em paralelo durante a transição, e a descontinuação deles está prevista para **2027**. Entre em contato com o seu Account Manager para planejar a migração.

> [!WARNING]
>
> **Orientation: Choosing Your Integration Flow**, before you begin, please review the [Official Integration Flow](https://docs.y.uno/docs/sdks/overview/understanding-flows.md).
>
> * **Standard Flow ([Full Checkout](https://docs.y.uno/docs/sdks/full-checkout/web-payments))**: Recommended for most merchants. Yuno handles the UI, security, and automatic updates for payment methods.
> * **Custom Flow (This SDK)**: Use this only if you require full control over the UX. **Note**: You will be responsible for manually handling payment statuses, 3DS transitions, and fraud routing data collection.

## Deep linking / retorno do navegador externo

Alguns fluxos de pagamento redirecionam os usuários para um navegador externo, incluindo desafios de autenticação 3DS, redirecionamentos de transferência bancária, pagamentos PIX e outros meios de pagamento alternativos. Trate o retorno deles ao seu app com os passos a seguir.

### Defina callback\_url na sessão de checkout

Inclua `callback_url` ao criar a sessão de checkout no seu backend:

```json theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
{
  "callback_url": "myapp://return"
}
```

### Configure os deep links

**iOS - Info.plist:**

```xml theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>CFBundleURLName</key>
        <string>com.yourapp</string>
        <key>CFBundleURLSchemes</key>
        <array>
            <string>myapp</string>
        </array>
    </dict>
</array>
```

**Android - AndroidManifest.xml:**

```xml theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
<activity android:name=".MainActivity">
    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data
            android:scheme="myapp"
            android:host="return" />
    </intent-filter>
</activity>
```

### Trate os deep links no react-native

```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
import { YunoSdk } from '@yuno-payments/yuno-sdk-react-native';
import { Linking } from 'react-native';
import { useEffect } from 'react';

function App() {
  useEffect(() => {
    // Handle initial URL (app opened from closed state)
    Linking.getInitialURL().then((url) => {
      if (url) {
        handleDeepLink(url);
      }
    });
    
    // Handle URL changes (app is running)
    const subscription = Linking.addEventListener('url', (event) => {
      handleDeepLink(event.url);
    });
    
    return () => {
      subscription.remove();
    };
  }, []);
  
  const handleDeepLink = async (url: string) => {
    // Check if it's a payment return URL
    if (url.startsWith('myapp://return')) {
      try {
        await YunoSdk.receiveDeeplink(url);
      } catch (error) {
        console.error('Error processing deep link:', error);
      }
    }
  };
}
```

### Continue o pagamento após o retorno

Depois de tratar o deep link, continue o fluxo de pagamento:

```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const handleDeepLink = async (url: string) => {
  if (url.startsWith('myapp://return')) {
    try {
      await YunoSdk.receiveDeeplink(url);
      
      // Continue payment flow
      await YunoSdk.continuePayment(
        checkoutSessionId,
        'US',
        true // show payment status
      );
    } catch (error) {
      console.error('Error:', error);
    }
  }
};
```

## Desempenho

### Carregamento lazy

Inicialize o SDK somente quando o usuário entrar no fluxo de pagamento, para economizar recursos.

```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const PaymentScreen = () => {
  const [yunoLoaded, setYunoLoaded] = useState(false);
  
  useEffect(() => {
    if (!yunoLoaded) {
      YunoSdk.initialize({
        apiKey: 'pk_test_key',
        countryCode: 'US',
      });
      setYunoLoaded(true);
    }
  }, []);
};
```

## Tratamento de erros

Escute o evento `onPaymentStatus` para tratar as falhas de forma adequada.

```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const subscription = YunoSdk.onPaymentStatus((state) => {
  if (state.status === 'FAILED') {
    Alert.alert('Error', 'Payment failed. Please try again.');
  }
});
```

## Configuração específica de cada plataforma

Trate as diferenças entre iOS e Android no seu app React Native.

### Configuração condicional

```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
import { Platform } from 'react-native';

await YunoSdk.initialize({
  apiKey: 'your-api-key',
  countryCode: 'US',
  ...(Platform.OS === 'ios' && {
    iosConfig: { /* iOS settings */ },
  }),
  ...(Platform.OS === 'android' && {
    androidConfig: { /* Android settings */ },
  }),
});
```

### Diferenças entre plataformas

| Recurso | iOS | Android |
| - | - | - |
| Leitura de cartão | Não disponível | Disponível |
| Deep links | Universal Links | Intent Filters |
| SO mínimo | iOS 15.1+ | API 21 (5.0)+ |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.