# SDK React-Native

## Installation

```groovy
npx expo install react-native-webview
npm install @kkiapay-org/react-native-sdk
```

## Utilisation

1. Importez le provider KKiaPay pour accéder à toutes les fonctionnalités du contexte

```groovy
// Dans le fichier App
import { KkiapayProvider } from '@kkiapay-org/react-native-sdk';

import TestComponent from './TestComponent';

export default function App() {
  return (
    <KkiapayProvider>
      <TestComponent />
    </KkiapayProvider>
  );
}
```

2. Utilisez le hook useKkiapay pour obtenir toutes les fonctions disponibles

```groovy
// Dans le composant -- TestComponent
import { useKkiapay } from '@kkiapay-org/react-native-sdk';
import { useEffect } from 'react';
import { Button, View } from 'react-native';

export default function TestComponent() {
  const { openKkiapayWidget, addSuccessListener, addFailedListener } = useKkiapay();

  useEffect(() => {
    addSuccessListener(data => {
      console.log('data ', data);
    });
    
    addFailedListener(data => {
      console.log('data ', data);
    });
  }, []);

  const openWidget = () => {
    openKkiapayWidget({
      amount: 4000,
      api_key: "xxxxxxxxxxxxxxxxxx",
      sandbox: true,
      email: "randomgail@gmail.com",
      phone: "97000000",
    });
  };

  return (
    <View>
      <Button title="Payer maintenant" onPress={openWidget} />
    </View>
  );
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kkiapay.me/v1/plugin-et-sdk/sdk-react-native.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
