@sesamy/sesamy-js 1.16.0 → 1.18.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 CHANGED
@@ -337,6 +337,17 @@ Creates a checkout session with Sesamy. This function initializes a checkout pro
337
337
  - sku (string): The SKU of the product to be purchased.
338
338
  - purchaseOptionsId (string, optional): The ID of the purchase options for the product.
339
339
  - language (string, optional): The language for the checkout session. If not set, it will be automatically fetched from the HTML element's `lang` attribute.
340
+ - redirectUrl (string, optional): The URL to redirect to after the checkout process is completed.
341
+ - address (Address, optional): The address for the checkout session.
342
+ - givenName: (string): The given name.
343
+ - familyName: (string): The family name.
344
+ - street (string): The street address.
345
+ - city (string): The city.
346
+ - zip (string): The postal code.
347
+ - country (string): The country.
348
+ - phoneNumber (string, optional): The phone number.
349
+ - email (string, optional): The email address.
350
+ - isBusiness (boolean, optional): Indicates if the checkout is for a business.
340
351
 
341
352
  ### Returns
342
353
 
@@ -352,6 +363,8 @@ Promise\<CheckoutResponse\>: A promise that resolves to the response JSON object
352
363
  - type (enum): The type of checkout session, currently only 'RECURRING' is supported.
353
364
  - currency (string): The currency used for the checkout session.
354
365
  - country (string): The country associated with the checkout session.
366
+ - redirectUrl (string, optional): The URL to redirect to after the checkout process is completed.
367
+ - email (string, optional): The email address for the checkout session.
355
368
  - language (string): The language used for the checkout session.
356
369
  - items (Array of objects): The items included in the checkout session.
357
370
  - sku (string): The SKU of the product.
@@ -400,6 +413,147 @@ In this example, a checkout session is created with a single item specified by i
400
413
 
401
414
  By using the `createCheckout` function, you can easily initialize a checkout process and handle the response from the Sesamy API to complete the transaction.
402
415
 
416
+ ## `checkouts.update(id: string, params: Partial<CreateCheckoutParams>)`
417
+
418
+ Updates a checkout session with Sesamy.
419
+
420
+ ### Parameters
421
+
422
+ - params (Partial<CreateCheckoutParams>): The updated parameters for the checkout session.
423
+ - items (Array of objects): An array of items to be included in the checkout.
424
+ - sku (string): The SKU of the product to be purchased.
425
+ - purchaseOptionsId (string, optional): The ID of the purchase options for the product.
426
+ - language (string, optional): The language for the checkout session.
427
+ - redirectUrl (string, optional): The URL to redirect to after the checkout process is completed.
428
+ - email (string, optional): The email address for the checkout session.
429
+ - address (Address, optional): The address for the checkout session.
430
+ - givenName: (string): The given name.
431
+ - familyName: (string): The family name.
432
+ - street (string): The street address.
433
+ - city (string): The city.
434
+ - zip (string): The postal code.
435
+ - country (string): The country.
436
+ - phoneNumber (string, optional): The phone number.
437
+ - email (string, optional): The email address.
438
+ - isBusiness (boolean, optional): Indicates if the checkout is for a business.
439
+
440
+ ### Returns
441
+
442
+ Promise\<CheckoutResponse\>: A promise that resolves to the response JSON object from the Sesamy API, which contains details about the updated checkout session.
443
+
444
+ ### CheckoutResponse Schema
445
+
446
+ - id (string): The unique identifier of the checkout session.
447
+ - checkoutUrl (string): The URL for the checkout session.
448
+ - status (enum): The status of the checkout session, can be 'PENDING' or 'PAID'.
449
+ - createdAt (string): The creation timestamp of the checkout session.
450
+ - modifiedAt (string): The last modified timestamp of the checkout session.
451
+ - type (enum): The type of checkout session, currently only 'RECURRING' is supported.
452
+ - currency (string): The currency used for the checkout session.
453
+ - country (string): The country associated with the checkout session.
454
+ - language (string): The language used for the checkout session.
455
+ - items (Array of objects): The items included in the checkout session.
456
+ - sku (string): The SKU of the product.
457
+ - purchaseOptionId (string, optional): The ID of the purchase option for the product.
458
+ - title (string): The title of the product.
459
+ - cover (string): The cover image URL of the product.
460
+ - itemsOwned (Array of strings): The SKUs of the items already owned by the user.
461
+ - discountCodes (Array of strings): The discount codes applied to the checkout session.
462
+ - paymentOptions (Array of objects): The available payment options.
463
+ - provider (string): The payment provider.
464
+ - methods (Array of strings): The payment methods supported by the provider.
465
+
466
+ ### Example
467
+
468
+ The following example demonstrates how to create a checkout session with Sesamy:
469
+
470
+ ```javascript
471
+ import { updateCheckout } from '@sesamy/sesamy-js';
472
+
473
+ // Create a checkout session with one item
474
+ const checkoutParams = {
475
+ email: 'test@example.com',
476
+ };
477
+
478
+ updateCheckout('checkoutId', checkoutParams)
479
+ .then(response => {
480
+ console.log('Checkout session updated:', response);
481
+ })
482
+ .catch(error => {
483
+ console.error('Error updating checkout session:', error);
484
+ });
485
+ ```
486
+
487
+ In this example, a checkout session is created with a single item specified by its SKU and an optional purchase options ID. The language is set to English (`'en'`), but if not provided, it will default to the language specified in the HTML `lang` attribute.
488
+
489
+ ### Additional Notes
490
+
491
+ - The `language` parameter is optional. If it is not provided, the language will be determined using the `getLanguage` function, which fetches the language from the `lang` attribute of the HTML document element.
492
+ - The `items` array must contain at least one item with a valid `sku`.
493
+
494
+ By using the `createCheckout` function, you can easily initialize a checkout process and handle the response from the Sesamy API to complete the transaction.
495
+
496
+ ## `checkouts.get(id: string)`
497
+
498
+ Retrieves the details of a specific checkout session from Sesamy. This function fetches the checkout session information based on the provided checkout session ID.
499
+
500
+ ### Parameters
501
+
502
+ - id (string): The unique identifier of the checkout session to retrieve.
503
+
504
+ ### Returns
505
+
506
+ Promise\<CheckoutResponse\>: A promise that resolves to the response JSON object from the Sesamy API, which contains details about the requested checkout session.
507
+
508
+ ### CheckoutResponse Schema
509
+
510
+ - id (string): The unique identifier of the checkout session.
511
+ - checkoutUrl (string): The URL for the checkout session.
512
+ - status (enum): The status of the checkout session, can be 'PENDING' or 'PAID'.
513
+ - createdAt (string): The creation timestamp of the checkout session.
514
+ - modifiedAt (string): The last modified timestamp of the checkout session.
515
+ - type (enum): The type of checkout session, currently only 'RECURRING' is supported.
516
+ - currency (string): The currency used for the checkout session.
517
+ - country (string): The country associated with the checkout session.
518
+ - language (string): The language used for the checkout session.
519
+ - items (Array of objects): The items included in the checkout session.
520
+ - sku (string): The SKU of the product.
521
+ - purchaseOptionId (string, optional): The ID of the purchase option for the product.
522
+ - title (string): The title of the product.
523
+ - cover (string): The cover image URL of the product.
524
+ - itemsOwned (Array of strings): The SKUs of the items already owned by the user.
525
+ - discountCodes (Array of strings): The discount codes applied to the checkout session.
526
+ - paymentOptions (Array of objects): The available payment options.
527
+ - provider (string): The payment provider.
528
+ - methods (Array of strings): The payment methods supported by the provider.
529
+
530
+ ### Example
531
+
532
+ The following example demonstrates how to retrieve the details of a specific checkout session with Sesamy:
533
+
534
+ ```javascript
535
+ import { getCheckout } from '@sesamy/sesamy-js';
536
+
537
+ // Retrieve the details of a checkout session by ID
538
+ const checkoutId = 'checkout-session-id';
539
+
540
+ getCheckout(checkoutId)
541
+ .then(response => {
542
+ console.log('Checkout session details:', response);
543
+ })
544
+ .catch(error => {
545
+ console.error('Error retrieving checkout session:', error);
546
+ });
547
+ ```
548
+
549
+ In this example, the details of a specific checkout session are retrieved using its unique ID. The function returns a promise that resolves to the details of the checkout session.
550
+
551
+ ### Additional Notes
552
+
553
+ - The `id` parameter is required and must be a valid checkout session identifier.
554
+
555
+ By using the `getCheckout` function, you can easily fetch the details of a specific checkout session from the Sesamy API to view or process the transaction information.
556
+
403
557
  ## Transform
404
558
 
405
559
  The transform module allows for dynamic content manipulation based on specified rules. This can include inserting, replacing, or removing elements on a webpage.