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

# React Native

> Payaza React Native Library.

## Installation

```
npm install react-native-payaza
```

```
yarn add react-native-payaza
```

### Installing Dependecies

Install React Native Webview

```
npm install react-native-webview
```

For Bear React Native flow

```
npm install --save @react-native-clipboard/clipboard
```

### Link Native Dependecies

From react-native 0.60 autolinking will take care of the link step but don't forget to run pod install
React Native modules that include native Objective-C, Swift, Java, or Kotlin code have to be "linked" so that the compiler knows to include them in the app.

```
react-native link react-native-webview
```

## Usage

Import the package

```
import Payaza, {
  type IPayaza,
  type PayazaErrorResponse,
  type PayazaSuccessResponse,
  PayazaConnectionMode,
} from 'react-native-payaza'
// ...
const payaza = React.useRef<IPayaza>(null);
// ...
const payNow = () => {
  payaza.current?.createTransaction({
    amount: Number(110),
    connectionMode: PayazaConnectionMode.LIVE_CONNECTION_MODE,
    email: "example@example.com",
    firstName: "<first name>",
    lastName: "<last name>",
    phoneNumber: "<+12345678900>",
    currencyCode: 'NGN',
    transactionReference: "transaction_reference",
  });
}
  const handleError = (response: PayazaErrorResponse) => {
    Alert.alert(response.data.message, 'Error Occurred');
  };
  const handleSuccess = (response: PayazaSuccessResponse) => {
    Alert.alert(
      response.data.message,
      `Transaction reference {$response.data.payaza_reference}`
    );
  };
// ...
return (
  <View>
    <TouchableOpacity onPress={payNow}>
      <Text style={styles.buttonText}>Pay Now</Text>
    </TouchableOpacity>
    <Payaza
      onSuccess={handleSuccess}
      onError={handleError}
      onClose={console.log}
      merchantKey="<public key>"
      ref={payaza}
    />
  </View>
)
```

### Arguments

| Parameter            | Description                                                                                                                               | Format |
| -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ------ |
| email                | The email address of the customer.                                                                                                        | string |
| firstName            | The first name of the customer.                                                                                                           | string |
| lastName             | The last name of the customer.                                                                                                            | string |
| phone\_number        | The phone number of the customer. It must be international standard i.e. +2348012345678                                                   | string |
| transactionReference | This is the transaction reference that you generated for the transaction. This unique and no 2 transactions can have the same reference.. | string |
| merchantKey          | This is your public API Key.                                                                                                              | string |
| connectionMode       | Mode of session (LIVE\_CONNECTION\_MODE or TEST\_CONNECTION\_MODE).                                                                       | string |
| amount               | The amount the customer is expected to pay.                                                                                               | amount |
| currencyCode         | It refers to the code of the currency.(NGN, USD etc.).                                                                                    | string |
