@nordhealth/provet-pay-elements 0.15.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.
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Types shared by the host side, which `mount()` runs on the consumer's page,
3
+ * and the element side, the card UI the host renders into the consumer's
4
+ * container.
5
+ */
6
+ /** Type/paint styling Adyen allows inside its secured-field iframes. */
7
+ interface SecuredFieldStyle {
8
+ background?: string;
9
+ caretColor?: string;
10
+ color?: string;
11
+ fontFamily?: string;
12
+ fontSize?: string;
13
+ fontSmoothing?: string;
14
+ fontStyle?: string;
15
+ fontWeight?: string;
16
+ letterSpacing?: string;
17
+ lineHeight?: string;
18
+ padding?: string;
19
+ textAlign?: string;
20
+ transition?: string;
21
+ }
22
+ /** Styling for the element. Two mechanisms, one object. */
23
+ interface PayCardAppearance {
24
+ /**
25
+ * The element's own design tokens. Each writes one `--pp-*` custom property,
26
+ * which styles the chrome and — through the mapping the element's stylesheet
27
+ * declares — Adyen's card fields with it. Values may be raw CSS values or
28
+ * `var(…)` references; unset ones keep the element's defaults.
29
+ */
30
+ variables?: {
31
+ colorAccent?: string;
32
+ /** Adyen's pay button. It carries white text, so keep it dark enough. */
33
+ colorButton?: string;
34
+ colorText?: string;
35
+ colorBorder?: string;
36
+ colorSurface?: string;
37
+ colorError?: string;
38
+ borderRadius?: string;
39
+ fontFamily?: string;
40
+ };
41
+ /**
42
+ * Styles applied INSIDE Adyen's cross-origin secured-field iframes.
43
+ * Only the type/paint subset above is supported there.
44
+ */
45
+ secured?: {
46
+ base?: SecuredFieldStyle;
47
+ error?: SecuredFieldStyle;
48
+ placeholder?: SecuredFieldStyle;
49
+ validated?: SecuredFieldStyle;
50
+ };
51
+ /**
52
+ * Raw custom properties, `--pp-*` or `--adyen-sdk-*` — the escape hatch, and
53
+ * the last word over anything `variables` wrote.
54
+ */
55
+ cssVariables?: Record<string, string>;
56
+ }
57
+
58
+ /** Gateway `recurring_model` — not Adyen's `recurringProcessingModel`. */
59
+ type RecurringModel = 'subscription' | 'one-off';
60
+ /**
61
+ * A Provet saved card, as `GET /pay/saved-cards/` lists it: only cards that can
62
+ * be charged, so a row carries no status. `id` is the `payment_card_id` handed
63
+ * to the feature.
64
+ */
65
+ interface SavedCard {
66
+ /** Provet sends the id as an integer; the element hands it on as a string. */
67
+ id: string;
68
+ /** Adyen brand code, e.g. "visa" | "mc"; the element renders the name. */
69
+ brand?: string | null;
70
+ last4?: string | null;
71
+ /** ISO date of the month printed on the card, e.g. "2030-03-31". */
72
+ expiration_date?: string | null;
73
+ /** The client's default card for charges. */
74
+ default?: boolean;
75
+ }
76
+ type ElementErrorType = 'session_error' | 'auth_error' | 'technical';
77
+ interface ElementErrorPayload {
78
+ type: ElementErrorType;
79
+ message: string;
80
+ }
81
+
82
+ /**
83
+ * Who the element acts for. Every field but `provetOrigin` and `refreshToken`
84
+ * is required: the element builds its Provet URLs from them and keys its
85
+ * stored session by them, so one shopper never resumes another's session.
86
+ */
87
+ interface ElementAuth {
88
+ /** The browser token: the `card_tokenization` Bearer the consumer's backend exchanged. */
89
+ token: string;
90
+ /**
91
+ * The Provet instance the token came from, e.g. `https://us.provetcloud.com`.
92
+ * Omit it to use the instance this build was made for.
93
+ */
94
+ provetOrigin?: string;
95
+ /** The clinic's Provet instance id — the tenant. */
96
+ provetId: string | number;
97
+ /**
98
+ * The shopper: the Provet client id the token's audience names
99
+ * (`client:<id>`) — not an OAuth client id.
100
+ */
101
+ clientId: string | number;
102
+ /** The clinic's Provet department id. It resolves who Adyen pays. */
103
+ departmentId: string | number;
104
+ /**
105
+ * Returns a fresh token when Provet answers 401. Without it an expired
106
+ * token is reported through `onError`.
107
+ */
108
+ refreshToken?: () => Promise<string>;
109
+ }
110
+ interface MountOptions {
111
+ auth: ElementAuth;
112
+ recurringModel?: RecurringModel;
113
+ locale?: string;
114
+ appearance?: PayCardAppearance;
115
+ /** The card fields are rendered. */
116
+ onReady?: () => void;
117
+ /**
118
+ * The shopper is done with the card. `card.id` is the handle to hand the
119
+ * feature; it is chargeable once the tokenization webhook resolves it
120
+ * server-side. A picked saved card carries the details the list showed; a
121
+ * card saved in the form carries only its `id`.
122
+ *
123
+ * It still fires after `unmount()` for a card whose save was already under
124
+ * way; no other callback does.
125
+ */
126
+ onSuccess: (result: {
127
+ card: SavedCard;
128
+ }) => void;
129
+ /** The `$0` auth was refused. The element retries in place. */
130
+ onRefused?: () => void;
131
+ onError?: (error: ElementErrorPayload) => void;
132
+ }
133
+ interface ElementHandle {
134
+ unmount(): void;
135
+ }
136
+ declare function mount(container: HTMLElement | string, options: MountOptions): ElementHandle;
137
+
138
+ declare const VERSION: string;
139
+
140
+ export { VERSION, mount };
141
+ export type { ElementAuth, ElementErrorPayload, ElementErrorType, ElementHandle, MountOptions, PayCardAppearance, RecurringModel, SavedCard, SecuredFieldStyle };
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Types shared by the host side, which `mount()` runs on the consumer's page,
3
+ * and the element side, the card UI the host renders into the consumer's
4
+ * container.
5
+ */
6
+ /** Type/paint styling Adyen allows inside its secured-field iframes. */
7
+ interface SecuredFieldStyle {
8
+ background?: string;
9
+ caretColor?: string;
10
+ color?: string;
11
+ fontFamily?: string;
12
+ fontSize?: string;
13
+ fontSmoothing?: string;
14
+ fontStyle?: string;
15
+ fontWeight?: string;
16
+ letterSpacing?: string;
17
+ lineHeight?: string;
18
+ padding?: string;
19
+ textAlign?: string;
20
+ transition?: string;
21
+ }
22
+ /** Styling for the element. Two mechanisms, one object. */
23
+ interface PayCardAppearance {
24
+ /**
25
+ * The element's own design tokens. Each writes one `--pp-*` custom property,
26
+ * which styles the chrome and — through the mapping the element's stylesheet
27
+ * declares — Adyen's card fields with it. Values may be raw CSS values or
28
+ * `var(…)` references; unset ones keep the element's defaults.
29
+ */
30
+ variables?: {
31
+ colorAccent?: string;
32
+ /** Adyen's pay button. It carries white text, so keep it dark enough. */
33
+ colorButton?: string;
34
+ colorText?: string;
35
+ colorBorder?: string;
36
+ colorSurface?: string;
37
+ colorError?: string;
38
+ borderRadius?: string;
39
+ fontFamily?: string;
40
+ };
41
+ /**
42
+ * Styles applied INSIDE Adyen's cross-origin secured-field iframes.
43
+ * Only the type/paint subset above is supported there.
44
+ */
45
+ secured?: {
46
+ base?: SecuredFieldStyle;
47
+ error?: SecuredFieldStyle;
48
+ placeholder?: SecuredFieldStyle;
49
+ validated?: SecuredFieldStyle;
50
+ };
51
+ /**
52
+ * Raw custom properties, `--pp-*` or `--adyen-sdk-*` — the escape hatch, and
53
+ * the last word over anything `variables` wrote.
54
+ */
55
+ cssVariables?: Record<string, string>;
56
+ }
57
+
58
+ /** Gateway `recurring_model` — not Adyen's `recurringProcessingModel`. */
59
+ type RecurringModel = 'subscription' | 'one-off';
60
+ /**
61
+ * A Provet saved card, as `GET /pay/saved-cards/` lists it: only cards that can
62
+ * be charged, so a row carries no status. `id` is the `payment_card_id` handed
63
+ * to the feature.
64
+ */
65
+ interface SavedCard {
66
+ /** Provet sends the id as an integer; the element hands it on as a string. */
67
+ id: string;
68
+ /** Adyen brand code, e.g. "visa" | "mc"; the element renders the name. */
69
+ brand?: string | null;
70
+ last4?: string | null;
71
+ /** ISO date of the month printed on the card, e.g. "2030-03-31". */
72
+ expiration_date?: string | null;
73
+ /** The client's default card for charges. */
74
+ default?: boolean;
75
+ }
76
+ type ElementErrorType = 'session_error' | 'auth_error' | 'technical';
77
+ interface ElementErrorPayload {
78
+ type: ElementErrorType;
79
+ message: string;
80
+ }
81
+
82
+ /**
83
+ * Who the element acts for. Every field but `provetOrigin` and `refreshToken`
84
+ * is required: the element builds its Provet URLs from them and keys its
85
+ * stored session by them, so one shopper never resumes another's session.
86
+ */
87
+ interface ElementAuth {
88
+ /** The browser token: the `card_tokenization` Bearer the consumer's backend exchanged. */
89
+ token: string;
90
+ /**
91
+ * The Provet instance the token came from, e.g. `https://us.provetcloud.com`.
92
+ * Omit it to use the instance this build was made for.
93
+ */
94
+ provetOrigin?: string;
95
+ /** The clinic's Provet instance id — the tenant. */
96
+ provetId: string | number;
97
+ /**
98
+ * The shopper: the Provet client id the token's audience names
99
+ * (`client:<id>`) — not an OAuth client id.
100
+ */
101
+ clientId: string | number;
102
+ /** The clinic's Provet department id. It resolves who Adyen pays. */
103
+ departmentId: string | number;
104
+ /**
105
+ * Returns a fresh token when Provet answers 401. Without it an expired
106
+ * token is reported through `onError`.
107
+ */
108
+ refreshToken?: () => Promise<string>;
109
+ }
110
+ interface MountOptions {
111
+ auth: ElementAuth;
112
+ recurringModel?: RecurringModel;
113
+ locale?: string;
114
+ appearance?: PayCardAppearance;
115
+ /** The card fields are rendered. */
116
+ onReady?: () => void;
117
+ /**
118
+ * The shopper is done with the card. `card.id` is the handle to hand the
119
+ * feature; it is chargeable once the tokenization webhook resolves it
120
+ * server-side. A picked saved card carries the details the list showed; a
121
+ * card saved in the form carries only its `id`.
122
+ *
123
+ * It still fires after `unmount()` for a card whose save was already under
124
+ * way; no other callback does.
125
+ */
126
+ onSuccess: (result: {
127
+ card: SavedCard;
128
+ }) => void;
129
+ /** The `$0` auth was refused. The element retries in place. */
130
+ onRefused?: () => void;
131
+ onError?: (error: ElementErrorPayload) => void;
132
+ }
133
+ interface ElementHandle {
134
+ unmount(): void;
135
+ }
136
+ declare function mount(container: HTMLElement | string, options: MountOptions): ElementHandle;
137
+
138
+ declare const VERSION: string;
139
+
140
+ export { VERSION, mount };
141
+ export type { ElementAuth, ElementErrorPayload, ElementErrorType, ElementHandle, MountOptions, PayCardAppearance, RecurringModel, SavedCard, SecuredFieldStyle };
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@nordhealth/provet-pay-elements",
3
+ "version": "0.15.0",
4
+ "description": "Embeddable Provet Pay card tokenizer — the Adyen Web v6 Sessions flow, mounted on the consumer’s own page and backed by Provet.",
5
+ "license": "SEE LICENSE IN LICENSE.md",
6
+ "homepage": "https://gitlab.com/nordhealth/projects/microservices/payment-gateway/pay-js/-/tree/master/provet-pay-elements",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://gitlab.com/nordhealth/projects/microservices/payment-gateway/pay-js.git",
10
+ "directory": "provet-pay-elements"
11
+ },
12
+ "sideEffects": false,
13
+ "exports": {
14
+ ".": {
15
+ "import": {
16
+ "types": "./dist/types/index.d.mts",
17
+ "default": "./dist/loader/provet-pay-elements.mjs"
18
+ },
19
+ "require": {
20
+ "types": "./dist/types/index.d.ts",
21
+ "default": "./dist/loader/provet-pay-elements.umd.js"
22
+ }
23
+ }
24
+ },
25
+ "main": "./dist/loader/provet-pay-elements.umd.js",
26
+ "module": "./dist/loader/provet-pay-elements.mjs",
27
+ "types": "./dist/types/index.d.ts",
28
+ "files": [
29
+ "dist",
30
+ "CHANGELOG.md",
31
+ "LICENSE.md",
32
+ "README.md"
33
+ ],
34
+ "scripts": {
35
+ "build": "pnpm tsc && pnpm lint && pnpm build:loader && pnpm build:types && tsc -p dev/tsconfig.dist.json",
36
+ "build:loader": "vite build",
37
+ "build:types": "tsc -p tsconfig.declarations.json && rollup -c rollup.dts.config.mjs && rm -rf dist/types-src",
38
+ "check:dist-types": "tsc -p dev/tsconfig.dist.json",
39
+ "depcheck": "depcheck",
40
+ "dev": "vite build && concurrently -n loader,provet \"vite build --watch\" \"node --watch --env-file-if-exists=dev/.env dev/server.js\"",
41
+ "lint": "eslint 'src/**/*.ts' 'vite.config.mts' 'vite.environment.mts' 'jest.setup.ts'",
42
+ "prepublishOnly": "pnpm build",
43
+ "scenarios:dummypms": "playwright test -c dev/scenarios/playwright.config.ts",
44
+ "sort-packages": "npx sort-package-json",
45
+ "test": "jest --selectProjects='@nordhealth/provet-pay-elements' --config='../jest.config.mjs'",
46
+ "try:dummypms": "node dev/try-on-dummypms.mjs",
47
+ "tsc": "tsc --noEmit"
48
+ },
49
+ "devDependencies": {
50
+ "@adyen/adyen-web": "catalog:",
51
+ "@types/node": "catalog:",
52
+ "concurrently": "catalog:",
53
+ "express": "catalog:",
54
+ "jest": "catalog:",
55
+ "jest-fetch-mock": "catalog:",
56
+ "rollup": "catalog:",
57
+ "rollup-plugin-dts": "catalog:",
58
+ "typescript": "catalog:",
59
+ "vite": "catalog:"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public",
63
+ "provenance": true
64
+ },
65
+ "type": "commonjs"
66
+ }