@glomopay/react-native-sdk 4.0.0 → 5.0.0
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/CHANGELOG.md +29 -0
- package/MIGRATION.md +112 -0
- package/README.md +173 -36
- package/lib/bridge/file-input-handler.d.ts +25 -0
- package/lib/bridge/file-input-handler.d.ts.map +1 -0
- package/lib/bridge/file-input-handler.js +38 -0
- package/lib/bridge/file-save-handler.d.ts +32 -0
- package/lib/bridge/file-save-handler.d.ts.map +1 -0
- package/lib/bridge/file-save-handler.js +92 -0
- package/lib/bridge/message-router.d.ts +44 -0
- package/lib/bridge/message-router.d.ts.map +1 -0
- package/lib/bridge/message-router.js +48 -0
- package/lib/bridge/payment-payload.d.ts +18 -0
- package/lib/bridge/payment-payload.d.ts.map +1 -0
- package/lib/bridge/payment-payload.js +31 -0
- package/lib/capabilities/file-save.d.ts +40 -0
- package/lib/capabilities/file-save.d.ts.map +1 -0
- package/lib/capabilities/file-save.js +101 -0
- package/lib/capabilities/index.d.ts +22 -0
- package/lib/capabilities/index.d.ts.map +1 -0
- package/lib/capabilities/index.js +34 -0
- package/lib/capabilities/use-capability-reporting.d.ts +24 -0
- package/lib/capabilities/use-capability-reporting.d.ts.map +1 -0
- package/lib/capabilities/use-capability-reporting.js +44 -0
- package/lib/config/base.d.ts +12 -0
- package/lib/config/base.d.ts.map +1 -1
- package/lib/config/base.js +13 -1
- package/lib/glomo-checkout.d.ts +9 -1
- package/lib/glomo-checkout.d.ts.map +1 -1
- package/lib/glomo-checkout.js +14 -5
- package/lib/glomo-lrs-checkout.d.ts +3 -0
- package/lib/glomo-lrs-checkout.d.ts.map +1 -1
- package/lib/glomo-lrs-checkout.js +34 -11
- package/lib/glomo-standard-checkout.d.ts +4 -1
- package/lib/glomo-standard-checkout.d.ts.map +1 -1
- package/lib/glomo-standard-checkout.js +21 -13
- package/lib/glomo-subscriptions-checkout.d.ts.map +1 -1
- package/lib/glomo-subscriptions-checkout.js +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +4 -3
- package/lib/injections/index.d.ts +24 -0
- package/lib/injections/index.d.ts.map +1 -1
- package/lib/injections/index.js +41 -0
- package/lib/injections/webview-flow.injection.d.ts.map +1 -1
- package/lib/injections/webview-flow.injection.js +76 -0
- package/lib/injections/webview-main.injection.d.ts.map +1 -1
- package/lib/injections/webview-main.injection.js +31 -0
- package/lib/injections/webview-standard.injection.d.ts.map +1 -1
- package/lib/injections/webview-standard.injection.js +31 -0
- package/lib/services/file-saver.d.ts +109 -0
- package/lib/services/file-saver.d.ts.map +1 -0
- package/lib/services/file-saver.js +416 -0
- package/lib/types/checkout.d.ts +67 -6
- package/lib/types/checkout.d.ts.map +1 -1
- package/lib/types/checkout.js +24 -2
- package/lib/types/standard-checkout.d.ts +6 -6
- package/lib/types/standard-checkout.d.ts.map +1 -1
- package/lib/types/subscriptions-checkout.d.ts +5 -3
- package/lib/types/subscriptions-checkout.d.ts.map +1 -1
- package/lib/use-glomo-checkout.d.ts +2 -2
- package/lib/use-glomo-checkout.d.ts.map +1 -1
- package/lib/use-glomo-checkout.js +25 -4
- package/lib/use-lrs-checkout.d.ts +18 -6
- package/lib/use-lrs-checkout.d.ts.map +1 -1
- package/lib/use-lrs-checkout.js +330 -171
- package/lib/use-standard-checkout.d.ts +18 -13
- package/lib/use-standard-checkout.d.ts.map +1 -1
- package/lib/use-standard-checkout.js +282 -206
- package/lib/utils/analytics.d.ts +177 -51
- package/lib/utils/analytics.d.ts.map +1 -1
- package/lib/utils/analytics.js +299 -81
- package/lib/utils/device-compliance.d.ts +57 -12
- package/lib/utils/device-compliance.d.ts.map +1 -1
- package/lib/utils/device-compliance.js +101 -37
- package/lib/utils/event-projections.d.ts +56 -0
- package/lib/utils/event-projections.d.ts.map +1 -0
- package/lib/utils/event-projections.js +42 -0
- package/lib/utils/file-metadata.d.ts +52 -0
- package/lib/utils/file-metadata.d.ts.map +1 -0
- package/lib/utils/file-metadata.js +134 -0
- package/lib/utils/use-sdk-session.d.ts +12 -0
- package/lib/utils/use-sdk-session.d.ts.map +1 -0
- package/lib/utils/use-sdk-session.js +37 -0
- package/lib/utils/validation.d.ts +37 -3
- package/lib/utils/validation.d.ts.map +1 -1
- package/lib/utils/validation.js +64 -8
- package/lib/webview/capability-props.d.ts +27 -0
- package/lib/webview/capability-props.d.ts.map +1 -0
- package/lib/webview/capability-props.js +61 -0
- package/lib/webview/use-permission-request.d.ts +33 -0
- package/lib/webview/use-permission-request.d.ts.map +1 -0
- package/lib/webview/use-permission-request.js +89 -0
- package/package.json +13 -3
- package/src/bridge/file-input-handler.ts +66 -0
- package/src/bridge/file-save-handler.ts +141 -0
- package/src/bridge/message-router.ts +92 -0
- package/src/bridge/payment-payload.ts +31 -0
- package/src/capabilities/file-save.ts +124 -0
- package/src/capabilities/index.ts +34 -0
- package/src/capabilities/use-capability-reporting.ts +55 -0
- package/src/config/base.ts +13 -0
- package/src/glomo-checkout.tsx +28 -11
- package/src/glomo-lrs-checkout.tsx +49 -27
- package/src/glomo-standard-checkout.tsx +33 -34
- package/src/glomo-subscriptions-checkout.tsx +1 -0
- package/src/index.ts +4 -2
- package/src/injections/index.ts +43 -0
- package/src/injections/webview-flow.injection.ts +76 -0
- package/src/injections/webview-main.injection.ts +31 -0
- package/src/injections/webview-standard.injection.ts +31 -0
- package/src/services/file-saver.ts +497 -0
- package/src/types/checkout.ts +72 -6
- package/src/types/standard-checkout.ts +6 -6
- package/src/types/subscriptions-checkout.ts +9 -3
- package/src/use-glomo-checkout.tsx +32 -7
- package/src/use-lrs-checkout.tsx +684 -366
- package/src/use-standard-checkout.tsx +731 -465
- package/src/utils/analytics.ts +422 -117
- package/src/utils/device-compliance.ts +148 -38
- package/src/utils/event-projections.ts +74 -0
- package/src/utils/file-metadata.ts +140 -0
- package/src/utils/use-sdk-session.ts +41 -0
- package/src/utils/validation.ts +70 -10
- package/src/webview/capability-props.ts +86 -0
- package/src/webview/use-permission-request.ts +114 -0
- package/src/jail-monkey.d.ts +0 -19
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/types/checkout.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/types/checkout.ts"],"names":[],"mappings":"AAAA,iDAAiD;AAEjD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEnD;;;;;;;;;GASG;AACH,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,oBAAY,oBAAoB;IAC5B,uBAAuB,4BAA4B;IACnD,sBAAsB,2BAA2B;CACpD;AAED,0DAA0D;AAC1D,MAAM,WAAW,gCAAgC;IAC7C,WAAW,EAAE,oBAAoB,CAAC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;;;;;;;;;;;GAYG;AACH,oBAAY,mBAAmB;IAC3B,kFAAkF;IAClF,eAAe,oBAAoB;IAEnC,gDAAgD;IAChD,kBAAkB,uBAAuB;IAEzC,sCAAsC;IACtC,aAAa,kBAAkB;CAClC;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,uBAAuB;IACpC,MAAM,EAAE,mBAAmB,CAAC;CAC/B;AAED,sEAAsE;AACtE,MAAM,MAAM,cAAc,GACpB,OAAO,GACP,sBAAsB,GACtB,qBAAqB,GACrB,oBAAoB,GACpB,gBAAgB,GAChB,mBAAmB,GACnB,yBAAyB,GACzB,wBAA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A;CAAE,CAAC,CAAC"}
|
package/lib/types/checkout.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/** Unified
|
|
2
|
+
/** Unified type definitions for GlomoCheckout */
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ASYNC_PAYMENT_EVENTS = void 0;
|
|
4
|
+
exports.TERMINATION_SOURCES = exports.ASYNC_PAYMENT_EVENTS = void 0;
|
|
5
5
|
/**
|
|
6
6
|
* Enum of asynchronous payment events that trigger the
|
|
7
7
|
* onUserJourneyCompleted callback. New events will be added
|
|
@@ -12,3 +12,25 @@ var ASYNC_PAYMENT_EVENTS;
|
|
|
12
12
|
ASYNC_PAYMENT_EVENTS["BANK_TRANSFER_SUBMITTED"] = "bank_transfer_submitted";
|
|
13
13
|
ASYNC_PAYMENT_EVENTS["PAY_VIA_BANK_COMPLETED"] = "pay_via_bank_completed";
|
|
14
14
|
})(ASYNC_PAYMENT_EVENTS || (exports.ASYNC_PAYMENT_EVENTS = ASYNC_PAYMENT_EVENTS = {}));
|
|
15
|
+
/**
|
|
16
|
+
* How a checkout ended, when it ended without a payment outcome.
|
|
17
|
+
*
|
|
18
|
+
* **Must stay exhaustive by construction.** Any future call site that terminates a checkout adds a
|
|
19
|
+
* member here rather than passing `undefined` or a catch-all - the whole value of "the payload
|
|
20
|
+
* always carries its source" is in the "always", and one lazy call site turns `source` into a field
|
|
21
|
+
* every merchant has to null-check.
|
|
22
|
+
*
|
|
23
|
+
* Deliberately does not include the back chevron over the bank flow. That returns the user to the
|
|
24
|
+
* main checkout with the session intact and the ability to pay, so reporting it as a termination
|
|
25
|
+
* would be false - and for a merchant who cancels the order on terminate it would cancel live
|
|
26
|
+
* orders every time a user backed out of one bank to try another.
|
|
27
|
+
*/
|
|
28
|
+
var TERMINATION_SOURCES;
|
|
29
|
+
(function (TERMINATION_SOURCES) {
|
|
30
|
+
/** The checkout page's own close control, over the bridge as `checkout.closed` */
|
|
31
|
+
TERMINATION_SOURCES["CHECKOUT_CLOSED"] = "checkout_closed";
|
|
32
|
+
/** Android hardware back or the back gesture */
|
|
33
|
+
TERMINATION_SOURCES["DEVICE_BACK_BUTTON"] = "device_back_button";
|
|
34
|
+
/** iOS swipe-down on the pageSheet */
|
|
35
|
+
TERMINATION_SOURCES["MODAL_DISMISS"] = "modal_dismiss";
|
|
36
|
+
})(TERMINATION_SOURCES || (exports.TERMINATION_SOURCES = TERMINATION_SOURCES = {}));
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/** Type definitions for the Standard Checkout flow */
|
|
2
2
|
import { type GlomoServer } from "../config/base";
|
|
3
3
|
import { type SdkError } from "../utils/analytics";
|
|
4
|
-
import { type GlomoUserJourneyCompletedPayload } from "./checkout";
|
|
4
|
+
import { type GlomoTerminationPayload, type GlomoUserJourneyCompletedPayload } from "./checkout";
|
|
5
5
|
/** Standard checkout statuses */
|
|
6
6
|
export type StandardCheckoutStatus = "ready" | "payment_in_progress" | "payment_successful" | "payment_failed" | "payment_cancelled" | "bank_transfer_submitted" | "pay_via_bank_completed";
|
|
7
|
-
/** The payload for a successful or failed standard payment */
|
|
7
|
+
/** The payload for a successful or failed standard payment. See GlomoCheckoutPayload on the optional fields. */
|
|
8
8
|
export interface GlomoStandardCheckoutPayload {
|
|
9
9
|
orderId: string;
|
|
10
|
-
paymentId
|
|
11
|
-
signature
|
|
10
|
+
paymentId?: string;
|
|
11
|
+
signature?: string;
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
14
|
* Ref handle for the standard checkout component.
|
|
@@ -27,10 +27,10 @@ export interface GlomoStandardCheckoutProps {
|
|
|
27
27
|
onPaymentSuccess: (payload: GlomoStandardCheckoutPayload) => void;
|
|
28
28
|
onPaymentFailure: (payload: GlomoStandardCheckoutPayload) => void;
|
|
29
29
|
onConnectionError?: (error: unknown) => void;
|
|
30
|
-
onPaymentTerminate?: () => void;
|
|
30
|
+
onPaymentTerminate?: (payload: GlomoTerminationPayload) => void;
|
|
31
31
|
onSdkError: (error: Array<SdkError>) => void;
|
|
32
32
|
onUserJourneyCompleted?: (payload: GlomoUserJourneyCompletedPayload) => void;
|
|
33
|
-
|
|
33
|
+
onUserRefusedDevicePermissions?: () => void;
|
|
34
34
|
devMode?: boolean;
|
|
35
35
|
}
|
|
36
36
|
//# sourceMappingURL=standard-checkout.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"standard-checkout.d.ts","sourceRoot":"","sources":["../../src/types/standard-checkout.ts"],"names":[],"mappings":"AAAA,sDAAsD;AAEtD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,KAAK,gCAAgC,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"standard-checkout.d.ts","sourceRoot":"","sources":["../../src/types/standard-checkout.ts"],"names":[],"mappings":"AAAA,sDAAsD;AAEtD,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,KAAK,uBAAuB,EAAE,KAAK,gCAAgC,EAAE,MAAM,YAAY,CAAC;AAEjG,iCAAiC;AACjC,MAAM,MAAM,sBAAsB,GAC5B,OAAO,GACP,qBAAqB,GACrB,oBAAoB,GACpB,gBAAgB,GAChB,mBAAmB,GACnB,yBAAyB,GACzB,wBAAwB,CAAC;AAE/B,gHAAgH;AAChH,MAAM,WAAW,4BAA4B;IACzC,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACrC,KAAK,EAAE,MAAM,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,sBAAsB,CAAC;CAC3C;AAED,gDAAgD;AAChD,MAAM,WAAW,0BAA0B;IACvC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,CAAC,OAAO,EAAE,4BAA4B,KAAK,IAAI,CAAC;IAClE,gBAAgB,EAAE,CAAC,OAAO,EAAE,4BAA4B,KAAK,IAAI,CAAC;IAClE,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAChE,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IAC7C,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,gCAAgC,KAAK,IAAI,CAAC;IAC7E,8BAA8B,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;CACrB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Type definitions for the Subscriptions Checkout flow */
|
|
2
2
|
import { type GlomoServer } from "../config/base";
|
|
3
3
|
import { type SdkError } from "../utils/analytics";
|
|
4
|
-
import { type GlomoCheckoutPayload, type GlomoUserJourneyCompletedPayload } from "./checkout";
|
|
4
|
+
import { type GlomoCheckoutPayload, type GlomoTerminationPayload, type GlomoUserJourneyCompletedPayload } from "./checkout";
|
|
5
5
|
import { type StandardCheckoutStatus } from "./standard-checkout";
|
|
6
6
|
/** Props for the subscriptions checkout component */
|
|
7
7
|
export interface GlomoSubscriptionsCheckoutProps {
|
|
@@ -11,11 +11,13 @@ export interface GlomoSubscriptionsCheckoutProps {
|
|
|
11
11
|
onPaymentSuccess: (payload: GlomoCheckoutPayload) => void;
|
|
12
12
|
onPaymentFailure: (payload: GlomoCheckoutPayload) => void;
|
|
13
13
|
onConnectionError?: (error: unknown) => void;
|
|
14
|
-
onPaymentTerminate?: () => void;
|
|
14
|
+
onPaymentTerminate?: (payload: GlomoTerminationPayload) => void;
|
|
15
15
|
onSdkError: (error: Array<SdkError>) => void;
|
|
16
16
|
onUserJourneyCompleted?: (payload: GlomoUserJourneyCompletedPayload) => void;
|
|
17
|
-
|
|
17
|
+
onUserRefusedDevicePermissions?: () => void;
|
|
18
18
|
devMode?: boolean;
|
|
19
|
+
/** Internal prop for automated tests - forwarded to GlomoStandardCheckoutInternal via rest spread */
|
|
20
|
+
_testInjectionScript?: string;
|
|
19
21
|
}
|
|
20
22
|
/**
|
|
21
23
|
* Ref handle for the subscriptions checkout component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions-checkout.d.ts","sourceRoot":"","sources":["../../src/types/subscriptions-checkout.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAE3D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,
|
|
1
|
+
{"version":3,"file":"subscriptions-checkout.d.ts","sourceRoot":"","sources":["../../src/types/subscriptions-checkout.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAE3D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACH,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,gCAAgC,EACxC,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAElE,qDAAqD;AACrD,MAAM,WAAW,+BAA+B;IAC5C,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC1D,gBAAgB,EAAE,CAAC,OAAO,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC1D,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC7C,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,IAAI,CAAC;IAChE,UAAU,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IAC7C,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE,gCAAgC,KAAK,IAAI,CAAC;IAC7E,8BAA8B,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,qGAAqG;IACrG,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC1C,KAAK,EAAE,MAAM,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,sBAAsB,CAAC;CAC3C"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Unified wrapper hook - detects order type (LRS vs Standard) via the order API
|
|
3
3
|
* and delegates to the appropriate inner checkout hook once resolved.
|
|
4
4
|
*/
|
|
5
|
-
import { type GlomoCheckoutProps, type CheckoutStatus } from "./types/checkout";
|
|
5
|
+
import { type GlomoCheckoutProps, type GlomoCheckoutInternalProps, type CheckoutStatus } from "./types/checkout";
|
|
6
6
|
import { type GlomoLrsCheckoutRef } from "./glomo-lrs-checkout";
|
|
7
7
|
import { type GlomoStandardCheckoutRef } from "./types/standard-checkout";
|
|
8
8
|
import { type GlomoSubscriptionsCheckoutRef } from "./types/subscriptions-checkout";
|
|
@@ -47,7 +47,7 @@ export interface UseGlomoCheckoutInternalReturn {
|
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
49
|
export declare function useGlomoCheckout(props: GlomoCheckoutProps): UseGlomoCheckoutReturn;
|
|
50
|
-
export declare function useGlomoCheckout(props: GlomoCheckoutProps, internalOptions: {
|
|
50
|
+
export declare function useGlomoCheckout(props: GlomoCheckoutProps & GlomoCheckoutInternalProps, internalOptions: {
|
|
51
51
|
_suppressDeprecationWarning: true;
|
|
52
52
|
}): UseGlomoCheckoutInternalReturn;
|
|
53
53
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-glomo-checkout.d.ts","sourceRoot":"","sources":["../src/use-glomo-checkout.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"use-glomo-checkout.d.ts","sourceRoot":"","sources":["../src/use-glomo-checkout.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,KAAK,kBAAkB,EAAE,KAAK,0BAA0B,EAAE,KAAK,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACjH,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,KAAK,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AAC1E,OAAO,EAAE,KAAK,6BAA6B,EAAE,MAAM,gCAAgC,CAAC;AACpF,OAAO,EAAE,KAAK,SAAS,EAAkB,MAAM,+BAA+B,CAAC;AAU/E,kDAAkD;AAClD,KAAK,iBAAiB,GAAG,SAAS,GAAG,eAAe,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACnC,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,SAAS,EAAE,MAAM,cAAc,CAAC;CACnC;AAED;;;GAGG;AACH,MAAM,WAAW,8BAA8B;IAC3C,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpC,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,SAAS,EAAE,MAAM,cAAc,CAAC;IAChC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;IAClD,gBAAgB,EAAE,KAAK,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAC;IAC5D,qBAAqB,EAAE,KAAK,CAAC,SAAS,CAAC,6BAA6B,CAAC,CAAC;IACtE,KAAK,EAAE,kBAAkB,CAAC;CAC7B;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,GAAG,sBAAsB,CAAC;AACpF,wBAAgB,gBAAgB,CAC5B,KAAK,EAAE,kBAAkB,GAAG,0BAA0B,EACtD,eAAe,EAAE;IAAE,2BAA2B,EAAE,IAAI,CAAA;CAAE,GACvD,8BAA8B,CAAC"}
|
|
@@ -10,8 +10,8 @@ const order_type_fetcher_1 = require("./services/order-type-fetcher");
|
|
|
10
10
|
const validation_1 = require("./utils/validation");
|
|
11
11
|
const analytics_1 = require("./utils/analytics");
|
|
12
12
|
function useGlomoCheckout(props, internalOptions) {
|
|
13
|
-
var _a
|
|
14
|
-
const { server, publicKey, orderId, subscriptionId, onSdkError, devMode = false } = props;
|
|
13
|
+
var _a;
|
|
14
|
+
const { server, publicKey, orderId, subscriptionId, onSdkError, devMode = false, _forceOrderType } = props;
|
|
15
15
|
// Order type resolved from the API - null until detection completes
|
|
16
16
|
const [orderType, setOrderType] = (0, react_1.useState)(null);
|
|
17
17
|
// Whether order type detection is in progress
|
|
@@ -23,7 +23,7 @@ function useGlomoCheckout(props, internalOptions) {
|
|
|
23
23
|
onSdkErrorRef.current = onSdkError;
|
|
24
24
|
// One-time deprecation warning for direct merchant usage
|
|
25
25
|
const suppressWarning = (_a = internalOptions === null || internalOptions === void 0 ? void 0 : internalOptions._suppressDeprecationWarning) !== null && _a !== void 0 ? _a : false;
|
|
26
|
-
const mockMode = (
|
|
26
|
+
const mockMode = (0, validation_1.isMockModeKey)(publicKey);
|
|
27
27
|
const hasWarnedRef = (0, react_1.useRef)(false);
|
|
28
28
|
(0, react_1.useEffect)(() => {
|
|
29
29
|
if (!hasWarnedRef.current && !suppressWarning) {
|
|
@@ -153,6 +153,27 @@ function useGlomoCheckout(props, internalOptions) {
|
|
|
153
153
|
}
|
|
154
154
|
return false;
|
|
155
155
|
}
|
|
156
|
+
/**
|
|
157
|
+
* Bypassing the fetchOrderType API call
|
|
158
|
+
* and using the provided order type directly,
|
|
159
|
+
* if _forceOrderType is set.
|
|
160
|
+
*
|
|
161
|
+
* This is ONLY meant to be used by automated testing harnesses,
|
|
162
|
+
* to simulate a checkout without actual API calls.
|
|
163
|
+
*
|
|
164
|
+
* Only available in __DEV__ builds (debug)
|
|
165
|
+
*/
|
|
166
|
+
if (__DEV__ && _forceOrderType) {
|
|
167
|
+
++fetchGenerationRef.current;
|
|
168
|
+
if (devMode) {
|
|
169
|
+
console.log(`[Glomo-RN-SDK] Forcing order type: ${_forceOrderType}`);
|
|
170
|
+
}
|
|
171
|
+
setOrderType(_forceOrderType);
|
|
172
|
+
return new Promise((resolve) => {
|
|
173
|
+
pendingStartResolveRef.current = resolve;
|
|
174
|
+
pendingStartRef.current = true;
|
|
175
|
+
});
|
|
176
|
+
}
|
|
156
177
|
// Detecting order type via the API
|
|
157
178
|
setDetecting(true);
|
|
158
179
|
const thisGeneration = ++fetchGenerationRef.current;
|
|
@@ -189,7 +210,7 @@ function useGlomoCheckout(props, internalOptions) {
|
|
|
189
210
|
pendingStartResolveRef.current = resolve;
|
|
190
211
|
pendingStartRef.current = true;
|
|
191
212
|
});
|
|
192
|
-
}, [devMode, publicKey, orderId, subscriptionId, server, onSdkError, propsError]);
|
|
213
|
+
}, [devMode, publicKey, orderId, subscriptionId, server, onSdkError, propsError, _forceOrderType]);
|
|
193
214
|
/**
|
|
194
215
|
* Auto-starting the inner component after order type is resolved and the component has rendered.
|
|
195
216
|
* The pendingStartRef bridges the async gap: start() sets it, and this effect fires after
|
|
@@ -3,7 +3,9 @@ import React from "react";
|
|
|
3
3
|
import { type NativeSyntheticEvent } from "react-native";
|
|
4
4
|
import { type WebViewNavigation, type WebViewMessageEvent, type WebView } from "react-native-webview";
|
|
5
5
|
import { type GlomoServer } from "./config/base";
|
|
6
|
+
import { type WebViewPermissionRequest } from "./webview/use-permission-request";
|
|
6
7
|
import { type SdkError } from "./utils/analytics";
|
|
8
|
+
import { type GlomoTerminationPayload } from "./types/checkout";
|
|
7
9
|
/** LRS checkout statuses */
|
|
8
10
|
export type LrsCheckoutStatus = "ready" | "payment_in_progress" | "payment_successful" | "payment_failed" | "payment_cancelled"
|
|
9
11
|
/**
|
|
@@ -17,11 +19,11 @@ export type LrsCheckoutStatus = "ready" | "payment_in_progress" | "payment_succe
|
|
|
17
19
|
* - "hasContent": carousel sent lrs.has_education_steps and should be shown to the user
|
|
18
20
|
*/
|
|
19
21
|
export type EducationCarouselState = "pending" | "hasContent";
|
|
20
|
-
/** The payload for a successful or failed payment */
|
|
22
|
+
/** The payload for a successful or failed payment. See GlomoCheckoutPayload on the optional fields. */
|
|
21
23
|
export interface GlomoLrsCheckoutPayload {
|
|
22
24
|
orderId: string;
|
|
23
|
-
paymentId
|
|
24
|
-
signature
|
|
25
|
+
paymentId?: string;
|
|
26
|
+
signature?: string;
|
|
25
27
|
}
|
|
26
28
|
/** The options for the useLrsCheckout hook */
|
|
27
29
|
export interface UseLrsCheckoutOptions {
|
|
@@ -31,8 +33,9 @@ export interface UseLrsCheckoutOptions {
|
|
|
31
33
|
onPaymentSuccess: (payload: GlomoLrsCheckoutPayload) => void;
|
|
32
34
|
onPaymentFailure: (payload: GlomoLrsCheckoutPayload) => void;
|
|
33
35
|
onConnectionError?: (error: unknown) => void;
|
|
34
|
-
onPaymentTerminate?: () => void;
|
|
36
|
+
onPaymentTerminate?: (payload: GlomoTerminationPayload) => void;
|
|
35
37
|
onSdkError: (error: Array<SdkError>) => void;
|
|
38
|
+
onUserRefusedDevicePermissions?: () => void;
|
|
36
39
|
devMode?: boolean;
|
|
37
40
|
}
|
|
38
41
|
/** The return values for the useLrsCheckout hook */
|
|
@@ -63,10 +66,19 @@ export interface UseLrsCheckoutReturn {
|
|
|
63
66
|
handleNavigationStateChange: (navState: WebViewNavigation) => void;
|
|
64
67
|
handleModalBackButton: () => void;
|
|
65
68
|
handleFlowBack: () => void;
|
|
69
|
+
handlePermissionRequest: (request: WebViewPermissionRequest) => void;
|
|
66
70
|
injectedMain?: string;
|
|
67
71
|
injectedFlow?: string;
|
|
68
72
|
injectedEducationCarousel?: string;
|
|
69
73
|
}
|
|
70
|
-
/**
|
|
71
|
-
|
|
74
|
+
/**
|
|
75
|
+
* The main SDK hook for the GlomoPay LRS Checkout flow
|
|
76
|
+
* Internal options meant to simulate an LRS checkout are for automated tests only.
|
|
77
|
+
*/
|
|
78
|
+
export interface UseLrsCheckoutInternalOptions {
|
|
79
|
+
_testInjectionScript?: string;
|
|
80
|
+
_testCarouselInjectionScript?: string;
|
|
81
|
+
_onEducationCarouselStateChange?: (state: string) => void;
|
|
82
|
+
}
|
|
83
|
+
export declare function useLrsCheckout({ server, publicKey, orderId, onPaymentSuccess, onPaymentFailure, onConnectionError, onPaymentTerminate, onSdkError, onUserRefusedDevicePermissions, devMode, }: UseLrsCheckoutOptions, mockMode: boolean, internalOptions?: UseLrsCheckoutInternalOptions): UseLrsCheckoutReturn;
|
|
72
84
|
//# sourceMappingURL=use-lrs-checkout.d.ts.map
|
|
@@ -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,KAAK,iBAAiB,EAAE,KAAK,mBAAmB,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAItG,OAAO,
|
|
1
|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