@flash-pay/react 0.1.0 → 2.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/dist/index.cjs.js +75 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +18 -0
- package/dist/index.d.ts +18 -2
- package/dist/index.es.js +43 -33
- package/dist/index.es.js.map +1 -1
- package/package.json +14 -13
- package/dist/FlashpayCheckout.d.ts +0 -14
- package/dist/FlashpayCheckout.test.d.ts +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,2 +1,75 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
FlashpayCheckout: () => FlashpayCheckout
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/FlashpayCheckout.tsx
|
|
28
|
+
var import_browser_sdk = require("@flash-pay/browser-sdk");
|
|
29
|
+
var import_react = require("react");
|
|
30
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
31
|
+
function FlashpayCheckout({
|
|
32
|
+
transactionId,
|
|
33
|
+
onSuccess,
|
|
34
|
+
onFailure,
|
|
35
|
+
onClose,
|
|
36
|
+
showTitle = true,
|
|
37
|
+
showDescription = true,
|
|
38
|
+
showAmount = true,
|
|
39
|
+
style,
|
|
40
|
+
origin
|
|
41
|
+
}) {
|
|
42
|
+
const containerRef = (0, import_react.useRef)(null);
|
|
43
|
+
const onSuccessRef = (0, import_react.useRef)(onSuccess);
|
|
44
|
+
const onFailureRef = (0, import_react.useRef)(onFailure);
|
|
45
|
+
const onCloseRef = (0, import_react.useRef)(onClose);
|
|
46
|
+
const styleRef = (0, import_react.useRef)(style);
|
|
47
|
+
(0, import_react.useEffect)(() => {
|
|
48
|
+
onSuccessRef.current = onSuccess;
|
|
49
|
+
onFailureRef.current = onFailure;
|
|
50
|
+
onCloseRef.current = onClose;
|
|
51
|
+
styleRef.current = style;
|
|
52
|
+
});
|
|
53
|
+
(0, import_react.useEffect)(() => {
|
|
54
|
+
if (!containerRef.current) return;
|
|
55
|
+
const instance = (0, import_browser_sdk.checkout)({
|
|
56
|
+
transactionId,
|
|
57
|
+
container: containerRef.current,
|
|
58
|
+
onSuccess: (data) => onSuccessRef.current?.(data),
|
|
59
|
+
onFailure: (data) => onFailureRef.current?.(data),
|
|
60
|
+
onClose: (data) => onCloseRef.current?.(data),
|
|
61
|
+
showTitle,
|
|
62
|
+
showDescription,
|
|
63
|
+
showAmount,
|
|
64
|
+
style: styleRef.current,
|
|
65
|
+
origin
|
|
66
|
+
});
|
|
67
|
+
return () => instance.destroy();
|
|
68
|
+
}, [transactionId, showTitle, showDescription, showAmount, origin]);
|
|
69
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: containerRef });
|
|
70
|
+
}
|
|
71
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
72
|
+
0 && (module.exports = {
|
|
73
|
+
FlashpayCheckout
|
|
74
|
+
});
|
|
75
|
+
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/FlashpayCheckout.tsx"],"sourcesContent":["export { FlashpayCheckout } from \"./FlashpayCheckout\";\nexport type { FlashpayCheckoutProps, PaymentEventData, PaymentData } from \"./FlashpayCheckout\";\n","import { checkout } from \"@flash-pay/browser-sdk\";\nimport type { PaymentEventData, PaymentData } from \"@flash-pay/browser-sdk\";\nimport { useEffect, useRef } from \"react\";\n\nexport type { PaymentEventData, PaymentData };\n\nexport interface FlashpayCheckoutProps {\n transactionId: string;\n onSuccess?: (data: PaymentEventData) => void;\n onFailure?: (data: PaymentEventData) => void;\n onClose?: (data: PaymentEventData) => void;\n showTitle?: boolean;\n showDescription?: boolean;\n showAmount?: boolean;\n style?: Partial<CSSStyleDeclaration>;\n origin?: string;\n}\n\nexport function FlashpayCheckout({\n transactionId,\n onSuccess,\n onFailure,\n onClose,\n showTitle = true,\n showDescription = true,\n showAmount = true,\n style,\n origin,\n}: FlashpayCheckoutProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Stable refs so callback / style identity changes don't re-initialize the SDK\n const onSuccessRef = useRef(onSuccess);\n const onFailureRef = useRef(onFailure);\n const onCloseRef = useRef(onClose);\n const styleRef = useRef(style);\n useEffect(() => {\n onSuccessRef.current = onSuccess;\n onFailureRef.current = onFailure;\n onCloseRef.current = onClose;\n styleRef.current = style;\n });\n\n useEffect(() => {\n if (!containerRef.current) return;\n const instance = checkout({\n transactionId,\n container: containerRef.current,\n onSuccess: (data) => onSuccessRef.current?.(data),\n onFailure: (data) => onFailureRef.current?.(data),\n onClose: (data) => onCloseRef.current?.(data),\n showTitle,\n showDescription,\n showAmount,\n style: styleRef.current,\n origin,\n });\n return () => instance.destroy();\n }, [transactionId, showTitle, showDescription, showAmount, origin]);\n\n return <div ref={containerRef} />;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,yBAAyB;AAEzB,mBAAkC;AA0DzB;AA1CF,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,aAAa;AAAA,EACb;AAAA,EACA;AACF,GAA0B;AACxB,QAAM,mBAAe,qBAAuB,IAAI;AAGhD,QAAM,mBAAe,qBAAO,SAAS;AACrC,QAAM,mBAAe,qBAAO,SAAS;AACrC,QAAM,iBAAa,qBAAO,OAAO;AACjC,QAAM,eAAW,qBAAO,KAAK;AAC7B,8BAAU,MAAM;AACd,iBAAa,UAAU;AACvB,iBAAa,UAAU;AACvB,eAAW,UAAU;AACrB,aAAS,UAAU;AAAA,EACrB,CAAC;AAED,8BAAU,MAAM;AACd,QAAI,CAAC,aAAa,QAAS;AAC3B,UAAM,eAAW,6BAAS;AAAA,MACxB;AAAA,MACA,WAAW,aAAa;AAAA,MACxB,WAAW,CAAC,SAAS,aAAa,UAAU,IAAI;AAAA,MAChD,WAAW,CAAC,SAAS,aAAa,UAAU,IAAI;AAAA,MAChD,SAAS,CAAC,SAAS,WAAW,UAAU,IAAI;AAAA,MAC5C;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO,SAAS;AAAA,MAChB;AAAA,IACF,CAAC;AACD,WAAO,MAAM,SAAS,QAAQ;AAAA,EAChC,GAAG,CAAC,eAAe,WAAW,iBAAiB,YAAY,MAAM,CAAC;AAElE,SAAO,4CAAC,SAAI,KAAK,cAAc;AACjC;","names":[]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { PaymentEventData } from '@flash-pay/browser-sdk';
|
|
3
|
+
export { PaymentData, PaymentEventData } from '@flash-pay/browser-sdk';
|
|
4
|
+
|
|
5
|
+
interface FlashpayCheckoutProps {
|
|
6
|
+
transactionId: string;
|
|
7
|
+
onSuccess?: (data: PaymentEventData) => void;
|
|
8
|
+
onFailure?: (data: PaymentEventData) => void;
|
|
9
|
+
onClose?: (data: PaymentEventData) => void;
|
|
10
|
+
showTitle?: boolean;
|
|
11
|
+
showDescription?: boolean;
|
|
12
|
+
showAmount?: boolean;
|
|
13
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
14
|
+
origin?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function FlashpayCheckout({ transactionId, onSuccess, onFailure, onClose, showTitle, showDescription, showAmount, style, origin, }: FlashpayCheckoutProps): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { FlashpayCheckout, type FlashpayCheckoutProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { PaymentEventData } from '@flash-pay/browser-sdk';
|
|
3
|
+
export { PaymentData, PaymentEventData } from '@flash-pay/browser-sdk';
|
|
4
|
+
|
|
5
|
+
interface FlashpayCheckoutProps {
|
|
6
|
+
transactionId: string;
|
|
7
|
+
onSuccess?: (data: PaymentEventData) => void;
|
|
8
|
+
onFailure?: (data: PaymentEventData) => void;
|
|
9
|
+
onClose?: (data: PaymentEventData) => void;
|
|
10
|
+
showTitle?: boolean;
|
|
11
|
+
showDescription?: boolean;
|
|
12
|
+
showAmount?: boolean;
|
|
13
|
+
style?: Partial<CSSStyleDeclaration>;
|
|
14
|
+
origin?: string;
|
|
15
|
+
}
|
|
16
|
+
declare function FlashpayCheckout({ transactionId, onSuccess, onFailure, onClose, showTitle, showDescription, showAmount, style, origin, }: FlashpayCheckoutProps): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { FlashpayCheckout, type FlashpayCheckoutProps };
|
package/dist/index.es.js
CHANGED
|
@@ -1,38 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
import { checkout
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
// src/FlashpayCheckout.tsx
|
|
2
|
+
import { checkout } from "@flash-pay/browser-sdk";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
function FlashpayCheckout({
|
|
6
|
+
transactionId,
|
|
7
|
+
onSuccess,
|
|
8
|
+
onFailure,
|
|
9
|
+
onClose,
|
|
10
|
+
showTitle = true,
|
|
11
|
+
showDescription = true,
|
|
12
|
+
showAmount = true,
|
|
13
|
+
style,
|
|
14
|
+
origin
|
|
14
15
|
}) {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
const containerRef = useRef(null);
|
|
17
|
+
const onSuccessRef = useRef(onSuccess);
|
|
18
|
+
const onFailureRef = useRef(onFailure);
|
|
19
|
+
const onCloseRef = useRef(onClose);
|
|
20
|
+
const styleRef = useRef(style);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
onSuccessRef.current = onSuccess;
|
|
23
|
+
onFailureRef.current = onFailure;
|
|
24
|
+
onCloseRef.current = onClose;
|
|
25
|
+
styleRef.current = style;
|
|
26
|
+
});
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (!containerRef.current) return;
|
|
29
|
+
const instance = checkout({
|
|
30
|
+
transactionId,
|
|
31
|
+
container: containerRef.current,
|
|
32
|
+
onSuccess: (data) => onSuccessRef.current?.(data),
|
|
33
|
+
onFailure: (data) => onFailureRef.current?.(data),
|
|
34
|
+
onClose: (data) => onCloseRef.current?.(data),
|
|
35
|
+
showTitle,
|
|
36
|
+
showDescription,
|
|
37
|
+
showAmount,
|
|
38
|
+
style: styleRef.current,
|
|
39
|
+
origin
|
|
31
40
|
});
|
|
32
|
-
return () =>
|
|
33
|
-
}, [
|
|
41
|
+
return () => instance.destroy();
|
|
42
|
+
}, [transactionId, showTitle, showDescription, showAmount, origin]);
|
|
43
|
+
return /* @__PURE__ */ jsx("div", { ref: containerRef });
|
|
34
44
|
}
|
|
35
45
|
export {
|
|
36
|
-
|
|
46
|
+
FlashpayCheckout
|
|
37
47
|
};
|
|
38
|
-
//# sourceMappingURL=index.es.js.map
|
|
48
|
+
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../src/FlashpayCheckout.tsx"],"sourcesContent":["import { checkout } from \"@flash-pay/browser-sdk\";\nimport type { PaymentEventData, PaymentData } from \"@flash-pay/browser-sdk\";\nimport { useEffect, useRef } from \"react\";\n\nexport type { PaymentEventData, PaymentData };\n\nexport interface FlashpayCheckoutProps {\n transactionId: string;\n onSuccess?: (data: PaymentEventData) => void;\n onFailure?: (data: PaymentEventData) => void;\n onClose?: (data: PaymentEventData) => void;\n showTitle?: boolean;\n showDescription?: boolean;\n showAmount?: boolean;\n style?: Partial<CSSStyleDeclaration>;\n origin?: string;\n}\n\nexport function FlashpayCheckout({\n transactionId,\n onSuccess,\n onFailure,\n onClose,\n showTitle = true,\n showDescription = true,\n showAmount = true,\n style,\n origin,\n}: FlashpayCheckoutProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n\n // Stable refs so callback / style identity changes don't re-initialize the SDK\n const onSuccessRef = useRef(onSuccess);\n const onFailureRef = useRef(onFailure);\n const onCloseRef = useRef(onClose);\n const styleRef = useRef(style);\n useEffect(() => {\n onSuccessRef.current = onSuccess;\n onFailureRef.current = onFailure;\n onCloseRef.current = onClose;\n styleRef.current = style;\n });\n\n useEffect(() => {\n if (!containerRef.current) return;\n const instance = checkout({\n transactionId,\n container: containerRef.current,\n onSuccess: (data) => onSuccessRef.current?.(data),\n onFailure: (data) => onFailureRef.current?.(data),\n onClose: (data) => onCloseRef.current?.(data),\n showTitle,\n showDescription,\n showAmount,\n style: styleRef.current,\n origin,\n });\n return () => instance.destroy();\n }, [transactionId, showTitle, showDescription, showAmount, origin]);\n\n return <div ref={containerRef} />;\n}\n"],"mappings":";AAAA,SAAS,gBAAgB;AAEzB,SAAS,WAAW,cAAc;AA0DzB;AA1CF,SAAS,iBAAiB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,aAAa;AAAA,EACb;AAAA,EACA;AACF,GAA0B;AACxB,QAAM,eAAe,OAAuB,IAAI;AAGhD,QAAM,eAAe,OAAO,SAAS;AACrC,QAAM,eAAe,OAAO,SAAS;AACrC,QAAM,aAAa,OAAO,OAAO;AACjC,QAAM,WAAW,OAAO,KAAK;AAC7B,YAAU,MAAM;AACd,iBAAa,UAAU;AACvB,iBAAa,UAAU;AACvB,eAAW,UAAU;AACrB,aAAS,UAAU;AAAA,EACrB,CAAC;AAED,YAAU,MAAM;AACd,QAAI,CAAC,aAAa,QAAS;AAC3B,UAAM,WAAW,SAAS;AAAA,MACxB;AAAA,MACA,WAAW,aAAa;AAAA,MACxB,WAAW,CAAC,SAAS,aAAa,UAAU,IAAI;AAAA,MAChD,WAAW,CAAC,SAAS,aAAa,UAAU,IAAI;AAAA,MAChD,SAAS,CAAC,SAAS,WAAW,UAAU,IAAI;AAAA,MAC5C;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO,SAAS;AAAA,MAChB;AAAA,IACF,CAAC;AACD,WAAO,MAAM,SAAS,QAAQ;AAAA,EAChC,GAAG,CAAC,eAAe,WAAW,iBAAiB,YAAY,MAAM,CAAC;AAElE,SAAO,oBAAC,SAAI,KAAK,cAAc;AACjC;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flash-pay/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Flashpay React component wrapper",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.es.js",
|
|
@@ -8,36 +8,37 @@
|
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
11
12
|
"import": "./dist/index.es.js",
|
|
12
|
-
"require": "./dist/index.cjs.js"
|
|
13
|
-
"types": "./dist/index.d.ts"
|
|
13
|
+
"require": "./dist/index.cjs.js"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
-
"files": [
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
17
19
|
"scripts": {
|
|
18
|
-
"build": "
|
|
19
|
-
"dev": "
|
|
20
|
+
"build": "tsup",
|
|
21
|
+
"dev": "tsup --watch",
|
|
20
22
|
"test": "vitest run",
|
|
21
23
|
"test:watch": "vitest"
|
|
22
24
|
},
|
|
23
25
|
"peerDependencies": {
|
|
24
|
-
"@flash-pay/browser-sdk": ">=0.
|
|
26
|
+
"@flash-pay/browser-sdk": ">=2.0.0",
|
|
25
27
|
"react": ">=18.0.0",
|
|
26
28
|
"react-dom": ">=18.0.0"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
29
31
|
"@flash-pay/browser-sdk": "workspace:*",
|
|
30
32
|
"@testing-library/react": "^16.0.0",
|
|
31
|
-
"@types/react": "^
|
|
32
|
-
"@types/react-dom": "^
|
|
33
|
+
"@types/react": "^19.0.0",
|
|
34
|
+
"@types/react-dom": "^19.0.0",
|
|
33
35
|
"@vitejs/plugin-react": "^4.0.0",
|
|
34
36
|
"ajv": "^8.18.0",
|
|
35
37
|
"jsdom": "^26.0.0",
|
|
36
|
-
"react": "^
|
|
37
|
-
"react-dom": "^
|
|
38
|
+
"react": "^19.0.0",
|
|
39
|
+
"react-dom": "^19.0.0",
|
|
40
|
+
"tsup": "^8.5.0",
|
|
38
41
|
"typescript": "^5.3.3",
|
|
39
|
-
"vite": "^7.3.1",
|
|
40
|
-
"vite-plugin-dts": "^4.5.4",
|
|
41
42
|
"vitest": "^3.0.0"
|
|
42
43
|
}
|
|
43
44
|
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { PaymentEventData, PaymentData } from '@flash-pay/browser-sdk';
|
|
2
|
-
export type { PaymentEventData, PaymentData };
|
|
3
|
-
export interface FlashpayCheckoutProps {
|
|
4
|
-
transactionId: string;
|
|
5
|
-
onSuccess?: (data: PaymentEventData) => void;
|
|
6
|
-
onFailure?: (data: PaymentEventData) => void;
|
|
7
|
-
onClose?: (data: PaymentEventData) => void;
|
|
8
|
-
showTitle?: boolean;
|
|
9
|
-
showDescription?: boolean;
|
|
10
|
-
showAmount?: boolean;
|
|
11
|
-
style?: Partial<CSSStyleDeclaration>;
|
|
12
|
-
origin?: string;
|
|
13
|
-
}
|
|
14
|
-
export declare function FlashpayCheckout({ transactionId, onSuccess, onFailure, onClose, showTitle, showDescription, showAmount, style, origin, }: FlashpayCheckoutProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|