@liquidcommerce/cloud-sdk 1.1.1 → 1.3.0
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 +42 -3
- package/dist/index.cjs +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/liquidcommerce-cloud-sdk.ssr.js +1 -1
- package/dist/types/core/payment-provider.service.d.ts +40 -7
- package/dist/types/enums.d.ts +3 -0
- package/dist/types/interfaces/liquid-commerce-client.interface.d.ts +166 -1
- package/dist/types/interfaces/payment.interface.d.ts +7 -7
- package/dist/types/interfaces/user.interface.d.ts +30 -1
- package/dist/types/liquid-commerce-client.d.ts +26 -7
- package/dist/types/services/payment.service.d.ts +23 -0
- package/dist/types/services/user.service.d.ts +31 -1
- package/package.json +1 -1
- package/umd/liquidcommerce-cloud-sdk.min.js +1 -1
|
@@ -9,6 +9,7 @@ export declare class PaymentProviderService implements IPaymentProvider {
|
|
|
9
9
|
private paymentElement;
|
|
10
10
|
private readonly events;
|
|
11
11
|
private readonly eventsErrorMsg;
|
|
12
|
+
private clientSecret;
|
|
12
13
|
/**
|
|
13
14
|
* Mounts the Stripe payment element to the specified container element on the page.
|
|
14
15
|
*
|
|
@@ -23,16 +24,27 @@ export declare class PaymentProviderService implements IPaymentProvider {
|
|
|
23
24
|
/**
|
|
24
25
|
* Generate a payment token for a liquid payment.
|
|
25
26
|
*
|
|
26
|
-
* This method generates a payment token using the Stripe API. The payment token represents the payment
|
|
27
|
-
* The method first checks if the Stripe instance and the Stripe Elements
|
|
27
|
+
* This method generates a payment token using the Stripe API. The payment token represents the payment
|
|
28
|
+
* information provided by the user. The method first checks if the Stripe instance and the Stripe Elements
|
|
29
|
+
* instance have been initialized. If not, it returns an error indicating that the payment form has not been
|
|
30
|
+
* initialized.
|
|
28
31
|
*
|
|
29
|
-
* Next, the method submits the payment form using the `submit()` method of the Stripe Elements instance.
|
|
32
|
+
* Next, the method submits the payment form using the `submit()` method of the Stripe Elements instance.
|
|
33
|
+
* If there is an error during the submission, it returns a validation error indicating the error message
|
|
34
|
+
* and code.
|
|
30
35
|
*
|
|
31
|
-
* After successful submission, the method creates a payment method using the `createPaymentMethod()`
|
|
36
|
+
* After successful submission, the method creates a payment method using the `createPaymentMethod()`
|
|
37
|
+
* method of the Stripe instance, passing the Stripe Elements instance as a parameter. If there is
|
|
38
|
+
* an error during the creation of the payment method, it returns the appropriate error containing
|
|
39
|
+
* the error message, code, and parameter (if applicable).
|
|
32
40
|
*
|
|
33
|
-
* If the payment method is successfully created, the method returns the payment information in the form
|
|
41
|
+
* If the payment method is successfully created, the method returns the payment information in the form
|
|
42
|
+
* of an object containing the payment method's ID, type, and card details (if available), as well as the
|
|
43
|
+
* creation timestamp. The card details include the card brand, country, expiration month, expiration year,
|
|
44
|
+
* last 4 digits, and funding source.
|
|
34
45
|
*
|
|
35
|
-
* If none of the above conditions are met, it returns an error indicating that the payment token generation
|
|
46
|
+
* If none of the above conditions are met, it returns an error indicating that the payment token generation
|
|
47
|
+
* has failed.
|
|
36
48
|
*
|
|
37
49
|
* @returns A Promise that resolves to either a LiquidPaymentToken object or a LiquidPaymentError object.
|
|
38
50
|
*
|
|
@@ -49,7 +61,7 @@ export declare class PaymentProviderService implements IPaymentProvider {
|
|
|
49
61
|
* - created (number): The timestamp indicating when the payment method was created.
|
|
50
62
|
*
|
|
51
63
|
* The LiquidPaymentError object has the following properties:
|
|
52
|
-
* - type (string): The type of the error (either 'client_error', 'validation_error', or '
|
|
64
|
+
* - type (string): The type of the error (either 'client_error', 'validation_error', api_error, or 'confirm_error').
|
|
53
65
|
* - message (string): The error message.
|
|
54
66
|
* - code (string): The error code (if applicable).
|
|
55
67
|
* - param (string): The error parameter (if applicable).
|
|
@@ -88,4 +100,25 @@ export declare class PaymentProviderService implements IPaymentProvider {
|
|
|
88
100
|
* @return {StripePaymentElementOptions} - The mapped Stripe payment element options.
|
|
89
101
|
*/
|
|
90
102
|
private mapElementOptions;
|
|
103
|
+
/**
|
|
104
|
+
* Unmounts the payment element from the DOM.
|
|
105
|
+
* Throws an error if the payment element has not been initialized.
|
|
106
|
+
*
|
|
107
|
+
* @return {void}
|
|
108
|
+
*/
|
|
109
|
+
unmount(): void;
|
|
110
|
+
/**
|
|
111
|
+
* Collapses the payment element if it has been initialized.
|
|
112
|
+
* Throws an error if the payment element has not been initialized.
|
|
113
|
+
*
|
|
114
|
+
* @return {void}
|
|
115
|
+
*/
|
|
116
|
+
collapse(): void;
|
|
117
|
+
/**
|
|
118
|
+
* Destroys the payment element if it has been initialized.
|
|
119
|
+
*
|
|
120
|
+
* @return {void} No return value.
|
|
121
|
+
* @throws {Error} Will throw an error if the payment element has not been initialized.
|
|
122
|
+
*/
|
|
123
|
+
destroy(): void;
|
|
91
124
|
}
|
package/dist/types/enums.d.ts
CHANGED
|
@@ -250,8 +250,11 @@ export declare enum CART_PARAM_ERROR_ENUM {
|
|
|
250
250
|
export declare enum CART_EVENT_ENUM {
|
|
251
251
|
OOS = "OutOfStock",
|
|
252
252
|
ITEMS_NOT_ADDED = "ItemsNotAdded",
|
|
253
|
+
ITEMS_REQUESTED_NOT_ADDED = "ItemsRequestedNotAdded",
|
|
253
254
|
ITEM_NOT_ENGRAVED = "ItemEngravingError",
|
|
254
255
|
ADDRESS_CHANGE = "AddressChange",
|
|
256
|
+
LOCATION_AVAILABILITY = "LocationAvailability",
|
|
257
|
+
REMOVED_EXISTING_ITEMS = "RemovedExistingCartItems",
|
|
255
258
|
RETAILER_MIN = "RetailerMinNotMet",
|
|
256
259
|
NO_ITEMS_IN_CART = "NoItemsInCart",
|
|
257
260
|
INVALID_ID = "InvalidId",
|
|
@@ -5,7 +5,7 @@ import type { ICart, ICartUpdateParams } from './cart.interface';
|
|
|
5
5
|
import type { ICatalog, ICatalogParams } from './catalog.service.interface';
|
|
6
6
|
import type { ICheckoutCompleteParams, ICheckoutCompleteResponse, ICheckoutPrepareParams, ICheckoutPrepareResponse } from './checkout.interface';
|
|
7
7
|
import type { ILiquidPaymentConfig, ILiquidPaymentToken, IPaymentElementEventMap } from './payment.interface';
|
|
8
|
-
import type { IPurgeResponse, IUser, IUserAddress, IUserAddressParams, IUserSessionParams } from './user.interface';
|
|
8
|
+
import type { IPurgeResponse, IUser, IUserAddress, IUserAddressParams, IUserPayment, IUserPaymentAddParams, IUserPaymentUpdateParams, IUserSessionParams } from './user.interface';
|
|
9
9
|
/**
|
|
10
10
|
* Interface representing the LiquidCommerce client.
|
|
11
11
|
* Provides access to methods related to addresses, catalogs, carts, and initialization.
|
|
@@ -344,6 +344,37 @@ export interface IUserMethod {
|
|
|
344
344
|
* @see {@link IPurgeResponse} for the structure of the user data returned.
|
|
345
345
|
*/
|
|
346
346
|
purge: (identifier: string) => Promise<IApiResponseWithData<IPurgeResponse>>;
|
|
347
|
+
/**
|
|
348
|
+
* Adds a new address for a user.
|
|
349
|
+
*
|
|
350
|
+
* @param {IUserAddressParams} params - The parameters for adding a new address.
|
|
351
|
+
* @returns {Promise<IApiResponseWithData<IUserAddress>>} A promise that resolves to the API response with the added address data.
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* const liquidCommerce = await LiquidCommerce(apiKey, config);
|
|
355
|
+
*
|
|
356
|
+
* try {
|
|
357
|
+
* const newAddress = await liquidCommerce.user.addAddress({
|
|
358
|
+
* customerId: 'c1fbd454-a540-4f42-86e9-f87a98bf1812',
|
|
359
|
+
* one: '100 Madison St',
|
|
360
|
+
* city: 'New York',
|
|
361
|
+
* state: 'NY',
|
|
362
|
+
* zip: '10004',
|
|
363
|
+
* type: 'shipping',
|
|
364
|
+
* isDefault: true
|
|
365
|
+
* });
|
|
366
|
+
*
|
|
367
|
+
* console.log('Added address:', newAddress?.data);
|
|
368
|
+
* } catch (error) {
|
|
369
|
+
* console.error('Failed to add address:', error);
|
|
370
|
+
* }
|
|
371
|
+
*
|
|
372
|
+
* @throws {Error} - Throws an error if the add address request fails or if authentication is unsuccessful.
|
|
373
|
+
*
|
|
374
|
+
* @see {@link IUserAddressParams} for the structure of the add address request parameters.
|
|
375
|
+
* @see {@link IUserAddress} for the structure of the user's address data returned.
|
|
376
|
+
*/
|
|
377
|
+
addAddress: (params: IUserAddressParams) => Promise<IApiResponseWithData<IUserAddress>>;
|
|
347
378
|
/**
|
|
348
379
|
* Updates or creates a new address for a user.
|
|
349
380
|
*
|
|
@@ -398,6 +429,86 @@ export interface IUserMethod {
|
|
|
398
429
|
* @see {@link IPurgeResponse} for the structure of the user's purged data state.
|
|
399
430
|
*/
|
|
400
431
|
purgeAddress: (addressId: string) => Promise<IApiResponseWithData<IPurgeResponse>>;
|
|
432
|
+
/**
|
|
433
|
+
* Adds a new payment method for a user.
|
|
434
|
+
*
|
|
435
|
+
* @param {IUserPaymentAddParams} params - The parameters for adding a new payment method.
|
|
436
|
+
* @returns {Promise<IApiResponseWithData<IUserPayment>>} A promise that resolves to the API response with the added payment method data.
|
|
437
|
+
*
|
|
438
|
+
* @example
|
|
439
|
+
* const liquidCommerce = await LiquidCommerce(apiKey, config);
|
|
440
|
+
*
|
|
441
|
+
* try {
|
|
442
|
+
* const newPayment = await liquidCommerce.user.addPayment({
|
|
443
|
+
* customerId: 'c1fbd454-a540-4f42-86e9-f87a98bf1812',
|
|
444
|
+
* paymentMethodId: 'pm_1234567890abcdef',
|
|
445
|
+
* isDefault: true
|
|
446
|
+
* });
|
|
447
|
+
*
|
|
448
|
+
* console.log('Added payment method:', newPayment?.data);
|
|
449
|
+
* } catch (error) {
|
|
450
|
+
* console.error('Failed to add payment method:', error);
|
|
451
|
+
* }
|
|
452
|
+
*
|
|
453
|
+
* @throws {Error} - Throws an error if the add payment request fails or if authentication is unsuccessful.
|
|
454
|
+
*
|
|
455
|
+
* @see {@link IUserPaymentParams} for the structure of the add payment request parameters.
|
|
456
|
+
* @see {@link IUserPayment} for the structure of the user's payment method data returned.
|
|
457
|
+
*/
|
|
458
|
+
addPayment: (params: IUserPaymentAddParams) => Promise<IApiResponseWithData<IUserPayment>>;
|
|
459
|
+
/**
|
|
460
|
+
* Updates a payment method for a user.
|
|
461
|
+
*
|
|
462
|
+
* @param {IUserPaymentUpdateParams} params - The parameters for updating a payment method.
|
|
463
|
+
* @returns {Promise<IApiResponseWithData<IUserPayment>>} A promise that resolves to the API response with the updated payment method data.
|
|
464
|
+
*
|
|
465
|
+
* @example
|
|
466
|
+
* const liquidCommerce = await LiquidCommerce(apiKey, config);
|
|
467
|
+
*
|
|
468
|
+
* try {
|
|
469
|
+
* const updatedPayment = await liquidCommerce.user.updatePayment({
|
|
470
|
+
* customerId: 'c1fbd454-a540-4f42-86e9-f87a98bf1812',
|
|
471
|
+
* paymentMethodId: 'pm_1234567890abcdef',
|
|
472
|
+
* isDefault: true
|
|
473
|
+
* });
|
|
474
|
+
*
|
|
475
|
+
* console.log('Updated payment method:', updatedPayment?.data);
|
|
476
|
+
* } catch (error) {
|
|
477
|
+
* console.error('Failed to update payment method:', error);
|
|
478
|
+
* }
|
|
479
|
+
*
|
|
480
|
+
* @throws {Error} - Throws an error if the update payment request fails or if authentication is unsuccessful.
|
|
481
|
+
*
|
|
482
|
+
* @see {@link IUserPaymentUpdateParams} for the structure of the update payment request parameters.
|
|
483
|
+
* @see {@link IUserPayment} for the structure of the user's payment method data returned.
|
|
484
|
+
*/
|
|
485
|
+
updatePayment: (params: IUserPaymentUpdateParams) => Promise<IApiResponseWithData<IUserPayment>>;
|
|
486
|
+
/**
|
|
487
|
+
* Purges a payment method for a user.
|
|
488
|
+
*
|
|
489
|
+
* @param {string} customerId - The ID of the customer.
|
|
490
|
+
* @param {string} paymentId - The ID of the payment method to purge.
|
|
491
|
+
* @returns {Promise<IApiResponseWithData<IPurgeResponse>>} A promise that resolves to the purge response.
|
|
492
|
+
*
|
|
493
|
+
* @example
|
|
494
|
+
* const liquidCommerce = await LiquidCommerce(apiKey, config);
|
|
495
|
+
*
|
|
496
|
+
* try {
|
|
497
|
+
* const paymentPurgeResponse = await liquidCommerce.user.purgePayment(
|
|
498
|
+
* 'c1fbd454-a540-4f42-86e9-f87a98bf1812',
|
|
499
|
+
* 'pm_1234567890abcdef'
|
|
500
|
+
* );
|
|
501
|
+
*
|
|
502
|
+
* console.log('Payment method purge response:', paymentPurgeResponse?.data);
|
|
503
|
+
* } catch (error) {
|
|
504
|
+
* console.error('Failed to purge payment method:', error);
|
|
505
|
+
* }
|
|
506
|
+
*
|
|
507
|
+
* @throws {Error} - Throws an error if the purge payment request fails or if authentication is unsuccessful.
|
|
508
|
+
*
|
|
509
|
+
* @see {@link IPurgeResponse} for the structure of the purge response data.
|
|
510
|
+
*/
|
|
511
|
+
purgePayment: (customerId: string, paymentId: string) => Promise<IApiResponseWithData<IPurgeResponse>>;
|
|
401
512
|
}
|
|
402
513
|
export interface IPaymentMethod {
|
|
403
514
|
/**
|
|
@@ -501,6 +612,60 @@ export interface IPaymentMethod {
|
|
|
501
612
|
* @throws {Error} - Throws an error if the payment element has not been initialized.
|
|
502
613
|
*/
|
|
503
614
|
unsubscribe<K extends keyof IPaymentElementEventMap>(eventType: K, handler?: (event: IPaymentElementEventMap[K]) => void): void;
|
|
615
|
+
/**
|
|
616
|
+
* Collapses the payment element if it has been initialized.
|
|
617
|
+
*
|
|
618
|
+
* @returns {void}
|
|
619
|
+
*
|
|
620
|
+
* @example
|
|
621
|
+
* const liquidCommerce = await LiquidCommerce(apiKey, config);
|
|
622
|
+
*
|
|
623
|
+
* try {
|
|
624
|
+
* liquidCommerce.payment.collapse();
|
|
625
|
+
* console.log('Payment element collapsed');
|
|
626
|
+
* } catch (error) {
|
|
627
|
+
* console.error('Failed to collapse payment element:', error);
|
|
628
|
+
* }
|
|
629
|
+
*
|
|
630
|
+
* @throws {Error} - Throws an error if the payment element has not been initialized.
|
|
631
|
+
*/
|
|
632
|
+
collapse(): void;
|
|
633
|
+
/**
|
|
634
|
+
* Unmounts the payment element from the DOM.
|
|
635
|
+
*
|
|
636
|
+
* @returns {void}
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* const liquidCommerce = await LiquidCommerce(apiKey, config);
|
|
640
|
+
*
|
|
641
|
+
* try {
|
|
642
|
+
* liquidCommerce.payment.unmount();
|
|
643
|
+
* console.log('Payment element unmounted');
|
|
644
|
+
* } catch (error) {
|
|
645
|
+
* console.error('Failed to unmount payment element:', error);
|
|
646
|
+
* }
|
|
647
|
+
*
|
|
648
|
+
* @throws {Error} - Throws an error if the payment element has not been initialized.
|
|
649
|
+
*/
|
|
650
|
+
unmount(): void;
|
|
651
|
+
/**
|
|
652
|
+
* Destroys the payment element if it has been initialized.
|
|
653
|
+
*
|
|
654
|
+
* @returns {void}
|
|
655
|
+
*
|
|
656
|
+
* @example
|
|
657
|
+
* const liquidCommerce = await LiquidCommerce(apiKey, config);
|
|
658
|
+
*
|
|
659
|
+
* try {
|
|
660
|
+
* liquidCommerce.payment.destroy();
|
|
661
|
+
* console.log('Payment element destroyed');
|
|
662
|
+
* } catch (error) {
|
|
663
|
+
* console.error('Failed to destroy payment element:', error);
|
|
664
|
+
* }
|
|
665
|
+
*
|
|
666
|
+
* @throws {Error} - Throws an error if the payment element has not been initialized.
|
|
667
|
+
*/
|
|
668
|
+
destroy(): void;
|
|
504
669
|
}
|
|
505
670
|
export interface ICheckoutMethod {
|
|
506
671
|
/**
|
|
@@ -16,12 +16,12 @@ export interface ILiquidPaymentToken {
|
|
|
16
16
|
id?: string;
|
|
17
17
|
type?: string;
|
|
18
18
|
card?: {
|
|
19
|
-
brand: string;
|
|
20
|
-
country: string;
|
|
21
|
-
expMonth: number;
|
|
22
|
-
expYear: number;
|
|
23
|
-
last4: string;
|
|
24
|
-
funding: string;
|
|
19
|
+
brand: string | null;
|
|
20
|
+
country: string | null;
|
|
21
|
+
expMonth: number | null;
|
|
22
|
+
expYear: number | null;
|
|
23
|
+
last4: string | null;
|
|
24
|
+
funding: string | null;
|
|
25
25
|
};
|
|
26
26
|
created?: number;
|
|
27
27
|
error?: {
|
|
@@ -30,7 +30,7 @@ export interface ILiquidPaymentToken {
|
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
32
|
export interface ILiquidPaymentError {
|
|
33
|
-
type: 'validation_error' | 'api_error' | 'client_error';
|
|
33
|
+
type: 'validation_error' | 'api_error' | 'client_error' | 'confirm_error';
|
|
34
34
|
message: string;
|
|
35
35
|
code?: string;
|
|
36
36
|
param?: string;
|
|
@@ -17,16 +17,33 @@ export interface IUserAddress {
|
|
|
17
17
|
updatedAt: Date;
|
|
18
18
|
isDefault?: boolean;
|
|
19
19
|
}
|
|
20
|
+
export interface ISavedCard {
|
|
21
|
+
brand: string | null;
|
|
22
|
+
country: string | null;
|
|
23
|
+
expMonth: number | null;
|
|
24
|
+
expYear: number | null;
|
|
25
|
+
last4: string | null;
|
|
26
|
+
funding: string | null;
|
|
27
|
+
}
|
|
28
|
+
export interface IUserPayment {
|
|
29
|
+
id: string;
|
|
30
|
+
type: string;
|
|
31
|
+
isDefault: boolean;
|
|
32
|
+
card?: ISavedCard;
|
|
33
|
+
}
|
|
20
34
|
export interface IUser {
|
|
21
35
|
id: string;
|
|
22
36
|
email: string;
|
|
23
37
|
firstName: string | null;
|
|
24
38
|
lastName: string | null;
|
|
25
39
|
phone: string | null;
|
|
40
|
+
company: string | null;
|
|
41
|
+
profileImage: string | null;
|
|
26
42
|
birthDate: string | null;
|
|
27
43
|
createdAt: Date;
|
|
28
44
|
updatedAt: Date;
|
|
29
45
|
addresses: IUserAddress[];
|
|
46
|
+
savedPayments: IUserPayment[];
|
|
30
47
|
session: IUserSession;
|
|
31
48
|
}
|
|
32
49
|
export interface IUserSessionParams extends ICoreParams {
|
|
@@ -35,6 +52,8 @@ export interface IUserSessionParams extends ICoreParams {
|
|
|
35
52
|
firstName?: string | null;
|
|
36
53
|
lastName?: string | null;
|
|
37
54
|
phone?: string | null;
|
|
55
|
+
company?: string | null;
|
|
56
|
+
profileImage?: string | null;
|
|
38
57
|
birthDate?: string | null;
|
|
39
58
|
}
|
|
40
59
|
export interface IPurgeResponse {
|
|
@@ -48,6 +67,16 @@ export interface IUserAddressParams extends ICoreParams {
|
|
|
48
67
|
city: string;
|
|
49
68
|
state: string;
|
|
50
69
|
zip: string;
|
|
51
|
-
isDefault?: boolean;
|
|
52
70
|
type: ENUM_ADDRESS_TYPE;
|
|
71
|
+
isDefault?: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface IUserPaymentParams extends ICoreParams {
|
|
74
|
+
customerId: string;
|
|
75
|
+
paymentMethodId: string;
|
|
76
|
+
}
|
|
77
|
+
export interface IUserPaymentAddParams extends IUserPaymentParams {
|
|
78
|
+
isDefault?: boolean;
|
|
79
|
+
}
|
|
80
|
+
export interface IUserPaymentUpdateParams extends IUserPaymentParams {
|
|
81
|
+
isDefault: boolean;
|
|
53
82
|
}
|
|
@@ -4,7 +4,7 @@ import type { ICatalog, ICatalogParams } from './interfaces/catalog.service.inte
|
|
|
4
4
|
import type { ICheckoutCompleteParams, ICheckoutCompleteResponse, ICheckoutPrepareParams, ICheckoutPrepareResponse } from './interfaces/checkout.interface';
|
|
5
5
|
import type { IAddressMethod, ICartMethod, ICatalogMethod, ICheckoutMethod, ILiquidCommerceClient, IPaymentMethod, IUserMethod } from './interfaces/liquid-commerce-client.interface';
|
|
6
6
|
import type { ILiquidPaymentConfig, ILiquidPaymentToken, IPaymentElementEventMap } from './interfaces/payment.interface';
|
|
7
|
-
import type { IPurgeResponse, IUser, IUserAddress, IUserAddressParams, IUserSessionParams } from './interfaces/user.interface';
|
|
7
|
+
import type { IPurgeResponse, IUser, IUserAddress, IUserAddressParams, IUserPayment, IUserPaymentAddParams, IUserPaymentUpdateParams, IUserSessionParams } from './interfaces/user.interface';
|
|
8
8
|
import type { IAddressAutocompleteParams, IAddressAutocompleteResult, IAddressDetailsParams, IAddressDetailsResult } from './services/address.service';
|
|
9
9
|
import type { IAvailabilityParams, IAvailabilityResponse } from './services/catalog.service';
|
|
10
10
|
import type { IApiResponseWithData, IApiResponseWithoutData, ILiquidCommerceConfig } from './types';
|
|
@@ -113,18 +113,28 @@ declare class LiquidCommerceClient implements ILiquidCommerceClient {
|
|
|
113
113
|
* Method for creating or updating a user session.
|
|
114
114
|
* @property {function(identifier: string): Promise<IApiResponseWithData<IPurgeResponse>>} purge -
|
|
115
115
|
* Method for purging a user's data from the system.
|
|
116
|
+
* @property {function(params: IUserAddressParams): Promise<IApiResponseWithData<IUserAddress>>} addAddress -
|
|
117
|
+
* Method for adding a new address for a user.
|
|
116
118
|
* @property {function(params: IUserAddressParams): Promise<IApiResponseWithData<IUserAddress>>} updateAddress -
|
|
117
|
-
* Method for updating
|
|
119
|
+
* Method for updating an existing user's address.
|
|
118
120
|
* @property {function(addressId: string): Promise<IApiResponseWithData<IPurgeResponse>>} purgeAddress -
|
|
119
121
|
* Method for purging a user's address.
|
|
122
|
+
* @property {function(params: IUserPaymentAddParams): Promise<IApiResponseWithData<IUserPayment>>} addPayment -
|
|
123
|
+
* Method for adding a new payment method for a user.
|
|
124
|
+
* @property {function(params: IUserPaymentUpdateParams): Promise<IApiResponseWithData<IUserPayment>>} updatePayment -
|
|
125
|
+
* Method for updating an existing payment method for a user.
|
|
126
|
+
* @property {function(customerId: string, paymentId: string): Promise<IApiResponseWithData<IPurgeResponse>>} purgePayment -
|
|
127
|
+
* Method for purging a user's payment method.
|
|
120
128
|
*
|
|
121
129
|
* @see {@link IUserSessionParams} for the structure of the session request parameters.
|
|
122
|
-
* @see {@link IUserAddressParams} for the structure of the address update request parameters.
|
|
130
|
+
* @see {@link IUserAddressParams} for the structure of the address add/update request parameters.
|
|
131
|
+
* @see {@link IUserPaymentAddParams} for the structure of the payment add request parameters.
|
|
132
|
+
* @see {@link IUserPaymentUpdateParams} for the structure of the payment update request parameters.
|
|
123
133
|
* @see {@link IUser} for the structure of the user data returned.
|
|
124
134
|
* @see {@link IUserAddress} for the structure of the user's address data returned.
|
|
125
|
-
* @see {@link
|
|
126
|
-
*
|
|
127
|
-
|
|
135
|
+
* @see {@link IUserPayment} for the structure of the user's payment method data returned.
|
|
136
|
+
* @see {@link IPurgeResponse} for the structure of the purge response data.
|
|
137
|
+
*/
|
|
128
138
|
user: IUserMethod;
|
|
129
139
|
/**
|
|
130
140
|
* Payment object that provides methods for payment-related operations.
|
|
@@ -143,6 +153,15 @@ declare class LiquidCommerceClient implements ILiquidCommerceClient {
|
|
|
143
153
|
* @property {function(eventType: K, handler?: function): void} unsubscribe -
|
|
144
154
|
* Method for unsubscribing from payment element events.
|
|
145
155
|
*
|
|
156
|
+
* @property {function(): void} collapse -
|
|
157
|
+
* Method for collapsing the payment element if it's expanded.
|
|
158
|
+
*
|
|
159
|
+
* @property {function(): void} unmount -
|
|
160
|
+
* Method for removing the payment element from the DOM.
|
|
161
|
+
*
|
|
162
|
+
* @property {function(): void} destroy -
|
|
163
|
+
* Method for completely removing the payment element and cleaning up associated resources.
|
|
164
|
+
*
|
|
146
165
|
* @see {@link ILiquidPaymentConfig} Represents the configuration for Liquid payment.
|
|
147
166
|
* @see {@link ILiquidPaymentToken} Represents a payment token for liquid payments.
|
|
148
167
|
* @see {@link ILiquidPaymentError} Represents an error that occurs during a liquid payment.
|
|
@@ -186,4 +205,4 @@ declare class LiquidCommerceClient implements ILiquidCommerceClient {
|
|
|
186
205
|
*/
|
|
187
206
|
export declare function LiquidCommerce(apiKey: string, config: ILiquidCommerceConfig): Promise<LiquidCommerceClient>;
|
|
188
207
|
export { LIQUID_COMMERCE_ENV };
|
|
189
|
-
export type { IAddressAutocompleteParams, IAddressAutocompleteResult, IAddressDetailsParams, IAddressDetailsResult, IAddressMethod, IApiResponseWithData, IApiResponseWithoutData, IAvailabilityParams, IAvailabilityResponse, ICart, ICartMethod, ICartUpdateParams, ICatalog, ICatalogMethod, ICatalogParams, ICheckoutCompleteParams, ICheckoutCompleteResponse, ICheckoutMethod, ICheckoutPrepareParams, ICheckoutPrepareResponse, ILiquidCommerceClient, ILiquidCommerceConfig, ILiquidPaymentConfig, ILiquidPaymentToken, IPaymentElementEventMap, IPaymentMethod, IPurgeResponse, IUser, IUserAddress, IUserAddressParams, IUserMethod, IUserSessionParams, };
|
|
208
|
+
export type { IAddressAutocompleteParams, IAddressAutocompleteResult, IAddressDetailsParams, IAddressDetailsResult, IAddressMethod, IApiResponseWithData, IApiResponseWithoutData, IAvailabilityParams, IAvailabilityResponse, ICart, ICartMethod, ICartUpdateParams, ICatalog, ICatalogMethod, ICatalogParams, ICheckoutCompleteParams, ICheckoutCompleteResponse, ICheckoutMethod, ICheckoutPrepareParams, ICheckoutPrepareResponse, ILiquidCommerceClient, ILiquidCommerceConfig, ILiquidPaymentConfig, ILiquidPaymentToken, IPaymentElementEventMap, IPaymentMethod, IPurgeResponse, IUser, IUserAddress, IUserAddressParams, IUserMethod, IUserPayment, IUserPaymentAddParams, IUserPaymentUpdateParams, IUserSessionParams, };
|
|
@@ -36,4 +36,27 @@ export declare class PaymentService {
|
|
|
36
36
|
* @return void
|
|
37
37
|
*/
|
|
38
38
|
unsubscribe<K extends keyof IPaymentElementEventMap>(eventType: K, handler?: (event: IPaymentElementEventMap[K]) => void): void;
|
|
39
|
+
/**
|
|
40
|
+
* Collapses the payment element if it has been initialized.
|
|
41
|
+
* Throws an error if the payment element has not been initialized.
|
|
42
|
+
*
|
|
43
|
+
* @return {void}
|
|
44
|
+
* @throws {Error} Will throw an error if the payment element has not been initialized.
|
|
45
|
+
*/
|
|
46
|
+
collapse: () => void;
|
|
47
|
+
/**
|
|
48
|
+
* Unmounts the payment element from the DOM.
|
|
49
|
+
* Throws an error if the payment element has not been initialized.
|
|
50
|
+
*
|
|
51
|
+
* @return {void}
|
|
52
|
+
* @throws {Error} Will throw an error if the payment element has not been initialized.
|
|
53
|
+
*/
|
|
54
|
+
unmount: () => void;
|
|
55
|
+
/**
|
|
56
|
+
* Destroys the payment element if it has been initialized.
|
|
57
|
+
*
|
|
58
|
+
* @return {void} No return value.
|
|
59
|
+
* @throws {Error} Will throw an error if the payment element has not been initialized.
|
|
60
|
+
*/
|
|
61
|
+
destroy: () => void;
|
|
39
62
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AuthenticatedService } from '../core';
|
|
2
|
-
import type { IPurgeResponse, IUser, IUserAddress, IUserAddressParams, IUserSessionParams } from '../interfaces/user.interface';
|
|
2
|
+
import type { IPurgeResponse, IUser, IUserAddress, IUserAddressParams, IUserPayment, IUserPaymentAddParams, IUserPaymentUpdateParams, IUserSessionParams } from '../interfaces/user.interface';
|
|
3
3
|
import type { IApiResponseWithData } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* A class representing a user service.
|
|
@@ -24,6 +24,7 @@ export declare class UserService {
|
|
|
24
24
|
* @throws {Error} If the purge request fails or if the identifier is not provided.
|
|
25
25
|
*/
|
|
26
26
|
purge(identifier: string): Promise<IApiResponseWithData<IPurgeResponse>>;
|
|
27
|
+
addAddress(params: IUserAddressParams): Promise<IApiResponseWithData<IUserAddress>>;
|
|
27
28
|
/**
|
|
28
29
|
* Updates or creates a new address for a user.
|
|
29
30
|
*
|
|
@@ -40,4 +41,33 @@ export declare class UserService {
|
|
|
40
41
|
* @throws {Error} If the address purge request fails or if the address ID is not provided.
|
|
41
42
|
*/
|
|
42
43
|
purgeAddress(addressId: string): Promise<IApiResponseWithData<IPurgeResponse>>;
|
|
44
|
+
/**
|
|
45
|
+
* Adds a new payment method for a user.
|
|
46
|
+
*
|
|
47
|
+
* @param {IUserPaymentParams} params - The parameters required to add a payment method.
|
|
48
|
+
* @param {string} params.customerId - The ID of the customer.
|
|
49
|
+
* @param {string} params.paymentMethodId - The ID of the payment method.
|
|
50
|
+
* @param {boolean} params.isDefault - Indicates whether the new payment method should be marked as default.
|
|
51
|
+
* @return {Promise<IApiResponseWithData<IUserPayment>>} - A promise that resolves to the response containing user payment information.
|
|
52
|
+
* @throws {Error} - Throws an error if required parameters are missing or if the request fails.
|
|
53
|
+
*/
|
|
54
|
+
addPayment(params: IUserPaymentAddParams): Promise<IApiResponseWithData<IUserPayment>>;
|
|
55
|
+
/**
|
|
56
|
+
* Updates whether the default payment method for a user.
|
|
57
|
+
*
|
|
58
|
+
* @param {IUserPaymentParams} params - The payment parameters required to update payment. Must include `customerId`,
|
|
59
|
+
* `paymentMethodId`, and a boolean `isDefault`.
|
|
60
|
+
* @returns {Promise<IApiResponseWithData<IUserPayment>>} - A promise that resolves to the API response containing
|
|
61
|
+
* the updated payment information.
|
|
62
|
+
* @throws {Error} - Throws an error if required parameters are missing or the request fails.
|
|
63
|
+
*/
|
|
64
|
+
updatePayment(params: IUserPaymentUpdateParams): Promise<IApiResponseWithData<IUserPayment>>;
|
|
65
|
+
/**
|
|
66
|
+
* Purges a payment record for a specified customer.
|
|
67
|
+
*
|
|
68
|
+
* @param {string} customerId - The ID of the customer whose payment record is to be purged.
|
|
69
|
+
* @param {string} paymentId - The ID of the payment record to be purged.
|
|
70
|
+
* @return {Promise<IApiResponseWithData<IPurgeResponse>>} A promise that resolves to the response of the purge request.
|
|
71
|
+
*/
|
|
72
|
+
purgePayment(customerId: string, paymentId: string): Promise<IApiResponseWithData<IPurgeResponse>>;
|
|
43
73
|
}
|