@lightspeed/online-payments-sdk 1.1.4 → 1.1.5
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/cjs/index.js +3 -1
- package/dist/cjs/v1/index.js +3 -1
- package/dist/cjs/v1/stripe/shared.js +5 -1
- package/dist/cjs/v1/stripe/themes.js +40 -0
- package/dist/cjs/v1/stripe/widget.js +45 -15
- package/dist/cjs/v1/stripe/widgets/moto.js +1 -1
- package/dist/cjs/v1/stripe/widgets/payment.js +1 -1
- package/dist/cjs/v1/widget.js +7 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/v1/index.d.ts +1 -0
- package/dist/v1/index.js +1 -0
- package/dist/v1/stripe/shared.d.ts +1 -1
- package/dist/v1/stripe/shared.js +5 -1
- package/dist/v1/stripe/themes.d.ts +10 -0
- package/dist/v1/stripe/themes.js +39 -0
- package/dist/v1/stripe/widget.js +45 -15
- package/dist/v1/stripe/widgets/moto.js +1 -1
- package/dist/v1/stripe/widgets/payment.js +1 -1
- package/dist/v1/widget.d.ts +1 -1
- package/dist/v1/widget.js +7 -2
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LightspeedPayments = void 0;
|
|
3
|
+
exports.LightspeedPayments = exports.THEME_COLORS = void 0;
|
|
4
4
|
var v1_1 = require("./v1");
|
|
5
|
+
var v1_2 = require("./v1");
|
|
6
|
+
Object.defineProperty(exports, "THEME_COLORS", { enumerable: true, get: function () { return v1_2.THEME_COLORS; } });
|
|
5
7
|
exports.LightspeedPayments = {
|
|
6
8
|
v1: v1_1.v1,
|
|
7
9
|
};
|
package/dist/cjs/v1/index.js
CHANGED
|
@@ -6,13 +6,15 @@
|
|
|
6
6
|
* Don't use * for exports. Be specific to prevent leaking internal APIs.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.v1 = exports.ProcessingError = exports.InvalidSessionError = exports.InvalidSessionPayloadError = exports.UnsupportedLocationError = void 0;
|
|
9
|
+
exports.v1 = exports.THEME_COLORS = exports.ProcessingError = exports.InvalidSessionError = exports.InvalidSessionPayloadError = exports.UnsupportedLocationError = void 0;
|
|
10
10
|
var widget_1 = require("./widget");
|
|
11
11
|
var error_1 = require("./error");
|
|
12
12
|
Object.defineProperty(exports, "UnsupportedLocationError", { enumerable: true, get: function () { return error_1.UnsupportedLocationError; } });
|
|
13
13
|
Object.defineProperty(exports, "InvalidSessionPayloadError", { enumerable: true, get: function () { return error_1.InvalidSessionPayloadError; } });
|
|
14
14
|
Object.defineProperty(exports, "InvalidSessionError", { enumerable: true, get: function () { return error_1.InvalidSessionError; } });
|
|
15
15
|
Object.defineProperty(exports, "ProcessingError", { enumerable: true, get: function () { return error_1.ProcessingError; } });
|
|
16
|
+
var themes_1 = require("./stripe/themes");
|
|
17
|
+
Object.defineProperty(exports, "THEME_COLORS", { enumerable: true, get: function () { return themes_1.THEME_COLORS; } });
|
|
16
18
|
exports.v1 = {
|
|
17
19
|
mountPaymentWidget: widget_1.mountPaymentWidget,
|
|
18
20
|
};
|
|
@@ -181,7 +181,11 @@ function createCustomTermsElement() {
|
|
|
181
181
|
/**
|
|
182
182
|
* Create and mount payment element
|
|
183
183
|
*/
|
|
184
|
-
function createPaymentElement(elements, options, mountElement, eventBroadcaster) {
|
|
184
|
+
function createPaymentElement(elements, options, mountElement, eventBroadcaster, theme) {
|
|
185
|
+
// Apply theme class to mount element (generic approach)
|
|
186
|
+
if (theme) {
|
|
187
|
+
mountElement.classList.add("lsp-theme-".concat(theme));
|
|
188
|
+
}
|
|
185
189
|
var paymentElement = elements.create('payment', options);
|
|
186
190
|
paymentElement.on('ready', function () {
|
|
187
191
|
return eventBroadcaster.publish({ status: 'Ready', code: 'Ready' });
|
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.THEME_COLORS = void 0;
|
|
3
4
|
exports.getThemeConfig = getThemeConfig;
|
|
5
|
+
/**
|
|
6
|
+
* Theme color constants for styling containers
|
|
7
|
+
* Use these to match the SDK's dark theme colors in your application
|
|
8
|
+
*/
|
|
9
|
+
exports.THEME_COLORS = {
|
|
10
|
+
DARK: {
|
|
11
|
+
BACKGROUND: '#1a1a1a',
|
|
12
|
+
TEXT: '#ffffff',
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* ID for the injected theme stylesheet element
|
|
17
|
+
*/
|
|
18
|
+
var THEME_STYLESHEET_ID = 'lsp-theme-styles';
|
|
19
|
+
/**
|
|
20
|
+
* Inject theme stylesheets into the document head
|
|
21
|
+
* Each theme can define its own container styling
|
|
22
|
+
*/
|
|
23
|
+
function ensureThemeStylesheet() {
|
|
24
|
+
if (document.getElementById(THEME_STYLESHEET_ID)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
var styleElement = document.createElement('style');
|
|
28
|
+
styleElement.id = THEME_STYLESHEET_ID;
|
|
29
|
+
styleElement.textContent = "\n /* Dark theme styles for the mount element */\n .lsp-theme-dark {\n background-color: ".concat(exports.THEME_COLORS.DARK.BACKGROUND, " !important;\n color: ").concat(exports.THEME_COLORS.DARK.TEXT, " !important;\n }\n /* Dark theme styles for Stripe custom terms elements */\n .lsp-theme-dark .stripe-terms-triangle {\n color: ").concat(exports.THEME_COLORS.DARK.TEXT, " !important;\n }\n .lsp-theme-dark .stripe-custom-terms-text {\n color: ").concat(exports.THEME_COLORS.DARK.TEXT, " !important;\n }\n .lsp-theme-dark .stripe-expandable-terms-content p {\n color: ").concat(exports.THEME_COLORS.DARK.TEXT, " !important;\n }\n \n /* Invoicing theme - no container styling needed */\n /* .lsp-theme-invoicing { } */\n ");
|
|
30
|
+
document.head.appendChild(styleElement);
|
|
31
|
+
}
|
|
4
32
|
/**
|
|
5
33
|
* Get theme configuration based on theme name
|
|
6
34
|
*/
|
|
@@ -37,6 +65,18 @@ function getThemeConfig(theme) {
|
|
|
37
65
|
type: 'tabs',
|
|
38
66
|
},
|
|
39
67
|
};
|
|
68
|
+
case 'dark':
|
|
69
|
+
// Ensure theme stylesheet is injected
|
|
70
|
+
ensureThemeStylesheet();
|
|
71
|
+
return {
|
|
72
|
+
appearance: {
|
|
73
|
+
theme: 'night',
|
|
74
|
+
},
|
|
75
|
+
fonts: [],
|
|
76
|
+
layout: {
|
|
77
|
+
type: 'tabs',
|
|
78
|
+
},
|
|
79
|
+
};
|
|
40
80
|
default:
|
|
41
81
|
return undefined;
|
|
42
82
|
}
|
|
@@ -45,22 +45,52 @@ var moto_1 = require("./widgets/moto");
|
|
|
45
45
|
*/
|
|
46
46
|
function mount(mountElement, session, eventBroadcaster, defaultValues, theme) {
|
|
47
47
|
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
-
var sessionType;
|
|
49
|
-
return __generator(this, function (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
case
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
var sessionType, widgetController, _a, originalUnmount_1, error_1;
|
|
49
|
+
return __generator(this, function (_b) {
|
|
50
|
+
switch (_b.label) {
|
|
51
|
+
case 0:
|
|
52
|
+
sessionType = session.metadata.sessionType;
|
|
53
|
+
_b.label = 1;
|
|
54
|
+
case 1:
|
|
55
|
+
_b.trys.push([1, 8, , 9]);
|
|
56
|
+
widgetController = void 0;
|
|
57
|
+
_a = sessionType;
|
|
58
|
+
switch (_a) {
|
|
59
|
+
case 'payment': return [3 /*break*/, 2];
|
|
60
|
+
case 'payment-with-save': return [3 /*break*/, 2];
|
|
61
|
+
case 'moto': return [3 /*break*/, 4];
|
|
62
|
+
case 'moto-with-save': return [3 /*break*/, 4];
|
|
63
|
+
case 'save': return [3 /*break*/, 4];
|
|
64
|
+
}
|
|
65
|
+
return [3 /*break*/, 6];
|
|
66
|
+
case 2: return [4 /*yield*/, (0, payment_1.mountPaymentWidget)(mountElement, session, eventBroadcaster, defaultValues, theme)];
|
|
67
|
+
case 3:
|
|
68
|
+
widgetController = _b.sent();
|
|
69
|
+
return [3 /*break*/, 7];
|
|
70
|
+
case 4: return [4 /*yield*/, (0, moto_1.mountMotoWidget)(mountElement, session, eventBroadcaster, defaultValues, theme)];
|
|
71
|
+
case 5:
|
|
72
|
+
widgetController = _b.sent();
|
|
73
|
+
return [3 /*break*/, 7];
|
|
74
|
+
case 6: throw new Error("Unsupported session type: ".concat(sessionType));
|
|
75
|
+
case 7:
|
|
76
|
+
originalUnmount_1 = widgetController.unmount;
|
|
77
|
+
widgetController.unmount = function () {
|
|
78
|
+
// Remove theme class on unmount (generic cleanup)
|
|
79
|
+
if (theme) {
|
|
80
|
+
mountElement.classList.remove("lsp-theme-".concat(theme));
|
|
81
|
+
}
|
|
82
|
+
originalUnmount_1();
|
|
83
|
+
};
|
|
84
|
+
return [2 /*return*/, widgetController];
|
|
85
|
+
case 8:
|
|
86
|
+
error_1 = _b.sent();
|
|
87
|
+
// Clean up theme class if mounting fails
|
|
88
|
+
if (theme) {
|
|
89
|
+
mountElement.classList.remove("lsp-theme-".concat(theme));
|
|
90
|
+
}
|
|
91
|
+
throw error_1;
|
|
92
|
+
case 9: return [2 /*return*/];
|
|
62
93
|
}
|
|
63
|
-
return [2 /*return*/];
|
|
64
94
|
});
|
|
65
95
|
});
|
|
66
96
|
}
|
|
@@ -51,7 +51,7 @@ function mountMotoWidget(mountElement, session, eventBroadcaster, defaultValues,
|
|
|
51
51
|
case 1:
|
|
52
52
|
_a = _c.sent(), stripe = _a.stripe, elements = _a.elements;
|
|
53
53
|
paymentOptions = (0, shared_1.createPaymentElementOptions)(defaultValues, theme);
|
|
54
|
-
_b = (0, shared_1.createPaymentElement)(elements, paymentOptions, mountElement, eventBroadcaster), paymentElement = _b.element, paymentContainer = _b.container, customTermsContainer = _b.customTermsContainer;
|
|
54
|
+
_b = (0, shared_1.createPaymentElement)(elements, paymentOptions, mountElement, eventBroadcaster, theme), paymentElement = _b.element, paymentContainer = _b.container, customTermsContainer = _b.customTermsContainer;
|
|
55
55
|
return [2 /*return*/, {
|
|
56
56
|
unmount: function () {
|
|
57
57
|
(0, shared_1.cleanupElements)(paymentElement, null, paymentContainer, null, customTermsContainer);
|
|
@@ -52,7 +52,7 @@ function mountPaymentWidget(mountElement, session, eventBroadcaster, defaultValu
|
|
|
52
52
|
addressOptions = (0, shared_1.createAddressElementOptions)(defaultValues);
|
|
53
53
|
_b = (0, shared_1.createAddressElement)(elements, addressOptions, mountElement), addressElement = _b.element, addressContainer = _b.container;
|
|
54
54
|
paymentOptions = (0, shared_1.createPaymentElementOptions)(defaultValues, theme, true);
|
|
55
|
-
_c = (0, shared_1.createPaymentElement)(elements, paymentOptions, mountElement, eventBroadcaster), paymentElement = _c.element, paymentContainer = _c.container, customTermsContainer = _c.customTermsContainer;
|
|
55
|
+
_c = (0, shared_1.createPaymentElement)(elements, paymentOptions, mountElement, eventBroadcaster, theme), paymentElement = _c.element, paymentContainer = _c.container, customTermsContainer = _c.customTermsContainer;
|
|
56
56
|
return [2 /*return*/, {
|
|
57
57
|
unmount: function () {
|
|
58
58
|
(0, shared_1.cleanupElements)(paymentElement, addressElement, paymentContainer, addressContainer, customTermsContainer);
|
package/dist/cjs/v1/widget.js
CHANGED
|
@@ -46,7 +46,7 @@ var common_1 = require("./logging/common");
|
|
|
46
46
|
var EventBroadcaster_1 = require("./EventBroadcaster");
|
|
47
47
|
function mountPaymentWidget(session, config) {
|
|
48
48
|
return __awaiter(this, void 0, void 0, function () {
|
|
49
|
-
var eventBroadcaster, decodedSession, logger_2, widgetController, _a, error_2;
|
|
49
|
+
var eventBroadcaster, decodedSession, logger_2, configSummary, widgetController, _a, error_2;
|
|
50
50
|
return __generator(this, function (_b) {
|
|
51
51
|
switch (_b.label) {
|
|
52
52
|
case 0:
|
|
@@ -62,7 +62,12 @@ function mountPaymentWidget(session, config) {
|
|
|
62
62
|
logger_2.log('info', event.status, { event: event });
|
|
63
63
|
return event;
|
|
64
64
|
});
|
|
65
|
-
|
|
65
|
+
configSummary = {
|
|
66
|
+
theme: config.theme || 'none',
|
|
67
|
+
listeners: config.listeners ? Object.keys(config.listeners) : [],
|
|
68
|
+
defaultValues: config.defaultValues ? Object.keys(config.defaultValues) : undefined,
|
|
69
|
+
};
|
|
70
|
+
logger_2.log('info', 'Mount', { configuration: configSummary });
|
|
66
71
|
widgetController = void 0;
|
|
67
72
|
_a = decodedSession.psp;
|
|
68
73
|
switch (_a) {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/v1/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export type { WidgetController, SessionType, DefaultValues } from './common';
|
|
|
10
10
|
export type { Event } from './EventBroadcaster';
|
|
11
11
|
export { UnsupportedLocationError, InvalidSessionPayloadError, InvalidSessionError, ProcessingError, } from './error';
|
|
12
12
|
export type { PaymentWidgetConfiguration, PaymentWidgetTheme } from './widget';
|
|
13
|
+
export { THEME_COLORS } from './stripe/themes';
|
|
13
14
|
export type LightspeedPaymentsV1 = {
|
|
14
15
|
/**
|
|
15
16
|
* Mounts the payment widget to the specified mount point.
|
package/dist/v1/index.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { mountPaymentWidget } from './widget';
|
|
8
8
|
export { UnsupportedLocationError, InvalidSessionPayloadError, InvalidSessionError, ProcessingError, } from './error';
|
|
9
|
+
export { THEME_COLORS } from './stripe/themes';
|
|
9
10
|
export var v1 = {
|
|
10
11
|
mountPaymentWidget: mountPaymentWidget,
|
|
11
12
|
};
|
|
@@ -30,7 +30,7 @@ export declare function createAddressElementOptions(defaultValues?: DefaultValue
|
|
|
30
30
|
/**
|
|
31
31
|
* Create and mount payment element
|
|
32
32
|
*/
|
|
33
|
-
export declare function createPaymentElement(elements: StripeElements, options: StripePaymentElementOptions, mountElement: HTMLElement, eventBroadcaster: EventBroadcaster): {
|
|
33
|
+
export declare function createPaymentElement(elements: StripeElements, options: StripePaymentElementOptions, mountElement: HTMLElement, eventBroadcaster: EventBroadcaster, theme?: PaymentWidgetTheme): {
|
|
34
34
|
element: StripePaymentElement;
|
|
35
35
|
container: HTMLElement;
|
|
36
36
|
customTermsContainer: HTMLElement;
|
package/dist/v1/stripe/shared.js
CHANGED
|
@@ -170,7 +170,11 @@ function createCustomTermsElement() {
|
|
|
170
170
|
/**
|
|
171
171
|
* Create and mount payment element
|
|
172
172
|
*/
|
|
173
|
-
export function createPaymentElement(elements, options, mountElement, eventBroadcaster) {
|
|
173
|
+
export function createPaymentElement(elements, options, mountElement, eventBroadcaster, theme) {
|
|
174
|
+
// Apply theme class to mount element (generic approach)
|
|
175
|
+
if (theme) {
|
|
176
|
+
mountElement.classList.add("lsp-theme-".concat(theme));
|
|
177
|
+
}
|
|
174
178
|
var paymentElement = elements.create('payment', options);
|
|
175
179
|
paymentElement.on('ready', function () {
|
|
176
180
|
return eventBroadcaster.publish({ status: 'Ready', code: 'Ready' });
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { Appearance } from '@stripe/stripe-js';
|
|
2
2
|
import { PaymentWidgetTheme } from '../widget';
|
|
3
|
+
/**
|
|
4
|
+
* Theme color constants for styling containers
|
|
5
|
+
* Use these to match the SDK's dark theme colors in your application
|
|
6
|
+
*/
|
|
7
|
+
export declare const THEME_COLORS: {
|
|
8
|
+
readonly DARK: {
|
|
9
|
+
readonly BACKGROUND: "#1a1a1a";
|
|
10
|
+
readonly TEXT: "#ffffff";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
3
13
|
/**
|
|
4
14
|
* Theme configuration for Stripe Elements appearance
|
|
5
15
|
*/
|
package/dist/v1/stripe/themes.js
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme color constants for styling containers
|
|
3
|
+
* Use these to match the SDK's dark theme colors in your application
|
|
4
|
+
*/
|
|
5
|
+
export var THEME_COLORS = {
|
|
6
|
+
DARK: {
|
|
7
|
+
BACKGROUND: '#1a1a1a',
|
|
8
|
+
TEXT: '#ffffff',
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* ID for the injected theme stylesheet element
|
|
13
|
+
*/
|
|
14
|
+
var THEME_STYLESHEET_ID = 'lsp-theme-styles';
|
|
15
|
+
/**
|
|
16
|
+
* Inject theme stylesheets into the document head
|
|
17
|
+
* Each theme can define its own container styling
|
|
18
|
+
*/
|
|
19
|
+
function ensureThemeStylesheet() {
|
|
20
|
+
if (document.getElementById(THEME_STYLESHEET_ID)) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
var styleElement = document.createElement('style');
|
|
24
|
+
styleElement.id = THEME_STYLESHEET_ID;
|
|
25
|
+
styleElement.textContent = "\n /* Dark theme styles for the mount element */\n .lsp-theme-dark {\n background-color: ".concat(THEME_COLORS.DARK.BACKGROUND, " !important;\n color: ").concat(THEME_COLORS.DARK.TEXT, " !important;\n }\n /* Dark theme styles for Stripe custom terms elements */\n .lsp-theme-dark .stripe-terms-triangle {\n color: ").concat(THEME_COLORS.DARK.TEXT, " !important;\n }\n .lsp-theme-dark .stripe-custom-terms-text {\n color: ").concat(THEME_COLORS.DARK.TEXT, " !important;\n }\n .lsp-theme-dark .stripe-expandable-terms-content p {\n color: ").concat(THEME_COLORS.DARK.TEXT, " !important;\n }\n \n /* Invoicing theme - no container styling needed */\n /* .lsp-theme-invoicing { } */\n ");
|
|
26
|
+
document.head.appendChild(styleElement);
|
|
27
|
+
}
|
|
1
28
|
/**
|
|
2
29
|
* Get theme configuration based on theme name
|
|
3
30
|
*/
|
|
@@ -34,6 +61,18 @@ export function getThemeConfig(theme) {
|
|
|
34
61
|
type: 'tabs',
|
|
35
62
|
},
|
|
36
63
|
};
|
|
64
|
+
case 'dark':
|
|
65
|
+
// Ensure theme stylesheet is injected
|
|
66
|
+
ensureThemeStylesheet();
|
|
67
|
+
return {
|
|
68
|
+
appearance: {
|
|
69
|
+
theme: 'night',
|
|
70
|
+
},
|
|
71
|
+
fonts: [],
|
|
72
|
+
layout: {
|
|
73
|
+
type: 'tabs',
|
|
74
|
+
},
|
|
75
|
+
};
|
|
37
76
|
default:
|
|
38
77
|
return undefined;
|
|
39
78
|
}
|
package/dist/v1/stripe/widget.js
CHANGED
|
@@ -41,22 +41,52 @@ import { mountMotoWidget } from './widgets/moto';
|
|
|
41
41
|
*/
|
|
42
42
|
export function mount(mountElement, session, eventBroadcaster, defaultValues, theme) {
|
|
43
43
|
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
-
var sessionType;
|
|
45
|
-
return __generator(this, function (
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
case
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
44
|
+
var sessionType, widgetController, _a, originalUnmount_1, error_1;
|
|
45
|
+
return __generator(this, function (_b) {
|
|
46
|
+
switch (_b.label) {
|
|
47
|
+
case 0:
|
|
48
|
+
sessionType = session.metadata.sessionType;
|
|
49
|
+
_b.label = 1;
|
|
50
|
+
case 1:
|
|
51
|
+
_b.trys.push([1, 8, , 9]);
|
|
52
|
+
widgetController = void 0;
|
|
53
|
+
_a = sessionType;
|
|
54
|
+
switch (_a) {
|
|
55
|
+
case 'payment': return [3 /*break*/, 2];
|
|
56
|
+
case 'payment-with-save': return [3 /*break*/, 2];
|
|
57
|
+
case 'moto': return [3 /*break*/, 4];
|
|
58
|
+
case 'moto-with-save': return [3 /*break*/, 4];
|
|
59
|
+
case 'save': return [3 /*break*/, 4];
|
|
60
|
+
}
|
|
61
|
+
return [3 /*break*/, 6];
|
|
62
|
+
case 2: return [4 /*yield*/, mountPaymentWidget(mountElement, session, eventBroadcaster, defaultValues, theme)];
|
|
63
|
+
case 3:
|
|
64
|
+
widgetController = _b.sent();
|
|
65
|
+
return [3 /*break*/, 7];
|
|
66
|
+
case 4: return [4 /*yield*/, mountMotoWidget(mountElement, session, eventBroadcaster, defaultValues, theme)];
|
|
67
|
+
case 5:
|
|
68
|
+
widgetController = _b.sent();
|
|
69
|
+
return [3 /*break*/, 7];
|
|
70
|
+
case 6: throw new Error("Unsupported session type: ".concat(sessionType));
|
|
71
|
+
case 7:
|
|
72
|
+
originalUnmount_1 = widgetController.unmount;
|
|
73
|
+
widgetController.unmount = function () {
|
|
74
|
+
// Remove theme class on unmount (generic cleanup)
|
|
75
|
+
if (theme) {
|
|
76
|
+
mountElement.classList.remove("lsp-theme-".concat(theme));
|
|
77
|
+
}
|
|
78
|
+
originalUnmount_1();
|
|
79
|
+
};
|
|
80
|
+
return [2 /*return*/, widgetController];
|
|
81
|
+
case 8:
|
|
82
|
+
error_1 = _b.sent();
|
|
83
|
+
// Clean up theme class if mounting fails
|
|
84
|
+
if (theme) {
|
|
85
|
+
mountElement.classList.remove("lsp-theme-".concat(theme));
|
|
86
|
+
}
|
|
87
|
+
throw error_1;
|
|
88
|
+
case 9: return [2 /*return*/];
|
|
58
89
|
}
|
|
59
|
-
return [2 /*return*/];
|
|
60
90
|
});
|
|
61
91
|
});
|
|
62
92
|
}
|
|
@@ -48,7 +48,7 @@ export function mountMotoWidget(mountElement, session, eventBroadcaster, default
|
|
|
48
48
|
case 1:
|
|
49
49
|
_a = _c.sent(), stripe = _a.stripe, elements = _a.elements;
|
|
50
50
|
paymentOptions = createPaymentElementOptions(defaultValues, theme);
|
|
51
|
-
_b = createPaymentElement(elements, paymentOptions, mountElement, eventBroadcaster), paymentElement = _b.element, paymentContainer = _b.container, customTermsContainer = _b.customTermsContainer;
|
|
51
|
+
_b = createPaymentElement(elements, paymentOptions, mountElement, eventBroadcaster, theme), paymentElement = _b.element, paymentContainer = _b.container, customTermsContainer = _b.customTermsContainer;
|
|
52
52
|
return [2 /*return*/, {
|
|
53
53
|
unmount: function () {
|
|
54
54
|
cleanupElements(paymentElement, null, paymentContainer, null, customTermsContainer);
|
|
@@ -49,7 +49,7 @@ export function mountPaymentWidget(mountElement, session, eventBroadcaster, defa
|
|
|
49
49
|
addressOptions = createAddressElementOptions(defaultValues);
|
|
50
50
|
_b = createAddressElement(elements, addressOptions, mountElement), addressElement = _b.element, addressContainer = _b.container;
|
|
51
51
|
paymentOptions = createPaymentElementOptions(defaultValues, theme, true);
|
|
52
|
-
_c = createPaymentElement(elements, paymentOptions, mountElement, eventBroadcaster), paymentElement = _c.element, paymentContainer = _c.container, customTermsContainer = _c.customTermsContainer;
|
|
52
|
+
_c = createPaymentElement(elements, paymentOptions, mountElement, eventBroadcaster, theme), paymentElement = _c.element, paymentContainer = _c.container, customTermsContainer = _c.customTermsContainer;
|
|
53
53
|
return [2 /*return*/, {
|
|
54
54
|
unmount: function () {
|
|
55
55
|
cleanupElements(paymentElement, addressElement, paymentContainer, addressContainer, customTermsContainer);
|
package/dist/v1/widget.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WidgetController, DefaultValues } from './common';
|
|
2
2
|
import { EventListeners } from './EventBroadcaster';
|
|
3
|
-
export type PaymentWidgetTheme = 'invoicing';
|
|
3
|
+
export type PaymentWidgetTheme = 'invoicing' | 'dark';
|
|
4
4
|
export type PaymentWidgetConfiguration = {
|
|
5
5
|
mountPoint: HTMLElement;
|
|
6
6
|
defaultValues?: DefaultValues;
|
package/dist/v1/widget.js
CHANGED
|
@@ -43,7 +43,7 @@ import { withLogging } from './logging/common';
|
|
|
43
43
|
import { EventBroadcaster } from './EventBroadcaster';
|
|
44
44
|
export function mountPaymentWidget(session, config) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function () {
|
|
46
|
-
var eventBroadcaster, decodedSession, logger_1, widgetController, _a, error_1;
|
|
46
|
+
var eventBroadcaster, decodedSession, logger_1, configSummary, widgetController, _a, error_1;
|
|
47
47
|
return __generator(this, function (_b) {
|
|
48
48
|
switch (_b.label) {
|
|
49
49
|
case 0:
|
|
@@ -59,7 +59,12 @@ export function mountPaymentWidget(session, config) {
|
|
|
59
59
|
logger_1.log('info', event.status, { event: event });
|
|
60
60
|
return event;
|
|
61
61
|
});
|
|
62
|
-
|
|
62
|
+
configSummary = {
|
|
63
|
+
theme: config.theme || 'none',
|
|
64
|
+
listeners: config.listeners ? Object.keys(config.listeners) : [],
|
|
65
|
+
defaultValues: config.defaultValues ? Object.keys(config.defaultValues) : undefined,
|
|
66
|
+
};
|
|
67
|
+
logger_1.log('info', 'Mount', { configuration: configSummary });
|
|
63
68
|
widgetController = void 0;
|
|
64
69
|
_a = decodedSession.psp;
|
|
65
70
|
switch (_a) {
|
package/package.json
CHANGED