Skip to main content

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

ParameterDescriptionFormat
emailThe email address of the customer.string
firstNameThe first name of the customer.string
lastNameThe last name of the customer.string
phone_numberThe phone number of the customer. It must be international standard i.e. +2348012345678string
transactionReferenceThis is the transaction reference that you generated for the transaction. This unique and no 2 transactions can have the same reference..string
merchantKeyThis is your public API Key.string
connectionModeMode of session (LIVE_CONNECTION_MODE or TEST_CONNECTION_MODE).string
amountThe amount the customer is expected to pay.amount
currencyCodeIt refers to the code of the currency.(NGN, USD etc.).string