@sesamy/sesamy-js 1.17.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 +92 -1
- package/dist/sesamy-js.cjs +4 -4
- package/dist/sesamy-js.d.ts +1 -0
- package/dist/sesamy-js.iife.js +4 -4
- package/dist/sesamy-js.mjs +637 -631
- package/package.json +2 -2
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,7 +413,85 @@ 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
|
|
|
403
|
-
|
|
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.
|
|
404
495
|
|
|
405
496
|
## `checkouts.get(id: string)`
|
|
406
497
|
|