@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 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 card functionality into your mobile applications.
3
+ A React Native library that provides a secure WebView component for integrating Gnosis Pay PSE functionality into your mobile applications.
4
4
 
5
- ## Features
5
+ ## Setup
6
6
 
7
- - 🔒 **Secure WebView Integration** - Safely embed Gnosis Pay card interfaces
8
- - 📱 **Cross-Platform** - Works on both iOS and Android
9
- - **Easy Integration** - Simple component with minimal setup
10
- - 🎛️ **Configurable** - Flexible configuration options for different environments
11
- - 📨 **Message Handling** - Built-in communication between WebView and React Native
12
- - 🔄 **WebView Controls** - Programmatic navigation and reload capabilities
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: "your-auth-token",
47
- cardToken: "your-card-token",
48
- baseUrl: "https://pse-backend.v2.gnosispay.com", // Optional
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
- baseUrl?: string; // Optional: Custom backend URL
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
- baseUrl: "https://pse-backend.v2.gnosispay.com",
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
- baseUrl: "https://pse-backend-staging.v2.gnosispay.com",
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 baseUrl is accessible
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 baseUrl = config.baseUrl || "https://pse-backend.v2.gnosispay.com";
55
- const webViewUrl = `${baseUrl}/native-webview`;
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";
@@ -62,8 +62,10 @@ const PSEWebView = forwardRef<PSEWebViewRef, PSEWebViewProps>(
62
62
  Alert.alert("PSE WebView Error", errorMessage);
63
63
  };
64
64
 
65
- const baseUrl = config.baseUrl || "https://pse-backend.v2.gnosispay.com";
66
- const webViewUrl = `${baseUrl}/native-webview`;
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
@@ -2,7 +2,7 @@ export interface PSEConfig {
2
2
  appId: string;
3
3
  authToken: string;
4
4
  cardToken: string;
5
- baseUrl?: string;
5
+ webViewUrl?: string;
6
6
  }
7
7
  export interface PSEWebViewProps {
8
8
  config: PSEConfig;
package/lib/types.ts CHANGED
@@ -2,7 +2,7 @@ export interface PSEConfig {
2
2
  appId: string;
3
3
  authToken: string;
4
4
  cardToken: string;
5
- baseUrl?: string;
5
+ webViewUrl?: string;
6
6
  }
7
7
 
8
8
  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.1",
4
+ "version": "1.0.2",
5
5
  "types": "lib/index.d.ts",
6
6
  "files": [
7
7
  "lib/",