@nordhealth/provet-pay-elements 0.15.0 → 0.18.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 +62 -0
- package/README.md +133 -38
- package/dist/loader/provet-pay-elements.mjs +2581 -2255
- package/dist/loader/provet-pay-elements.mjs.map +1 -1
- package/dist/loader/provet-pay-elements.umd.js +7 -7
- package/dist/loader/provet-pay-elements.umd.js.map +1 -1
- package/dist/types/index.d.mts +170 -21
- package/dist/types/index.d.ts +170 -21
- package/package.json +1 -1
package/dist/types/index.d.mts
CHANGED
|
@@ -3,29 +3,67 @@
|
|
|
3
3
|
* and the element side, the card UI the host renders into the consumer's
|
|
4
4
|
* container.
|
|
5
5
|
*/
|
|
6
|
-
/**
|
|
7
|
-
interface
|
|
6
|
+
/** Adyen's `StyleDefinitions`: the CSS a card field's iframe accepts. */
|
|
7
|
+
interface StyleDefinitions {
|
|
8
8
|
background?: string;
|
|
9
9
|
caretColor?: string;
|
|
10
10
|
color?: string;
|
|
11
|
+
display?: string;
|
|
12
|
+
font?: string;
|
|
11
13
|
fontFamily?: string;
|
|
12
14
|
fontSize?: string;
|
|
15
|
+
fontSizeAdjust?: string;
|
|
13
16
|
fontSmoothing?: string;
|
|
17
|
+
fontStretch?: string;
|
|
14
18
|
fontStyle?: string;
|
|
19
|
+
fontVariant?: string;
|
|
20
|
+
fontVariantAlternates?: string;
|
|
21
|
+
fontVariantCaps?: string;
|
|
22
|
+
fontVariantEastAsian?: string;
|
|
23
|
+
fontVariantLigatures?: string;
|
|
24
|
+
fontVariantNumeric?: string;
|
|
15
25
|
fontWeight?: string;
|
|
16
26
|
letterSpacing?: string;
|
|
17
27
|
lineHeight?: string;
|
|
28
|
+
mozOsxFontSmoothing?: string;
|
|
29
|
+
mozTransition?: string;
|
|
30
|
+
outline?: string;
|
|
31
|
+
opacity?: string;
|
|
18
32
|
padding?: string;
|
|
19
33
|
textAlign?: string;
|
|
34
|
+
textShadow?: string;
|
|
20
35
|
transition?: string;
|
|
36
|
+
webkitFontSmoothing?: string;
|
|
37
|
+
webkitTransition?: string;
|
|
38
|
+
wordSpacing?: string;
|
|
21
39
|
}
|
|
22
|
-
/**
|
|
40
|
+
/** Adyen's `StylesObject`: the card fields' `styles`, by field state. */
|
|
41
|
+
interface StylesObject {
|
|
42
|
+
base?: StyleDefinitions;
|
|
43
|
+
error?: StyleDefinitions;
|
|
44
|
+
validated?: StyleDefinitions;
|
|
45
|
+
placeholder?: StyleDefinitions;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Adyen's `DisclaimerMsgObject`: a line under the card fields. `%{linkText}`
|
|
49
|
+
* in `message` becomes `linkText`, linking to `link`.
|
|
50
|
+
*/
|
|
51
|
+
interface DisclaimerMsgObject {
|
|
52
|
+
message: string;
|
|
53
|
+
linkText: string;
|
|
54
|
+
link: string;
|
|
55
|
+
}
|
|
56
|
+
/** Adyen's `ResultCode`. */
|
|
57
|
+
type ResultCode = 'AuthenticationFinished' | 'AuthenticationNotRequired' | 'Authorised' | 'Cancelled' | 'ChallengeShopper' | 'Error' | 'IdentifyShopper' | 'PartiallyAuthorised' | 'Pending' | 'PresentToShopper' | 'Received' | 'RedirectShopper' | 'Refused';
|
|
58
|
+
/** Styling for the element's own UI. Adyen's card fields take `styles`. */
|
|
23
59
|
interface PayCardAppearance {
|
|
24
60
|
/**
|
|
25
61
|
* The element's own design tokens. Each writes one `--pp-*` custom property,
|
|
26
62
|
* which styles the chrome and — through the mapping the element's stylesheet
|
|
27
|
-
* declares — Adyen's card fields with it.
|
|
28
|
-
* `
|
|
63
|
+
* declares — Adyen's card fields with it. `colorText`, `fontFamily` and
|
|
64
|
+
* `colorError` also reach inside the fields' iframes, where `styles` wins
|
|
65
|
+
* over them. Values may be raw CSS values or `var(…)` references; unset ones
|
|
66
|
+
* keep the element's defaults.
|
|
29
67
|
*/
|
|
30
68
|
variables?: {
|
|
31
69
|
colorAccent?: string;
|
|
@@ -38,22 +76,76 @@ interface PayCardAppearance {
|
|
|
38
76
|
borderRadius?: string;
|
|
39
77
|
fontFamily?: string;
|
|
40
78
|
};
|
|
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
79
|
/**
|
|
52
80
|
* Raw custom properties, `--pp-*` or `--adyen-sdk-*` — the escape hatch, and
|
|
53
81
|
* the last word over anything `variables` wrote.
|
|
54
82
|
*/
|
|
55
83
|
cssVariables?: Record<string, string>;
|
|
56
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Adyen's `CustomTranslations`: text by locale, then by translation key. One
|
|
87
|
+
* object serves Adyen's card fields (Adyen's keys) and the component's own
|
|
88
|
+
* text (`PayCardTranslations`).
|
|
89
|
+
*/
|
|
90
|
+
type CustomTranslations = Record<string, Record<string, string>>;
|
|
91
|
+
/**
|
|
92
|
+
* The component's own keys, in Adyen's format: `%{name}` placeholders are
|
|
93
|
+
* filled in by the component. The `savedCards.remove*` keys belong to
|
|
94
|
+
* removing a saved card, which this version does not offer yet; they may
|
|
95
|
+
* change before it does.
|
|
96
|
+
*/
|
|
97
|
+
interface PayCardTranslations {
|
|
98
|
+
/** Default: "Back to saved cards" */
|
|
99
|
+
'provetPay.backToSavedCards'?: string;
|
|
100
|
+
/** Default: "Card saved" */
|
|
101
|
+
'provetPay.cardSaved'?: string;
|
|
102
|
+
/** Default: "This card form had too many attempts. Try again later, or use another card." */
|
|
103
|
+
'provetPay.errors.attempts_exceeded'?: string;
|
|
104
|
+
/** Default: "The card form is not available right now. Reload the page and try again." */
|
|
105
|
+
'provetPay.errors.auth_error'?: string;
|
|
106
|
+
/** Default: "The card form is not available right now. Reload the page and try again." */
|
|
107
|
+
'provetPay.errors.auth_forbidden'?: string;
|
|
108
|
+
/** Default: "The card setup was cancelled." */
|
|
109
|
+
'provetPay.errors.cancelled'?: string;
|
|
110
|
+
/** Default: "Something went wrong while setting up the card." */
|
|
111
|
+
'provetPay.errors.config_invalid'?: string;
|
|
112
|
+
/** Default: "Could not reach the server. Check your connection and try again." */
|
|
113
|
+
'provetPay.errors.network'?: string;
|
|
114
|
+
/** Default: "The card form could not be opened. Try again later." */
|
|
115
|
+
'provetPay.errors.session_error'?: string;
|
|
116
|
+
/** Default: "Something went wrong while setting up the card." */
|
|
117
|
+
'provetPay.errors.technical'?: string;
|
|
118
|
+
/** Default: "Loading the card form" (read by screen readers) */
|
|
119
|
+
'provetPay.loading'?: string;
|
|
120
|
+
/** Default: "The card check was cancelled. Try again." */
|
|
121
|
+
'provetPay.notices.cancelled'?: string;
|
|
122
|
+
/** Default: "Something went wrong while checking the card. Try again, or use another card." */
|
|
123
|
+
'provetPay.notices.error'?: string;
|
|
124
|
+
/** Default: "The card was declined. Try another card." */
|
|
125
|
+
'provetPay.notices.refused'?: string;
|
|
126
|
+
/** Default: "Add a new card" */
|
|
127
|
+
'provetPay.savedCards.addNew'?: string;
|
|
128
|
+
/** Default: "Choose your saved card" (one card) */
|
|
129
|
+
'provetPay.savedCards.choose'?: string;
|
|
130
|
+
/** Default: "Choose one of your %{count} saved cards" (more than one; `__2`, `__3` … name an exact count) */
|
|
131
|
+
'provetPay.savedCards.choose__plural'?: string;
|
|
132
|
+
/** Default: "(EXP: %{date})" */
|
|
133
|
+
'provetPay.savedCards.expiry'?: string;
|
|
134
|
+
/** Default: "Use a saved card" */
|
|
135
|
+
'provetPay.savedCards.heading'?: string;
|
|
136
|
+
/** Default: "Saved cards" (read by screen readers) */
|
|
137
|
+
'provetPay.savedCards.list'?: string;
|
|
138
|
+
/** Default: "Saved card" (a card with no number on record) */
|
|
139
|
+
'provetPay.savedCards.noNumber'?: string;
|
|
140
|
+
/** Default: "Remove %{card}" */
|
|
141
|
+
'provetPay.savedCards.remove'?: string;
|
|
142
|
+
/** Default: "Cancel" */
|
|
143
|
+
'provetPay.savedCards.removeCancel'?: string;
|
|
144
|
+
/** Default: "Remove" */
|
|
145
|
+
'provetPay.savedCards.removeConfirm'?: string;
|
|
146
|
+
/** Default: "Remove this saved card?" */
|
|
147
|
+
'provetPay.savedCards.removeQuestion'?: string;
|
|
148
|
+
}
|
|
57
149
|
|
|
58
150
|
/** Gateway `recurring_model` — not Adyen's `recurringProcessingModel`. */
|
|
59
151
|
type RecurringModel = 'subscription' | 'one-off';
|
|
@@ -110,9 +202,38 @@ interface ElementAuth {
|
|
|
110
202
|
interface MountOptions {
|
|
111
203
|
auth: ElementAuth;
|
|
112
204
|
recurringModel?: RecurringModel;
|
|
205
|
+
/**
|
|
206
|
+
* Adyen's `locale`, for example `fi-FI` or `no-NO`. Adyen's card fields and
|
|
207
|
+
* the component's text both read it as Adyen does. Left out or empty, both
|
|
208
|
+
* get `DEFAULT_LOCALE` (`en-GB`). Adyen has no British English of its own,
|
|
209
|
+
* so its card fields read US English, with Adyen's keys from `translations`
|
|
210
|
+
* for the English locale it settles on, if any. Setting it on this object
|
|
211
|
+
* after `mount()` changes the language, as `changeLocale` does.
|
|
212
|
+
*/
|
|
113
213
|
locale?: string;
|
|
214
|
+
/**
|
|
215
|
+
* Adyen's `translations`, keyed by locale: Adyen's keys change the card
|
|
216
|
+
* fields, the `provetPay.*` keys (`PayCardTranslations`) the component's
|
|
217
|
+
* text. A locale neither ships works this way too.
|
|
218
|
+
*/
|
|
219
|
+
translations?: CustomTranslations;
|
|
114
220
|
appearance?: PayCardAppearance;
|
|
115
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* Adyen's `styles` for the card fields, by field state. They win over what
|
|
223
|
+
* `appearance.variables` reaches inside the fields.
|
|
224
|
+
*/
|
|
225
|
+
styles?: StylesObject;
|
|
226
|
+
/**
|
|
227
|
+
* Adyen's `disclaimerMessage`: a line under the card fields. Adyen asks for
|
|
228
|
+
* the shopper's consent before a card is stored for later payments; this is
|
|
229
|
+
* one place to ask for it.
|
|
230
|
+
*/
|
|
231
|
+
disclaimerMessage?: DisclaimerMsgObject;
|
|
232
|
+
/**
|
|
233
|
+
* The shopper has something to act on: the saved cards, or the card fields
|
|
234
|
+
* once Adyen says they are ready. Called once per mount, and once more each
|
|
235
|
+
* time `changeLocale` starts the form again.
|
|
236
|
+
*/
|
|
116
237
|
onReady?: () => void;
|
|
117
238
|
/**
|
|
118
239
|
* The shopper is done with the card. `card.id` is the handle to hand the
|
|
@@ -121,21 +242,49 @@ interface MountOptions {
|
|
|
121
242
|
* card saved in the form carries only its `id`.
|
|
122
243
|
*
|
|
123
244
|
* It still fires after `unmount()` for a card whose save was already under
|
|
124
|
-
* way; no other callback does.
|
|
245
|
+
* way; no other callback does. `resultCode` is Adyen's for a card saved in the
|
|
246
|
+
* form, for example `Authorised`; a picked card has none.
|
|
125
247
|
*/
|
|
126
248
|
onSuccess: (result: {
|
|
127
249
|
card: SavedCard;
|
|
250
|
+
resultCode?: ResultCode;
|
|
128
251
|
}) => void;
|
|
129
|
-
/**
|
|
130
|
-
|
|
252
|
+
/**
|
|
253
|
+
* The `$0` check ended `Refused`, `Cancelled` or `Error`, Adyen's
|
|
254
|
+
* `resultCode`. The form says why, and the shopper retries in place.
|
|
255
|
+
*/
|
|
256
|
+
onRefused?: (result: {
|
|
257
|
+
resultCode: ResultCode;
|
|
258
|
+
}) => void;
|
|
259
|
+
/**
|
|
260
|
+
* Something went wrong. When the component cannot go on, the form shows a
|
|
261
|
+
* banner. When Adyen reports an error with its card fields loaded and on the
|
|
262
|
+
* page, such as a failed call during the check, the form stays and the
|
|
263
|
+
* shopper can try again.
|
|
264
|
+
*/
|
|
131
265
|
onError?: (error: ElementErrorPayload) => void;
|
|
132
266
|
}
|
|
133
267
|
interface ElementHandle {
|
|
134
268
|
unmount(): void;
|
|
269
|
+
/**
|
|
270
|
+
* Starts the form again in `locale`, which takes what the `locale` option
|
|
271
|
+
* takes; setting `locale` on the options object does the same. Adyen takes
|
|
272
|
+
* a locale only when it starts, so its card fields start again too: what the
|
|
273
|
+
* shopper typed into them is cleared, and `onReady` is called again. An open
|
|
274
|
+
* card session is resumed; one still being opened is not waited for. It
|
|
275
|
+
* does nothing for the locale the form already has, while a card check is
|
|
276
|
+
* running, once the card is saved, or after `unmount()`.
|
|
277
|
+
*/
|
|
278
|
+
changeLocale(locale?: string): void;
|
|
135
279
|
}
|
|
136
280
|
declare function mount(container: HTMLElement | string, options: MountOptions): ElementHandle;
|
|
137
281
|
|
|
282
|
+
/** The locale the component and Adyen get when the consumer passes none, and the component's fallback. */
|
|
283
|
+
declare const DEFAULT_LOCALE = "en-GB";
|
|
284
|
+
/** The component's own text in `DEFAULT_LOCALE`: every `provetPay.*` key with its British English default. Read-only. */
|
|
285
|
+
declare const DEFAULT_TRANSLATIONS: Readonly<Required<PayCardTranslations>>;
|
|
286
|
+
|
|
138
287
|
declare const VERSION: string;
|
|
139
288
|
|
|
140
|
-
export { VERSION, mount };
|
|
141
|
-
export type { ElementAuth, ElementErrorPayload, ElementErrorType, ElementHandle, MountOptions, PayCardAppearance, RecurringModel, SavedCard,
|
|
289
|
+
export { DEFAULT_LOCALE, DEFAULT_TRANSLATIONS, VERSION, mount };
|
|
290
|
+
export type { CustomTranslations, DisclaimerMsgObject, ElementAuth, ElementErrorPayload, ElementErrorType, ElementHandle, MountOptions, PayCardAppearance, PayCardTranslations, RecurringModel, ResultCode, SavedCard, StyleDefinitions, StylesObject };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,29 +3,67 @@
|
|
|
3
3
|
* and the element side, the card UI the host renders into the consumer's
|
|
4
4
|
* container.
|
|
5
5
|
*/
|
|
6
|
-
/**
|
|
7
|
-
interface
|
|
6
|
+
/** Adyen's `StyleDefinitions`: the CSS a card field's iframe accepts. */
|
|
7
|
+
interface StyleDefinitions {
|
|
8
8
|
background?: string;
|
|
9
9
|
caretColor?: string;
|
|
10
10
|
color?: string;
|
|
11
|
+
display?: string;
|
|
12
|
+
font?: string;
|
|
11
13
|
fontFamily?: string;
|
|
12
14
|
fontSize?: string;
|
|
15
|
+
fontSizeAdjust?: string;
|
|
13
16
|
fontSmoothing?: string;
|
|
17
|
+
fontStretch?: string;
|
|
14
18
|
fontStyle?: string;
|
|
19
|
+
fontVariant?: string;
|
|
20
|
+
fontVariantAlternates?: string;
|
|
21
|
+
fontVariantCaps?: string;
|
|
22
|
+
fontVariantEastAsian?: string;
|
|
23
|
+
fontVariantLigatures?: string;
|
|
24
|
+
fontVariantNumeric?: string;
|
|
15
25
|
fontWeight?: string;
|
|
16
26
|
letterSpacing?: string;
|
|
17
27
|
lineHeight?: string;
|
|
28
|
+
mozOsxFontSmoothing?: string;
|
|
29
|
+
mozTransition?: string;
|
|
30
|
+
outline?: string;
|
|
31
|
+
opacity?: string;
|
|
18
32
|
padding?: string;
|
|
19
33
|
textAlign?: string;
|
|
34
|
+
textShadow?: string;
|
|
20
35
|
transition?: string;
|
|
36
|
+
webkitFontSmoothing?: string;
|
|
37
|
+
webkitTransition?: string;
|
|
38
|
+
wordSpacing?: string;
|
|
21
39
|
}
|
|
22
|
-
/**
|
|
40
|
+
/** Adyen's `StylesObject`: the card fields' `styles`, by field state. */
|
|
41
|
+
interface StylesObject {
|
|
42
|
+
base?: StyleDefinitions;
|
|
43
|
+
error?: StyleDefinitions;
|
|
44
|
+
validated?: StyleDefinitions;
|
|
45
|
+
placeholder?: StyleDefinitions;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Adyen's `DisclaimerMsgObject`: a line under the card fields. `%{linkText}`
|
|
49
|
+
* in `message` becomes `linkText`, linking to `link`.
|
|
50
|
+
*/
|
|
51
|
+
interface DisclaimerMsgObject {
|
|
52
|
+
message: string;
|
|
53
|
+
linkText: string;
|
|
54
|
+
link: string;
|
|
55
|
+
}
|
|
56
|
+
/** Adyen's `ResultCode`. */
|
|
57
|
+
type ResultCode = 'AuthenticationFinished' | 'AuthenticationNotRequired' | 'Authorised' | 'Cancelled' | 'ChallengeShopper' | 'Error' | 'IdentifyShopper' | 'PartiallyAuthorised' | 'Pending' | 'PresentToShopper' | 'Received' | 'RedirectShopper' | 'Refused';
|
|
58
|
+
/** Styling for the element's own UI. Adyen's card fields take `styles`. */
|
|
23
59
|
interface PayCardAppearance {
|
|
24
60
|
/**
|
|
25
61
|
* The element's own design tokens. Each writes one `--pp-*` custom property,
|
|
26
62
|
* which styles the chrome and — through the mapping the element's stylesheet
|
|
27
|
-
* declares — Adyen's card fields with it.
|
|
28
|
-
* `
|
|
63
|
+
* declares — Adyen's card fields with it. `colorText`, `fontFamily` and
|
|
64
|
+
* `colorError` also reach inside the fields' iframes, where `styles` wins
|
|
65
|
+
* over them. Values may be raw CSS values or `var(…)` references; unset ones
|
|
66
|
+
* keep the element's defaults.
|
|
29
67
|
*/
|
|
30
68
|
variables?: {
|
|
31
69
|
colorAccent?: string;
|
|
@@ -38,22 +76,76 @@ interface PayCardAppearance {
|
|
|
38
76
|
borderRadius?: string;
|
|
39
77
|
fontFamily?: string;
|
|
40
78
|
};
|
|
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
79
|
/**
|
|
52
80
|
* Raw custom properties, `--pp-*` or `--adyen-sdk-*` — the escape hatch, and
|
|
53
81
|
* the last word over anything `variables` wrote.
|
|
54
82
|
*/
|
|
55
83
|
cssVariables?: Record<string, string>;
|
|
56
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Adyen's `CustomTranslations`: text by locale, then by translation key. One
|
|
87
|
+
* object serves Adyen's card fields (Adyen's keys) and the component's own
|
|
88
|
+
* text (`PayCardTranslations`).
|
|
89
|
+
*/
|
|
90
|
+
type CustomTranslations = Record<string, Record<string, string>>;
|
|
91
|
+
/**
|
|
92
|
+
* The component's own keys, in Adyen's format: `%{name}` placeholders are
|
|
93
|
+
* filled in by the component. The `savedCards.remove*` keys belong to
|
|
94
|
+
* removing a saved card, which this version does not offer yet; they may
|
|
95
|
+
* change before it does.
|
|
96
|
+
*/
|
|
97
|
+
interface PayCardTranslations {
|
|
98
|
+
/** Default: "Back to saved cards" */
|
|
99
|
+
'provetPay.backToSavedCards'?: string;
|
|
100
|
+
/** Default: "Card saved" */
|
|
101
|
+
'provetPay.cardSaved'?: string;
|
|
102
|
+
/** Default: "This card form had too many attempts. Try again later, or use another card." */
|
|
103
|
+
'provetPay.errors.attempts_exceeded'?: string;
|
|
104
|
+
/** Default: "The card form is not available right now. Reload the page and try again." */
|
|
105
|
+
'provetPay.errors.auth_error'?: string;
|
|
106
|
+
/** Default: "The card form is not available right now. Reload the page and try again." */
|
|
107
|
+
'provetPay.errors.auth_forbidden'?: string;
|
|
108
|
+
/** Default: "The card setup was cancelled." */
|
|
109
|
+
'provetPay.errors.cancelled'?: string;
|
|
110
|
+
/** Default: "Something went wrong while setting up the card." */
|
|
111
|
+
'provetPay.errors.config_invalid'?: string;
|
|
112
|
+
/** Default: "Could not reach the server. Check your connection and try again." */
|
|
113
|
+
'provetPay.errors.network'?: string;
|
|
114
|
+
/** Default: "The card form could not be opened. Try again later." */
|
|
115
|
+
'provetPay.errors.session_error'?: string;
|
|
116
|
+
/** Default: "Something went wrong while setting up the card." */
|
|
117
|
+
'provetPay.errors.technical'?: string;
|
|
118
|
+
/** Default: "Loading the card form" (read by screen readers) */
|
|
119
|
+
'provetPay.loading'?: string;
|
|
120
|
+
/** Default: "The card check was cancelled. Try again." */
|
|
121
|
+
'provetPay.notices.cancelled'?: string;
|
|
122
|
+
/** Default: "Something went wrong while checking the card. Try again, or use another card." */
|
|
123
|
+
'provetPay.notices.error'?: string;
|
|
124
|
+
/** Default: "The card was declined. Try another card." */
|
|
125
|
+
'provetPay.notices.refused'?: string;
|
|
126
|
+
/** Default: "Add a new card" */
|
|
127
|
+
'provetPay.savedCards.addNew'?: string;
|
|
128
|
+
/** Default: "Choose your saved card" (one card) */
|
|
129
|
+
'provetPay.savedCards.choose'?: string;
|
|
130
|
+
/** Default: "Choose one of your %{count} saved cards" (more than one; `__2`, `__3` … name an exact count) */
|
|
131
|
+
'provetPay.savedCards.choose__plural'?: string;
|
|
132
|
+
/** Default: "(EXP: %{date})" */
|
|
133
|
+
'provetPay.savedCards.expiry'?: string;
|
|
134
|
+
/** Default: "Use a saved card" */
|
|
135
|
+
'provetPay.savedCards.heading'?: string;
|
|
136
|
+
/** Default: "Saved cards" (read by screen readers) */
|
|
137
|
+
'provetPay.savedCards.list'?: string;
|
|
138
|
+
/** Default: "Saved card" (a card with no number on record) */
|
|
139
|
+
'provetPay.savedCards.noNumber'?: string;
|
|
140
|
+
/** Default: "Remove %{card}" */
|
|
141
|
+
'provetPay.savedCards.remove'?: string;
|
|
142
|
+
/** Default: "Cancel" */
|
|
143
|
+
'provetPay.savedCards.removeCancel'?: string;
|
|
144
|
+
/** Default: "Remove" */
|
|
145
|
+
'provetPay.savedCards.removeConfirm'?: string;
|
|
146
|
+
/** Default: "Remove this saved card?" */
|
|
147
|
+
'provetPay.savedCards.removeQuestion'?: string;
|
|
148
|
+
}
|
|
57
149
|
|
|
58
150
|
/** Gateway `recurring_model` — not Adyen's `recurringProcessingModel`. */
|
|
59
151
|
type RecurringModel = 'subscription' | 'one-off';
|
|
@@ -110,9 +202,38 @@ interface ElementAuth {
|
|
|
110
202
|
interface MountOptions {
|
|
111
203
|
auth: ElementAuth;
|
|
112
204
|
recurringModel?: RecurringModel;
|
|
205
|
+
/**
|
|
206
|
+
* Adyen's `locale`, for example `fi-FI` or `no-NO`. Adyen's card fields and
|
|
207
|
+
* the component's text both read it as Adyen does. Left out or empty, both
|
|
208
|
+
* get `DEFAULT_LOCALE` (`en-GB`). Adyen has no British English of its own,
|
|
209
|
+
* so its card fields read US English, with Adyen's keys from `translations`
|
|
210
|
+
* for the English locale it settles on, if any. Setting it on this object
|
|
211
|
+
* after `mount()` changes the language, as `changeLocale` does.
|
|
212
|
+
*/
|
|
113
213
|
locale?: string;
|
|
214
|
+
/**
|
|
215
|
+
* Adyen's `translations`, keyed by locale: Adyen's keys change the card
|
|
216
|
+
* fields, the `provetPay.*` keys (`PayCardTranslations`) the component's
|
|
217
|
+
* text. A locale neither ships works this way too.
|
|
218
|
+
*/
|
|
219
|
+
translations?: CustomTranslations;
|
|
114
220
|
appearance?: PayCardAppearance;
|
|
115
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* Adyen's `styles` for the card fields, by field state. They win over what
|
|
223
|
+
* `appearance.variables` reaches inside the fields.
|
|
224
|
+
*/
|
|
225
|
+
styles?: StylesObject;
|
|
226
|
+
/**
|
|
227
|
+
* Adyen's `disclaimerMessage`: a line under the card fields. Adyen asks for
|
|
228
|
+
* the shopper's consent before a card is stored for later payments; this is
|
|
229
|
+
* one place to ask for it.
|
|
230
|
+
*/
|
|
231
|
+
disclaimerMessage?: DisclaimerMsgObject;
|
|
232
|
+
/**
|
|
233
|
+
* The shopper has something to act on: the saved cards, or the card fields
|
|
234
|
+
* once Adyen says they are ready. Called once per mount, and once more each
|
|
235
|
+
* time `changeLocale` starts the form again.
|
|
236
|
+
*/
|
|
116
237
|
onReady?: () => void;
|
|
117
238
|
/**
|
|
118
239
|
* The shopper is done with the card. `card.id` is the handle to hand the
|
|
@@ -121,21 +242,49 @@ interface MountOptions {
|
|
|
121
242
|
* card saved in the form carries only its `id`.
|
|
122
243
|
*
|
|
123
244
|
* It still fires after `unmount()` for a card whose save was already under
|
|
124
|
-
* way; no other callback does.
|
|
245
|
+
* way; no other callback does. `resultCode` is Adyen's for a card saved in the
|
|
246
|
+
* form, for example `Authorised`; a picked card has none.
|
|
125
247
|
*/
|
|
126
248
|
onSuccess: (result: {
|
|
127
249
|
card: SavedCard;
|
|
250
|
+
resultCode?: ResultCode;
|
|
128
251
|
}) => void;
|
|
129
|
-
/**
|
|
130
|
-
|
|
252
|
+
/**
|
|
253
|
+
* The `$0` check ended `Refused`, `Cancelled` or `Error`, Adyen's
|
|
254
|
+
* `resultCode`. The form says why, and the shopper retries in place.
|
|
255
|
+
*/
|
|
256
|
+
onRefused?: (result: {
|
|
257
|
+
resultCode: ResultCode;
|
|
258
|
+
}) => void;
|
|
259
|
+
/**
|
|
260
|
+
* Something went wrong. When the component cannot go on, the form shows a
|
|
261
|
+
* banner. When Adyen reports an error with its card fields loaded and on the
|
|
262
|
+
* page, such as a failed call during the check, the form stays and the
|
|
263
|
+
* shopper can try again.
|
|
264
|
+
*/
|
|
131
265
|
onError?: (error: ElementErrorPayload) => void;
|
|
132
266
|
}
|
|
133
267
|
interface ElementHandle {
|
|
134
268
|
unmount(): void;
|
|
269
|
+
/**
|
|
270
|
+
* Starts the form again in `locale`, which takes what the `locale` option
|
|
271
|
+
* takes; setting `locale` on the options object does the same. Adyen takes
|
|
272
|
+
* a locale only when it starts, so its card fields start again too: what the
|
|
273
|
+
* shopper typed into them is cleared, and `onReady` is called again. An open
|
|
274
|
+
* card session is resumed; one still being opened is not waited for. It
|
|
275
|
+
* does nothing for the locale the form already has, while a card check is
|
|
276
|
+
* running, once the card is saved, or after `unmount()`.
|
|
277
|
+
*/
|
|
278
|
+
changeLocale(locale?: string): void;
|
|
135
279
|
}
|
|
136
280
|
declare function mount(container: HTMLElement | string, options: MountOptions): ElementHandle;
|
|
137
281
|
|
|
282
|
+
/** The locale the component and Adyen get when the consumer passes none, and the component's fallback. */
|
|
283
|
+
declare const DEFAULT_LOCALE = "en-GB";
|
|
284
|
+
/** The component's own text in `DEFAULT_LOCALE`: every `provetPay.*` key with its British English default. Read-only. */
|
|
285
|
+
declare const DEFAULT_TRANSLATIONS: Readonly<Required<PayCardTranslations>>;
|
|
286
|
+
|
|
138
287
|
declare const VERSION: string;
|
|
139
288
|
|
|
140
|
-
export { VERSION, mount };
|
|
141
|
-
export type { ElementAuth, ElementErrorPayload, ElementErrorType, ElementHandle, MountOptions, PayCardAppearance, RecurringModel, SavedCard,
|
|
289
|
+
export { DEFAULT_LOCALE, DEFAULT_TRANSLATIONS, VERSION, mount };
|
|
290
|
+
export type { CustomTranslations, DisclaimerMsgObject, ElementAuth, ElementErrorPayload, ElementErrorType, ElementHandle, MountOptions, PayCardAppearance, PayCardTranslations, RecurringModel, ResultCode, SavedCard, StyleDefinitions, StylesObject };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nordhealth/provet-pay-elements",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
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
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"homepage": "https://gitlab.com/nordhealth/projects/microservices/payment-gateway/pay-js/-/tree/master/provet-pay-elements",
|