@glomopay/react-native-sdk 1.3.3 → 1.3.5

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.
@@ -1 +1 @@
1
- {"version":3,"file":"glomo-lrs-checkout.d.ts","sourceRoot":"","sources":["../src/glomo-lrs-checkout.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAE1C,OAAO,KAAmD,MAAM,OAAO,CAAC;AAIxE,OAAO,EAAkB,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACxG,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAChE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;CACjD;AAED,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,MAAM,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,iBAAiB,CAAC;CACtC;AA4MD,eAAO,MAAM,gBAAgB,mGAAoF,CAAC"}
1
+ {"version":3,"file":"glomo-lrs-checkout.d.ts","sourceRoot":"","sources":["../src/glomo-lrs-checkout.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAE1C,OAAO,KAAmD,MAAM,OAAO,CAAC;AAIxE,OAAO,EAAkB,KAAK,qBAAqB,EAAE,KAAK,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACxG,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGlD,MAAM,WAAW,qBAAsB,SAAQ,qBAAqB;IAChE,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;CACjD;AAED,MAAM,WAAW,mBAAmB;IAChC,KAAK,EAAE,MAAM,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,iBAAiB,CAAC;CACtC;AAkND,eAAO,MAAM,gBAAgB,mGAAoF,CAAC"}
@@ -68,7 +68,7 @@ function GlomoLrsCheckoutComponent({ server, publicKey, orderId, onPaymentSucces
68
68
  }
69
69
  return (_a = publicKey === null || publicKey === void 0 ? void 0 : publicKey.toLowerCase().startsWith("test_")) !== null && _a !== void 0 ? _a : false;
70
70
  }, [publicKey, devMode]);
71
- const { start, status, showCheckout, flowWebViewUrl, showFlowWebView, checkoutUrl, mainWebViewRef, flowWebViewRef, handleMainWebViewMessage, handleFlowWebViewMessage, handleError, handleHttpError, handleNavigationStateChange, handleModalBackButton, injectedMain, injectedFlow, } = (0, use_lrs_checkout_1.useLrsCheckout)({
71
+ const { start, status, showCheckout, flowWebViewUrl, showFlowWebView, checkoutUrl, mainWebViewRef, flowWebViewRef, handleMainWebViewMessage, handleFlowWebViewMessage, handleError, handleHttpError, handleNavigationStateChange, handleModalBackButton, handleFlowBack, injectedMain, injectedFlow, } = (0, use_lrs_checkout_1.useLrsCheckout)({
72
72
  server,
73
73
  publicKey,
74
74
  orderId,
@@ -130,6 +130,11 @@ function GlomoLrsCheckoutComponent({ server, publicKey, orderId, onPaymentSucces
130
130
  <react_native_1.View style={styles.mainWebViewContainer}>{MainWebViewComponent}</react_native_1.View>
131
131
 
132
132
  {showFlowWebView && flowWebViewUrl && FlowWebViewComponent && (<react_native_1.View style={styles.flowWebViewContainer}>
133
+ <react_native_1.SafeAreaView style={styles.flowHeader}>
134
+ <react_native_1.TouchableOpacity onPress={handleFlowBack} style={styles.flowBackButton}>
135
+ <react_native_1.Text style={styles.flowBackChevron}>‹</react_native_1.Text>
136
+ </react_native_1.TouchableOpacity>
137
+ </react_native_1.SafeAreaView>
133
138
  <react_native_1.View style={styles.flowWebViewContent}>{FlowWebViewComponent}</react_native_1.View>
134
139
  </react_native_1.View>)}
135
140
  </react_native_1.View>
@@ -155,10 +160,26 @@ const styles = react_native_1.StyleSheet.create({
155
160
  left: 0,
156
161
  right: 0,
157
162
  bottom: 0,
163
+ flexDirection: "column",
158
164
  backgroundColor: "#fff",
159
165
  zIndex: 99999,
160
166
  elevation: 99999,
161
167
  },
168
+ flowHeader: {
169
+ backgroundColor: "#fff",
170
+ borderBottomWidth: 1,
171
+ borderBottomColor: "#e0e0e0",
172
+ paddingTop: react_native_1.Platform.OS === "android" ? react_native_1.StatusBar.currentHeight : 0,
173
+ },
174
+ flowBackButton: {
175
+ paddingVertical: 6,
176
+ paddingLeft: 20,
177
+ },
178
+ flowBackChevron: {
179
+ fontSize: 42,
180
+ color: "#333",
181
+ lineHeight: 42,
182
+ },
162
183
  flowWebViewContent: {
163
184
  flex: 1,
164
185
  },
@@ -1 +1 @@
1
- {"version":3,"file":"webview-flow.injection.d.ts","sourceRoot":"","sources":["../../src/injections/webview-flow.injection.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,eAAO,MAAM,cAAc,EAAE,MAoK5B,CAAC"}
1
+ {"version":3,"file":"webview-flow.injection.d.ts","sourceRoot":"","sources":["../../src/injections/webview-flow.injection.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,eAAO,MAAM,cAAc,EAAE,MA8K5B,CAAC"}
@@ -113,6 +113,16 @@ exports.injectedScript = `
113
113
  return originalSend.apply(this, arguments);
114
114
  };
115
115
 
116
+ // Intercepting programmatic form.submit() — force target="_blank" to "_self"
117
+ // This prevents forms from trying to open new windows (which fail silently in WebView)
118
+ const originalSubmit = HTMLFormElement.prototype.submit;
119
+ HTMLFormElement.prototype.submit = function() {
120
+ if (this.target === '_blank') {
121
+ this.target = '_self';
122
+ }
123
+ return originalSubmit.call(this);
124
+ };
125
+
116
126
  // Intercepting window.open
117
127
  const originalWindowOpen = window.open;
118
128
  window.open = function(url, target, features) {
@@ -46,6 +46,7 @@ export interface UseLrsCheckoutReturn {
46
46
  }>) => void;
47
47
  handleNavigationStateChange: (navState: WebViewNavigation) => void;
48
48
  handleModalBackButton: () => void;
49
+ handleFlowBack: () => void;
49
50
  injectedMain?: string;
50
51
  injectedFlow?: string;
51
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-lrs-checkout.d.ts","sourceRoot":"","sources":["../src/use-lrs-checkout.tsx"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,KAA4D,MAAM,OAAO,CAAC;AACjF,OAAO,EAAY,KAAK,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEnE,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAO5F,OAAO,EAYH,KAAK,QAAQ,EAChB,MAAM,mBAAmB,CAAC;AAE3B,4BAA4B;AAC5B,MAAM,MAAM,iBAAiB,GAEvB,OAAO,GAGP,qBAAqB,GAGrB,oBAAoB,GAGpB,gBAAgB,GAGhB,mBAAmB,CAAC;AAE1B,qDAAqD;AACrD,MAAM,WAAW,uBAAuB;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,8CAA8C;AAC9C,MAAM,WAAW,qBAAqB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAC7D,gBAAgB,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAC7D,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAC;IAChC,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,oDAAoD;AACpD,MAAM,WA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c,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACzC,cAAc,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;IACzC,wBAAwB,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC/D,wBAAwB,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,IAAI,CAAC;IAC/D,WAAW,EAAE,CACT,cAAc,EAAE,oBAAoB,CAAC;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,KAC7F,IAAI,CAAC;IACV,eAAe,EAAE,CAAC,cAAc,EAAE,oBAAoB,CAAC;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,KAAK,IAAI,CAAC;IAC9G,2BAA2B,EAAE,CAAC,QAAQ,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACnE,qBAAqB,EAAE,MAAM,IAAI,CAAC;IAClC,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,2DAA2D;AAC3D,wBAAgB,cAAc,CAC1B,EACI,MAAM,EACN,SAAS,EACT,OAAO,EACP,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,UAAU,EACV,OAAe,GAClB,EAAE,qBAAqB,EACxB,QAAQ,EAAE,OAAO,GAClB,oBAAoB,CA8uBtB"}
@@ -396,6 +396,15 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
396
396
  }
397
397
  }
398
398
  }, [showFlowWebView, devMode, onPaymentTerminate, status, orderId, mockMode, checkoutUrl]);
399
+ /** Closes the flow WebView and returns to the main checkout */
400
+ const handleFlowBack = (0, react_1.useCallback)(() => {
401
+ if (devMode) {
402
+ console.log("[GlomoPay RN SDK] Flow WebView back button pressed");
403
+ }
404
+ setShowFlowWebView(false);
405
+ setFlowWebViewUrl("");
406
+ (0, analytics_1.trackWindowClose)("flow", orderId, publicKey, devMode, mockMode, checkoutUrl);
407
+ }, [devMode, orderId, publicKey, mockMode, checkoutUrl]);
399
408
  /**
400
409
  * Initiator method for the LRS Checkout flow.
401
410
  * Using a ref, the LRS flow can be started by calling this method.
@@ -570,6 +579,7 @@ function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymen
570
579
  handleHttpError,
571
580
  handleNavigationStateChange,
572
581
  handleModalBackButton,
582
+ handleFlowBack,
573
583
  injectedMain: injections_1.InjectionScripts.main,
574
584
  injectedFlow: injections_1.InjectionScripts.flow,
575
585
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glomopay/react-native-sdk",
3
- "version": "1.3.3",
3
+ "version": "1.3.5",
4
4
  "description": "The React Native SDK for GlomoPay",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
@@ -1,7 +1,7 @@
1
1
  /** The GlomoPay LRS Checkout Component */
2
2
 
3
3
  import React, { useMemo, useImperativeHandle, forwardRef } from "react";
4
- import { StyleSheet, View, Modal, Platform } from "react-native";
4
+ import { StyleSheet, View, Modal, Platform, SafeAreaView, StatusBar, TouchableOpacity, Text } from "react-native";
5
5
  import { WebView, type WebViewMessageEvent } from "react-native-webview";
6
6
 
7
7
  import { useLrsCheckout, type UseLrsCheckoutOptions, type LrsCheckoutStatus } from "./use-lrs-checkout";
@@ -75,6 +75,7 @@ function GlomoLrsCheckoutComponent(
75
75
  handleHttpError,
76
76
  handleNavigationStateChange,
77
77
  handleModalBackButton,
78
+ handleFlowBack,
78
79
  injectedMain,
79
80
  injectedFlow,
80
81
  } = useLrsCheckout(
@@ -212,6 +213,11 @@ function GlomoLrsCheckoutComponent(
212
213
 
213
214
  {showFlowWebView && flowWebViewUrl && FlowWebViewComponent && (
214
215
  <View style={styles.flowWebViewContainer}>
216
+ <SafeAreaView style={styles.flowHeader}>
217
+ <TouchableOpacity onPress={handleFlowBack} style={styles.flowBackButton}>
218
+ <Text style={styles.flowBackChevron}>‹</Text>
219
+ </TouchableOpacity>
220
+ </SafeAreaView>
215
221
  <View style={styles.flowWebViewContent}>{FlowWebViewComponent}</View>
216
222
  </View>
217
223
  )}
@@ -242,10 +248,26 @@ const styles = StyleSheet.create({
242
248
  left: 0,
243
249
  right: 0,
244
250
  bottom: 0,
251
+ flexDirection: "column",
245
252
  backgroundColor: "#fff",
246
253
  zIndex: 99999,
247
254
  elevation: 99999,
248
255
  },
256
+ flowHeader: {
257
+ backgroundColor: "#fff",
258
+ borderBottomWidth: 1,
259
+ borderBottomColor: "#e0e0e0",
260
+ paddingTop: Platform.OS === "android" ? StatusBar.currentHeight : 0,
261
+ },
262
+ flowBackButton: {
263
+ paddingVertical: 6,
264
+ paddingLeft: 20,
265
+ },
266
+ flowBackChevron: {
267
+ fontSize: 42,
268
+ color: "#333",
269
+ lineHeight: 42,
270
+ },
249
271
  flowWebViewContent: {
250
272
  flex: 1,
251
273
  },
@@ -110,6 +110,16 @@ export const injectedScript: string = `
110
110
  return originalSend.apply(this, arguments);
111
111
  };
112
112
 
113
+ // Intercepting programmatic form.submit() — force target="_blank" to "_self"
114
+ // This prevents forms from trying to open new windows (which fail silently in WebView)
115
+ const originalSubmit = HTMLFormElement.prototype.submit;
116
+ HTMLFormElement.prototype.submit = function() {
117
+ if (this.target === '_blank') {
118
+ this.target = '_self';
119
+ }
120
+ return originalSubmit.call(this);
121
+ };
122
+
113
123
  // Intercepting window.open
114
124
  const originalWindowOpen = window.open;
115
125
  window.open = function(url, target, features) {
@@ -80,6 +80,7 @@ export interface UseLrsCheckoutReturn {
80
80
  handleHttpError: (syntheticEvent: NativeSyntheticEvent<{ statusCode: number; description?: string }>) => void;
81
81
  handleNavigationStateChange: (navState: WebViewNavigation) => void;
82
82
  handleModalBackButton: () => void;
83
+ handleFlowBack: () => void;
83
84
  injectedMain?: string;
84
85
  injectedFlow?: string;
85
86
  }
@@ -594,6 +595,16 @@ export function useLrsCheckout(
594
595
  }
595
596
  }, [showFlowWebView, devMode, onPaymentTerminate, status, orderId, mockMode, checkoutUrl]);
596
597
 
598
+ /** Closes the flow WebView and returns to the main checkout */
599
+ const handleFlowBack = useCallback(() => {
600
+ if (devMode) {
601
+ console.log("[GlomoPay RN SDK] Flow WebView back button pressed");
602
+ }
603
+ setShowFlowWebView(false);
604
+ setFlowWebViewUrl("");
605
+ trackWindowClose("flow", orderId, publicKey, devMode, mockMode, checkoutUrl);
606
+ }, [devMode, orderId, publicKey, mockMode, checkoutUrl]);
607
+
597
608
  /**
598
609
  * Initiator method for the LRS Checkout flow.
599
610
  * Using a ref, the LRS flow can be started by calling this method.
@@ -834,6 +845,7 @@ export function useLrsCheckout(
834
845
  handleHttpError,
835
846
  handleNavigationStateChange,
836
847
  handleModalBackButton,
848
+ handleFlowBack,
837
849
  injectedMain: InjectionScripts.main,
838
850
  injectedFlow: InjectionScripts.flow,
839
851
  };