Flutterwave's native SDK in React Native without WebView
npm install react-native-flutterwave-sdkThis library uses the official flutterwave's native android sdk and ios sdk


``sh`
npm install react-native-flutterwave-sdk
or using yarn
`sh`
yarn add react-native-flutterwave-sdk
`js
import { initializeRaveSdk } from 'react-native-flutterwave-sdk';
return (
title={'Make Payment'}
onPress={async () => {
try {
// this will display flutterwave payment page
const response = await initializeRaveSdk({
ref: 'unique_txn_ref...', // this is your transaction reference
publicKey: 'FLWPUBK_TEST-XXXXXXXXXXXXXXX-X',
encryptionKey: 'FLWSECK_TESTxxxxxxxxx',
amount: 3500,
currency: 'NGN',
email: 'string',
fName: 'Richard',
lName: 'Hendricks',
bankTransferPayments: { enabled: true },
acceptCardPayments: true,
acceptAccountPayments: true,
acceptMpesaPayments: true,
acceptUssdPayments: true,
acceptBarterPayments: true,
isStagingEnv: true,
allowSaveCardFeature: true,
shouldDisplayFee: true,
showStagingLabel: true,
});
if (response.status === 'success') {
// handle payment completion
}
} catch (e) {
// handle error here
console.error(e);
}
}}
/>
);
`
Please Note: calling toggleDarkMode(boolean) method will change color scheme of your entire app
`js
import { toggleDarkMode } from 'react-native-flutterwave-sdk';
const [isDarkMode, setDarkMode] = useState();
useEffect(() => {
toggleDarkMode(!!isDarkMode);
}, [isDarkMode]);
return (
title={'Toggle theme'}
onPress={() => {
setDarkMode(!isDarkMode);
}}
/>
);
`
You can apply custom styling to Flutterwave's Drop Ui.
To do this, you need to provide styling in your styles.xml in the android folder of your react native app.
You can edit the following styling example to your own taste
`xml`
then you can provide the name of your styling to the argument of initializeRaveSdk()
`js`
initializeRaveSdk({
...props,
theme: 'MyCustomRaveTheme',
});
MIT