React Native
Transak React Native SDK
TipCamera Permission: Please ensure required camera permissions are configured in AndroidManifest.xml (Android) & Info.plist (iOS)
You can integrate Transak into your React Native project using our React Native SDK.
Required Permissions
// update permissions in the AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /><key>NSCameraUsageDescription</key>
<string>Camera Access</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location Access</string>
<key>NSMicrophoneUsageDescription</key>
<string>Mic Access</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Photo Library Access</string>Installation - Without Expo
Without Exponpm i @transak/react-native-sdkInstall these required peer dependencies to facilitate auto-linking.
npm i react-native-webview
npm i react-native-inappbrowser-reborn
npm i @react-native-community/netinfoInstallation - With Expo
With Exponpm i @transak/ui-expo-sdkInstall these required peer dependencies to facilitate auto-linking.
npm i react-native-webview
npm i expo-web-browser
npm i @react-native-community/netinfoExample usage
Call the Create Widget URL with the widget parameters to securely generate a widgetUrl, and use it in the code as illustrated.
import {
TransakWebView,
Events,
TransakConfig,
OnTransakEvent,
Order,
} from '@transak/react-native-sdk';
function TransakWebViewIntegration() {
const transakConfig: TransakConfig = {
widgetUrl: "https://global-stg.transak.com?apiKey=YOUR_API_KEY&sessionId=<YOUR_SESSION_ID>",
referrer: "https://your-domain.com"
};
const onTransakEventHandler: OnTransakEvent = (event, data) => {
switch (event) {
case Events.TRANSAK_WIDGET_INITIALISED:
console.log('Widget initialized:', event, data);
break;
case Events.TRANSAK_ORDER_CREATED:
console.log('Order created:', event, data);
break;
case Events.TRANSAK_ORDER_SUCCESSFUL:
console.log('Order successful:', event, data);
break;
case Events.TRANSAK_ORDER_FAILED:
console.log('Order failed:', event, data);
break;
case Events.TRANSAK_WIDGET_CLOSE:
console.log('Widget closed:', event, data);
break;
default:
console.log('Widget event:', event, data);
}
};
return (
<TransakWebView
transakConfig={transakConfig}
onTransakEvent={onTransakEventHandler}
/>
);
}
import {
TransakWebView,
Events,
TransakConfig,
OnTransakEvent,
Order,
} from '@transak/ui-expo-sdk';
function TransakWebViewIntegration() {
const transakConfig: TransakConfig = {
widgetUrl: "https://global-stg.transak.com?apiKey=YOUR_API_KEY&sessionId=<YOUR_SESSION_ID>",
referrer: "https://your-domain.com"
};
const onTransakEventHandler: OnTransakEvent = (event, data) => {
switch (event) {
case Events.TRANSAK_WIDGET_INITIALISED:
console.log('Widget initialized:', event, data);
break;
case Events.TRANSAK_ORDER_CREATED:
console.log('Order created:', event, data);
break;
case Events.TRANSAK_ORDER_SUCCESSFUL:
console.log('Order successful:', event, data);
break;
case Events.TRANSAK_ORDER_FAILED:
console.log('Order failed:', event, data);
break;
case Events.TRANSAK_WIDGET_CLOSE:
console.log('Widget closed:', event, data);
break;
default:
console.log('Widget event:', event, data);
}
};
return (
<TransakWebView
transakConfig={transakConfig}
onTransakEvent={onTransakEventHandler}
/>
);
}
Props
| Prop | Description |
|---|---|
| transakConfig | Supports widgetUrl and referrer as mandatory parameters |
| onTransakEvent | Callback function to listen to events mentioned below. |
Supported Events
| Event Name | Description |
|---|---|
TRANSAK_WIDGET_INITIALISED | Widget initialised with query params |
TRANSAK_ORDER_CREATED | Order created by user |
TRANSAK_ORDER_SUCCESSFUL | Order is successful |
TRANSAK_ORDER_CANCELLED | Order is cancelled |
TRANSAK_ORDER_FAILED | Order is failed |
TRANSAK_WALLET_REDIRECTION | Widget is about to redirect to passed url |
TRANSAK_WIDGET_CLOSE | Widget is about to close |
React Native WebView
TipCamera Permission: Please ensure the below:
- Required camera permissions are configured in AndroidManifest.xml(Android) & Info.plist (iOS)
- Required camera permissions are passed to Webview
- If you are integrating Transak in an iFrame inside Webview please ensure the required camera permissions are passed to the iFrame
We highly recommend using our React Native SDK package for smooth functioning of camera & payment permissions.
npm i react-native-webviewimport { WebView } from 'react-native-webview';<WebView
source={{ url: 'https://global.transak.com?apiKey=<YOUR_API_KEY>&sessionId=<YOUR_SESSION_ID>' }}
enableApplePay
allowsInlineMediaPlayback
mediaPlaybackRequiresUserAction={false}
/>Please avoid passing any of these props to the WebView component, as it will result in Apple Pay not working: sharedCookiesEnabled, injectedJavaScript, injectedJavaScriptBeforeContentLoaded
Note:- Google Pay works only with Transak React Native SDK integration for Mobile
Updated 1 day ago