@gnosispay/pse-react-native 1.0.1 → 1.0.2
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 +21 -17
- package/lib/PSEWebView.js +4 -2
- package/lib/PSEWebView.tsx +4 -2
- package/lib/types.d.ts +1 -1
- package/lib/types.ts +1 -1
- package/package.json +1 -1
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
|
-
authToken: "
|
|
47
|
-
cardToken: "
|
|
48
|
-
|
|
50
|
+
authToken: "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) => {
|
|
@@ -102,7 +106,7 @@ interface PSEConfig {
|
|
|
102
106
|
appId: string; // Your application identifier
|
|
103
107
|
authToken: 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
|
|
|
@@ -172,7 +176,7 @@ const config = {
|
|
|
172
176
|
appId: "your-prod-app-id",
|
|
173
177
|
authToken: "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
|
|
|
@@ -183,7 +187,7 @@ const config = {
|
|
|
183
187
|
appId: "your-staging-app-id",
|
|
184
188
|
authToken: "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,7 +243,7 @@ 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
|
|
package/lib/PSEWebView.js
CHANGED
|
@@ -51,8 +51,10 @@ const PSEWebView = forwardRef(({ config, onError, onMessage, onLoad, style, test
|
|
|
51
51
|
onError?.(errorMessage);
|
|
52
52
|
Alert.alert("PSE WebView Error", errorMessage);
|
|
53
53
|
};
|
|
54
|
-
const
|
|
55
|
-
|
|
54
|
+
const webViewUrl = config.webViewUrl;
|
|
55
|
+
if (!webViewUrl) {
|
|
56
|
+
throw new Error("webViewUrl is required");
|
|
57
|
+
}
|
|
56
58
|
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
59
|
});
|
|
58
60
|
PSEWebView.displayName = "PSEWebView";
|
package/lib/PSEWebView.tsx
CHANGED
|
@@ -62,8 +62,10 @@ const PSEWebView = forwardRef<PSEWebViewRef, PSEWebViewProps>(
|
|
|
62
62
|
Alert.alert("PSE WebView Error", errorMessage);
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
-
const
|
|
66
|
-
|
|
65
|
+
const webViewUrl = config.webViewUrl;
|
|
66
|
+
if (!webViewUrl) {
|
|
67
|
+
throw new Error("webViewUrl is required");
|
|
68
|
+
}
|
|
67
69
|
|
|
68
70
|
return (
|
|
69
71
|
<WebView
|
package/lib/types.d.ts
CHANGED
package/lib/types.ts
CHANGED