@netappsng/react-native-netappspaysdk
v0.2.1
Published
test
Downloads
418
Readme
@netappsng/react-native-netappspaysdk
Netapps payment sdk
Installation
npm install @netappsng/react-native-netappspaysdk
or
yarn add @netappsng/react-native-netappspaysdk
Note: For IOS Add Don't forget to added this to Info.plist ->
<key>LSApplicationQueriesSchemes</key>
<array>
<string>tel</string>
<string>telprompt</string>
</array>
For Android Add the following in 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" />
Find File and update android/build.gradle in buildscript {
}
add the following
allprojects {
repositories {
maven {
url "https://jitpack.io"
credentials { username "jp_iu426m6k793tts6nisfjg8at42" }
}
}
}
<!-- Add NFC Permission -->
<uses-permission android:name="android.permission.NFC" />
<uses-feature android:name="android.hardware.nfc" android:required="false" />
Note: if you are using expo use this npm sdk instead expo-react-native-netappspaysdk
Example Usage
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: '[email protected]',
fullname: 'Nwoko Ndubueze',
narration: 'Testing',
};
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, 'copy ussd code');
}
});
const handleMakePayment = () => {
initPayment(payload);
};
return (
<NetAppsPayProvider publicKey="Netappspaykey">
<Button onPress={handleMakePayment}>
<Label>Make Payment</Label>
</Button>
</NetAppsPayProvider>
);
}