@sesamy/sesamy-js 1.17.0 → 1.18.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 +94 -2
- package/dist/sesamy-js.cjs +5 -5
- package/dist/sesamy-js.d.ts +2 -0
- package/dist/sesamy-js.iife.js +5 -5
- package/dist/sesamy-js.mjs +869 -862
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -262,7 +262,7 @@ setToken(accessToken, expiresIn)
|
|
|
262
262
|
|
|
263
263
|
## `generateLink(params: GenerateAccountLink | GenerateConsumeLink)`
|
|
264
264
|
|
|
265
|
-
Generates a link to a Sesamy
|
|
265
|
+
Generates a link to a Sesamy-hosted service such as account or consume. If the user is authenticated, the link will be signed so that the user can access the service without logging in again.
|
|
266
266
|
|
|
267
267
|
### Parameters
|
|
268
268
|
|
|
@@ -273,6 +273,7 @@ Generates a link to a Sesamy hosted service such as account or consume. If the u
|
|
|
273
273
|
- shorten (boolean, optional): If true, the link will be shortened.
|
|
274
274
|
- ttl (number, optional): The time-to-live for the shortened link in seconds.
|
|
275
275
|
- redirectUrl (string, optional): The URL to redirect to after the link is accessed.
|
|
276
|
+
- language (string, optional): The language for the link. If not provided the language will be fetched from the HTML element's `lang` attribute.
|
|
276
277
|
|
|
277
278
|
### Returns
|
|
278
279
|
|
|
@@ -337,6 +338,17 @@ Creates a checkout session with Sesamy. This function initializes a checkout pro
|
|
|
337
338
|
- sku (string): The SKU of the product to be purchased.
|
|
338
339
|
- purchaseOptionsId (string, optional): The ID of the purchase options for the product.
|
|
339
340
|
- language (string, optional): The language for the checkout session. If not set, it will be automatically fetched from the HTML element's `lang` attribute.
|
|
341
|
+
- redirectUrl (string, optional): The URL to redirect to after the checkout process is completed.
|
|
342
|
+
- address (Address, optional): The address for the checkout session.
|
|
343
|
+
- givenName: (string): The given name.
|
|
344
|
+
- familyName: (string): The family name.
|
|
345
|
+
- street (string): The street address.
|
|
346
|
+
- city (string): The city.
|
|
347
|
+
- zip (string): The postal code.
|
|
348
|
+
- country (string): The country.
|
|
349
|
+
- phoneNumber (string, optional): The phone number.
|
|
350
|
+
- email (string, optional): The email address.
|
|
351
|
+
- isBusiness (boolean, optional): Indicates if the checkout is for a business.
|
|
340
352
|
|
|
341
353
|
### Returns
|
|
342
354
|
|
|
@@ -352,6 +364,8 @@ Promise\<CheckoutResponse\>: A promise that resolves to the response JSON object
|
|
|
352
364
|
- type (enum): The type of checkout session, currently only 'RECURRING' is supported.
|
|
353
365
|
- currency (string): The currency used for the checkout session.
|
|
354
366
|
- country (string): The country associated with the checkout session.
|
|
367
|
+
- redirectUrl (string, optional): The URL to redirect to after the checkout process is completed.
|
|
368
|
+
- email (string, optional): The email address for the checkout session.
|
|
355
369
|
- language (string): The language used for the checkout session.
|
|
356
370
|
- items (Array of objects): The items included in the checkout session.
|
|
357
371
|
- sku (string): The SKU of the product.
|
|
@@ -400,7 +414,85 @@ In this example, a checkout session is created with a single item specified by i
|
|
|
400
414
|
|
|
401
415
|
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
416
|
|
|
403
|
-
|
|
417
|
+
## `checkouts.update(id: string, params: Partial<CreateCheckoutParams>)`
|
|
418
|
+
|
|
419
|
+
Updates a checkout session with Sesamy.
|
|
420
|
+
|
|
421
|
+
### Parameters
|
|
422
|
+
|
|
423
|
+
- params (Partial<CreateCheckoutParams>): The updated parameters for the checkout session.
|
|
424
|
+
- items (Array of objects): An array of items to be included in the checkout.
|
|
425
|
+
- sku (string): The SKU of the product to be purchased.
|
|
426
|
+
- purchaseOptionsId (string, optional): The ID of the purchase options for the product.
|
|
427
|
+
- language (string, optional): The language for the checkout session.
|
|
428
|
+
- redirectUrl (string, optional): The URL to redirect to after the checkout process is completed.
|
|
429
|
+
- email (string, optional): The email address for the checkout session.
|
|
430
|
+
- address (Address, optional): The address for the checkout session.
|
|
431
|
+
- givenName: (string): The given name.
|
|
432
|
+
- familyName: (string): The family name.
|
|
433
|
+
- street (string): The street address.
|
|
434
|
+
- city (string): The city.
|
|
435
|
+
- zip (string): The postal code.
|
|
436
|
+
- country (string): The country.
|
|
437
|
+
- phoneNumber (string, optional): The phone number.
|
|
438
|
+
- email (string, optional): The email address.
|
|
439
|
+
- isBusiness (boolean, optional): Indicates if the checkout is for a business.
|
|
440
|
+
|
|
441
|
+
### Returns
|
|
442
|
+
|
|
443
|
+
Promise\<CheckoutResponse\>: A promise that resolves to the response JSON object from the Sesamy API, which contains details about the updated checkout session.
|
|
444
|
+
|
|
445
|
+
### CheckoutResponse Schema
|
|
446
|
+
|
|
447
|
+
- id (string): The unique identifier of the checkout session.
|
|
448
|
+
- checkoutUrl (string): The URL for the checkout session.
|
|
449
|
+
- status (enum): The status of the checkout session, can be 'PENDING' or 'PAID'.
|
|
450
|
+
- createdAt (string): The creation timestamp of the checkout session.
|
|
451
|
+
- modifiedAt (string): The last modified timestamp of the checkout session.
|
|
452
|
+
- type (enum): The type of checkout session, currently only 'RECURRING' is supported.
|
|
453
|
+
- currency (string): The currency used for the checkout session.
|
|
454
|
+
- country (string): The country associated with the checkout session.
|
|
455
|
+
- language (string): The language used for the checkout session.
|
|
456
|
+
- items (Array of objects): The items included in the checkout session.
|
|
457
|
+
- sku (string): The SKU of the product.
|
|
458
|
+
- purchaseOptionId (string, optional): The ID of the purchase option for the product.
|
|
459
|
+
- title (string): The title of the product.
|
|
460
|
+
- cover (string): The cover image URL of the product.
|
|
461
|
+
- itemsOwned (Array of strings): The SKUs of the items already owned by the user.
|
|
462
|
+
- discountCodes (Array of strings): The discount codes applied to the checkout session.
|
|
463
|
+
- paymentOptions (Array of objects): The available payment options.
|
|
464
|
+
- provider (string): The payment provider.
|
|
465
|
+
- methods (Array of strings): The payment methods supported by the provider.
|
|
466
|
+
|
|
467
|
+
### Example
|
|
468
|
+
|
|
469
|
+
The following example demonstrates how to create a checkout session with Sesamy:
|
|
470
|
+
|
|
471
|
+
```javascript
|
|
472
|
+
import { updateCheckout } from '@sesamy/sesamy-js';
|
|
473
|
+
|
|
474
|
+
// Create a checkout session with one item
|
|
475
|
+
const checkoutParams = {
|
|
476
|
+
email: 'test@example.com',
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
updateCheckout('checkoutId', checkoutParams)
|
|
480
|
+
.then(response => {
|
|
481
|
+
console.log('Checkout session updated:', response);
|
|
482
|
+
})
|
|
483
|
+
.catch(error => {
|
|
484
|
+
console.error('Error updating checkout session:', error);
|
|
485
|
+
});
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
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.
|
|
489
|
+
|
|
490
|
+
### Additional Notes
|
|
491
|
+
|
|
492
|
+
- 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.
|
|
493
|
+
- The `items` array must contain at least one item with a valid `sku`.
|
|
494
|
+
|
|
495
|
+
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
496
|
|
|
405
497
|
## `checkouts.get(id: string)`
|
|
406
498
|
|