@lightspeed/online-payments-sdk 1.7.2 → 1.7.3

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 CHANGED
@@ -1,6 +1,11 @@
1
1
  # Lightspeed Online Payments SDK
2
2
 
3
- `@lightspeed/online-payments-sdk` is a browser SDK for mounting Lightspeed Payments widgets (Stripe and Adyen) in web applications.
3
+ `@lightspeed/online-payments-sdk` is a browser SDK for displaying Lightspeed Payments widgets in your web application.
4
+
5
+ This is intended for partners who wish to add payments functionality to an integration with a Lightspeed product.
6
+
7
+ For onboarding questions, account configuration, or production enablement: contact your Lightspeed
8
+ representative.
4
9
 
5
10
  ## Installation
6
11
 
@@ -8,94 +13,123 @@
8
13
  npm install @lightspeed/online-payments-sdk
9
14
  ```
10
15
 
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
- });
16
+ ## Requirements
19
17
 
20
- controller.unmount();
21
- ```
18
+ - A browser environment with `window` and `document`
19
+ - A payment session obtained from your Lightspeed Payments integration
20
+ - An HTML element where the payment widget can be mounted
22
21
 
23
- ## Compatibility
24
-
25
- - TypeScript/JavaScript
26
- - Browser runtime (requires `window`)
27
-
28
- ## Theming
22
+ ## Quick start
29
23
 
30
- The SDK supports custom themes. If no theme is specified, Stripe defaults are used.
24
+ Add a mount element to your page:
31
25
 
32
- ### Available themes
26
+ ```html
27
+ <div id="payment-widget"></div>
28
+ ```
33
29
 
34
- - default (no `theme` value)
35
- - `invoicing`
36
- - `dark`
30
+ Mount the widget with the payment session from your integration:
37
31
 
38
32
  ```ts
39
33
  import {LightspeedPayments} from '@lightspeed/online-payments-sdk';
40
34
 
41
- await LightspeedPayments.v1.mountPaymentWidget(paymentSession, {
42
- mountPoint: document.getElementById('payment-widget')!,
43
- theme: 'dark',
35
+ const mountPoint = document.getElementById('payment-widget');
36
+
37
+ if (!mountPoint) {
38
+ throw new Error('Payment widget mount point was not found');
39
+ }
40
+
41
+ const controller = await LightspeedPayments.v1.mountPaymentWidget(session, {
42
+ mountPoint,
44
43
  });
45
44
  ```
46
45
 
47
- ### Container styling
46
+ Keep the returned controller to submit the widget or remove it when the containing page or component is no longer needed.
47
+
48
+ ## Configuration
48
49
 
49
- For dark mode, the SDK styles the mount element you pass in `mountPoint`. If you style a parent wrapper, use `THEME_COLORS`.
50
+ `mountPaymentWidget(session, configuration)` accepts a payment session and the following configuration:
51
+
52
+ | Option | Description |
53
+ | --------------- | ---------------------------------------------------------------- |
54
+ | `mountPoint` | Required `HTMLElement` where the SDK renders the payment widget. |
55
+ | `defaultValues` | Optional initial address values: `country` and `postalCode`. |
56
+ | `listeners` | Optional callbacks for widget lifecycle and payment events. |
57
+ | `theme` | Optional visual theme: `dark`. |
50
58
 
51
59
  ```ts
52
- import {THEME_COLORS} from '@lightspeed/online-payments-sdk';
60
+ const controller = await LightspeedPayments.v1.mountPaymentWidget(session, {
61
+ mountPoint,
62
+ defaultValues: {
63
+ country: 'CA',
64
+ postalCode: 'H1H1H1',
65
+ },
66
+ listeners: {
67
+ onReady: () => {
68
+ // The widget is ready for payer input.
69
+ },
70
+ onChange: event => {
71
+ submitButton.disabled = event.code !== 'Complete';
72
+ },
73
+ onSucceeded: () => {
74
+ // Continue after a successful payment or payment-method save.
75
+ },
76
+ onDeclined: event => {
77
+ // Show a decline message appropriate for event.code.
78
+ },
79
+ onError: event => {
80
+ // Handle a widget or processing error.
81
+ },
82
+ },
83
+ });
53
84
  ```
54
85
 
55
- ## Documentation
86
+ ### Events
56
87
 
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`
88
+ Listeners receive an event with a `status` and `code`. Available listener names are `onReady`, `onChange`, `onSucceeded`, `onPending`, `onDeclined`, and `onError`.
59
89
 
60
- ## Development
90
+ | Status | Codes |
91
+ | ----------- | -------------------------------------------------------------------------------------------------------------- |
92
+ | `Ready` | `Ready` |
93
+ | `Change` | `Complete`, `Incomplete` |
94
+ | `Succeeded` | `Authorized` |
95
+ | `Pending` | `Processing` |
96
+ | `Declined` | `CardValidation`, `Generic`, `PaymentMethodNotSupported` |
97
+ | `Error` | `Unexpected`, `InvalidSession`, `InvalidSessionPayload`, `UnsupportedLocation`, `Processing`, `FormValidation` |
61
98
 
62
- Run SDK checks (same order as CI):
99
+ ## Submit and unmount
63
100
 
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
- ```
101
+ Call `submit()` in response to your application's payment action. Call `unmount()` before removing or replacing the mount element.
69
102
 
70
- Build package:
103
+ ```ts
104
+ submitButton.addEventListener('click', async () => {
105
+ await controller.submit();
106
+ });
71
107
 
72
- ```sh
73
- npm run build --workspace @lightspeed/online-payments-sdk
108
+ // For example, during page or component cleanup.
109
+ controller.unmount();
74
110
  ```
75
111
 
76
- Inspect publish contents:
112
+ ## Theming
77
113
 
78
- ```sh
79
- npm pack --dry-run
80
- ```
114
+ Use `theme` to select a widget appearance:
81
115
 
82
- ## Publishing and release flow
116
+ - Omit `theme` to use the default appearance.
117
+ - `dark` uses a dark appearance and styles the mount element with a dark background.
83
118
 
84
- Publishing is handled by CircleCI (not manual local publish).
119
+ Custom themes can be used with support from the Lightspeed Payments team.
85
120
 
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`.
121
+ ```ts
122
+ await LightspeedPayments.v1.mountPaymentWidget(session, {
123
+ mountPoint,
124
+ theme: 'dark',
125
+ });
126
+ ```
92
127
 
93
- In practice: bump `version` in `packages/lsp-online-payments-sdk/package.json`, merge to `main`, then approve the release hold in CircleCI.
128
+ For a wrapper around a widget using the `dark` theme, use `THEME_COLORS` to match the SDK's dark container colors:
94
129
 
95
- ### Sandbox releases
130
+ ```ts
131
+ import {THEME_COLORS} from '@lightspeed/online-payments-sdk';
96
132
 
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.
133
+ wrapper.style.backgroundColor = THEME_COLORS.DARK.BACKGROUND;
134
+ wrapper.style.color = THEME_COLORS.DARK.TEXT;
135
+ ```
@@ -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.7.2';
6
+ exports.SDK_VERSION = '1.7.3';
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.7.2";
1
+ export declare const SDK_VERSION = "1.7.3";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // This file is auto-generated during the build process
2
2
  // DO NOT EDIT MANUALLY - Version is extracted from package.json
3
- export var SDK_VERSION = '1.7.2';
3
+ export var SDK_VERSION = '1.7.3';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightspeed/online-payments-sdk",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "description": "Process online-payments with Lightspeed Payments",
5
5
  "author": "Lightspeed Commerce Inc.",
6
6
  "license": "SEE LICENSE IN LICENSE.md",