straumur-web-component 2.0.0-alpha.7 → 2.0.0-beta.1
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 +115 -28
- package/dist/index.cjs +17 -12
- package/dist/index.d.cts +72 -102
- package/dist/index.d.ts +72 -102
- package/dist/index.js +20 -15
- package/dist/index.mjs +17 -12
- package/package.json +12 -7
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -9,8 +9,11 @@ declare const translations: {
|
|
|
9
9
|
"cards.securityCode4DigitsInfo": string;
|
|
10
10
|
"cards.storePaymentMethod": string;
|
|
11
11
|
"cards.saveCardDetails": string;
|
|
12
|
+
"cards.cardBrand": string;
|
|
12
13
|
"googlePay.title": string;
|
|
13
14
|
"applePay.title": string;
|
|
15
|
+
"kortalan.title": string;
|
|
16
|
+
"kortalan.payButton": string;
|
|
14
17
|
"stored-cards.expiryDate": string;
|
|
15
18
|
"stored-cards.securityCode3Digits": string;
|
|
16
19
|
"stored-cards.securityCode3DigitsOptional": string;
|
|
@@ -22,6 +25,9 @@ declare const translations: {
|
|
|
22
25
|
"stored-cards.removeStoredCardQuestionCancel": string;
|
|
23
26
|
"stored-cards.saveCardDetails": string;
|
|
24
27
|
"success.paymentAuthorized": string;
|
|
28
|
+
"success.paymentPending": string;
|
|
29
|
+
"payment.processing": string;
|
|
30
|
+
"payment.loading": string;
|
|
25
31
|
"error.unknownError": string;
|
|
26
32
|
"error.failedToInitializeStraumurWebComponent": string;
|
|
27
33
|
"error.failedToInitializePaymentMethods": string;
|
|
@@ -30,8 +36,7 @@ declare const translations: {
|
|
|
30
36
|
"error.paymentUnsuccessful": string;
|
|
31
37
|
"error.failedToSubmitPaymentDetails": string;
|
|
32
38
|
"error.paymentDetailsFailed": string;
|
|
33
|
-
"error.
|
|
34
|
-
"error.applePayNotAvailable": string;
|
|
39
|
+
"error.paymentNotConfirmed": string;
|
|
35
40
|
"error.failedToSubmitRemoveStoredPaymentCard": string;
|
|
36
41
|
"error.failedToRemoveStoredPaymentCard": string;
|
|
37
42
|
};
|
|
@@ -45,8 +50,11 @@ declare const translations: {
|
|
|
45
50
|
"cards.securityCode4DigitsInfo": string;
|
|
46
51
|
"cards.storePaymentMethod": string;
|
|
47
52
|
"cards.saveCardDetails": string;
|
|
53
|
+
"cards.cardBrand": string;
|
|
48
54
|
"googlePay.title": string;
|
|
49
55
|
"applePay.title": string;
|
|
56
|
+
"kortalan.title": string;
|
|
57
|
+
"kortalan.payButton": string;
|
|
50
58
|
"stored-cards.expiryDate": string;
|
|
51
59
|
"stored-cards.securityCode3Digits": string;
|
|
52
60
|
"stored-cards.securityCode3DigitsOptional": string;
|
|
@@ -58,6 +66,9 @@ declare const translations: {
|
|
|
58
66
|
"stored-cards.removeStoredCardQuestionCancel": string;
|
|
59
67
|
"stored-cards.saveCardDetails": string;
|
|
60
68
|
"success.paymentAuthorized": string;
|
|
69
|
+
"success.paymentPending": string;
|
|
70
|
+
"payment.processing": string;
|
|
71
|
+
"payment.loading": string;
|
|
61
72
|
"error.unknownError": string;
|
|
62
73
|
"error.failedToInitializeStraumurWebComponent": string;
|
|
63
74
|
"error.failedToInitializePaymentMethods": string;
|
|
@@ -66,8 +77,7 @@ declare const translations: {
|
|
|
66
77
|
"error.paymentUnsuccessful": string;
|
|
67
78
|
"error.failedToSubmitPaymentDetails": string;
|
|
68
79
|
"error.paymentDetailsFailed": string;
|
|
69
|
-
"error.
|
|
70
|
-
"error.applePayNotAvailable": string;
|
|
80
|
+
"error.paymentNotConfirmed": string;
|
|
71
81
|
"error.failedToSubmitRemoveStoredPaymentCard": string;
|
|
72
82
|
"error.failedToRemoveStoredPaymentCard": string;
|
|
73
83
|
};
|
|
@@ -78,44 +88,18 @@ type TranslationKey = keyof (typeof translations)["en-US"] | keyof (typeof trans
|
|
|
78
88
|
/** The locale vocabulary of the public API: short codes only. */
|
|
79
89
|
type PublicLocale = "is" | "en";
|
|
80
90
|
|
|
81
|
-
type PaymentMethod = "card" | "storedcard" | "googlepay" | "applepay";
|
|
91
|
+
type PaymentMethod = "card" | "storedcard" | "googlepay" | "applepay" | "kortalan";
|
|
82
92
|
/**
|
|
83
93
|
* A slot in the rendered payment-method list: a standalone method, or "instantpayments" for the
|
|
84
94
|
* express wallet row. Used to order the options via `orderPaymentMethods`.
|
|
85
95
|
*/
|
|
86
96
|
type PaymentMethodOrder = PaymentMethod | "instantpayments";
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
clientStateDataIndicator: boolean;
|
|
94
|
-
storePaymentMethod?: boolean;
|
|
95
|
-
paymentMethod: {
|
|
96
|
-
[key: string]: unknown;
|
|
97
|
-
checkoutAttemptId?: string;
|
|
98
|
-
};
|
|
99
|
-
browserInfo?: BrowserInfo;
|
|
100
|
-
}
|
|
101
|
-
interface BrowserInfo {
|
|
102
|
-
acceptHeader: string;
|
|
103
|
-
colorDepth: number;
|
|
104
|
-
language: string;
|
|
105
|
-
javaEnabled: boolean;
|
|
106
|
-
screenHeight: number;
|
|
107
|
-
screenWidth: number;
|
|
108
|
-
userAgent: string;
|
|
109
|
-
timeZoneOffset: number;
|
|
110
|
-
}
|
|
111
|
-
interface ICreateDetailsBody {
|
|
112
|
-
sessionId: string;
|
|
113
|
-
details: {
|
|
114
|
-
redirectResult?: string;
|
|
115
|
-
threeDSResult?: string;
|
|
116
|
-
[key: string]: unknown;
|
|
117
|
-
};
|
|
118
|
-
}
|
|
97
|
+
/**
|
|
98
|
+
* Which payment method to open (expand) on load via `openDefaultPaymentMethod`. "firstStoredCard"
|
|
99
|
+
* opens the first saved card. Ignored (nothing pre-opened, chooser stays collapsed) when the
|
|
100
|
+
* requested method isn't available (e.g. a wallet that's in `instantPayments`, or no saved cards).
|
|
101
|
+
*/
|
|
102
|
+
type OpenDefaultPaymentMethod = "card" | "firstStoredCard" | "googlepay" | "applepay";
|
|
119
103
|
|
|
120
104
|
type StraumurWebBaseConfiguration = {
|
|
121
105
|
environment: "test" | "live";
|
|
@@ -123,39 +107,55 @@ type StraumurWebBaseConfiguration = {
|
|
|
123
107
|
onPaymentFailed?: (data: PaymentFailedData) => void;
|
|
124
108
|
placeholders?: Placeholders;
|
|
125
109
|
locale?: PublicLocale;
|
|
126
|
-
localizations?:
|
|
127
|
-
instantPayments?:
|
|
110
|
+
localizations?: Localizations;
|
|
111
|
+
instantPayments?: InstantPaymentMethod[];
|
|
128
112
|
hideSubmitButton?: boolean;
|
|
129
113
|
onCardValidityChanged?: (isValid: boolean, isActive: boolean) => void;
|
|
130
114
|
allowedPaymentMethods?: PaymentMethod[];
|
|
131
115
|
/**
|
|
132
|
-
* Top-to-bottom order of the payment-method options. Tokens: "card", "storedcard", "
|
|
133
|
-
* "applepay", and "instantpayments" (the express
|
|
134
|
-
* renders only inside the "instantpayments" slot, never standalone, so its
|
|
135
|
-
* effectively ignored. Any available method you omit is appended in the
|
|
136
|
-
* ["instantpayments", "storedcard", "card", "googlepay", "applepay"].
|
|
116
|
+
* Top-to-bottom order of the payment-method options. Tokens: "card", "storedcard", "kortalan",
|
|
117
|
+
* "googlepay", "applepay", and "instantpayments" (the express row). A method listed in
|
|
118
|
+
* `instantPayments` renders only inside the "instantpayments" slot, never standalone, so its
|
|
119
|
+
* standalone token here is effectively ignored. Any available method you omit is appended in the
|
|
120
|
+
* default order. Defaults to ["instantpayments", "kortalan", "storedcard", "card", "googlepay", "applepay"].
|
|
137
121
|
*/
|
|
138
122
|
orderPaymentMethods?: PaymentMethodOrder[];
|
|
123
|
+
/**
|
|
124
|
+
* Which payment method to open (expand) on load: "card", "firstStoredCard", "googlepay" or
|
|
125
|
+
* "applepay". If that method isn't available — a wallet that's in `instantPayments`, or
|
|
126
|
+
* "firstStoredCard" with no saved cards — it's ignored and no method is pre-opened (the chooser
|
|
127
|
+
* stays collapsed). Omit for the same collapsed default.
|
|
128
|
+
*/
|
|
129
|
+
openDefaultPaymentMethod?: OpenDefaultPaymentMethod;
|
|
139
130
|
/**
|
|
140
131
|
* Color theme for the widget. Accepts a mode ("light" | "dark" | "system"), or a
|
|
141
|
-
* {@link ThemeConfiguration} object to also override the wallet button styling. "system" follows
|
|
132
|
+
* {@link ThemeConfiguration} object to also override the wallet / Kortalán button styling. "system" follows
|
|
142
133
|
* the shopper's OS/browser preference (`prefers-color-scheme`) and updates live if it changes.
|
|
143
134
|
* Defaults to "light".
|
|
144
135
|
*/
|
|
145
136
|
theme?: Theme | ThemeConfiguration;
|
|
146
137
|
};
|
|
138
|
+
/**
|
|
139
|
+
* Per-language overrides of the built-in copy, keyed by language then TranslationKey. Language keys
|
|
140
|
+
* are the public short codes ("is" / "en"); the full tags ("is-IS" / "en-US") are still accepted for
|
|
141
|
+
* 1.x compatibility.
|
|
142
|
+
*/
|
|
143
|
+
type Localizations = Partial<Record<LocalizationLanguage, Partial<Record<TranslationKey, string>>>>;
|
|
144
|
+
/** A `localizations` key: the public short code, or (legacy, still accepted) the full tag. */
|
|
145
|
+
type LocalizationLanguage = PublicLocale | Language;
|
|
147
146
|
type Theme = "light" | "dark" | "system";
|
|
148
147
|
/** Google Pay button style override: "white" = light button, "dark" = black button. */
|
|
149
148
|
type GooglePayButtonTheme = "dark" | "white";
|
|
150
149
|
/** Apple Pay button style override: "light" = white button, "dark" = black button. */
|
|
151
150
|
type ApplePayButtonTheme = "dark" | "light";
|
|
151
|
+
/** Kortalán express-button style override: "light" = whitish button, "dark" = blackish button. */
|
|
152
152
|
/**
|
|
153
|
-
* Object form of `theme`: the widget color mode plus optional per-
|
|
154
|
-
* When an override is omitted the
|
|
155
|
-
*
|
|
153
|
+
* Object form of `theme`: the widget color `mode` plus optional per-button style overrides.
|
|
154
|
+
* When an override is omitted the button follows the mode — a light widget gets a light/whitish
|
|
155
|
+
* button, a dark widget gets a black/blackish one.
|
|
156
156
|
*/
|
|
157
157
|
type ThemeConfiguration = {
|
|
158
|
-
|
|
158
|
+
mode: Theme;
|
|
159
159
|
googlePayButtonTheme?: GooglePayButtonTheme;
|
|
160
160
|
applePayButtonTheme?: ApplePayButtonTheme;
|
|
161
161
|
};
|
|
@@ -170,78 +170,48 @@ type PaymentCompletedData = {
|
|
|
170
170
|
type PaymentFailedData = {
|
|
171
171
|
resultCode: ResultCode;
|
|
172
172
|
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
type
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
submitPayment(data: AdvancedSubmitState["data"]): Promise<PaymentFlowResult>;
|
|
190
|
-
submitAdditionalDetails(data: AdvancedAdditionalDetailsState["data"]): Promise<PaymentFlowResult>;
|
|
191
|
-
disableToken?: (storedPaymentMethodId: string) => Promise<void>;
|
|
192
|
-
beforeSubmit?: () => boolean | Promise<boolean>;
|
|
193
|
-
}
|
|
194
|
-
type ResultMessage = {
|
|
195
|
-
key: TranslationKey;
|
|
196
|
-
} | {
|
|
197
|
-
text: string;
|
|
198
|
-
};
|
|
199
|
-
type UniqueInstantPayments = [Extract<PaymentMethod, "googlepay">] | [Extract<PaymentMethod, "applepay">] | [Extract<PaymentMethod, "googlepay">, Extract<PaymentMethod, "applepay">] | [Extract<PaymentMethod, "applepay">, Extract<PaymentMethod, "googlepay">];
|
|
200
|
-
type StraumurCheckoutConfiguration = {
|
|
201
|
-
mode: "session" | "advanced";
|
|
202
|
-
sessionId?: string;
|
|
203
|
-
environment: "test" | "live";
|
|
204
|
-
countryCode: string;
|
|
205
|
-
paymentFlow: PaymentFlow;
|
|
206
|
-
onPaymentCompleted?: (data: PaymentCompletedData) => void;
|
|
207
|
-
onPaymentFailed?: (data: PaymentFailedData) => void;
|
|
208
|
-
placeholders?: Placeholders;
|
|
209
|
-
locale: Language;
|
|
210
|
-
customLocalizations?: Partial<Record<Language, Partial<Record<TranslationKey, string>>>>;
|
|
211
|
-
instantPayments?: UniqueInstantPayments;
|
|
212
|
-
hideSubmitButton?: boolean;
|
|
213
|
-
onCardValidityChanged?: (isValid: boolean, isActive: boolean) => void;
|
|
214
|
-
allowedPaymentMethods?: PaymentMethod[];
|
|
215
|
-
orderPaymentMethods?: PaymentMethodOrder[];
|
|
216
|
-
theme: Theme;
|
|
173
|
+
/**
|
|
174
|
+
* A payment method that can be placed in `instantPayments` to render as an express button at the top
|
|
175
|
+
* of the widget: the two Adyen wallets. Kortalán is deliberately NOT expressible here — it cannot be
|
|
176
|
+
* rendered in the express strip. Duplicates are ignored at runtime (the instant strip dedupes), so
|
|
177
|
+
* this is a plain array rather than a unique-tuple union.
|
|
178
|
+
*/
|
|
179
|
+
type InstantPaymentMethod = Extract<PaymentMethod, "googlepay" | "applepay">;
|
|
180
|
+
/**
|
|
181
|
+
* What updateConfig() accepts: the public configuration options that can change after construction.
|
|
182
|
+
* The session itself (sessionId, environment) is fixed for the instance's lifetime — the payment flow
|
|
183
|
+
* captures it at construction — so it is not updatable; create a new StraumurCheckout instead.
|
|
184
|
+
*/
|
|
185
|
+
type StraumurCheckoutUpdateOptions = Partial<Pick<StraumurWebBaseConfiguration, "onPaymentCompleted" | "onPaymentFailed" | "placeholders" | "locale" | "localizations" | "instantPayments" | "hideSubmitButton" | "onCardValidityChanged" | "allowedPaymentMethods" | "orderPaymentMethods" | "openDefaultPaymentMethod" | "theme">> & {
|
|
186
|
+
/** @deprecated Use `localizations` (same shape; the name the constructor uses). */
|
|
187
|
+
customLocalizations?: Localizations;
|
|
188
|
+
/** @deprecated Use `theme: { mode, googlePayButtonTheme }`. */
|
|
217
189
|
googlePayButtonTheme?: GooglePayButtonTheme;
|
|
190
|
+
/** @deprecated Use `theme: { mode, applePayButtonTheme }`. */
|
|
218
191
|
applePayButtonTheme?: ApplePayButtonTheme;
|
|
219
192
|
};
|
|
220
|
-
type StraumurCheckoutUpdateOptions = Partial<Omit<StraumurCheckoutConfiguration, "mode" | "paymentFlow" | "locale">> & {
|
|
221
|
-
locale?: PublicLocale;
|
|
222
|
-
};
|
|
223
193
|
type PlaceholderKeys = "cardNumber" | "expiryDate" | "expiryMonth" | "expiryYear" | "securityCodeThreeDigits" | "securityCodeFourDigits";
|
|
224
194
|
type Placeholders = Partial<Record<PlaceholderKeys, string>>;
|
|
225
195
|
|
|
226
196
|
declare class StraumurCheckout {
|
|
227
197
|
private configuration;
|
|
228
|
-
private advancedConfiguration;
|
|
229
198
|
private paymentMethods;
|
|
230
199
|
private mountElement;
|
|
231
200
|
private i18n;
|
|
232
201
|
private submitApi;
|
|
233
202
|
private initializationFailed;
|
|
203
|
+
private resultScreen;
|
|
234
204
|
constructor(publicConfig: StraumurWebConfiguration);
|
|
235
205
|
mount(selector: HTMLElement | string): Promise<void>;
|
|
236
206
|
private renderComponent;
|
|
237
|
-
handleSuccess
|
|
238
|
-
handleError
|
|
239
|
-
private
|
|
240
|
-
submitDetails(redirectResult: string, selector?: HTMLElement | string): Promise<void>;
|
|
207
|
+
private handleSuccess;
|
|
208
|
+
private handleError;
|
|
209
|
+
private showResultScreen;
|
|
210
|
+
submitDetails(redirectResult: string, paymentCheckoutReference?: string, selector?: HTMLElement | string): Promise<void>;
|
|
241
211
|
updateConfig(newConfig: StraumurCheckoutUpdateOptions): void;
|
|
242
212
|
setLanguage(locale: PublicLocale): void;
|
|
243
213
|
destroy(): void;
|
|
244
214
|
submitCard(): boolean;
|
|
245
215
|
}
|
|
246
216
|
|
|
247
|
-
export { type ApplePayButtonTheme, type GooglePayButtonTheme, type PaymentCompletedData, type PaymentFailedData, type PaymentMethod, type PaymentMethodOrder, type Placeholders, type ResultCode, StraumurCheckout, type StraumurWebConfiguration, type Theme, type ThemeConfiguration };
|
|
217
|
+
export { type ApplePayButtonTheme, type GooglePayButtonTheme, type LocalizationLanguage, type Localizations, type OpenDefaultPaymentMethod, type PaymentCompletedData, type PaymentFailedData, type PaymentMethod, type PaymentMethodOrder, type Placeholders, type PublicLocale, type ResultCode, StraumurCheckout, type StraumurCheckoutUpdateOptions, type StraumurWebConfiguration, type Theme, type ThemeConfiguration, type TranslationKey };
|
package/dist/index.d.ts
CHANGED
|
@@ -9,8 +9,11 @@ declare const translations: {
|
|
|
9
9
|
"cards.securityCode4DigitsInfo": string;
|
|
10
10
|
"cards.storePaymentMethod": string;
|
|
11
11
|
"cards.saveCardDetails": string;
|
|
12
|
+
"cards.cardBrand": string;
|
|
12
13
|
"googlePay.title": string;
|
|
13
14
|
"applePay.title": string;
|
|
15
|
+
"kortalan.title": string;
|
|
16
|
+
"kortalan.payButton": string;
|
|
14
17
|
"stored-cards.expiryDate": string;
|
|
15
18
|
"stored-cards.securityCode3Digits": string;
|
|
16
19
|
"stored-cards.securityCode3DigitsOptional": string;
|
|
@@ -22,6 +25,9 @@ declare const translations: {
|
|
|
22
25
|
"stored-cards.removeStoredCardQuestionCancel": string;
|
|
23
26
|
"stored-cards.saveCardDetails": string;
|
|
24
27
|
"success.paymentAuthorized": string;
|
|
28
|
+
"success.paymentPending": string;
|
|
29
|
+
"payment.processing": string;
|
|
30
|
+
"payment.loading": string;
|
|
25
31
|
"error.unknownError": string;
|
|
26
32
|
"error.failedToInitializeStraumurWebComponent": string;
|
|
27
33
|
"error.failedToInitializePaymentMethods": string;
|
|
@@ -30,8 +36,7 @@ declare const translations: {
|
|
|
30
36
|
"error.paymentUnsuccessful": string;
|
|
31
37
|
"error.failedToSubmitPaymentDetails": string;
|
|
32
38
|
"error.paymentDetailsFailed": string;
|
|
33
|
-
"error.
|
|
34
|
-
"error.applePayNotAvailable": string;
|
|
39
|
+
"error.paymentNotConfirmed": string;
|
|
35
40
|
"error.failedToSubmitRemoveStoredPaymentCard": string;
|
|
36
41
|
"error.failedToRemoveStoredPaymentCard": string;
|
|
37
42
|
};
|
|
@@ -45,8 +50,11 @@ declare const translations: {
|
|
|
45
50
|
"cards.securityCode4DigitsInfo": string;
|
|
46
51
|
"cards.storePaymentMethod": string;
|
|
47
52
|
"cards.saveCardDetails": string;
|
|
53
|
+
"cards.cardBrand": string;
|
|
48
54
|
"googlePay.title": string;
|
|
49
55
|
"applePay.title": string;
|
|
56
|
+
"kortalan.title": string;
|
|
57
|
+
"kortalan.payButton": string;
|
|
50
58
|
"stored-cards.expiryDate": string;
|
|
51
59
|
"stored-cards.securityCode3Digits": string;
|
|
52
60
|
"stored-cards.securityCode3DigitsOptional": string;
|
|
@@ -58,6 +66,9 @@ declare const translations: {
|
|
|
58
66
|
"stored-cards.removeStoredCardQuestionCancel": string;
|
|
59
67
|
"stored-cards.saveCardDetails": string;
|
|
60
68
|
"success.paymentAuthorized": string;
|
|
69
|
+
"success.paymentPending": string;
|
|
70
|
+
"payment.processing": string;
|
|
71
|
+
"payment.loading": string;
|
|
61
72
|
"error.unknownError": string;
|
|
62
73
|
"error.failedToInitializeStraumurWebComponent": string;
|
|
63
74
|
"error.failedToInitializePaymentMethods": string;
|
|
@@ -66,8 +77,7 @@ declare const translations: {
|
|
|
66
77
|
"error.paymentUnsuccessful": string;
|
|
67
78
|
"error.failedToSubmitPaymentDetails": string;
|
|
68
79
|
"error.paymentDetailsFailed": string;
|
|
69
|
-
"error.
|
|
70
|
-
"error.applePayNotAvailable": string;
|
|
80
|
+
"error.paymentNotConfirmed": string;
|
|
71
81
|
"error.failedToSubmitRemoveStoredPaymentCard": string;
|
|
72
82
|
"error.failedToRemoveStoredPaymentCard": string;
|
|
73
83
|
};
|
|
@@ -78,44 +88,18 @@ type TranslationKey = keyof (typeof translations)["en-US"] | keyof (typeof trans
|
|
|
78
88
|
/** The locale vocabulary of the public API: short codes only. */
|
|
79
89
|
type PublicLocale = "is" | "en";
|
|
80
90
|
|
|
81
|
-
type PaymentMethod = "card" | "storedcard" | "googlepay" | "applepay";
|
|
91
|
+
type PaymentMethod = "card" | "storedcard" | "googlepay" | "applepay" | "kortalan";
|
|
82
92
|
/**
|
|
83
93
|
* A slot in the rendered payment-method list: a standalone method, or "instantpayments" for the
|
|
84
94
|
* express wallet row. Used to order the options via `orderPaymentMethods`.
|
|
85
95
|
*/
|
|
86
96
|
type PaymentMethodOrder = PaymentMethod | "instantpayments";
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
clientStateDataIndicator: boolean;
|
|
94
|
-
storePaymentMethod?: boolean;
|
|
95
|
-
paymentMethod: {
|
|
96
|
-
[key: string]: unknown;
|
|
97
|
-
checkoutAttemptId?: string;
|
|
98
|
-
};
|
|
99
|
-
browserInfo?: BrowserInfo;
|
|
100
|
-
}
|
|
101
|
-
interface BrowserInfo {
|
|
102
|
-
acceptHeader: string;
|
|
103
|
-
colorDepth: number;
|
|
104
|
-
language: string;
|
|
105
|
-
javaEnabled: boolean;
|
|
106
|
-
screenHeight: number;
|
|
107
|
-
screenWidth: number;
|
|
108
|
-
userAgent: string;
|
|
109
|
-
timeZoneOffset: number;
|
|
110
|
-
}
|
|
111
|
-
interface ICreateDetailsBody {
|
|
112
|
-
sessionId: string;
|
|
113
|
-
details: {
|
|
114
|
-
redirectResult?: string;
|
|
115
|
-
threeDSResult?: string;
|
|
116
|
-
[key: string]: unknown;
|
|
117
|
-
};
|
|
118
|
-
}
|
|
97
|
+
/**
|
|
98
|
+
* Which payment method to open (expand) on load via `openDefaultPaymentMethod`. "firstStoredCard"
|
|
99
|
+
* opens the first saved card. Ignored (nothing pre-opened, chooser stays collapsed) when the
|
|
100
|
+
* requested method isn't available (e.g. a wallet that's in `instantPayments`, or no saved cards).
|
|
101
|
+
*/
|
|
102
|
+
type OpenDefaultPaymentMethod = "card" | "firstStoredCard" | "googlepay" | "applepay";
|
|
119
103
|
|
|
120
104
|
type StraumurWebBaseConfiguration = {
|
|
121
105
|
environment: "test" | "live";
|
|
@@ -123,39 +107,55 @@ type StraumurWebBaseConfiguration = {
|
|
|
123
107
|
onPaymentFailed?: (data: PaymentFailedData) => void;
|
|
124
108
|
placeholders?: Placeholders;
|
|
125
109
|
locale?: PublicLocale;
|
|
126
|
-
localizations?:
|
|
127
|
-
instantPayments?:
|
|
110
|
+
localizations?: Localizations;
|
|
111
|
+
instantPayments?: InstantPaymentMethod[];
|
|
128
112
|
hideSubmitButton?: boolean;
|
|
129
113
|
onCardValidityChanged?: (isValid: boolean, isActive: boolean) => void;
|
|
130
114
|
allowedPaymentMethods?: PaymentMethod[];
|
|
131
115
|
/**
|
|
132
|
-
* Top-to-bottom order of the payment-method options. Tokens: "card", "storedcard", "
|
|
133
|
-
* "applepay", and "instantpayments" (the express
|
|
134
|
-
* renders only inside the "instantpayments" slot, never standalone, so its
|
|
135
|
-
* effectively ignored. Any available method you omit is appended in the
|
|
136
|
-
* ["instantpayments", "storedcard", "card", "googlepay", "applepay"].
|
|
116
|
+
* Top-to-bottom order of the payment-method options. Tokens: "card", "storedcard", "kortalan",
|
|
117
|
+
* "googlepay", "applepay", and "instantpayments" (the express row). A method listed in
|
|
118
|
+
* `instantPayments` renders only inside the "instantpayments" slot, never standalone, so its
|
|
119
|
+
* standalone token here is effectively ignored. Any available method you omit is appended in the
|
|
120
|
+
* default order. Defaults to ["instantpayments", "kortalan", "storedcard", "card", "googlepay", "applepay"].
|
|
137
121
|
*/
|
|
138
122
|
orderPaymentMethods?: PaymentMethodOrder[];
|
|
123
|
+
/**
|
|
124
|
+
* Which payment method to open (expand) on load: "card", "firstStoredCard", "googlepay" or
|
|
125
|
+
* "applepay". If that method isn't available — a wallet that's in `instantPayments`, or
|
|
126
|
+
* "firstStoredCard" with no saved cards — it's ignored and no method is pre-opened (the chooser
|
|
127
|
+
* stays collapsed). Omit for the same collapsed default.
|
|
128
|
+
*/
|
|
129
|
+
openDefaultPaymentMethod?: OpenDefaultPaymentMethod;
|
|
139
130
|
/**
|
|
140
131
|
* Color theme for the widget. Accepts a mode ("light" | "dark" | "system"), or a
|
|
141
|
-
* {@link ThemeConfiguration} object to also override the wallet button styling. "system" follows
|
|
132
|
+
* {@link ThemeConfiguration} object to also override the wallet / Kortalán button styling. "system" follows
|
|
142
133
|
* the shopper's OS/browser preference (`prefers-color-scheme`) and updates live if it changes.
|
|
143
134
|
* Defaults to "light".
|
|
144
135
|
*/
|
|
145
136
|
theme?: Theme | ThemeConfiguration;
|
|
146
137
|
};
|
|
138
|
+
/**
|
|
139
|
+
* Per-language overrides of the built-in copy, keyed by language then TranslationKey. Language keys
|
|
140
|
+
* are the public short codes ("is" / "en"); the full tags ("is-IS" / "en-US") are still accepted for
|
|
141
|
+
* 1.x compatibility.
|
|
142
|
+
*/
|
|
143
|
+
type Localizations = Partial<Record<LocalizationLanguage, Partial<Record<TranslationKey, string>>>>;
|
|
144
|
+
/** A `localizations` key: the public short code, or (legacy, still accepted) the full tag. */
|
|
145
|
+
type LocalizationLanguage = PublicLocale | Language;
|
|
147
146
|
type Theme = "light" | "dark" | "system";
|
|
148
147
|
/** Google Pay button style override: "white" = light button, "dark" = black button. */
|
|
149
148
|
type GooglePayButtonTheme = "dark" | "white";
|
|
150
149
|
/** Apple Pay button style override: "light" = white button, "dark" = black button. */
|
|
151
150
|
type ApplePayButtonTheme = "dark" | "light";
|
|
151
|
+
/** Kortalán express-button style override: "light" = whitish button, "dark" = blackish button. */
|
|
152
152
|
/**
|
|
153
|
-
* Object form of `theme`: the widget color mode plus optional per-
|
|
154
|
-
* When an override is omitted the
|
|
155
|
-
*
|
|
153
|
+
* Object form of `theme`: the widget color `mode` plus optional per-button style overrides.
|
|
154
|
+
* When an override is omitted the button follows the mode — a light widget gets a light/whitish
|
|
155
|
+
* button, a dark widget gets a black/blackish one.
|
|
156
156
|
*/
|
|
157
157
|
type ThemeConfiguration = {
|
|
158
|
-
|
|
158
|
+
mode: Theme;
|
|
159
159
|
googlePayButtonTheme?: GooglePayButtonTheme;
|
|
160
160
|
applePayButtonTheme?: ApplePayButtonTheme;
|
|
161
161
|
};
|
|
@@ -170,78 +170,48 @@ type PaymentCompletedData = {
|
|
|
170
170
|
type PaymentFailedData = {
|
|
171
171
|
resultCode: ResultCode;
|
|
172
172
|
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
type
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
submitPayment(data: AdvancedSubmitState["data"]): Promise<PaymentFlowResult>;
|
|
190
|
-
submitAdditionalDetails(data: AdvancedAdditionalDetailsState["data"]): Promise<PaymentFlowResult>;
|
|
191
|
-
disableToken?: (storedPaymentMethodId: string) => Promise<void>;
|
|
192
|
-
beforeSubmit?: () => boolean | Promise<boolean>;
|
|
193
|
-
}
|
|
194
|
-
type ResultMessage = {
|
|
195
|
-
key: TranslationKey;
|
|
196
|
-
} | {
|
|
197
|
-
text: string;
|
|
198
|
-
};
|
|
199
|
-
type UniqueInstantPayments = [Extract<PaymentMethod, "googlepay">] | [Extract<PaymentMethod, "applepay">] | [Extract<PaymentMethod, "googlepay">, Extract<PaymentMethod, "applepay">] | [Extract<PaymentMethod, "applepay">, Extract<PaymentMethod, "googlepay">];
|
|
200
|
-
type StraumurCheckoutConfiguration = {
|
|
201
|
-
mode: "session" | "advanced";
|
|
202
|
-
sessionId?: string;
|
|
203
|
-
environment: "test" | "live";
|
|
204
|
-
countryCode: string;
|
|
205
|
-
paymentFlow: PaymentFlow;
|
|
206
|
-
onPaymentCompleted?: (data: PaymentCompletedData) => void;
|
|
207
|
-
onPaymentFailed?: (data: PaymentFailedData) => void;
|
|
208
|
-
placeholders?: Placeholders;
|
|
209
|
-
locale: Language;
|
|
210
|
-
customLocalizations?: Partial<Record<Language, Partial<Record<TranslationKey, string>>>>;
|
|
211
|
-
instantPayments?: UniqueInstantPayments;
|
|
212
|
-
hideSubmitButton?: boolean;
|
|
213
|
-
onCardValidityChanged?: (isValid: boolean, isActive: boolean) => void;
|
|
214
|
-
allowedPaymentMethods?: PaymentMethod[];
|
|
215
|
-
orderPaymentMethods?: PaymentMethodOrder[];
|
|
216
|
-
theme: Theme;
|
|
173
|
+
/**
|
|
174
|
+
* A payment method that can be placed in `instantPayments` to render as an express button at the top
|
|
175
|
+
* of the widget: the two Adyen wallets. Kortalán is deliberately NOT expressible here — it cannot be
|
|
176
|
+
* rendered in the express strip. Duplicates are ignored at runtime (the instant strip dedupes), so
|
|
177
|
+
* this is a plain array rather than a unique-tuple union.
|
|
178
|
+
*/
|
|
179
|
+
type InstantPaymentMethod = Extract<PaymentMethod, "googlepay" | "applepay">;
|
|
180
|
+
/**
|
|
181
|
+
* What updateConfig() accepts: the public configuration options that can change after construction.
|
|
182
|
+
* The session itself (sessionId, environment) is fixed for the instance's lifetime — the payment flow
|
|
183
|
+
* captures it at construction — so it is not updatable; create a new StraumurCheckout instead.
|
|
184
|
+
*/
|
|
185
|
+
type StraumurCheckoutUpdateOptions = Partial<Pick<StraumurWebBaseConfiguration, "onPaymentCompleted" | "onPaymentFailed" | "placeholders" | "locale" | "localizations" | "instantPayments" | "hideSubmitButton" | "onCardValidityChanged" | "allowedPaymentMethods" | "orderPaymentMethods" | "openDefaultPaymentMethod" | "theme">> & {
|
|
186
|
+
/** @deprecated Use `localizations` (same shape; the name the constructor uses). */
|
|
187
|
+
customLocalizations?: Localizations;
|
|
188
|
+
/** @deprecated Use `theme: { mode, googlePayButtonTheme }`. */
|
|
217
189
|
googlePayButtonTheme?: GooglePayButtonTheme;
|
|
190
|
+
/** @deprecated Use `theme: { mode, applePayButtonTheme }`. */
|
|
218
191
|
applePayButtonTheme?: ApplePayButtonTheme;
|
|
219
192
|
};
|
|
220
|
-
type StraumurCheckoutUpdateOptions = Partial<Omit<StraumurCheckoutConfiguration, "mode" | "paymentFlow" | "locale">> & {
|
|
221
|
-
locale?: PublicLocale;
|
|
222
|
-
};
|
|
223
193
|
type PlaceholderKeys = "cardNumber" | "expiryDate" | "expiryMonth" | "expiryYear" | "securityCodeThreeDigits" | "securityCodeFourDigits";
|
|
224
194
|
type Placeholders = Partial<Record<PlaceholderKeys, string>>;
|
|
225
195
|
|
|
226
196
|
declare class StraumurCheckout {
|
|
227
197
|
private configuration;
|
|
228
|
-
private advancedConfiguration;
|
|
229
198
|
private paymentMethods;
|
|
230
199
|
private mountElement;
|
|
231
200
|
private i18n;
|
|
232
201
|
private submitApi;
|
|
233
202
|
private initializationFailed;
|
|
203
|
+
private resultScreen;
|
|
234
204
|
constructor(publicConfig: StraumurWebConfiguration);
|
|
235
205
|
mount(selector: HTMLElement | string): Promise<void>;
|
|
236
206
|
private renderComponent;
|
|
237
|
-
handleSuccess
|
|
238
|
-
handleError
|
|
239
|
-
private
|
|
240
|
-
submitDetails(redirectResult: string, selector?: HTMLElement | string): Promise<void>;
|
|
207
|
+
private handleSuccess;
|
|
208
|
+
private handleError;
|
|
209
|
+
private showResultScreen;
|
|
210
|
+
submitDetails(redirectResult: string, paymentCheckoutReference?: string, selector?: HTMLElement | string): Promise<void>;
|
|
241
211
|
updateConfig(newConfig: StraumurCheckoutUpdateOptions): void;
|
|
242
212
|
setLanguage(locale: PublicLocale): void;
|
|
243
213
|
destroy(): void;
|
|
244
214
|
submitCard(): boolean;
|
|
245
215
|
}
|
|
246
216
|
|
|
247
|
-
export { type ApplePayButtonTheme, type GooglePayButtonTheme, type PaymentCompletedData, type PaymentFailedData, type PaymentMethod, type PaymentMethodOrder, type Placeholders, type ResultCode, StraumurCheckout, type StraumurWebConfiguration, type Theme, type ThemeConfiguration };
|
|
217
|
+
export { type ApplePayButtonTheme, type GooglePayButtonTheme, type LocalizationLanguage, type Localizations, type OpenDefaultPaymentMethod, type PaymentCompletedData, type PaymentFailedData, type PaymentMethod, type PaymentMethodOrder, type Placeholders, type PublicLocale, type ResultCode, StraumurCheckout, type StraumurCheckoutUpdateOptions, type StraumurWebConfiguration, type Theme, type ThemeConfiguration, type TranslationKey };
|