0.5.1 • Published 7 months ago

@netappsng/react-native-netappspaysdk v0.5.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

NetApps Payment SDK for React Native — easily accept payments via card, USSD, transfer, PayAttitude, and more.


Table of Contents


Installation

Install the SDK using either npm or yarn:

npm install @netappsng/react-native-netappspaysdk

or

yarn add @netappsng/react-native-netappspaysdk

Setup Instructions

iOS Setup

In your project's Info.plist, add the following to allow phone call functionality:

<key>LSApplicationQueriesSchemes</key>
<array>
  <string>tel</string>
  <string>telprompt</string>
</array>

Android Setup

Add the following permissions to your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

If you plan to use NFC payments, also add:

<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc" android:required="false" />

Using NetApps POS Server (Optional)

If you want to connect to the NetApps POS Payment solution:

  1. Install the POS plugin:
npm install react-native-netappspay-pos-plugins
  1. In your android/build.gradle, before apply plugin: "com.facebook.react.rootproject", add:
apply from: "../node_modules/react-native-netappspay-pos-plugins/android/NetappspayRepos.gradle"
  1. Then continue with:
apply plugin: "com.facebook.react.rootproject"

Example Usage

Here's how you can integrate and trigger a payment:

import * as React from 'react';
import { NetAppsPayProvider, useNetAppsPay } from '@netappsng/react-native-netappspaysdk';

const payload = {
  currency: 'NGN',
  amount: 100,
  phone: "081******",
  tx_ref: "1234",
  paymentChannels: 'card,ussd,transfer,payatitude',
  email: 'nwokolawrence6@gmail.com',
  fullname: 'Nwoko Ndubueze',
  narration: 'Testing',
// if pos is enabled
  device: "true" | "false", // this is to choose to use external device or not
  longitude: "11",
  latitude: "233"
};

export default function App() {
  const { initPayment, cancelPayment, closePaymentModal } = useNetAppsPay({
    onFailed: (response) => {
      console.log(response, 'Failed');
    },
    onSuccessful: (response) => {
      console.log(response, 'Successful');
    },
    onCopyUssdCode: (ussdCode) => {
      console.log(ussdCode, 'Copied USSD code');
    }
  });

  const handleMakePayment = () => {
    initPayment(payload);
  };

  return (
    <NetAppsPayProvider publicKey="Netappspaykey">
      <Button onPress={handleMakePayment}>
        <Label>Make Payment</Label>
      </Button>
    </NetAppsPayProvider>
  );
}

Expo Support

If you are using Expo, install the Expo-compatible SDK instead:

npm install @netappsng/expo-react-native-netappspaysdk

➡️ View @netappsng/expo-react-native-netappspaysdk on npm

0.3.0

8 months ago

0.5.0

7 months ago

0.5.1

7 months ago

0.4.1

7 months ago

0.4.0

8 months ago

0.2.1

1 year ago

0.1.80

2 years ago

0.1.74

2 years ago

0.1.76

2 years ago

0.1.77

2 years ago

0.1.70

2 years ago

0.1.72

2 years ago

0.1.68

2 years ago

0.1.66

2 years ago

0.1.65

2 years ago

0.1.52

2 years ago

0.1.53

2 years ago

0.1.54

2 years ago

0.1.55

2 years ago

0.1.56

2 years ago

0.1.57

2 years ago

0.1.58

2 years ago

0.1.50

2 years ago

0.1.51

2 years ago

0.1.63

2 years ago

0.1.64

2 years ago

0.1.60

2 years ago

0.1.61

2 years ago

0.1.62

2 years ago

0.1.49

2 years ago

0.1.48

2 years ago

0.1.30

3 years ago

0.1.31

3 years ago

0.1.32

3 years ago

0.1.33

3 years ago

0.1.34

3 years ago

0.1.35

3 years ago

0.1.36

3 years ago

0.1.37

3 years ago

0.1.27

3 years ago

0.1.28

3 years ago

0.1.29

3 years ago

0.1.41

3 years ago

0.1.42

3 years ago

0.1.43

3 years ago

0.1.44

3 years ago

0.1.46

3 years ago

0.1.47

3 years ago

0.1.25

3 years ago

0.1.26

3 years ago

0.1.40

3 years ago

0.1.38

3 years ago

0.1.39

3 years ago

0.1.21

3 years ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.23

3 years ago

0.1.12

3 years ago

0.1.24

3 years ago

0.1.13

3 years ago

0.1.14

3 years ago

0.1.15

3 years ago

0.1.16

3 years ago

0.1.17

3 years ago

0.1.18

3 years ago

0.1.19

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago