@liquidcommerce/elements-sdk 2.7.18 → 2.7.20

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.
@@ -27,5 +27,5 @@ export declare class ApiClientService {
27
27
  getPaymentSession(cartId: string): Promise<ApiResult<ICheckoutPaymentSession>>;
28
28
  confirmPaymentSession(params: ICheckoutPaymentConfirmParams): Promise<ApiResult<ICheckoutPaymentConfirm>>;
29
29
  addAnonymousProduct(params: IAnonymousCheckoutAddProductParams): Promise<ApiResult<IAnonymousCheckoutAddProductResponse>>;
30
- checkoutComplete(token: string): Promise<ApiResult<ICheckoutComplete>>;
30
+ checkoutComplete(token: string, payment?: string): Promise<ApiResult<ICheckoutComplete>>;
31
31
  }
@@ -4,11 +4,22 @@ import type { IProductAvailabilityResponse } from '@/interfaces/api/product.inte
4
4
  import type { BillingFieldName, CustomerFieldName, GiftFieldName } from '@/modules/checkout/constant';
5
5
  import { BaseActionService } from './base-action.service';
6
6
  import type { IAddProductParams } from './client-cart-action.service';
7
+ export interface ISavedPaymentMethodInput {
8
+ id: string;
9
+ card: {
10
+ brand: string;
11
+ last4: string;
12
+ expMonth?: string | number;
13
+ expYear?: string | number;
14
+ };
15
+ }
7
16
  export interface ICheckoutActions {
8
17
  openCheckout: () => void;
9
18
  closeCheckout: () => void;
10
19
  toggleCheckout: () => void;
11
20
  exitCheckout: () => void;
21
+ setSavedPaymentMethod: (params: ISavedPaymentMethodInput) => void;
22
+ clearSavedPaymentMethod: () => void;
12
23
  addProduct: (params: IAddProductParams[], openCheckout?: boolean) => Promise<void>;
13
24
  applyPromoCode: (promoCode: string) => Promise<void>;
14
25
  removePromoCode: () => Promise<void>;
@@ -39,6 +50,8 @@ export declare class ClientCheckoutActionService extends BaseActionService {
39
50
  private closeCheckout;
40
51
  private toggleCheckout;
41
52
  private exitCheckout;
53
+ private setSavedPaymentMethod;
54
+ private clearSavedPaymentMethod;
42
55
  private addProduct;
43
56
  private applyPromoCode;
44
57
  private removePromoCode;
@@ -19,7 +19,6 @@ export interface IClientConfigs {
19
19
  version?: string;
20
20
  clientPrepared: boolean;
21
21
  promoTicker: IPromoTicker[] | null;
22
- paymentMethodId?: string;
23
22
  openShadowDom?: boolean;
24
23
  hasCustomApiUrl?: boolean;
25
24
  mockMode: boolean;
@@ -35,7 +34,6 @@ export interface IClientConfigInput {
35
34
  promoTicker?: IPromoTicker[];
36
35
  development?: {
37
36
  customApiUrl?: string;
38
- paymentMethodId?: string;
39
37
  openShadowDom?: boolean;
40
38
  mockMode?: boolean;
41
39
  };
@@ -49,7 +47,6 @@ export declare class ClientConfigService {
49
47
  getConfigs(): IClientConfigs;
50
48
  get<K extends keyof IClientConfigs>(key: K): IClientConfigs[K];
51
49
  set<K extends keyof IClientConfigs>(key: K, value: IClientConfigs[K]): void;
52
- isDevelopment(): boolean;
53
50
  isStaging(): boolean;
54
51
  isProduction(): boolean;
55
52
  isBuilder(): boolean;
@@ -38,6 +38,7 @@ export interface ICheckoutStore {
38
38
  customerForm: ICheckoutCustomerFormStore;
39
39
  giftRecipientForm: ICheckoutGiftRecipientFormStore;
40
40
  paymentForm: ICheckoutPaymentFormStore;
41
+ injectedPaymentMethod: ICheckoutPaymentMethodStore | null;
41
42
  shippingAddress: ICheckoutShippingAddress;
42
43
  promoCode: ICheckoutPromoCode | null;
43
44
  giftCards: ICheckoutGiftCard[];
@@ -9,7 +9,6 @@ export interface IElementsProxyConfig {
9
9
  }
10
10
  export interface ILiquidCommerceElementsDevelopmentConfig {
11
11
  customApiUrl?: string;
12
- paymentMethodId?: string;
13
12
  openShadowDom?: boolean;
14
13
  mockMode?: boolean;
15
14
  }
@@ -19,7 +19,7 @@ export declare class CheckoutCommands extends BaseCommand {
19
19
  toggleBillingSameAsShipping(active?: boolean): Promise<void>;
20
20
  toggleMarketingPreferences(fieldName: 'canEmail' | 'canSms', active?: boolean): Promise<void>;
21
21
  getPaymentSession(): Promise<void>;
22
- confirmPaymentSession(confirmationTokenId: string, setupIntentId: string): Promise<ICheckoutPaymentMethodStore | null>;
22
+ confirmPaymentSession(confirmationTokenId: string, setupIntentId: string): Promise<ICheckoutPaymentMethodStore>;
23
23
  applyPromoCode(code: string): Promise<void>;
24
24
  removePromoCode(): Promise<void>;
25
25
  clearPromoCodeError(): Promise<void>;
@@ -50,6 +50,8 @@ export declare class CheckoutCommands extends BaseCommand {
50
50
  deliveryInstructions: string;
51
51
  }): Promise<void>;
52
52
  editPaymentForm(): Promise<void>;
53
+ private resetCheckoutPreservingInjected;
54
+ private markInjectedPaymentReady;
53
55
  savePaymentForm({ billingFormData, paymentSession, }: {
54
56
  billingFormData?: ICheckoutBilling;
55
57
  paymentSession?: {
@@ -5,7 +5,6 @@ export interface ICheckoutSendToFormComponentParams {
5
5
  }
6
6
  export declare class CheckoutPaymentComponent extends BaseComponent<ICheckoutSendToFormComponentParams, ICheckoutComponent> {
7
7
  private stripeHandlerElement;
8
- private hardcodedPaymentElement;
9
8
  private saveButton;
10
9
  private errorMessageElement;
11
10
  private billingFormData;
@@ -17,6 +16,7 @@ export declare class CheckoutPaymentComponent extends BaseComponent<ICheckoutSen
17
16
  private isSavingPayment;
18
17
  get hostClasses(): string[];
19
18
  constructor();
19
+ private getInjectedPaymentMethod;
20
20
  onStoreWatch(changes: IOnStoreChanged[]): void;
21
21
  private handleBillingSameAsShippingChange;
22
22
  afterRender(): Promise<void>;
@@ -287,6 +287,45 @@ window.LiquidCommerce.elements.actions.checkout.updateGiftInfo({
287
287
  });
288
288
  ```
289
289
 
290
+ ## Payment Method
291
+
292
+ ### actions.checkout.setSavedPaymentMethod()
293
+
294
+ ```typescript
295
+ setSavedPaymentMethod(params: {
296
+ id: string;
297
+ card: {
298
+ brand: string;
299
+ last4: string;
300
+ expMonth?: string | number;
301
+ expYear?: string | number;
302
+ };
303
+ }): void
304
+ ```
305
+
306
+ Pre-select a saved payment method for the checkout. When set, the payment step renders a read-only card summary (e.g. `Visa ending in 4242`) instead of the Stripe card form, and the shopper places the order without re-entering card details. The `id` is bound to the checkout when the payment form is saved.
307
+
308
+ `id` must be a payment method the backend already holds for the checkout's customer (for example, a card fetched server-side and handed to the page). If the backend does not recognize the `id` for this checkout's customer, saving the payment step fails with an error (`The selected payment method could not be applied to this checkout.`) and the order cannot be placed — pass only a payment method confirmed to belong to the customer. The `card` fields are used only to render the summary. It can be set at any time — before opening checkout, or while it is open — and the payment step updates accordingly. The selection persists across a cart reset within the session.
309
+
310
+ ```javascript
311
+ window.LiquidCommerce.elements.actions.checkout.setSavedPaymentMethod({
312
+ id: 'pm_123',
313
+ card: { brand: 'Visa', last4: '4242', expMonth: '12', expYear: '30' }
314
+ });
315
+ ```
316
+
317
+ ### actions.checkout.clearSavedPaymentMethod()
318
+
319
+ ```typescript
320
+ clearSavedPaymentMethod(): void
321
+ ```
322
+
323
+ Remove a previously set saved payment method, restoring the Stripe card-entry form.
324
+
325
+ ```javascript
326
+ window.LiquidCommerce.elements.actions.checkout.clearSavedPaymentMethod();
327
+ ```
328
+
290
329
  ## Data Retrieval
291
330
 
292
331
  ### actions.checkout.getDetails()
@@ -185,7 +185,6 @@ checkout: {
185
185
  ```typescript
186
186
  interface ILiquidCommerceElementsDevelopmentConfig {
187
187
  customApiUrl?: string;
188
- paymentMethodId?: string;
189
188
  openShadowDom?: boolean;
190
189
  }
191
190
  ```
@@ -195,7 +194,6 @@ interface ILiquidCommerceElementsDevelopmentConfig {
195
194
  ```javascript
196
195
  development: {
197
196
  customApiUrl: 'http://localhost:3000/api',
198
- paymentMethodId: 'pm_test_123', // For testing without Stripe form
199
197
  openShadowDom: true // Disable Shadow DOM for debugging
200
198
  }
201
199
  ```
@@ -508,7 +508,6 @@ See [Proxy Setup Guide](../integration/proxy-setup.md) for implementation detail
508
508
  ```typescript
509
509
  interface ILiquidCommerceElementsDevelopmentConfig {
510
510
  customApiUrl?: string;
511
- paymentMethodId?: string;
512
511
  openShadowDom?: boolean;
513
512
  }
514
513
  ```
@@ -516,9 +515,10 @@ interface ILiquidCommerceElementsDevelopmentConfig {
516
515
  | Property | Type | Description |
517
516
  |----------|------|-------------|
518
517
  | `customApiUrl` | `string` | Custom API URL for local or custom backend testing |
519
- | `paymentMethodId` | `string` | Hardcoded Stripe payment method ID for automated testing |
520
518
  | `openShadowDom` | `boolean` | Disable Shadow DOM isolation for debugging (default: `false`) |
521
519
 
520
+ > To pre-select a payment method and skip the card form (in any environment), use [`actions.checkout.setSavedPaymentMethod`](./actions/checkout-actions.md#actionscheckoutsetsavedpaymentmethod) instead.
521
+
522
522
  ---
523
523
 
524
524
  ## See Also
@@ -134,7 +134,6 @@ interface IElementsProxyConfig {
134
134
  ```typescript
135
135
  interface ILiquidCommerceElementsDevelopmentConfig {
136
136
  customApiUrl?: string;
137
- paymentMethodId?: string;
138
137
  openShadowDom?: boolean;
139
138
  }
140
139
  ```
@@ -285,12 +285,24 @@ const client = await Elements('YOUR_API_KEY', {
285
285
  env: 'development',
286
286
  debugMode: 'console', // or 'panel'
287
287
  development: {
288
- openShadowDom: true, // Makes debugging easier
289
- paymentMethodId: 'pm_test_123' // Bypass Stripe for tests
288
+ openShadowDom: true // Makes debugging easier
290
289
  }
291
290
  });
292
291
  ```
293
292
 
293
+ ### Skip card entry in checkout tests
294
+
295
+ Pre-select a saved payment method so the checkout payment step shows a read-only summary and never mounts the Stripe card form. Pass a payment method id the backend already has for the checkout's customer:
296
+
297
+ ```javascript
298
+ window.LiquidCommerce.elements.actions.checkout.setSavedPaymentMethod({
299
+ id: 'pm_123',
300
+ card: { brand: 'Visa', last4: '4242', expMonth: '12', expYear: '30' }
301
+ });
302
+ ```
303
+
304
+ `setSavedPaymentMethod` is a production action (also exposed on the checkout-only client), not test-only — beyond tests, use it to pre-fill a returning shopper's saved card. See [Checkout Actions](../api/actions/checkout-actions.md#actionscheckoutsetsavedpaymentmethod).
305
+
294
306
  ### Handle Test Scenarios
295
307
 
296
308
  ```javascript
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "LiquidCommerce Elements SDK",
4
4
  "license": "UNLICENSED",
5
5
  "author": "LiquidCommerce Team",
6
- "version": "2.7.18",
6
+ "version": "2.7.20",
7
7
  "homepage": "https://docs.liquidcommerce.co/elements-sdk",
8
8
  "repository": {
9
9
  "type": "git",
@@ -77,11 +77,11 @@
77
77
  "embeddable commerce"
78
78
  ],
79
79
  "devDependencies": {
80
- "@biomejs/biome": "^2.4.15",
81
- "@commitlint/cli": "^21.0.1",
82
- "@commitlint/config-conventional": "^21.0.1",
80
+ "@biomejs/biome": "^2.4.16",
81
+ "@commitlint/cli": "^21.0.2",
82
+ "@commitlint/config-conventional": "^21.0.2",
83
83
  "@rollup/plugin-alias": "^6.0.0",
84
- "@rollup/plugin-commonjs": "^29.0.2",
84
+ "@rollup/plugin-commonjs": "^29.0.3",
85
85
  "@rollup/plugin-json": "^6.1.0",
86
86
  "@rollup/plugin-node-resolve": "^16.0.3",
87
87
  "@rollup/plugin-replace": "^6.0.3",
@@ -93,11 +93,11 @@
93
93
  "@semantic-release/npm": "^13.1.5",
94
94
  "@semantic-release/release-notes-generator": "^14.1.1",
95
95
  "@types/core-js": "^2.5.8",
96
- "@types/node": "^25.7.0",
96
+ "@types/node": "^25.9.1",
97
97
  "conventional-changelog": "^7.2.0",
98
98
  "husky": "^9.1.7",
99
99
  "process": "^0.11.10",
100
- "rollup": "^4.60.3",
100
+ "rollup": "^4.61.0",
101
101
  "rollup-obfuscator": "^4.1.1",
102
102
  "rollup-plugin-typescript2": "^0.37.0",
103
103
  "semantic-release": "^25.0.3",