@lightspeed/online-payments-sdk 1.6.0 → 1.6.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 +92 -1
- package/dist/cjs/v1/stripe/shared.js +4 -4
- package/dist/cjs/v1/stripe/widgets/payment.js +8 -2
- package/dist/cjs/version.js +1 -1
- package/dist/v1/stripe/shared.d.ts +2 -1
- package/dist/v1/stripe/shared.js +4 -4
- package/dist/v1/stripe/widgets/payment.js +8 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -1 +1,92 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Lightspeed Online Payments SDK
|
|
2
|
+
|
|
3
|
+
`@lightspeed/online-payments-sdk` is a browser SDK for mounting Lightspeed Payments widgets (Stripe and Adyen) in web applications.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install @lightspeed/online-payments-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import {LightspeedPayments} from '@lightspeed/online-payments-sdk';
|
|
15
|
+
|
|
16
|
+
const controller = await LightspeedPayments.v1.mountPaymentWidget(sessionToken, {
|
|
17
|
+
mountPoint: document.getElementById('payment-widget')!,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
controller.unmount();
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Compatibility
|
|
24
|
+
|
|
25
|
+
- TypeScript/JavaScript
|
|
26
|
+
- Browser runtime (requires `window`)
|
|
27
|
+
|
|
28
|
+
## Theming
|
|
29
|
+
|
|
30
|
+
The SDK supports custom themes. If no theme is specified, Stripe defaults are used.
|
|
31
|
+
|
|
32
|
+
### Available themes
|
|
33
|
+
|
|
34
|
+
- default (no `theme` value)
|
|
35
|
+
- `invoicing`
|
|
36
|
+
- `dark`
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
import {LightspeedPayments} from '@lightspeed/online-payments-sdk';
|
|
40
|
+
|
|
41
|
+
await LightspeedPayments.v1.mountPaymentWidget(paymentSession, {
|
|
42
|
+
mountPoint: document.getElementById('payment-widget')!,
|
|
43
|
+
theme: 'dark',
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Container styling
|
|
48
|
+
|
|
49
|
+
For dark mode, the SDK styles the mount element you pass in `mountPoint`. If you style a parent wrapper, use `THEME_COLORS`.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
import {THEME_COLORS} from '@lightspeed/online-payments-sdk';
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Documentation
|
|
56
|
+
|
|
57
|
+
- Datadog logging reference: `packages/lsp-online-payments-sdk/docs/DATADOG_LOGGING.md`
|
|
58
|
+
|
|
59
|
+
## Development
|
|
60
|
+
|
|
61
|
+
Run SDK checks (same order as CI):
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
npm run lint --workspace @lightspeed/online-payments-sdk
|
|
65
|
+
npm run typecheck --workspace @lightspeed/online-payments-sdk
|
|
66
|
+
npm run test --workspace @lightspeed/online-payments-sdk
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Build package:
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
npm run build --workspace @lightspeed/online-payments-sdk
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Inspect publish contents:
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
npm pack --dry-run
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Publishing and release flow
|
|
82
|
+
|
|
83
|
+
Publishing is handled by CircleCI (not manual local publish).
|
|
84
|
+
|
|
85
|
+
- Release path runs on `main` and `release/*`.
|
|
86
|
+
- CircleCI runs quality gates (`lint`, `typecheck`, unit tests, build, e2e).
|
|
87
|
+
- `verify_package_version` compares local `package.json` version with npm.
|
|
88
|
+
- If local version is not higher, publish is skipped.
|
|
89
|
+
- If local version is higher, the workflow pauses at manual approval (`pause_workflow`).
|
|
90
|
+
- A human must approve before the `release` job runs `npm publish`.
|
|
91
|
+
|
|
92
|
+
In practice: bump `version` in `packages/lsp-online-payments-sdk/package.json`, merge to `main`, then approve the release hold in CircleCI.
|
|
@@ -93,9 +93,11 @@ function initStripe(context, theme) {
|
|
|
93
93
|
* @param theme - Theme configuration
|
|
94
94
|
* @param hideNameField - Whether to hide the billing details name field (used when address element is present to avoid duplicates with ACH)
|
|
95
95
|
* @param businessName - Overrides the merchant name Stripe renders in mandate text (passed to `business.name`)
|
|
96
|
+
* @param showCardMandate - Forces Stripe to render its card mandate text (which includes `business.name`). Used for partner payment-with-save flows where Stripe would otherwise not show terms.
|
|
96
97
|
*/
|
|
97
|
-
function createPaymentElementOptions(defaultValues, theme, hideNameField, businessName) {
|
|
98
|
+
function createPaymentElementOptions(defaultValues, theme, hideNameField, businessName, showCardMandate) {
|
|
98
99
|
if (hideNameField === void 0) { hideNameField = false; }
|
|
100
|
+
if (showCardMandate === void 0) { showCardMandate = false; }
|
|
99
101
|
var options = __assign(__assign(__assign({ wallets: {
|
|
100
102
|
applePay: 'never',
|
|
101
103
|
googlePay: 'never',
|
|
@@ -106,9 +108,7 @@ function createPaymentElementOptions(defaultValues, theme, hideNameField, busine
|
|
|
106
108
|
name: 'never', // prevent duplicate Name field on the form when using ACH (only when address element is present)
|
|
107
109
|
},
|
|
108
110
|
},
|
|
109
|
-
})), { terms: {
|
|
110
|
-
usBankAccount: 'never', // Hide Stripe's default T&Cs (shown for ACH payments)
|
|
111
|
-
} }), (businessName && { business: { name: businessName } }));
|
|
111
|
+
})), { terms: __assign({ usBankAccount: 'never' }, (showCardMandate && businessName && { card: 'always' })) }), (businessName && { business: { name: businessName } }));
|
|
112
112
|
if (defaultValues) {
|
|
113
113
|
options.defaultValues = {
|
|
114
114
|
billingDetails: {
|
|
@@ -43,7 +43,7 @@ var shared_1 = require("../shared");
|
|
|
43
43
|
*/
|
|
44
44
|
function mountPaymentWidget(mountElement, session, eventBroadcaster, defaultValues, theme) {
|
|
45
45
|
return __awaiter(this, void 0, void 0, function () {
|
|
46
|
-
var _a, stripe, elements, addressOptions, _b, addressElement, addressContainer, paymentOptions, _c, paymentElement, paymentContainer, customTermsContainer;
|
|
46
|
+
var _a, stripe, elements, addressOptions, _b, addressElement, addressContainer, productMetadata, isPartnerProduct, showCardMandate, paymentOptions, _c, paymentElement, paymentContainer, customTermsContainer;
|
|
47
47
|
return __generator(this, function (_d) {
|
|
48
48
|
switch (_d.label) {
|
|
49
49
|
case 0: return [4 /*yield*/, (0, shared_1.initStripe)(session.context, theme)];
|
|
@@ -51,7 +51,13 @@ function mountPaymentWidget(mountElement, session, eventBroadcaster, defaultValu
|
|
|
51
51
|
_a = _d.sent(), stripe = _a.stripe, elements = _a.elements;
|
|
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
|
+
productMetadata = session.metadata.product;
|
|
55
|
+
isPartnerProduct = typeof productMetadata === 'string' &&
|
|
56
|
+
productMetadata.startsWith('partner:');
|
|
57
|
+
showCardMandate = session.metadata.sessionType === 'payment-with-save' &&
|
|
58
|
+
!!session.context.businessName &&
|
|
59
|
+
isPartnerProduct;
|
|
60
|
+
paymentOptions = (0, shared_1.createPaymentElementOptions)(defaultValues, theme, true, session.context.businessName, showCardMandate);
|
|
55
61
|
_c = (0, shared_1.createPaymentElement)(elements, paymentOptions, mountElement, eventBroadcaster), paymentElement = _c.element, paymentContainer = _c.container, customTermsContainer = _c.customTermsContainer;
|
|
56
62
|
// Setup change handler that emits Complete only when both elements are complete
|
|
57
63
|
(0, shared_1.setupChangeEventHandler)(paymentElement, eventBroadcaster, addressElement);
|
package/dist/cjs/version.js
CHANGED
|
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.SDK_VERSION = void 0;
|
|
4
4
|
// This file is auto-generated during the build process
|
|
5
5
|
// DO NOT EDIT MANUALLY - Version is extracted from package.json
|
|
6
|
-
exports.SDK_VERSION = '1.6.
|
|
6
|
+
exports.SDK_VERSION = '1.6.1';
|
|
@@ -22,8 +22,9 @@ export declare function initStripe(context: StripeContext, theme?: PaymentWidget
|
|
|
22
22
|
* @param theme - Theme configuration
|
|
23
23
|
* @param hideNameField - Whether to hide the billing details name field (used when address element is present to avoid duplicates with ACH)
|
|
24
24
|
* @param businessName - Overrides the merchant name Stripe renders in mandate text (passed to `business.name`)
|
|
25
|
+
* @param showCardMandate - Forces Stripe to render its card mandate text (which includes `business.name`). Used for partner payment-with-save flows where Stripe would otherwise not show terms.
|
|
25
26
|
*/
|
|
26
|
-
export declare function createPaymentElementOptions(defaultValues?: DefaultValues, theme?: PaymentWidgetTheme, hideNameField?: boolean, businessName?: string): StripePaymentElementOptions;
|
|
27
|
+
export declare function createPaymentElementOptions(defaultValues?: DefaultValues, theme?: PaymentWidgetTheme, hideNameField?: boolean, businessName?: string, showCardMandate?: boolean): StripePaymentElementOptions;
|
|
27
28
|
/**
|
|
28
29
|
* Create address element options
|
|
29
30
|
*/
|
package/dist/v1/stripe/shared.js
CHANGED
|
@@ -81,9 +81,11 @@ export function initStripe(context, theme) {
|
|
|
81
81
|
* @param theme - Theme configuration
|
|
82
82
|
* @param hideNameField - Whether to hide the billing details name field (used when address element is present to avoid duplicates with ACH)
|
|
83
83
|
* @param businessName - Overrides the merchant name Stripe renders in mandate text (passed to `business.name`)
|
|
84
|
+
* @param showCardMandate - Forces Stripe to render its card mandate text (which includes `business.name`). Used for partner payment-with-save flows where Stripe would otherwise not show terms.
|
|
84
85
|
*/
|
|
85
|
-
export function createPaymentElementOptions(defaultValues, theme, hideNameField, businessName) {
|
|
86
|
+
export function createPaymentElementOptions(defaultValues, theme, hideNameField, businessName, showCardMandate) {
|
|
86
87
|
if (hideNameField === void 0) { hideNameField = false; }
|
|
88
|
+
if (showCardMandate === void 0) { showCardMandate = false; }
|
|
87
89
|
var options = __assign(__assign(__assign({ wallets: {
|
|
88
90
|
applePay: 'never',
|
|
89
91
|
googlePay: 'never',
|
|
@@ -94,9 +96,7 @@ export function createPaymentElementOptions(defaultValues, theme, hideNameField,
|
|
|
94
96
|
name: 'never', // prevent duplicate Name field on the form when using ACH (only when address element is present)
|
|
95
97
|
},
|
|
96
98
|
},
|
|
97
|
-
})), { terms: {
|
|
98
|
-
usBankAccount: 'never', // Hide Stripe's default T&Cs (shown for ACH payments)
|
|
99
|
-
} }), (businessName && { business: { name: businessName } }));
|
|
99
|
+
})), { terms: __assign({ usBankAccount: 'never' }, (showCardMandate && businessName && { card: 'always' })) }), (businessName && { business: { name: businessName } }));
|
|
100
100
|
if (defaultValues) {
|
|
101
101
|
options.defaultValues = {
|
|
102
102
|
billingDetails: {
|
|
@@ -40,7 +40,7 @@ import { initStripe, createPaymentElementOptions, createAddressElementOptions, c
|
|
|
40
40
|
*/
|
|
41
41
|
export function mountPaymentWidget(mountElement, session, eventBroadcaster, defaultValues, theme) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var _a, stripe, elements, addressOptions, _b, addressElement, addressContainer, paymentOptions, _c, paymentElement, paymentContainer, customTermsContainer;
|
|
43
|
+
var _a, stripe, elements, addressOptions, _b, addressElement, addressContainer, productMetadata, isPartnerProduct, showCardMandate, paymentOptions, _c, paymentElement, paymentContainer, customTermsContainer;
|
|
44
44
|
return __generator(this, function (_d) {
|
|
45
45
|
switch (_d.label) {
|
|
46
46
|
case 0: return [4 /*yield*/, initStripe(session.context, theme)];
|
|
@@ -48,7 +48,13 @@ export function mountPaymentWidget(mountElement, session, eventBroadcaster, defa
|
|
|
48
48
|
_a = _d.sent(), stripe = _a.stripe, elements = _a.elements;
|
|
49
49
|
addressOptions = createAddressElementOptions(defaultValues);
|
|
50
50
|
_b = createAddressElement(elements, addressOptions, mountElement), addressElement = _b.element, addressContainer = _b.container;
|
|
51
|
-
|
|
51
|
+
productMetadata = session.metadata.product;
|
|
52
|
+
isPartnerProduct = typeof productMetadata === 'string' &&
|
|
53
|
+
productMetadata.startsWith('partner:');
|
|
54
|
+
showCardMandate = session.metadata.sessionType === 'payment-with-save' &&
|
|
55
|
+
!!session.context.businessName &&
|
|
56
|
+
isPartnerProduct;
|
|
57
|
+
paymentOptions = createPaymentElementOptions(defaultValues, theme, true, session.context.businessName, showCardMandate);
|
|
52
58
|
_c = createPaymentElement(elements, paymentOptions, mountElement, eventBroadcaster), paymentElement = _c.element, paymentContainer = _c.container, customTermsContainer = _c.customTermsContainer;
|
|
53
59
|
// Setup change handler that emits Complete only when both elements are complete
|
|
54
60
|
setupChangeEventHandler(paymentElement, eventBroadcaster, addressElement);
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "1.6.
|
|
1
|
+
export declare const SDK_VERSION = "1.6.1";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightspeed/online-payments-sdk",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "Process online-payments with Lightspeed Payments",
|
|
5
5
|
"author": "Lightspeed Commerce Inc.",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -32,18 +32,18 @@
|
|
|
32
32
|
"@eslint/js": "^9.33.0",
|
|
33
33
|
"@types/jest": "^30.0.0",
|
|
34
34
|
"gts": "^6.0.2",
|
|
35
|
-
"jest": "^30.2
|
|
36
|
-
"jest-environment-jsdom": "^30.
|
|
35
|
+
"jest": "^30.4.2",
|
|
36
|
+
"jest-environment-jsdom": "^30.4.1",
|
|
37
37
|
"jest-junit": "^16.0.0",
|
|
38
|
-
"rollup": "^4.
|
|
39
|
-
"ts-jest": "^29.4.
|
|
38
|
+
"rollup": "^4.62.2",
|
|
39
|
+
"ts-jest": "^29.4.11",
|
|
40
40
|
"tslib": "^2.8.1",
|
|
41
41
|
"typescript": "^5.9.3",
|
|
42
|
-
"typescript-eslint": "^8.
|
|
42
|
+
"typescript-eslint": "^8.63.0"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@adyen/adyen-web": "^6.
|
|
46
|
-
"@datadog/browser-logs": "^6.
|
|
45
|
+
"@adyen/adyen-web": "^6.40.1",
|
|
46
|
+
"@datadog/browser-logs": "^6.33.0",
|
|
47
47
|
"@stripe/stripe-js": "^7.9.0"
|
|
48
48
|
}
|
|
49
49
|
}
|