Skip to content

Commit d4e6d19

Browse files
committed
Update readme integration code as per v2 changes
1 parent 04c2b72 commit d4e6d19

File tree

2 files changed

+32
-41
lines changed

2 files changed

+32
-41
lines changed

README.md

+31-40
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,52 @@ A React Native SDK for decentralised applications to onboard their global user b
55
## Installation
66

77
```sh
8-
# Using yarn
9-
yarn add @transak/react-native-sdk
10-
11-
# Using npm
12-
npm install @transak/react-native-sdk
8+
npm i @transak/react-native-sdk
139
```
1410

1511
Install these required peer dependencies to facilitate auto-linking.
1612

1713
```sh
18-
# Using yarn
19-
yarn add react-native-webview
20-
yarn add react-native-inappbrowser-reborn
21-
yarn add @react-native-community/netinfo
22-
23-
# Using npm
24-
npm install react-native-webview
25-
npm install react-native-inappbrowser-reborn
26-
npm install @react-native-community/netinfo
14+
npm i react-native-webview
15+
npm i react-native-inappbrowser-reborn
16+
npm i @react-native-community/netinfo
2717
```
2818

2919
## Example usage
3020

31-
```js
32-
import TransakWebView from '@transak/react-native-sdk';
21+
```tsx
22+
import { TransakWebView, Environments, Events, TransakConfig, EventTypes, Order } from '@transak/react-native-sdk';
3323

34-
function TransakReactNativeSdkIntegration() {
35-
const transakEventHandler = (event, data) => {
24+
function TransakWebViewIntegration() {
25+
const transakConfig: TransakConfig = {
26+
apiKey: '<your-api-key>', // (Required)
27+
environment: Environments.STAGING/Environments.PRODUCTION, // (Required)
28+
// .....
29+
// For the full list of query params refer Props section below
30+
};
31+
const onTransakEventHandler = (event: EventTypes, data: Order) => {
3632
switch(event) {
37-
case 'ORDER_PROCESSING':
38-
console.log(data);
33+
case Events.ORDER_CREATED:
34+
console.log(event, data);
3935
break;
4036

41-
case 'ORDER_COMPLETED':
42-
console.log(data);
37+
case Events.ORDER_PROCESSING:
38+
console.log(event, data);
39+
break;
40+
41+
case Events.ORDER_COMPLETED:
42+
console.log(event, data);
4343
break;
4444

4545
default:
46-
console.log(data);
46+
console.log(event, data);
4747
}
4848
};
4949

5050
return (
5151
<TransakWebView
52-
queryParams={{
53-
apiKey: '<your-api-key>',
54-
environment: '<environment: STAGING/PRODUCTION>',
55-
// .....
56-
// For the full list of query params refer Props section below
57-
}}
58-
onTransakEventHandler={transakEventHandler}
59-
60-
style={} // react-native-webview prop
61-
onLoadStart={} // react-native-webview prop
62-
onLoadEnd={} // react-native-webview prop
52+
transakConfig={transakConfig}
53+
onTransakEvent={onTransakEventHandler}
6354
// .....
6455
// For the full list of react-native-webview props refer Props section below
6556
/>
@@ -69,12 +60,12 @@ function TransakReactNativeSdkIntegration() {
6960

7061
### Props
7162

72-
| Prop | Description |
73-
|:----------------------|:--------------------------------------------------------------------------------------------------------------|
74-
| queryParams | Refer [here](https://docs.transak.com/docs/sdk) for the full list of query params |
75-
| onTransakEventHandler | Accepts callback function to listen to order related [events](https://docs.transak.com/docs/websocket-events) |
76-
77-
This component accepts most of the [react-native-webview props](https://github.com/react-native-webview/react-native-webview/blob/HEAD/docs/Reference.md), except the following: source, injectJavaScript, sharedCookiesEnabled, injectedJavaScript, injectedJavaScriptBeforeContentLoaded
63+
| Prop | Description |
64+
|:---------------|:------------------------------------------------------------------------------------------------------|
65+
| transakConfig | Refer [here](https://docs.transak.com/docs/sdk) for the full list of customisation options |
66+
| onTransakEvent | Callback function to listen to order related [events](https://docs.transak.com/docs/websocket-events) |
67+
<br />
68+
This component accepts most of the [react-native-webview props](https://github.com/react-native-webview/react-native-webview/blob/HEAD/docs/Reference.md), except the following: sharedCookiesEnabled, injectedJavaScript, injectedJavaScriptBeforeContentLoaded
7869

7970
## License
8071

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@transak/react-native-sdk",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "A React Native SDK for decentralised applications to onboard their global user base with fiat currency",
55
"type": "module",
66
"types": "lib/index.d.ts",

0 commit comments

Comments
 (0)