@sesamy/sesamy-js 1.55.0 → 1.57.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
@@ -1102,6 +1102,10 @@ Creates a checkout session with Sesamy. This function initializes a checkout pro
1102
1102
  - sourceId (string, optional): Source identifier.
1103
1103
  - \_ga, \_gid, \_fbp, \_fbc (strings, optional): Analytics tracking cookies.
1104
1104
  - referralEmail (string, optional): Email of the referrer.
1105
+ - payerEmail (string, optional): Email of the payer (person paying for the purchase).
1106
+ - requireAddress (boolean, optional): If true, requires the customer to provide an address during checkout.
1107
+ - giftMode (boolean, optional): If true, enables gift mode for the checkout.
1108
+ - metaData (Record<string, string>, optional): Custom metadata to store with the checkout (e.g., { "campaign": "summer2024", "source": "mobile" }).
1105
1109
 
1106
1110
  ### Returns
1107
1111
 
@@ -1162,52 +1166,38 @@ const checkout = await sesamy.checkouts.create({
1162
1166
  ],
1163
1167
  email: 'customer@example.com',
1164
1168
  redirectUrl: 'https://yoursite.com/checkout-complete',
1169
+ requireAddress: true,
1170
+ metaData: {
1171
+ campaignId: 'summer_2024',
1172
+ source: 'mobile_app',
1173
+ },
1165
1174
  });
1166
1175
 
1167
1176
  // Redirect to checkout
1168
1177
  window.location.href = checkout.checkoutUrl;
1169
1178
  ```
1170
1179
 
1171
- Advanced example with multiple items and tracking:
1180
+ Advanced example with gift mode and payer email:
1172
1181
 
1173
1182
  ```javascript
1174
1183
  const checkout = await sesamy.checkouts.create({
1175
1184
  items: [
1176
1185
  {
1177
- sku: 'premium_annual',
1178
- purchaseOptionId: 'po_456',
1179
- price: 99.99,
1180
- currency: 'USD',
1181
- },
1182
- {
1183
- sku: 'addon_feature',
1184
- price: 9.99,
1186
+ sku: 'premium_gift',
1187
+ purchaseOptionId: 'po_gift',
1188
+ price: 49.99,
1185
1189
  currency: 'USD',
1186
1190
  },
1187
1191
  ],
1188
- email: 'customer@example.com',
1189
- givenName: 'John',
1190
- familyName: 'Doe',
1191
- phoneNumber: '+1234567890',
1192
- address: {
1193
- street: '123 Main St',
1194
- city: 'San Francisco',
1195
- zip: '94102',
1196
- country: 'US',
1197
- },
1192
+ email: 'recipient@example.com',
1193
+ payerEmail: 'sender@example.com',
1198
1194
  redirectUrl: 'https://yoursite.com/checkout-complete',
1195
+ giftMode: true,
1199
1196
  language: 'en',
1200
- attribution: {
1201
- utmSource: 'email',
1202
- utmMedium: 'newsletter',
1203
- utmCampaign: 'summer_sale_2024',
1197
+ metaData: {
1198
+ giftMessage: 'Happy Birthday!',
1199
+ giftFrom: 'John',
1204
1200
  },
1205
- requestedDiscountCodes: ['WELCOME10', 'EARLYBIRD'],
1206
- paymentMethodsFilter: [{ provider: 'stripe', methods: ['card'] }, { provider: 'klarna' }],
1207
- });
1208
-
1209
- window.location.href = checkout.checkoutUrl;
1210
- ```
1211
1201
 
1212
1202
  ### Additional Notes
1213
1203
 
@@ -1247,6 +1237,10 @@ Updates an existing checkout session with Sesamy. You can update customer inform
1247
1237
  - paymentMethodsFilter (Array of objects, optional): Updated payment method filters.
1248
1238
  - requestedDiscountCodes (Array of strings, optional): Updated discount codes to apply.
1249
1239
  - attribution (object, optional): Updated attribution and tracking data.
1240
+ - payerEmail (string, optional): Updated payer email.
1241
+ - requireAddress (boolean, optional): Updated address requirement.
1242
+ - giftMode (boolean, optional): Updated gift mode status.
1243
+ - metaData (Record<string, string>, optional): Updated metadata.
1250
1244
 
1251
1245
  ### Returns
1252
1246
 
@@ -2844,3 +2838,55 @@ The Events API can be used for various scenarios where you need to communicate b
2844
2838
  4. **Analytics**: Emit events for key user interactions that other scripts might want to track.
2845
2839
 
2846
2840
  Events emitted through this API are also automatically tracked in analytics with the prefix `event:`.
2841
+
2842
+ ## Using the SDK for Link Generation
2843
+
2844
+ While `sesamy-js` provides `generateLink` which automatically signs links if the user is authenticated, you can also use the `@sesamy/sdk` package directly to generate unsigned links without requiring authentication. This is useful for generating shareable links or links for unauthenticated users.
2845
+
2846
+ ### SDK Link Generation Example
2847
+
2848
+ ```javascript
2849
+ import { client } from '@sesamy/sdk';
2850
+
2851
+ // Generate a checkout link (no authentication required)
2852
+ const checkoutUrl = client.checkout.generateLink(
2853
+ { apiUrl: 'https://api-proxy.example.com' },
2854
+ {
2855
+ items: [{ sku: 'premium-monthly' }],
2856
+ email: 'user@example.com',
2857
+ language: 'en',
2858
+ redirectUrl: 'https://example.com/success',
2859
+ requireAddress: true,
2860
+ giftMode: false,
2861
+ metaData: {
2862
+ campaignId: 'summer_2024',
2863
+ source: 'newsletter',
2864
+ },
2865
+ }
2866
+ );
2867
+
2868
+ // Generate account management links
2869
+ const accountUrl = client.links.generateAccountLink(
2870
+ { baseUrl: 'https://app.example.com', clientId: 'your-client-id' },
2871
+ { language: 'en', redirectUrl: 'https://example.com' }
2872
+ );
2873
+
2874
+ // Generate change payment link
2875
+ const changePaymentUrl = client.links.generateChangePaymentLink(
2876
+ { baseUrl: 'https://app.example.com', clientId: 'your-client-id' },
2877
+ { contractId: 'contract-123', language: 'en' }
2878
+ );
2879
+
2880
+ // Generate consume content link
2881
+ const consumeUrl = client.links.generateConsumeLink(
2882
+ { baseUrl: 'https://app.example.com', clientId: 'your-client-id' },
2883
+ { sku: 'product-123', language: 'en' }
2884
+ );
2885
+ ```
2886
+
2887
+ ### Differences Between sesamy-js generateLink and SDK Links
2888
+
2889
+ - **sesamy-js `generateLink`**: Includes authentication token in hash if user is authenticated, automatically includes tracking cookies and attribution data, supports link shortening via TTL
2890
+ - **SDK `links.*`**: Pure URL generation without authentication, useful for generating shareable links, links for unauthenticated users, or backend link generation
2891
+
2892
+ ````