@gnosispay/pse-react-native 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -21
- package/lib/PSEWebView.js +6 -3
- package/lib/PSEWebView.tsx +6 -3
- package/lib/types.d.ts +4 -2
- package/lib/types.ts +5 -2
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -1,20 +1,24 @@
|
|
|
1
1
|
# PSE React Native
|
|
2
2
|
|
|
3
|
-
A React Native library that provides a secure WebView component for integrating Gnosis Pay
|
|
3
|
+
A React Native library that provides a secure WebView component for integrating Gnosis Pay PSE functionality into your mobile applications.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Setup
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
This guide assumes that you have already integrated PSE SDK into your web flow.
|
|
8
|
+
|
|
9
|
+
On your backend, you first need to host the static HTML wrapper for the PSE SDK client.
|
|
10
|
+
We have provided an [example HTML file](https://github.com/gnosispay/ui/blob/main/pse-backend-demo/src/static/native-webview.html) in our example for [backend integration](https://github.com/gnosispay/ui/blob/main/pse-backend-demo/).
|
|
11
|
+
|
|
12
|
+
We recommend putting this endpoint in the same application that serves the ephemeral tokens to your PSE integration, so you can easily inject that token into the frame.
|
|
13
|
+
|
|
14
|
+
Then you should pass the URL to this frame as `webViewUrl` parameter.
|
|
15
|
+
|
|
16
|
+
Refer to [PSE Docs](https://docs.gnosispay.com/cards/pse-integration) for all further details.
|
|
13
17
|
|
|
14
18
|
## Installation
|
|
15
19
|
|
|
16
20
|
```bash
|
|
17
|
-
npm install pse-react-native
|
|
21
|
+
npm install @gnosispay/pse-react-native
|
|
18
22
|
```
|
|
19
23
|
|
|
20
24
|
### Peer Dependencies
|
|
@@ -36,16 +40,16 @@ npx expo install react-native-webview
|
|
|
36
40
|
```tsx
|
|
37
41
|
import React, { useRef } from "react";
|
|
38
42
|
import { View, Button, Alert } from "react-native";
|
|
39
|
-
import { PSEWebView, PSEWebViewRef } from "pse-react-native";
|
|
43
|
+
import { PSEWebView, PSEWebViewRef } from "@gnosispay/pse-react-native";
|
|
40
44
|
|
|
41
45
|
export default function PaymentScreen() {
|
|
42
46
|
const webViewRef = useRef<PSEWebViewRef>(null);
|
|
43
47
|
|
|
44
48
|
const config = {
|
|
45
49
|
appId: "your-app-id",
|
|
46
|
-
|
|
47
|
-
cardToken: "
|
|
48
|
-
|
|
50
|
+
gnosisPayApiAuthToken: "users-gnosispay-api-token",
|
|
51
|
+
cardToken: "users-card-token",
|
|
52
|
+
webViewUrl: "https://pse-backend.v2.gnosispay.com/native-webview",
|
|
49
53
|
};
|
|
50
54
|
|
|
51
55
|
const handleError = (error: string) => {
|
|
@@ -100,9 +104,9 @@ export default function PaymentScreen() {
|
|
|
100
104
|
```tsx
|
|
101
105
|
interface PSEConfig {
|
|
102
106
|
appId: string; // Your application identifier
|
|
103
|
-
|
|
107
|
+
gnosisPayApiAuthToken: string; // Authentication token
|
|
104
108
|
cardToken: string; // Card-specific token
|
|
105
|
-
|
|
109
|
+
webViewUrl?: string; // Full URL where your PSE iframe is hosted
|
|
106
110
|
}
|
|
107
111
|
```
|
|
108
112
|
|
|
@@ -170,9 +174,9 @@ const handleError = (error: string) => {
|
|
|
170
174
|
```tsx
|
|
171
175
|
const config = {
|
|
172
176
|
appId: "your-prod-app-id",
|
|
173
|
-
|
|
177
|
+
gnosisPayApiAuthToken: "your-prod-auth-token",
|
|
174
178
|
cardToken: "your-prod-card-token",
|
|
175
|
-
|
|
179
|
+
webViewUrl: "https://pse-backend.v2.gnosispay.com/native-webview",
|
|
176
180
|
};
|
|
177
181
|
```
|
|
178
182
|
|
|
@@ -181,9 +185,9 @@ const config = {
|
|
|
181
185
|
```tsx
|
|
182
186
|
const config = {
|
|
183
187
|
appId: "your-staging-app-id",
|
|
184
|
-
|
|
188
|
+
gnosisPayApiAuthToken: "your-staging-auth-token",
|
|
185
189
|
cardToken: "your-staging-card-token",
|
|
186
|
-
|
|
190
|
+
webViewUrl: "https://pse-backend-staging.v2.gnosispay.com/native-webview",
|
|
187
191
|
};
|
|
188
192
|
```
|
|
189
193
|
|
|
@@ -239,11 +243,11 @@ This compiles the TypeScript source files and generates the distribution files i
|
|
|
239
243
|
|
|
240
244
|
- Verify your authentication tokens are valid
|
|
241
245
|
- Check network connectivity
|
|
242
|
-
- Ensure the
|
|
246
|
+
- Ensure the webViewUrl is accessible
|
|
243
247
|
|
|
244
248
|
**Authentication errors:**
|
|
245
249
|
|
|
246
|
-
- Double-check your appId,
|
|
250
|
+
- Double-check your appId, gnosisPayApiAuthToken, and cardToken
|
|
247
251
|
- Verify tokens haven't expired
|
|
248
252
|
- Contact your PSE provider for token validation
|
|
249
253
|
|
package/lib/PSEWebView.js
CHANGED
|
@@ -18,8 +18,9 @@ const PSEWebView = forwardRef(({ config, onError, onMessage, onLoad, style, test
|
|
|
18
18
|
// Send parameters to webview after it loads
|
|
19
19
|
const params = {
|
|
20
20
|
appId: config.appId.trim(),
|
|
21
|
-
|
|
21
|
+
gnosisPayApiAuthToken: config.gnosisPayApiAuthToken.trim(),
|
|
22
22
|
cardToken: config.cardToken.trim(),
|
|
23
|
+
elementType: config.elementType,
|
|
23
24
|
};
|
|
24
25
|
const message = JSON.stringify(params);
|
|
25
26
|
webViewRef.current?.postMessage(message);
|
|
@@ -51,8 +52,10 @@ const PSEWebView = forwardRef(({ config, onError, onMessage, onLoad, style, test
|
|
|
51
52
|
onError?.(errorMessage);
|
|
52
53
|
Alert.alert("PSE WebView Error", errorMessage);
|
|
53
54
|
};
|
|
54
|
-
const
|
|
55
|
-
|
|
55
|
+
const webViewUrl = config.webViewUrl;
|
|
56
|
+
if (!webViewUrl) {
|
|
57
|
+
throw new Error("webViewUrl is required");
|
|
58
|
+
}
|
|
56
59
|
return (<WebView ref={webViewRef} source={{ uri: webViewUrl }} style={[styles.webview, style]} startInLoadingState={true} scalesPageToFit={true} onLoad={handleWebViewLoad} onMessage={handleWebViewMessage} onError={handleWebViewError} javaScriptEnabled={true} testID={testID}/>);
|
|
57
60
|
});
|
|
58
61
|
PSEWebView.displayName = "PSEWebView";
|
package/lib/PSEWebView.tsx
CHANGED
|
@@ -23,8 +23,9 @@ const PSEWebView = forwardRef<PSEWebViewRef, PSEWebViewProps>(
|
|
|
23
23
|
// Send parameters to webview after it loads
|
|
24
24
|
const params = {
|
|
25
25
|
appId: config.appId.trim(),
|
|
26
|
-
|
|
26
|
+
gnosisPayApiAuthToken: config.gnosisPayApiAuthToken.trim(),
|
|
27
27
|
cardToken: config.cardToken.trim(),
|
|
28
|
+
elementType: config.elementType,
|
|
28
29
|
};
|
|
29
30
|
|
|
30
31
|
const message = JSON.stringify(params);
|
|
@@ -62,8 +63,10 @@ const PSEWebView = forwardRef<PSEWebViewRef, PSEWebViewProps>(
|
|
|
62
63
|
Alert.alert("PSE WebView Error", errorMessage);
|
|
63
64
|
};
|
|
64
65
|
|
|
65
|
-
const
|
|
66
|
-
|
|
66
|
+
const webViewUrl = config.webViewUrl;
|
|
67
|
+
if (!webViewUrl) {
|
|
68
|
+
throw new Error("webViewUrl is required");
|
|
69
|
+
}
|
|
67
70
|
|
|
68
71
|
return (
|
|
69
72
|
<WebView
|
package/lib/types.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import type { ElementType } from "@gnosispay/pse-sdk";
|
|
1
2
|
export interface PSEConfig {
|
|
2
3
|
appId: string;
|
|
3
|
-
|
|
4
|
+
gnosisPayApiAuthToken: string;
|
|
4
5
|
cardToken: string;
|
|
5
|
-
|
|
6
|
+
webViewUrl?: string;
|
|
7
|
+
elementType: ElementType;
|
|
6
8
|
}
|
|
7
9
|
export interface PSEWebViewProps {
|
|
8
10
|
config: PSEConfig;
|
package/lib/types.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import type { ElementType } from "@gnosispay/pse-sdk";
|
|
2
|
+
|
|
1
3
|
export interface PSEConfig {
|
|
2
4
|
appId: string;
|
|
3
|
-
|
|
5
|
+
gnosisPayApiAuthToken: string;
|
|
4
6
|
cardToken: string;
|
|
5
|
-
|
|
7
|
+
webViewUrl?: string;
|
|
8
|
+
elementType: ElementType;
|
|
6
9
|
}
|
|
7
10
|
|
|
8
11
|
export interface PSEWebViewProps {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gnosispay/pse-react-native",
|
|
3
3
|
"main": "lib/index.js",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"files": [
|
|
7
7
|
"lib/",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@expo/vector-icons": "^14.1.0",
|
|
39
|
+
"@gnosispay/pse-sdk": "^1.2.2",
|
|
39
40
|
"@react-navigation/bottom-tabs": "^7.3.10",
|
|
40
41
|
"@react-navigation/elements": "^2.3.8",
|
|
41
42
|
"@react-navigation/native": "^7.1.6",
|
|
@@ -52,21 +53,21 @@
|
|
|
52
53
|
"expo-symbols": "~0.4.5",
|
|
53
54
|
"expo-system-ui": "~5.0.10",
|
|
54
55
|
"expo-web-browser": "~14.2.0",
|
|
55
|
-
"react": "
|
|
56
|
+
"react": ">=18.0.0",
|
|
56
57
|
"react-dom": "19.0.0",
|
|
57
|
-
"react-native": "0.
|
|
58
|
+
"react-native": ">=0.70.0",
|
|
58
59
|
"react-native-gesture-handler": "~2.24.0",
|
|
59
60
|
"react-native-reanimated": "~3.17.4",
|
|
60
61
|
"react-native-safe-area-context": "5.4.0",
|
|
61
62
|
"react-native-screens": "~4.11.1",
|
|
62
63
|
"react-native-web": "~0.20.0",
|
|
63
|
-
"react-native-webview": "13.
|
|
64
|
+
"react-native-webview": ">=13.0.0"
|
|
64
65
|
},
|
|
65
66
|
"devDependencies": {
|
|
66
67
|
"@babel/core": "^7.25.2",
|
|
67
68
|
"@types/react": "~19.0.10",
|
|
68
|
-
"typescript": "~5.8.3",
|
|
69
69
|
"eslint": "^9.25.0",
|
|
70
|
-
"eslint-config-expo": "~9.2.0"
|
|
70
|
+
"eslint-config-expo": "~9.2.0",
|
|
71
|
+
"typescript": "~5.8.3"
|
|
71
72
|
}
|
|
72
73
|
}
|