@school24/paymentjs-rn 1.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/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @school24/paymentjs-rn
2
+
3
+ React Native WebView wrapper for PaymentJS (Adyen Web Drop-in).
4
+
5
+ This library allows you to reuse your existing `payment.js` and
6
+ `react-test.html` inside a React Native app with a clean, native-friendly API.
7
+
8
+ ---
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install @school24/paymentjs-rn react-native-webview
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import type { PaymentJSProps } from "./types";
3
+ declare const PaymentJS: React.FC<PaymentJSProps>;
4
+ export default PaymentJS;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const react_1 = __importStar(require("react"));
37
+ const react_native_1 = require("react-native");
38
+ const react_native_webview_1 = require("react-native-webview");
39
+ const PaymentJS = (props) => {
40
+ const { uri, onSuccess, onFailure, style } = props;
41
+ const handleMessage = (0, react_1.useCallback)((event) => {
42
+ var _a, _b;
43
+ try {
44
+ // Type guard for WebView events
45
+ const data = (_b = (_a = event === null || event === void 0 ? void 0 : event.nativeEvent) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : event === null || event === void 0 ? void 0 : event.data;
46
+ if (!data)
47
+ return;
48
+ const message = JSON.parse(data);
49
+ if (message.source !== "PaymentJS")
50
+ return;
51
+ switch (message.event) {
52
+ case "PAYMENT_SUCCESS":
53
+ onSuccess(message.payload);
54
+ break;
55
+ case "PAYMENT_ERROR":
56
+ case "CONFIG_ERROR":
57
+ onFailure === null || onFailure === void 0 ? void 0 : onFailure(message.payload);
58
+ break;
59
+ }
60
+ }
61
+ catch (err) {
62
+ onFailure === null || onFailure === void 0 ? void 0 : onFailure({
63
+ message: "Invalid message from payment WebView",
64
+ error: err
65
+ });
66
+ }
67
+ }, [onSuccess, onFailure]);
68
+ return (react_1.default.createElement(react_native_1.View, { style: [{ flex: 1, backgroundColor: "#fff" }, style] },
69
+ react_1.default.createElement(react_native_webview_1.WebView, { source: { uri }, javaScriptEnabled: true, domStorageEnabled: true, originWhitelist: ["*"], startInLoadingState: true, onMessage: handleMessage, allowsBackForwardNavigationGestures: true, setSupportMultipleWindows: false })));
70
+ };
71
+ exports.default = PaymentJS;
@@ -0,0 +1,2 @@
1
+ export { default as PaymentJS } from "./PaymentJS";
2
+ export * from "./types";
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ Object.defineProperty(exports, "__esModule", { value: true });
20
+ exports.PaymentJS = void 0;
21
+ var PaymentJS_1 = require("./PaymentJS");
22
+ Object.defineProperty(exports, "PaymentJS", { enumerable: true, get: function () { return __importDefault(PaymentJS_1).default; } });
23
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,25 @@
1
+ import { StyleProp, ViewStyle } from "react-native";
2
+ export type PaymentJSEvent = "PAYMENT_SUCCESS" | "PAYMENT_ERROR" | "CONFIG_ERROR";
3
+ export interface PaymentJSMessage {
4
+ source: "PaymentJS";
5
+ event: PaymentJSEvent;
6
+ payload: any;
7
+ }
8
+ export interface PaymentJSProps {
9
+ /**
10
+ * Full URL to react-test.html with query params
11
+ */
12
+ uri: string;
13
+ /**
14
+ * Called when payment completes successfully
15
+ */
16
+ onSuccess: (payload: any) => void;
17
+ /**
18
+ * Called when payment fails or config error occurs
19
+ */
20
+ onFailure?: (payload: any) => void;
21
+ /**
22
+ * Optional container styling
23
+ */
24
+ style?: StyleProp<ViewStyle>;
25
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@school24/paymentjs-rn",
3
+ "version": "1.0.0",
4
+ "description": "React Native WebView wrapper for PaymentJS (Adyen)",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "npx tsc",
12
+ "prepublishOnly": "npm run build"
13
+ },
14
+ "keywords": [
15
+ "react-native",
16
+ "payments",
17
+ "adyen",
18
+ "webview",
19
+ "school24"
20
+ ],
21
+ "author": "School24",
22
+ "license": "MIT",
23
+ "peerDependencies": {
24
+ "react": ">=17",
25
+ "react-native": ">=0.68",
26
+ "react-native-webview": ">=11"
27
+ },
28
+ "devDependencies": {
29
+ "@types/react": "^19.2.7",
30
+ "@types/react-native": "^0.72.8",
31
+ "typescript": "^5.9.3"
32
+ }
33
+ }