@liquidcommerce/cloud-sdk 1.8.0 → 1.8.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 CHANGED
@@ -24,7 +24,7 @@ The LiquidCommerce Cloud SDK provides an easy way to interact with our APIs thro
24
24
  - [Payment Element](#payment-element)
25
25
  - [Legacy Payment](#legacy-payment)
26
26
  - [Checkout](#checkout)
27
- - [Order](#order)
27
+ - [Orders](#orders)
28
28
  - [Webhook](#webhook)
29
29
  - [Response Types](#response-types)
30
30
  - [Error Handling](#error-handling)
@@ -100,6 +100,21 @@ interface ApiResponse<T> {
100
100
 
101
101
  ## Services and Usage
102
102
 
103
+ ### Auth
104
+
105
+ While the SDK handles authentication automatically, you can also manually retrieve the authentication details:
106
+
107
+ ```typescript
108
+ // Manually retrieve authentication details
109
+ try {
110
+ const authDetails = await client.auth();
111
+ console.log('Access Token:', authDetails.token);
112
+ console.log('Expires In:', authDetails.exp);
113
+ } catch (error) {
114
+ console.error('Failed to get auth details:', error);
115
+ }
116
+ ```
117
+
103
118
  ### Address
104
119
 
105
120
  Services for address validation and lookup:
@@ -304,6 +319,7 @@ const paymentSession = await client.user.paymentSession({
304
319
  // cartId: 'your_cart_id',
305
320
  // checkoutToken: 'your_checkout_token',
306
321
  // customerId: 'your_customer_id',
322
+ // customerEmail: 'your_customer_id',
307
323
  });
308
324
 
309
325
  const { key, secret } = paymentSession.data.session;
@@ -341,9 +357,7 @@ const { key, secret } = paymentSession.data.session;
341
357
  Once the user has filled out the payment form, create a confirmation token. This token securely represents the payment details.
342
358
 
343
359
  ```typescript
344
- const result = await paymentElement.createConfirmationToken({
345
- returnUrl: 'https://your-return-url.com/checkout/confirm',
346
- });
360
+ const result = await paymentElement.createConfirmationToken();
347
361
 
348
362
  if (result.token) {
349
363
  // Token successfully created
@@ -658,21 +672,26 @@ await paymentElement.mount({
658
672
  const result = await paymentElement.createConfirmationToken();
659
673
 
660
674
  if (result.token) {
661
- // 5. Complete checkout with the confirmation token
662
- const completedCheckout = await client.checkout.complete({
663
- token: preparedCheckout.data.token,
664
- payment: result.token,
665
- });
675
+ // 5. Confirm the payment collected with the confirmation token
676
+ const confirmation = await client.user.confirmPaymentSession(confirmationToken);
677
+
678
+ if (confirmation?.data?.id) {
679
+ // 6. Complete checkout with the confirmation token
680
+ const completedCheckout = await client.checkout.complete({
681
+ token: preparedCheckout.data.token,
682
+ payment: confirmation?.data?.id,
683
+ });
684
+ }
666
685
  }
667
686
 
668
- // 6. Clean up
687
+ // 7. Clean up
669
688
  paymentElement.unmount();
670
689
  paymentElement.destroy();
671
690
  ```
672
691
 
673
- ### Order
692
+ ### Orders
674
693
 
675
- Order retrieval services:
694
+ Provides secure access to order data throughout the finalized states of the order lifecycle within the LiquidCommerce ecosystem.
676
695
 
677
696
  ```typescript
678
697
  const orderClient = await LiquidCommerceOrders({
@@ -26,6 +26,17 @@ export interface ILiquidCommerceClient {
26
26
  *
27
27
  * @return {Promise<IAuth>} A promise that resolves to an authentication service
28
28
  * response containing details of the authentication process.
29
+ *
30
+ * @example
31
+ * const liquidCommerce = await LiquidCommerce(apiKey, config);
32
+ *
33
+ * try {
34
+ * const authResponse = await liquidCommerce.auth();
35
+ * console.log('Authentication details:', authResponse);
36
+ * // This will log an IAuth object e.g. { token: 'jwt-token', exp: 167... }
37
+ * } catch (error) {
38
+ * console.error('Authentication failed:', error);
39
+ * }
29
40
  */
30
41
  auth(): Promise<IAuth>;
31
42
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@liquidcommerce/cloud-sdk",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "LiquidCommerce Cloud SDK",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.esm.js",