@lightspeed/online-payments-sdk 1.6.0 → 1.6.2
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 +101 -1
- package/dist/cjs/v1/stripe/shared.js +4 -4
- package/dist/cjs/v1/stripe/terms.js +1 -1
- 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/terms.d.ts +1 -1
- package/dist/v1/stripe/terms.js +1 -1
- 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,101 @@
|
|
|
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
|
+
- Sandbox releases (testing unreleased builds in a real app): `packages/lsp-online-payments-sdk/docs/sandbox-releases.md`
|
|
59
|
+
|
|
60
|
+
## Development
|
|
61
|
+
|
|
62
|
+
Run SDK checks (same order as CI):
|
|
63
|
+
|
|
64
|
+
```sh
|
|
65
|
+
npm run lint --workspace @lightspeed/online-payments-sdk
|
|
66
|
+
npm run typecheck --workspace @lightspeed/online-payments-sdk
|
|
67
|
+
npm run test --workspace @lightspeed/online-payments-sdk
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Build package:
|
|
71
|
+
|
|
72
|
+
```sh
|
|
73
|
+
npm run build --workspace @lightspeed/online-payments-sdk
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Inspect publish contents:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
npm pack --dry-run
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Publishing and release flow
|
|
83
|
+
|
|
84
|
+
Publishing is handled by CircleCI (not manual local publish).
|
|
85
|
+
|
|
86
|
+
- Release path runs on `main` and `release/*`.
|
|
87
|
+
- CircleCI runs quality gates (`lint`, `typecheck`, unit tests, build, e2e).
|
|
88
|
+
- `verify_package_version` compares local `package.json` version with npm.
|
|
89
|
+
- If local version is not higher, publish is skipped.
|
|
90
|
+
- If local version is higher, the workflow pauses at manual approval (`pause_workflow`).
|
|
91
|
+
- A human must approve before the `release` job runs `npm publish`.
|
|
92
|
+
|
|
93
|
+
In practice: bump `version` in `packages/lsp-online-payments-sdk/package.json`, merge to `main`, then approve the release hold in CircleCI.
|
|
94
|
+
|
|
95
|
+
### Sandbox releases
|
|
96
|
+
|
|
97
|
+
To test unreleased SDK changes inside a real app without touching the production
|
|
98
|
+
package on public npm, publish a **sandbox** build to GitHub Packages: push a
|
|
99
|
+
`sandbox/*` branch and approve the `hold_sandbox` step in CircleCI. Consuming an
|
|
100
|
+
app requires no `import` changes — just an `.npmrc` scope + a `package.json`
|
|
101
|
+
alias. See `docs/sandbox-releases.md` for the full publish and consume steps.
|
|
@@ -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: {
|
|
@@ -25,7 +25,7 @@ exports.ACH_TERMS_TEXT = {
|
|
|
25
25
|
*/
|
|
26
26
|
EXPANDED_TERMS_PARAGRAPHS: [
|
|
27
27
|
'By providing your bank account details and confirming this payment, you authorize the merchant to debit your account for the amount shown.',
|
|
28
|
-
'If you choose to save your bank account for future payments, this authorization will also apply to any amounts now or hereafter due and payable, including amounts previously invoiced, accrued, outstanding, or otherwise payable, in addition to current, and future payment obligations owed for products or services provided by the merchant, until you cancel it.',
|
|
28
|
+
'If you choose to save your bank account for future payments, this authorization will also apply to any amounts now or hereafter due and payable, including amounts previously invoiced, accrued, outstanding, or otherwise payable, in addition to current, and future payment obligations owed for products or services provided by the merchant, until you cancel it. For returns due to insufficient funds or uncollected funds, the merchant may retry the debit up to two additional times. If you save your bank account, you authorize Stripe and Lightspeed to access your account status and balance information, where available, before submitting current or future ACH payments. A balance check does not guarantee that an ACH payment will be completed.',
|
|
29
29
|
'You also authorize the merchant to credit your account as necessary to correct any erroneous debits.',
|
|
30
30
|
'You may revoke authorization at any time by contacting the merchant, allowing up to thirty (30) days for processing.\nYou confirm that you are an authorized signer on the account and that sufficient funds will be available for each payment.\nACH payments may take up to five (5) business days to complete, and you may be responsible for fees if a payment is returned.',
|
|
31
31
|
],
|
|
@@ -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.2';
|
|
@@ -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: {
|
|
@@ -20,7 +20,7 @@ export declare const ACH_TERMS_TEXT: {
|
|
|
20
20
|
* Each entry is a separate paragraph rendered when the user expands
|
|
21
21
|
* "these terms". Kept as plain text — HTML structure is built in code.
|
|
22
22
|
*/
|
|
23
|
-
readonly EXPANDED_TERMS_PARAGRAPHS: readonly ["By providing your bank account details and confirming this payment, you authorize the merchant to debit your account for the amount shown.", "If you choose to save your bank account for future payments, this authorization will also apply to any amounts now or hereafter due and payable, including amounts previously invoiced, accrued, outstanding, or otherwise payable, in addition to current, and future payment obligations owed for products or services provided by the merchant, until you cancel it.", "You also authorize the merchant to credit your account as necessary to correct any erroneous debits.", "You may revoke authorization at any time by contacting the merchant, allowing up to thirty (30) days for processing.\nYou confirm that you are an authorized signer on the account and that sufficient funds will be available for each payment.\nACH payments may take up to five (5) business days to complete, and you may be responsible for fees if a payment is returned."];
|
|
23
|
+
readonly EXPANDED_TERMS_PARAGRAPHS: readonly ["By providing your bank account details and confirming this payment, you authorize the merchant to debit your account for the amount shown.", "If you choose to save your bank account for future payments, this authorization will also apply to any amounts now or hereafter due and payable, including amounts previously invoiced, accrued, outstanding, or otherwise payable, in addition to current, and future payment obligations owed for products or services provided by the merchant, until you cancel it. For returns due to insufficient funds or uncollected funds, the merchant may retry the debit up to two additional times. If you save your bank account, you authorize Stripe and Lightspeed to access your account status and balance information, where available, before submitting current or future ACH payments. A balance check does not guarantee that an ACH payment will be completed.", "You also authorize the merchant to credit your account as necessary to correct any erroneous debits.", "You may revoke authorization at any time by contacting the merchant, allowing up to thirty (30) days for processing.\nYou confirm that you are an authorized signer on the account and that sufficient funds will be available for each payment.\nACH payments may take up to five (5) business days to complete, and you may be responsible for fees if a payment is returned."];
|
|
24
24
|
/**
|
|
25
25
|
* Final paragraph containing a link to the Privacy Policy.
|
|
26
26
|
* The link text and URL are defined separately so translators only
|
package/dist/v1/stripe/terms.js
CHANGED
|
@@ -22,7 +22,7 @@ export var ACH_TERMS_TEXT = {
|
|
|
22
22
|
*/
|
|
23
23
|
EXPANDED_TERMS_PARAGRAPHS: [
|
|
24
24
|
'By providing your bank account details and confirming this payment, you authorize the merchant to debit your account for the amount shown.',
|
|
25
|
-
'If you choose to save your bank account for future payments, this authorization will also apply to any amounts now or hereafter due and payable, including amounts previously invoiced, accrued, outstanding, or otherwise payable, in addition to current, and future payment obligations owed for products or services provided by the merchant, until you cancel it.',
|
|
25
|
+
'If you choose to save your bank account for future payments, this authorization will also apply to any amounts now or hereafter due and payable, including amounts previously invoiced, accrued, outstanding, or otherwise payable, in addition to current, and future payment obligations owed for products or services provided by the merchant, until you cancel it. For returns due to insufficient funds or uncollected funds, the merchant may retry the debit up to two additional times. If you save your bank account, you authorize Stripe and Lightspeed to access your account status and balance information, where available, before submitting current or future ACH payments. A balance check does not guarantee that an ACH payment will be completed.',
|
|
26
26
|
'You also authorize the merchant to credit your account as necessary to correct any erroneous debits.',
|
|
27
27
|
'You may revoke authorization at any time by contacting the merchant, allowing up to thirty (30) days for processing.\nYou confirm that you are an authorized signer on the account and that sufficient funds will be available for each payment.\nACH payments may take up to five (5) business days to complete, and you may be responsible for fees if a payment is returned.',
|
|
28
28
|
],
|
|
@@ -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.2";
|
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.2",
|
|
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
|
}
|