@waffo/pancake-ts 0.3.3 → 0.4.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/CHANGELOG.md +25 -0
- package/README.md +8 -4
- package/dist/index.cjs +32 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -61
- package/dist/index.d.ts +72 -61
- package/dist/index.js +32 -15
- package/dist/index.js.map +1 -1
- package/docs/api-reference.md +19 -16
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -211,7 +211,12 @@ declare enum ErrorLayer {
|
|
|
211
211
|
* @see waffo-pancake-user-service/app/lib/utils/jwt.ts IssueSessionTokenRequest
|
|
212
212
|
*/
|
|
213
213
|
interface IssueSessionTokenParams {
|
|
214
|
-
/**
|
|
214
|
+
/**
|
|
215
|
+
* Buyer identity — encoded into the JWT payload for merchant-side buyer
|
|
216
|
+
* identification. Accepts an email or any merchant-provided identifier string.
|
|
217
|
+
* To pre-fill the checkout page's email field, use `buyerEmail` on
|
|
218
|
+
* `checkout.authenticated.create`.
|
|
219
|
+
*/
|
|
215
220
|
buyerIdentity: string;
|
|
216
221
|
/** Store ID (optional when `productId` is provided) */
|
|
217
222
|
storeId?: string;
|
|
@@ -304,7 +309,13 @@ interface CreateStoreParams {
|
|
|
304
309
|
/** Store name (slug is auto-generated) */
|
|
305
310
|
name: string;
|
|
306
311
|
}
|
|
307
|
-
/**
|
|
312
|
+
/**
|
|
313
|
+
* Parameters for updating a store.
|
|
314
|
+
*
|
|
315
|
+
* Settings objects support partial updates — omitted sub-fields keep their
|
|
316
|
+
* existing values, `null` clears a field, and a concrete value sets it.
|
|
317
|
+
* Pass the entire settings object as `null` to clear all fields in the group.
|
|
318
|
+
*/
|
|
308
319
|
interface UpdateStoreParams {
|
|
309
320
|
/** Store ID */
|
|
310
321
|
id: string;
|
|
@@ -318,12 +329,12 @@ interface UpdateStoreParams {
|
|
|
318
329
|
supportEmail?: string | null;
|
|
319
330
|
/** Store website URL (set to `null` to remove) */
|
|
320
331
|
website?: string | null;
|
|
321
|
-
/** Webhook configuration
|
|
322
|
-
webhookSettings?: WebhookSettings | null;
|
|
323
|
-
/** Notification preferences (set to `null` to
|
|
324
|
-
notificationSettings?: NotificationSettings | null;
|
|
325
|
-
/** Checkout page theme configuration (set to `null` to
|
|
326
|
-
checkoutSettings?: CheckoutSettings | null;
|
|
332
|
+
/** Webhook configuration (partial update — omitted fields keep existing values, set to `null` to clear all) */
|
|
333
|
+
webhookSettings?: Partial<WebhookSettings> | null;
|
|
334
|
+
/** Notification preferences (partial update — omitted fields keep existing values, set to `null` to clear all) */
|
|
335
|
+
notificationSettings?: Partial<NotificationSettings> | null;
|
|
336
|
+
/** Checkout page theme configuration (partial update — omitted fields keep existing values, set to `null` to clear all) */
|
|
337
|
+
checkoutSettings?: Partial<CheckoutSettings> | null;
|
|
327
338
|
}
|
|
328
339
|
/** Parameters for deleting (soft-delete) a store. */
|
|
329
340
|
interface DeleteStoreParams {
|
|
@@ -746,8 +757,11 @@ interface RefundTicket {
|
|
|
746
757
|
/**
|
|
747
758
|
* Parameters for anonymous checkout.
|
|
748
759
|
*
|
|
749
|
-
* The buyer
|
|
750
|
-
*
|
|
760
|
+
* The buyer reaches the checkout page without a session token. Merchants may still
|
|
761
|
+
* pre-fill `buyerEmail` and `billingDetail`; omitting them leaves the form blank.
|
|
762
|
+
*
|
|
763
|
+
* Accepts every field of {@link CreateCheckoutSessionParams} — this wrapper simply
|
|
764
|
+
* forwards the params unchanged to `/v1/actions/checkout/create-session`.
|
|
751
765
|
*
|
|
752
766
|
* @example
|
|
753
767
|
* const result = await client.checkout.anonymous.create({
|
|
@@ -756,61 +770,32 @@ interface RefundTicket {
|
|
|
756
770
|
* });
|
|
757
771
|
* // Redirect to result.checkoutUrl
|
|
758
772
|
*/
|
|
759
|
-
|
|
760
|
-
/** Product ID */
|
|
761
|
-
productId: string;
|
|
762
|
-
/** Currency code (ISO 4217) */
|
|
763
|
-
currency: string;
|
|
764
|
-
/** Optional price snapshot override (reads from DB if omitted) */
|
|
765
|
-
priceSnapshot?: PriceInfo;
|
|
766
|
-
/** Trial toggle override (subscription only) */
|
|
767
|
-
withTrial?: boolean;
|
|
768
|
-
/** Redirect URL after successful payment */
|
|
769
|
-
successUrl?: string;
|
|
770
|
-
/** Session expiration in seconds (default: 45 minutes) */
|
|
771
|
-
expiresInSeconds?: number;
|
|
772
|
-
/** Dark mode override (true=dark, false=light, omit=use store default) */
|
|
773
|
-
darkMode?: boolean;
|
|
774
|
-
/** Custom metadata */
|
|
775
|
-
metadata?: Record<string, string>;
|
|
776
|
-
}
|
|
773
|
+
type AnonymousCheckoutParams = CreateCheckoutSessionParams;
|
|
777
774
|
/**
|
|
778
775
|
* Parameters for authenticated checkout.
|
|
779
776
|
*
|
|
780
|
-
*
|
|
781
|
-
*
|
|
777
|
+
* Merges the checkout-session fields ({@link CreateCheckoutSessionParams}) with the
|
|
778
|
+
* extra `buyerIdentity` required by `issue-session-token`. The wrapper splits the
|
|
779
|
+
* input: `buyerIdentity` goes to the token call; everything else (including
|
|
780
|
+
* `buyerEmail`) goes to the create-session call. The two fields are independent.
|
|
782
781
|
*
|
|
783
782
|
* @example
|
|
784
783
|
* const result = await client.checkout.authenticated.create({
|
|
785
784
|
* productId: "PROD_xxx",
|
|
786
785
|
* currency: "USD",
|
|
787
|
-
* buyerIdentity: "
|
|
786
|
+
* buyerIdentity: "user-123", // merchant-side buyer id (goes into JWT)
|
|
787
|
+
* buyerEmail: "customer@example.com", // pre-filled on the checkout page
|
|
788
788
|
* });
|
|
789
789
|
* // Redirect to result.checkoutUrl (includes #token=...)
|
|
790
790
|
*/
|
|
791
|
-
interface AuthenticatedCheckoutParams {
|
|
792
|
-
/**
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
791
|
+
interface AuthenticatedCheckoutParams extends CreateCheckoutSessionParams {
|
|
792
|
+
/**
|
|
793
|
+
* Buyer identity — sent to `issue-session-token` and encoded into the JWT
|
|
794
|
+
* payload for merchant-side buyer identification. Accepts an email or any
|
|
795
|
+
* merchant-provided identifier string. Use `buyerEmail` to pre-fill the
|
|
796
|
+
* checkout page's email input.
|
|
797
|
+
*/
|
|
797
798
|
buyerIdentity: string;
|
|
798
|
-
/** Pre-filled buyer email (defaults to `buyerIdentity` when omitted) */
|
|
799
|
-
buyerEmail?: string;
|
|
800
|
-
/** Pre-filled billing details */
|
|
801
|
-
billingDetail?: BillingDetail;
|
|
802
|
-
/** Optional price snapshot override (reads from DB if omitted) */
|
|
803
|
-
priceSnapshot?: PriceInfo;
|
|
804
|
-
/** Trial toggle override (subscription only) */
|
|
805
|
-
withTrial?: boolean;
|
|
806
|
-
/** Redirect URL after successful payment */
|
|
807
|
-
successUrl?: string;
|
|
808
|
-
/** Session expiration in seconds (default: 45 minutes) */
|
|
809
|
-
expiresInSeconds?: number;
|
|
810
|
-
/** Dark mode override (true=dark, false=light, omit=use store default) */
|
|
811
|
-
darkMode?: boolean;
|
|
812
|
-
/** Custom metadata */
|
|
813
|
-
metadata?: Record<string, string>;
|
|
814
799
|
}
|
|
815
800
|
/**
|
|
816
801
|
* Result of an authenticated checkout creation.
|
|
@@ -1157,7 +1142,8 @@ declare class BuyerGraphQL {
|
|
|
1157
1142
|
/**
|
|
1158
1143
|
* Anonymous checkout — no buyer identity provided.
|
|
1159
1144
|
*
|
|
1160
|
-
* The buyer
|
|
1145
|
+
* The buyer reaches the checkout page without a session token. Merchants may still
|
|
1146
|
+
* pre-fill `buyerEmail` and `billingDetail` on the page by passing them here.
|
|
1161
1147
|
* Internally creates a checkout session and returns the redirect URL.
|
|
1162
1148
|
*/
|
|
1163
1149
|
declare class CheckoutAnonymousResource {
|
|
@@ -1170,11 +1156,20 @@ declare class CheckoutAnonymousResource {
|
|
|
1170
1156
|
* @returns Session ID, checkout URL, and expiration
|
|
1171
1157
|
*
|
|
1172
1158
|
* @example
|
|
1159
|
+
* // Minimal — buyer fills everything on the page
|
|
1173
1160
|
* const result = await client.checkout.anonymous.create({
|
|
1174
1161
|
* productId: "PROD_xxx",
|
|
1175
1162
|
* currency: "USD",
|
|
1176
1163
|
* });
|
|
1177
|
-
*
|
|
1164
|
+
*
|
|
1165
|
+
* @example
|
|
1166
|
+
* // Pre-fill email and billing without issuing a session token
|
|
1167
|
+
* const result = await client.checkout.anonymous.create({
|
|
1168
|
+
* productId: "PROD_xxx",
|
|
1169
|
+
* currency: "USD",
|
|
1170
|
+
* buyerEmail: "customer@example.com",
|
|
1171
|
+
* billingDetail: { country: "US", isBusiness: false, postcode: "10001" },
|
|
1172
|
+
* });
|
|
1178
1173
|
*/
|
|
1179
1174
|
create(params: AnonymousCheckoutParams): Promise<CheckoutSessionResult>;
|
|
1180
1175
|
}
|
|
@@ -1193,10 +1188,12 @@ declare class CheckoutAuthenticatedResource {
|
|
|
1193
1188
|
* Create an authenticated checkout session.
|
|
1194
1189
|
*
|
|
1195
1190
|
* Behavior:
|
|
1196
|
-
* - Issues a session token via `issue-session-token`
|
|
1197
|
-
* - Creates a checkout session via `create-session`
|
|
1198
|
-
* - Appends the token to the checkout URL as a URL fragment
|
|
1199
|
-
*
|
|
1191
|
+
* - Issues a session token via `issue-session-token` (receives `buyerIdentity` + `productId` only)
|
|
1192
|
+
* - Creates a checkout session via `create-session` (receives every other field unchanged)
|
|
1193
|
+
* - Appends the token to the checkout URL as a URL fragment (`#token=...`)
|
|
1194
|
+
*
|
|
1195
|
+
* `buyerIdentity` and `buyerEmail` are independent inputs: identity is for the JWT,
|
|
1196
|
+
* email is for pre-filling the checkout page. The SDK forwards each to its own endpoint.
|
|
1200
1197
|
*
|
|
1201
1198
|
* @param params - Checkout parameters including buyer identity
|
|
1202
1199
|
* @returns Session details with token-appended checkout URL
|
|
@@ -1205,7 +1202,8 @@ declare class CheckoutAuthenticatedResource {
|
|
|
1205
1202
|
* const result = await client.checkout.authenticated.create({
|
|
1206
1203
|
* productId: "PROD_xxx",
|
|
1207
1204
|
* currency: "USD",
|
|
1208
|
-
* buyerIdentity: "
|
|
1205
|
+
* buyerIdentity: "user-123",
|
|
1206
|
+
* buyerEmail: "customer@example.com",
|
|
1209
1207
|
* });
|
|
1210
1208
|
* // Redirect to result.checkoutUrl (includes #token=...)
|
|
1211
1209
|
*/
|
|
@@ -1233,7 +1231,8 @@ declare class CheckoutAuthenticatedResource {
|
|
|
1233
1231
|
* const result = await client.checkout.authenticated.create({
|
|
1234
1232
|
* productId: "PROD_xxx",
|
|
1235
1233
|
* currency: "USD",
|
|
1236
|
-
* buyerIdentity: "
|
|
1234
|
+
* buyerIdentity: "userIdInYourSystem",
|
|
1235
|
+
* buyerEmail: "customer@example.com",
|
|
1237
1236
|
* });
|
|
1238
1237
|
* // result.checkoutUrl includes #token=...
|
|
1239
1238
|
*/
|
|
@@ -1449,14 +1448,26 @@ declare class StoresResource {
|
|
|
1449
1448
|
/**
|
|
1450
1449
|
* Update an existing store's settings.
|
|
1451
1450
|
*
|
|
1451
|
+
* Settings objects (`webhookSettings`, `notificationSettings`, `checkoutSettings`)
|
|
1452
|
+
* support partial updates: omitted sub-fields keep existing values, `null` clears
|
|
1453
|
+
* a field. Pass the entire settings object as `null` to clear all fields.
|
|
1454
|
+
*
|
|
1452
1455
|
* @param params - Fields to update (only provided fields are changed)
|
|
1453
1456
|
* @returns Updated store entity
|
|
1454
1457
|
*
|
|
1455
1458
|
* @example
|
|
1459
|
+
* // Update name
|
|
1456
1460
|
* const { store } = await client.stores.update({
|
|
1457
1461
|
* id: "STO_xxx",
|
|
1458
1462
|
* name: "Updated Name",
|
|
1459
1463
|
* });
|
|
1464
|
+
*
|
|
1465
|
+
* @example
|
|
1466
|
+
* // Clear test webhook URL while keeping other webhook settings
|
|
1467
|
+
* const { store } = await client.stores.update({
|
|
1468
|
+
* id: "STO_xxx",
|
|
1469
|
+
* webhookSettings: { testWebhookUrl: null },
|
|
1470
|
+
* });
|
|
1460
1471
|
*/
|
|
1461
1472
|
update(params: UpdateStoreParams): Promise<{
|
|
1462
1473
|
store: Store;
|
package/dist/index.d.ts
CHANGED
|
@@ -211,7 +211,12 @@ declare enum ErrorLayer {
|
|
|
211
211
|
* @see waffo-pancake-user-service/app/lib/utils/jwt.ts IssueSessionTokenRequest
|
|
212
212
|
*/
|
|
213
213
|
interface IssueSessionTokenParams {
|
|
214
|
-
/**
|
|
214
|
+
/**
|
|
215
|
+
* Buyer identity — encoded into the JWT payload for merchant-side buyer
|
|
216
|
+
* identification. Accepts an email or any merchant-provided identifier string.
|
|
217
|
+
* To pre-fill the checkout page's email field, use `buyerEmail` on
|
|
218
|
+
* `checkout.authenticated.create`.
|
|
219
|
+
*/
|
|
215
220
|
buyerIdentity: string;
|
|
216
221
|
/** Store ID (optional when `productId` is provided) */
|
|
217
222
|
storeId?: string;
|
|
@@ -304,7 +309,13 @@ interface CreateStoreParams {
|
|
|
304
309
|
/** Store name (slug is auto-generated) */
|
|
305
310
|
name: string;
|
|
306
311
|
}
|
|
307
|
-
/**
|
|
312
|
+
/**
|
|
313
|
+
* Parameters for updating a store.
|
|
314
|
+
*
|
|
315
|
+
* Settings objects support partial updates — omitted sub-fields keep their
|
|
316
|
+
* existing values, `null` clears a field, and a concrete value sets it.
|
|
317
|
+
* Pass the entire settings object as `null` to clear all fields in the group.
|
|
318
|
+
*/
|
|
308
319
|
interface UpdateStoreParams {
|
|
309
320
|
/** Store ID */
|
|
310
321
|
id: string;
|
|
@@ -318,12 +329,12 @@ interface UpdateStoreParams {
|
|
|
318
329
|
supportEmail?: string | null;
|
|
319
330
|
/** Store website URL (set to `null` to remove) */
|
|
320
331
|
website?: string | null;
|
|
321
|
-
/** Webhook configuration
|
|
322
|
-
webhookSettings?: WebhookSettings | null;
|
|
323
|
-
/** Notification preferences (set to `null` to
|
|
324
|
-
notificationSettings?: NotificationSettings | null;
|
|
325
|
-
/** Checkout page theme configuration (set to `null` to
|
|
326
|
-
checkoutSettings?: CheckoutSettings | null;
|
|
332
|
+
/** Webhook configuration (partial update — omitted fields keep existing values, set to `null` to clear all) */
|
|
333
|
+
webhookSettings?: Partial<WebhookSettings> | null;
|
|
334
|
+
/** Notification preferences (partial update — omitted fields keep existing values, set to `null` to clear all) */
|
|
335
|
+
notificationSettings?: Partial<NotificationSettings> | null;
|
|
336
|
+
/** Checkout page theme configuration (partial update — omitted fields keep existing values, set to `null` to clear all) */
|
|
337
|
+
checkoutSettings?: Partial<CheckoutSettings> | null;
|
|
327
338
|
}
|
|
328
339
|
/** Parameters for deleting (soft-delete) a store. */
|
|
329
340
|
interface DeleteStoreParams {
|
|
@@ -746,8 +757,11 @@ interface RefundTicket {
|
|
|
746
757
|
/**
|
|
747
758
|
* Parameters for anonymous checkout.
|
|
748
759
|
*
|
|
749
|
-
* The buyer
|
|
750
|
-
*
|
|
760
|
+
* The buyer reaches the checkout page without a session token. Merchants may still
|
|
761
|
+
* pre-fill `buyerEmail` and `billingDetail`; omitting them leaves the form blank.
|
|
762
|
+
*
|
|
763
|
+
* Accepts every field of {@link CreateCheckoutSessionParams} — this wrapper simply
|
|
764
|
+
* forwards the params unchanged to `/v1/actions/checkout/create-session`.
|
|
751
765
|
*
|
|
752
766
|
* @example
|
|
753
767
|
* const result = await client.checkout.anonymous.create({
|
|
@@ -756,61 +770,32 @@ interface RefundTicket {
|
|
|
756
770
|
* });
|
|
757
771
|
* // Redirect to result.checkoutUrl
|
|
758
772
|
*/
|
|
759
|
-
|
|
760
|
-
/** Product ID */
|
|
761
|
-
productId: string;
|
|
762
|
-
/** Currency code (ISO 4217) */
|
|
763
|
-
currency: string;
|
|
764
|
-
/** Optional price snapshot override (reads from DB if omitted) */
|
|
765
|
-
priceSnapshot?: PriceInfo;
|
|
766
|
-
/** Trial toggle override (subscription only) */
|
|
767
|
-
withTrial?: boolean;
|
|
768
|
-
/** Redirect URL after successful payment */
|
|
769
|
-
successUrl?: string;
|
|
770
|
-
/** Session expiration in seconds (default: 45 minutes) */
|
|
771
|
-
expiresInSeconds?: number;
|
|
772
|
-
/** Dark mode override (true=dark, false=light, omit=use store default) */
|
|
773
|
-
darkMode?: boolean;
|
|
774
|
-
/** Custom metadata */
|
|
775
|
-
metadata?: Record<string, string>;
|
|
776
|
-
}
|
|
773
|
+
type AnonymousCheckoutParams = CreateCheckoutSessionParams;
|
|
777
774
|
/**
|
|
778
775
|
* Parameters for authenticated checkout.
|
|
779
776
|
*
|
|
780
|
-
*
|
|
781
|
-
*
|
|
777
|
+
* Merges the checkout-session fields ({@link CreateCheckoutSessionParams}) with the
|
|
778
|
+
* extra `buyerIdentity` required by `issue-session-token`. The wrapper splits the
|
|
779
|
+
* input: `buyerIdentity` goes to the token call; everything else (including
|
|
780
|
+
* `buyerEmail`) goes to the create-session call. The two fields are independent.
|
|
782
781
|
*
|
|
783
782
|
* @example
|
|
784
783
|
* const result = await client.checkout.authenticated.create({
|
|
785
784
|
* productId: "PROD_xxx",
|
|
786
785
|
* currency: "USD",
|
|
787
|
-
* buyerIdentity: "
|
|
786
|
+
* buyerIdentity: "user-123", // merchant-side buyer id (goes into JWT)
|
|
787
|
+
* buyerEmail: "customer@example.com", // pre-filled on the checkout page
|
|
788
788
|
* });
|
|
789
789
|
* // Redirect to result.checkoutUrl (includes #token=...)
|
|
790
790
|
*/
|
|
791
|
-
interface AuthenticatedCheckoutParams {
|
|
792
|
-
/**
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
791
|
+
interface AuthenticatedCheckoutParams extends CreateCheckoutSessionParams {
|
|
792
|
+
/**
|
|
793
|
+
* Buyer identity — sent to `issue-session-token` and encoded into the JWT
|
|
794
|
+
* payload for merchant-side buyer identification. Accepts an email or any
|
|
795
|
+
* merchant-provided identifier string. Use `buyerEmail` to pre-fill the
|
|
796
|
+
* checkout page's email input.
|
|
797
|
+
*/
|
|
797
798
|
buyerIdentity: string;
|
|
798
|
-
/** Pre-filled buyer email (defaults to `buyerIdentity` when omitted) */
|
|
799
|
-
buyerEmail?: string;
|
|
800
|
-
/** Pre-filled billing details */
|
|
801
|
-
billingDetail?: BillingDetail;
|
|
802
|
-
/** Optional price snapshot override (reads from DB if omitted) */
|
|
803
|
-
priceSnapshot?: PriceInfo;
|
|
804
|
-
/** Trial toggle override (subscription only) */
|
|
805
|
-
withTrial?: boolean;
|
|
806
|
-
/** Redirect URL after successful payment */
|
|
807
|
-
successUrl?: string;
|
|
808
|
-
/** Session expiration in seconds (default: 45 minutes) */
|
|
809
|
-
expiresInSeconds?: number;
|
|
810
|
-
/** Dark mode override (true=dark, false=light, omit=use store default) */
|
|
811
|
-
darkMode?: boolean;
|
|
812
|
-
/** Custom metadata */
|
|
813
|
-
metadata?: Record<string, string>;
|
|
814
799
|
}
|
|
815
800
|
/**
|
|
816
801
|
* Result of an authenticated checkout creation.
|
|
@@ -1157,7 +1142,8 @@ declare class BuyerGraphQL {
|
|
|
1157
1142
|
/**
|
|
1158
1143
|
* Anonymous checkout — no buyer identity provided.
|
|
1159
1144
|
*
|
|
1160
|
-
* The buyer
|
|
1145
|
+
* The buyer reaches the checkout page without a session token. Merchants may still
|
|
1146
|
+
* pre-fill `buyerEmail` and `billingDetail` on the page by passing them here.
|
|
1161
1147
|
* Internally creates a checkout session and returns the redirect URL.
|
|
1162
1148
|
*/
|
|
1163
1149
|
declare class CheckoutAnonymousResource {
|
|
@@ -1170,11 +1156,20 @@ declare class CheckoutAnonymousResource {
|
|
|
1170
1156
|
* @returns Session ID, checkout URL, and expiration
|
|
1171
1157
|
*
|
|
1172
1158
|
* @example
|
|
1159
|
+
* // Minimal — buyer fills everything on the page
|
|
1173
1160
|
* const result = await client.checkout.anonymous.create({
|
|
1174
1161
|
* productId: "PROD_xxx",
|
|
1175
1162
|
* currency: "USD",
|
|
1176
1163
|
* });
|
|
1177
|
-
*
|
|
1164
|
+
*
|
|
1165
|
+
* @example
|
|
1166
|
+
* // Pre-fill email and billing without issuing a session token
|
|
1167
|
+
* const result = await client.checkout.anonymous.create({
|
|
1168
|
+
* productId: "PROD_xxx",
|
|
1169
|
+
* currency: "USD",
|
|
1170
|
+
* buyerEmail: "customer@example.com",
|
|
1171
|
+
* billingDetail: { country: "US", isBusiness: false, postcode: "10001" },
|
|
1172
|
+
* });
|
|
1178
1173
|
*/
|
|
1179
1174
|
create(params: AnonymousCheckoutParams): Promise<CheckoutSessionResult>;
|
|
1180
1175
|
}
|
|
@@ -1193,10 +1188,12 @@ declare class CheckoutAuthenticatedResource {
|
|
|
1193
1188
|
* Create an authenticated checkout session.
|
|
1194
1189
|
*
|
|
1195
1190
|
* Behavior:
|
|
1196
|
-
* - Issues a session token via `issue-session-token`
|
|
1197
|
-
* - Creates a checkout session via `create-session`
|
|
1198
|
-
* - Appends the token to the checkout URL as a URL fragment
|
|
1199
|
-
*
|
|
1191
|
+
* - Issues a session token via `issue-session-token` (receives `buyerIdentity` + `productId` only)
|
|
1192
|
+
* - Creates a checkout session via `create-session` (receives every other field unchanged)
|
|
1193
|
+
* - Appends the token to the checkout URL as a URL fragment (`#token=...`)
|
|
1194
|
+
*
|
|
1195
|
+
* `buyerIdentity` and `buyerEmail` are independent inputs: identity is for the JWT,
|
|
1196
|
+
* email is for pre-filling the checkout page. The SDK forwards each to its own endpoint.
|
|
1200
1197
|
*
|
|
1201
1198
|
* @param params - Checkout parameters including buyer identity
|
|
1202
1199
|
* @returns Session details with token-appended checkout URL
|
|
@@ -1205,7 +1202,8 @@ declare class CheckoutAuthenticatedResource {
|
|
|
1205
1202
|
* const result = await client.checkout.authenticated.create({
|
|
1206
1203
|
* productId: "PROD_xxx",
|
|
1207
1204
|
* currency: "USD",
|
|
1208
|
-
* buyerIdentity: "
|
|
1205
|
+
* buyerIdentity: "user-123",
|
|
1206
|
+
* buyerEmail: "customer@example.com",
|
|
1209
1207
|
* });
|
|
1210
1208
|
* // Redirect to result.checkoutUrl (includes #token=...)
|
|
1211
1209
|
*/
|
|
@@ -1233,7 +1231,8 @@ declare class CheckoutAuthenticatedResource {
|
|
|
1233
1231
|
* const result = await client.checkout.authenticated.create({
|
|
1234
1232
|
* productId: "PROD_xxx",
|
|
1235
1233
|
* currency: "USD",
|
|
1236
|
-
* buyerIdentity: "
|
|
1234
|
+
* buyerIdentity: "userIdInYourSystem",
|
|
1235
|
+
* buyerEmail: "customer@example.com",
|
|
1237
1236
|
* });
|
|
1238
1237
|
* // result.checkoutUrl includes #token=...
|
|
1239
1238
|
*/
|
|
@@ -1449,14 +1448,26 @@ declare class StoresResource {
|
|
|
1449
1448
|
/**
|
|
1450
1449
|
* Update an existing store's settings.
|
|
1451
1450
|
*
|
|
1451
|
+
* Settings objects (`webhookSettings`, `notificationSettings`, `checkoutSettings`)
|
|
1452
|
+
* support partial updates: omitted sub-fields keep existing values, `null` clears
|
|
1453
|
+
* a field. Pass the entire settings object as `null` to clear all fields.
|
|
1454
|
+
*
|
|
1452
1455
|
* @param params - Fields to update (only provided fields are changed)
|
|
1453
1456
|
* @returns Updated store entity
|
|
1454
1457
|
*
|
|
1455
1458
|
* @example
|
|
1459
|
+
* // Update name
|
|
1456
1460
|
* const { store } = await client.stores.update({
|
|
1457
1461
|
* id: "STO_xxx",
|
|
1458
1462
|
* name: "Updated Name",
|
|
1459
1463
|
* });
|
|
1464
|
+
*
|
|
1465
|
+
* @example
|
|
1466
|
+
* // Clear test webhook URL while keeping other webhook settings
|
|
1467
|
+
* const { store } = await client.stores.update({
|
|
1468
|
+
* id: "STO_xxx",
|
|
1469
|
+
* webhookSettings: { testWebhookUrl: null },
|
|
1470
|
+
* });
|
|
1460
1471
|
*/
|
|
1461
1472
|
update(params: UpdateStoreParams): Promise<{
|
|
1462
1473
|
store: Store;
|
package/dist/index.js
CHANGED
|
@@ -464,11 +464,20 @@ var CheckoutAnonymousResource = class {
|
|
|
464
464
|
* @returns Session ID, checkout URL, and expiration
|
|
465
465
|
*
|
|
466
466
|
* @example
|
|
467
|
+
* // Minimal — buyer fills everything on the page
|
|
467
468
|
* const result = await client.checkout.anonymous.create({
|
|
468
469
|
* productId: "PROD_xxx",
|
|
469
470
|
* currency: "USD",
|
|
470
471
|
* });
|
|
471
|
-
*
|
|
472
|
+
*
|
|
473
|
+
* @example
|
|
474
|
+
* // Pre-fill email and billing without issuing a session token
|
|
475
|
+
* const result = await client.checkout.anonymous.create({
|
|
476
|
+
* productId: "PROD_xxx",
|
|
477
|
+
* currency: "USD",
|
|
478
|
+
* buyerEmail: "customer@example.com",
|
|
479
|
+
* billingDetail: { country: "US", isBusiness: false, postcode: "10001" },
|
|
480
|
+
* });
|
|
472
481
|
*/
|
|
473
482
|
async create(params) {
|
|
474
483
|
validateCheckoutCommon(params);
|
|
@@ -485,10 +494,12 @@ var CheckoutAuthenticatedResource = class {
|
|
|
485
494
|
* Create an authenticated checkout session.
|
|
486
495
|
*
|
|
487
496
|
* Behavior:
|
|
488
|
-
* - Issues a session token via `issue-session-token`
|
|
489
|
-
* - Creates a checkout session via `create-session`
|
|
490
|
-
* - Appends the token to the checkout URL as a URL fragment
|
|
491
|
-
*
|
|
497
|
+
* - Issues a session token via `issue-session-token` (receives `buyerIdentity` + `productId` only)
|
|
498
|
+
* - Creates a checkout session via `create-session` (receives every other field unchanged)
|
|
499
|
+
* - Appends the token to the checkout URL as a URL fragment (`#token=...`)
|
|
500
|
+
*
|
|
501
|
+
* `buyerIdentity` and `buyerEmail` are independent inputs: identity is for the JWT,
|
|
502
|
+
* email is for pre-filling the checkout page. The SDK forwards each to its own endpoint.
|
|
492
503
|
*
|
|
493
504
|
* @param params - Checkout parameters including buyer identity
|
|
494
505
|
* @returns Session details with token-appended checkout URL
|
|
@@ -497,14 +508,15 @@ var CheckoutAuthenticatedResource = class {
|
|
|
497
508
|
* const result = await client.checkout.authenticated.create({
|
|
498
509
|
* productId: "PROD_xxx",
|
|
499
510
|
* currency: "USD",
|
|
500
|
-
* buyerIdentity: "
|
|
511
|
+
* buyerIdentity: "user-123",
|
|
512
|
+
* buyerEmail: "customer@example.com",
|
|
501
513
|
* });
|
|
502
514
|
* // Redirect to result.checkoutUrl (includes #token=...)
|
|
503
515
|
*/
|
|
504
516
|
async create(params) {
|
|
505
517
|
validateCheckoutCommon(params);
|
|
506
518
|
validateRequired("buyerIdentity", params.buyerIdentity);
|
|
507
|
-
const { buyerIdentity,
|
|
519
|
+
const { buyerIdentity, ...sessionParams } = params;
|
|
508
520
|
const [tokenResult, sessionResult] = await Promise.all([
|
|
509
521
|
this.http.post(
|
|
510
522
|
"/v1/actions/auth/issue-session-token",
|
|
@@ -514,14 +526,7 @@ var CheckoutAuthenticatedResource = class {
|
|
|
514
526
|
},
|
|
515
527
|
{ idempotencyWindow: 60 }
|
|
516
528
|
),
|
|
517
|
-
this.http.post(
|
|
518
|
-
"/v1/actions/checkout/create-session",
|
|
519
|
-
{
|
|
520
|
-
...sessionFields,
|
|
521
|
-
buyerEmail: buyerEmail ?? buyerIdentity
|
|
522
|
-
},
|
|
523
|
-
{ idempotencyWindow: 60 }
|
|
524
|
-
)
|
|
529
|
+
this.http.post("/v1/actions/checkout/create-session", sessionParams, { idempotencyWindow: 60 })
|
|
525
530
|
]);
|
|
526
531
|
return {
|
|
527
532
|
sessionId: sessionResult.sessionId,
|
|
@@ -786,14 +791,26 @@ var StoresResource = class {
|
|
|
786
791
|
/**
|
|
787
792
|
* Update an existing store's settings.
|
|
788
793
|
*
|
|
794
|
+
* Settings objects (`webhookSettings`, `notificationSettings`, `checkoutSettings`)
|
|
795
|
+
* support partial updates: omitted sub-fields keep existing values, `null` clears
|
|
796
|
+
* a field. Pass the entire settings object as `null` to clear all fields.
|
|
797
|
+
*
|
|
789
798
|
* @param params - Fields to update (only provided fields are changed)
|
|
790
799
|
* @returns Updated store entity
|
|
791
800
|
*
|
|
792
801
|
* @example
|
|
802
|
+
* // Update name
|
|
793
803
|
* const { store } = await client.stores.update({
|
|
794
804
|
* id: "STO_xxx",
|
|
795
805
|
* name: "Updated Name",
|
|
796
806
|
* });
|
|
807
|
+
*
|
|
808
|
+
* @example
|
|
809
|
+
* // Clear test webhook URL while keeping other webhook settings
|
|
810
|
+
* const { store } = await client.stores.update({
|
|
811
|
+
* id: "STO_xxx",
|
|
812
|
+
* webhookSettings: { testWebhookUrl: null },
|
|
813
|
+
* });
|
|
797
814
|
*/
|
|
798
815
|
async update(params) {
|
|
799
816
|
validateShortId("id", params.id, "STO");
|