@waffo/pancake-ts 0.3.1 → 0.3.2

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 CHANGED
@@ -4,6 +4,12 @@ All notable changes to `@waffo/pancake-ts` will be documented in this file.
4
4
 
5
5
  Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [0.3.2] - 2026-04-10
8
+
9
+ ### Fixed
10
+
11
+ - **Cloudflare Workers compatibility** — `fetch` is now bound to `globalThis` when no custom `fetch` is provided. Fixes `TypeError: Illegal invocation` in edge runtimes (Cloudflare Workers, Vercel Edge) where unbound `fetch` references lose their `this` context. Affected both `HttpClient` (merchant API Key auth) and `BuyerHttpClient` (session token auth). Users no longer need to pass `{ fetch: globalThis.fetch.bind(globalThis) }` as a workaround.
12
+
7
13
  ## [0.3.1] - 2026-04-09
8
14
 
9
15
  ### Changed
package/README.md CHANGED
@@ -22,15 +22,15 @@ import { WaffoPancake } from "@waffo/pancake-ts";
22
22
 
23
23
  // Merchant ID and API Key are available in Dashboard > Settings > Developers
24
24
  const client = new WaffoPancake({
25
- merchantId: process.env.WAFFO_MERCHANT_ID!, // MER_{base62} format
25
+ merchantId: process.env.WAFFO_MERCHANT_ID!, // MER_{base62} format
26
26
  privateKey: process.env.WAFFO_PRIVATE_KEY!,
27
27
  });
28
28
 
29
29
  // Create a checkout session — one call handles token + session + URL
30
30
  const result = await client.checkout.authenticated.create({
31
- productId: "PROD_xxx", // from Dashboard > Products
31
+ productId: "PROD_xxx", // from Dashboard > Products
32
32
  currency: "USD",
33
- buyerIdentity: req.user.email, // your user's identity
33
+ buyerIdentity: req.user.email, // your user's identity
34
34
  });
35
35
 
36
36
  // Redirect buyer to the checkout page (opens in new tab)
@@ -40,13 +40,13 @@ res.json({ checkoutUrl: result.checkoutUrl });
40
40
 
41
41
  ## Configuration
42
42
 
43
- | Parameter | Type | Required | Description |
44
- |-----------|------|----------|-------------|
45
- | `merchantId` | `string` | Yes | Merchant ID in `MER_{base62}` format |
46
- | `privateKey` | `string` | Yes | RSA private key in PEM format (auto-normalized, see [docs](docs/api-reference.md)) |
47
- | `baseUrl` | `string` | No | API base URL override |
48
- | `fetch` | `typeof fetch` | No | Custom fetch implementation |
49
- | `webhookPublicKey` | `string \| { test?, prod? }` | No | Custom webhook public key(s) |
43
+ | Parameter | Type | Required | Description |
44
+ | ------------------ | ---------------------------- | -------- | ---------------------------------------------------------------------------------- |
45
+ | `merchantId` | `string` | Yes | Merchant ID in `MER_{base62}` format |
46
+ | `privateKey` | `string` | Yes | RSA private key in PEM format (auto-normalized, see [docs](docs/api-reference.md)) |
47
+ | `baseUrl` | `string` | No | API base URL override |
48
+ | `fetch` | `typeof fetch` | No | Custom fetch implementation |
49
+ | `webhookPublicKey` | `string \| { test?, prod? }` | No | Custom webhook public key(s) |
50
50
 
51
51
  The SDK auto-normalizes key formats: standard PEM, PKCS#1, literal `\n` from env vars, raw base64, and Windows line endings are all accepted.
52
52
 
@@ -57,19 +57,19 @@ Waffo supports two checkout modes based on whether the merchant knows the buyer'
57
57
  - **Merchants with their own sites** know who the buyer is — they have user accounts, login systems, or collect buyer info before checkout. The merchant provides the buyer's identity upfront, and the checkout form arrives pre-filled.
58
58
  - **Template stores and shared links** have no prior buyer context — the buyer arrives directly at the checkout page and fills in their own details.
59
59
 
60
- | Mode | Method | Buyer Identity | Form State | Use Case |
61
- |------|--------|---------------|------------|----------|
62
- | **Authenticated** | `checkout.authenticated.create()` | Merchant provides | Pre-filled | Merchant sites with user accounts |
63
- | **Anonymous** | `checkout.anonymous.create()` | Not provided | Empty | Template stores, one-time purchase links |
60
+ | Mode | Method | Buyer Identity | Form State | Use Case |
61
+ | ----------------- | --------------------------------- | ----------------- | ---------- | ---------------------------------------- |
62
+ | **Authenticated** | `checkout.authenticated.create()` | Merchant provides | Pre-filled | Merchant sites with user accounts |
63
+ | **Anonymous** | `checkout.anonymous.create()` | Not provided | Empty | Template stores, one-time purchase links |
64
64
 
65
65
  > **We recommend authenticated checkout whenever possible.** The most important reason: authenticated checkout binds the order to the `buyerIdentity` you provide, which is a **merchant-controlled stable identifier**. Even if the buyer changes the email on the checkout form, the order is still tied to the identity you specified. In anonymous mode, the buyer self-reports their email on the form — if they enter a different address, the system treats them as a new user, which means **previous orders become unlinked** and **subscription trial periods can be exploited** (a new email = a new user = a fresh trial).
66
66
  >
67
- > | | Authenticated | Anonymous |
68
- > |---|---|---|
69
- > | **Identity** | Merchant-provided, stable across orders | Self-reported email, may vary |
70
- > | **Form** | Pre-filled from merchant-provided identity | Empty, buyer fills manually |
67
+ > | | Authenticated | Anonymous |
68
+ > | ----------------- | ----------------------------------------------------------------- | -------------------------------------------------- |
69
+ > | **Identity** | Merchant-provided, stable across orders | Self-reported email, may vary |
70
+ > | **Form** | Pre-filled from merchant-provided identity | Empty, buyer fills manually |
71
71
  > | **Post-purchase** | Full self-service (see [Buyer Self-Service](#buyer-self-service)) | Create orders only — no post-purchase self-service |
72
- > | **Session** | 5-minute TTL, auto-refreshes | 1-minute, single-use |
72
+ > | **Session** | 5-minute TTL, auto-refreshes | 1-minute, single-use |
73
73
 
74
74
  Both modes support **dynamic pricing** and **trial control** at checkout time:
75
75
 
@@ -101,7 +101,7 @@ const result = await client.checkout.authenticated.create({
101
101
  productId: "PROD_xxx",
102
102
  currency: "USD",
103
103
  buyerIdentity: "customer@example.com",
104
- withTrial: true, // force enable trial (false = skip, omit = default rules)
104
+ withTrial: true, // force enable trial (false = skip, omit = default rules)
105
105
  billingDetail: { country: "US", isBusiness: false },
106
106
  });
107
107
 
@@ -126,7 +126,7 @@ const result = await client.checkout.anonymous.create({
126
126
  productId: "PROD_xxx",
127
127
  currency: "USD",
128
128
  priceSnapshot: { amount: "4.99", taxCategory: "saas" },
129
- withTrial: false, // skip trial for this session
129
+ withTrial: false, // skip trial for this session
130
130
  });
131
131
 
132
132
  window.open(result.checkoutUrl, "_blank", "noopener,noreferrer");
@@ -164,10 +164,7 @@ import { verifyWebhook, WebhookEventType } from "@waffo/pancake-ts";
164
164
  // Express (IMPORTANT: use raw body — parsed JSON breaks signature verification)
165
165
  app.post("/webhooks", express.raw({ type: "application/json" }), (req, res) => {
166
166
  try {
167
- const event = verifyWebhook(
168
- req.body.toString("utf-8"),
169
- req.headers["x-waffo-signature"] as string,
170
- );
167
+ const event = verifyWebhook(req.body.toString("utf-8"), req.headers["x-waffo-signature"] as string);
171
168
 
172
169
  // Respond immediately, process asynchronously
173
170
  res.status(200).send("OK");
@@ -417,8 +414,8 @@ try {
417
414
  await client.stores.create({ name: "" });
418
415
  } catch (err) {
419
416
  if (err instanceof WaffoPancakeError) {
420
- console.log(err.status); // 400
421
- console.log(err.errors); // [{ message: "...", layer: "store" }, ...]
417
+ console.log(err.status); // 400
418
+ console.log(err.errors); // [{ message: "...", layer: "store" }, ...]
422
419
  // errors[0] = deepest layer, errors[n] = outermost layer
423
420
  }
424
421
  }
@@ -426,61 +423,61 @@ try {
426
423
 
427
424
  ## Resources
428
425
 
429
- | Namespace | Methods | Description |
430
- |-----------|---------|-------------|
431
- | `client.checkout.authenticated` | `create()` | Authenticated checkout (recommended) |
432
- | `client.checkout.anonymous` | `create()` | Anonymous checkout |
433
- | `client.checkout` | `createSession()` | Low-level checkout session |
434
- | `client.buyer(token)` | `cancelSubscription()` `cancelOnetimeOrder()` `reactivateSubscription()` `createRefundTicket()` `resubmitRefundTicket()` | Buyer self-service |
435
- | `client.buyer(token).graphql` | `query<T>()` | Buyer-scoped GraphQL queries |
436
- | `client.webhooks` | `verify<T>()` | Webhook signature verification |
437
- | `client.graphql` | `query<T>()` | Merchant GraphQL queries |
438
- | `client.auth` | `issueSessionToken()` | Issue a buyer session token (JWT) |
439
- | `client.stores` | `create()` `update()` `delete()` | Store management |
440
- | `client.storeMerchants` | `add()` `remove()` `updateRole()` | Store members (coming soon) |
441
- | `client.onetimeProducts` | `create()` `update()` `publish()` `updateStatus()` | One-time products |
442
- | `client.subscriptionProducts` | `create()` `update()` `publish()` `updateStatus()` | Subscription products |
443
- | `client.subscriptionProductGroups` | `create()` `update()` `delete()` `publish()` | Product groups |
444
- | `client.orders` | `cancelSubscription()` | Order management |
426
+ | Namespace | Methods | Description |
427
+ | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------ |
428
+ | `client.checkout.authenticated` | `create()` | Authenticated checkout (recommended) |
429
+ | `client.checkout.anonymous` | `create()` | Anonymous checkout |
430
+ | `client.checkout` | `createSession()` | Low-level checkout session |
431
+ | `client.buyer(token)` | `cancelSubscription()` `cancelOnetimeOrder()` `reactivateSubscription()` `createRefundTicket()` `resubmitRefundTicket()` | Buyer self-service |
432
+ | `client.buyer(token).graphql` | `query<T>()` | Buyer-scoped GraphQL queries |
433
+ | `client.webhooks` | `verify<T>()` | Webhook signature verification |
434
+ | `client.graphql` | `query<T>()` | Merchant GraphQL queries |
435
+ | `client.auth` | `issueSessionToken()` | Issue a buyer session token (JWT) |
436
+ | `client.stores` | `create()` `update()` `delete()` | Store management |
437
+ | `client.storeMerchants` | `add()` `remove()` `updateRole()` | Store members (coming soon) |
438
+ | `client.onetimeProducts` | `create()` `update()` `publish()` `updateStatus()` | One-time products |
439
+ | `client.subscriptionProducts` | `create()` `update()` `publish()` `updateStatus()` | Subscription products |
440
+ | `client.subscriptionProductGroups` | `create()` `update()` `delete()` `publish()` | Product groups |
441
+ | `client.orders` | `cancelSubscription()` | Order management |
445
442
 
446
443
  ## Documentation
447
444
 
448
- | Document | Content |
449
- |----------|---------|
445
+ | Document | Content |
446
+ | -------------------------------------- | ---------------------------------------------------------------------------- |
450
447
  | [API Reference](docs/api-reference.md) | Complete method reference — parameters, return types, `BillingDetail` fields |
451
- | [GraphQL Guide](docs/graphql-guide.md) | Queries, filters, analytics, introspection, delivery logs |
452
- | [Webhook Guide](docs/webhook-guide.md) | Signature verification, event types, key resolution, retry mechanism |
453
- | [Changelog](CHANGELOG.md) | Version history and migration guides |
448
+ | [GraphQL Guide](docs/graphql-guide.md) | Queries, filters, analytics, introspection, delivery logs |
449
+ | [Webhook Guide](docs/webhook-guide.md) | Signature verification, event types, key resolution, retry mechanism |
450
+ | [Changelog](CHANGELOG.md) | Version history and migration guides |
454
451
 
455
452
  ## Exports
456
453
 
457
454
  ### Classes & Functions
458
455
 
459
- | Export | Description |
460
- |--------|-------------|
461
- | `WaffoPancake` | SDK client with auto-signed requests |
456
+ | Export | Description |
457
+ | ------------------- | ------------------------------------------- |
458
+ | `WaffoPancake` | SDK client with auto-signed requests |
462
459
  | `WaffoPancakeError` | API error with status and call-stack errors |
463
- | `verifyWebhook` | Standalone webhook signature verification |
460
+ | `verifyWebhook` | Standalone webhook signature verification |
464
461
 
465
462
  ### Enums
466
463
 
467
- | Export | Values |
468
- |--------|--------|
469
- | `Environment` | `Test`, `Prod` |
470
- | `TaxCategory` | `DigitalGoods`, `SaaS`, `Software`, `Ebook`, `OnlineCourse`, `Consulting`, `ProfessionalService` |
471
- | `BillingPeriod` | `Weekly`, `Monthly`, `Quarterly`, `Yearly` |
472
- | `ProductVersionStatus` | `Active`, `Inactive` |
473
- | `EntityStatus` | `Active`, `Inactive`, `Suspended` |
474
- | `StoreRole` | `Owner`, `Admin`, `Member` |
475
- | `OnetimeOrderStatus` | `Pending`, `Completed`, `Canceled` |
476
- | `SubscriptionOrderStatus` | `Pending`, `Active`, `Canceling`, `PastDue`, `Closed`, `Canceled`, `Expired` |
477
- | `PaymentStatus` | `Pending`, `Succeeded`, `Failed`, `Canceled` |
478
- | `RefundTicketStatus` | `Pending`, `Approved`, `Rejected`, `Processing`, `Succeeded`, `Failed` |
479
- | `RefundStatus` | `Succeeded`, `Failed` |
480
- | `MediaType` | `Image`, `Video` |
481
- | `CheckoutSessionProductType` | `Onetime`, `Subscription` |
482
- | `ErrorLayer` | `Gateway`, `User`, `Store`, `Product`, `Order`, `Ticket`, `GraphQL`, `Resource`, `Email` |
483
- | `WebhookEventType` | `OrderCompleted`, `SubscriptionActivated`, `SubscriptionPaymentSucceeded`, `SubscriptionCanceling`, `SubscriptionUncanceled`, `SubscriptionUpdated`, `SubscriptionCanceled`, `SubscriptionPastDue`, `RefundSucceeded`, `RefundFailed` |
464
+ | Export | Values |
465
+ | ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
466
+ | `Environment` | `Test`, `Prod` |
467
+ | `TaxCategory` | `DigitalGoods`, `SaaS`, `Software`, `Ebook`, `OnlineCourse`, `Consulting`, `ProfessionalService` |
468
+ | `BillingPeriod` | `Weekly`, `Monthly`, `Quarterly`, `Yearly` |
469
+ | `ProductVersionStatus` | `Active`, `Inactive` |
470
+ | `EntityStatus` | `Active`, `Inactive`, `Suspended` |
471
+ | `StoreRole` | `Owner`, `Admin`, `Member` |
472
+ | `OnetimeOrderStatus` | `Pending`, `Completed`, `Canceled` |
473
+ | `SubscriptionOrderStatus` | `Pending`, `Active`, `Canceling`, `PastDue`, `Closed`, `Canceled`, `Expired` |
474
+ | `PaymentStatus` | `Pending`, `Succeeded`, `Failed`, `Canceled` |
475
+ | `RefundTicketStatus` | `Pending`, `Approved`, `Rejected`, `Processing`, `Succeeded`, `Failed` |
476
+ | `RefundStatus` | `Succeeded`, `Failed` |
477
+ | `MediaType` | `Image`, `Video` |
478
+ | `CheckoutSessionProductType` | `Onetime`, `Subscription` |
479
+ | `ErrorLayer` | `Gateway`, `User`, `Store`, `Product`, `Order`, `Ticket`, `GraphQL`, `Resource`, `Email` |
480
+ | `WebhookEventType` | `OrderCompleted`, `SubscriptionActivated`, `SubscriptionPaymentSucceeded`, `SubscriptionCanceling`, `SubscriptionUncanceled`, `SubscriptionUpdated`, `SubscriptionCanceled`, `SubscriptionPastDue`, `RefundSucceeded`, `RefundFailed` |
484
481
 
485
482
  ### Types
486
483
 
package/dist/index.cjs CHANGED
@@ -62,7 +62,7 @@ var BuyerHttpClient = class {
62
62
  constructor(token, config) {
63
63
  this.token = token;
64
64
  this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
65
- this._fetch = config.fetch ?? fetch;
65
+ this._fetch = config.fetch ?? globalThis.fetch.bind(globalThis);
66
66
  }
67
67
  /**
68
68
  * Send a Bearer-authenticated POST request and return the parsed `data` field.
@@ -77,7 +77,7 @@ var BuyerHttpClient = class {
77
77
  method: "POST",
78
78
  headers: {
79
79
  "Content-Type": "application/json",
80
- "Authorization": `Bearer ${this.token}`
80
+ Authorization: `Bearer ${this.token}`
81
81
  },
82
82
  body: JSON.stringify(body)
83
83
  });
@@ -104,9 +104,7 @@ var PKCS1_PUB_HEADER = "-----BEGIN RSA PUBLIC KEY-----";
104
104
  var PKCS1_PUB_FOOTER = "-----END RSA PUBLIC KEY-----";
105
105
  function normalizePrivateKey(raw) {
106
106
  if (!raw || !raw.trim()) {
107
- throw new Error(
108
- "Private key is empty. Provide an RSA private key in PEM format."
109
- );
107
+ throw new Error("Private key is empty. Provide an RSA private key in PEM format.");
110
108
  }
111
109
  let pem = raw.replace(/\\n/g, "\n").replace(/\r\n/g, "\n");
112
110
  pem = pem.trim();
@@ -116,9 +114,7 @@ function normalizePrivateKey(raw) {
116
114
  if (hasHeader) {
117
115
  const base64 = pem.replace(/-----BEGIN (?:RSA )?PRIVATE KEY-----/g, "").replace(/-----END (?:RSA )?PRIVATE KEY-----/g, "").replace(/\s+/g, "");
118
116
  if (!base64) {
119
- throw new Error(
120
- "Private key contains PEM headers but no key data. Check the key content."
121
- );
117
+ throw new Error("Private key contains PEM headers but no key data. Check the key content.");
122
118
  }
123
119
  const header = hasPkcs1Header ? PKCS1_HEADER : PKCS8_HEADER;
124
120
  const footer = hasPkcs1Header ? PKCS1_FOOTER : PKCS8_FOOTER;
@@ -129,9 +125,7 @@ ${footer}`;
129
125
  } else {
130
126
  const base64 = pem.replace(/\s+/g, "");
131
127
  if (!/^[A-Za-z0-9+/]+=*$/.test(base64)) {
132
- throw new Error(
133
- "Private key is not valid PEM or base64. Expected an RSA private key in PEM format or raw base64."
134
- );
128
+ throw new Error("Private key is not valid PEM or base64. Expected an RSA private key in PEM format or raw base64.");
135
129
  }
136
130
  const wrapped = base64.match(/.{1,64}/g).join("\n");
137
131
  pem = `${PKCS8_HEADER}
@@ -141,17 +135,13 @@ ${PKCS8_FOOTER}`;
141
135
  try {
142
136
  (0, import_node_crypto.createPrivateKey)(pem);
143
137
  } catch {
144
- throw new Error(
145
- "Private key could not be parsed. Ensure it is a valid RSA private key in PKCS#8 or PKCS#1 (PEM) format."
146
- );
138
+ throw new Error("Private key could not be parsed. Ensure it is a valid RSA private key in PKCS#8 or PKCS#1 (PEM) format.");
147
139
  }
148
140
  return pem;
149
141
  }
150
142
  function normalizePublicKey(raw) {
151
143
  if (!raw || !raw.trim()) {
152
- throw new Error(
153
- "Public key is empty. Provide an RSA public key in PEM format."
154
- );
144
+ throw new Error("Public key is empty. Provide an RSA public key in PEM format.");
155
145
  }
156
146
  let pem = raw.replace(/\\n/g, "\n").replace(/\r\n/g, "\n");
157
147
  pem = pem.trim();
@@ -161,9 +151,7 @@ function normalizePublicKey(raw) {
161
151
  if (hasHeader) {
162
152
  const base64 = pem.replace(/-----BEGIN (?:RSA )?PUBLIC KEY-----/g, "").replace(/-----END (?:RSA )?PUBLIC KEY-----/g, "").replace(/\s+/g, "");
163
153
  if (!base64) {
164
- throw new Error(
165
- "Public key contains PEM headers but no key data. Check the key content."
166
- );
154
+ throw new Error("Public key contains PEM headers but no key data. Check the key content.");
167
155
  }
168
156
  const header = hasPkcs1PubHeader ? PKCS1_PUB_HEADER : SPKI_HEADER;
169
157
  const footer = hasPkcs1PubHeader ? PKCS1_PUB_FOOTER : SPKI_FOOTER;
@@ -174,9 +162,7 @@ ${footer}`;
174
162
  } else {
175
163
  const base64 = pem.replace(/\s+/g, "");
176
164
  if (!/^[A-Za-z0-9+/]+=*$/.test(base64)) {
177
- throw new Error(
178
- "Public key is not valid PEM or base64. Expected an RSA public key in PEM format or raw base64."
179
- );
165
+ throw new Error("Public key is not valid PEM or base64. Expected an RSA public key in PEM format or raw base64.");
180
166
  }
181
167
  const wrapped = base64.match(/.{1,64}/g).join("\n");
182
168
  pem = `${SPKI_HEADER}
@@ -186,9 +172,7 @@ ${SPKI_FOOTER}`;
186
172
  try {
187
173
  (0, import_node_crypto.createPublicKey)(pem);
188
174
  } catch {
189
- throw new Error(
190
- "Public key could not be parsed. Ensure it is a valid RSA public key in SPKI or PKCS#1 (PEM) format."
191
- );
175
+ throw new Error("Public key could not be parsed. Ensure it is a valid RSA public key in SPKI or PKCS#1 (PEM) format.");
192
176
  }
193
177
  return pem;
194
178
  }
@@ -214,7 +198,7 @@ var HttpClient = class {
214
198
  this.merchantId = config.merchantId;
215
199
  this.privateKey = normalizePrivateKey(config.privateKey);
216
200
  this.baseUrl = (config.baseUrl ?? DEFAULT_BASE_URL2).replace(/\/+$/, "");
217
- this._fetch = config.fetch ?? fetch;
201
+ this._fetch = config.fetch ?? globalThis.fetch.bind(globalThis);
218
202
  }
219
203
  /**
220
204
  * Send a signed POST request and return the parsed `data` field.
@@ -384,9 +368,7 @@ var AuthResource = class {
384
368
  */
385
369
  async issueSessionToken(params) {
386
370
  if (!params.storeId && !params.productId) {
387
- throw new WaffoPancakeError(400, [
388
- { message: "Missing required field: provide storeId or productId", layer: "sdk" }
389
- ]);
371
+ throw new WaffoPancakeError(400, [{ message: "Missing required field: provide storeId or productId", layer: "sdk" }]);
390
372
  }
391
373
  if (params.storeId) {
392
374
  validateShortId("storeId", params.storeId, "STO");
@@ -419,10 +401,7 @@ var BuyerSession = class {
419
401
  */
420
402
  async cancelSubscription(params) {
421
403
  validateShortId("orderId", params.orderId, "ORD");
422
- return this.http.post(
423
- "/v1/actions/subscription-order/cancel-order",
424
- params
425
- );
404
+ return this.http.post("/v1/actions/subscription-order/cancel-order", params);
426
405
  }
427
406
  /**
428
407
  * Cancel a one-time order (only while payment is still pending).
@@ -435,10 +414,7 @@ var BuyerSession = class {
435
414
  */
436
415
  async cancelOnetimeOrder(params) {
437
416
  validateShortId("orderId", params.orderId, "ORD");
438
- return this.http.post(
439
- "/v1/actions/onetime-order/cancel-order",
440
- params
441
- );
417
+ return this.http.post("/v1/actions/onetime-order/cancel-order", params);
442
418
  }
443
419
  /**
444
420
  * Reactivate a subscription that is in `canceling` status.
@@ -452,10 +428,7 @@ var BuyerSession = class {
452
428
  */
453
429
  async reactivateSubscription(params) {
454
430
  validateShortId("orderId", params.orderId, "ORD");
455
- return this.http.post(
456
- "/v1/actions/subscription-order/reactivate-order",
457
- params
458
- );
431
+ return this.http.post("/v1/actions/subscription-order/reactivate-order", params);
459
432
  }
460
433
  /**
461
434
  * Submit a refund request for a payment.
@@ -475,10 +448,7 @@ var BuyerSession = class {
475
448
  validateRequired("reason", params.reason);
476
449
  validateAmountString("requestedAmount.amount", params.requestedAmount.amount);
477
450
  validateCurrencyCode("requestedAmount.currency", params.requestedAmount.currency);
478
- return this.http.post(
479
- "/v1/actions/refund-ticket/create-ticket",
480
- params
481
- );
451
+ return this.http.post("/v1/actions/refund-ticket/create-ticket", params);
482
452
  }
483
453
  /**
484
454
  * Resubmit a previously rejected refund ticket with updated details.
@@ -500,10 +470,7 @@ var BuyerSession = class {
500
470
  validateRequired("reason", params.reason);
501
471
  validateAmountString("requestedAmount.amount", params.requestedAmount.amount);
502
472
  validateCurrencyCode("requestedAmount.currency", params.requestedAmount.currency);
503
- return this.http.post(
504
- "/v1/actions/refund-ticket/resubmit-ticket",
505
- params
506
- );
473
+ return this.http.post("/v1/actions/refund-ticket/resubmit-ticket", params);
507
474
  }
508
475
  };
509
476
  var BuyerGraphQL = class {
@@ -547,11 +514,7 @@ var CheckoutAnonymousResource = class {
547
514
  */
548
515
  async create(params) {
549
516
  validateCheckoutCommon(params);
550
- return this.http.post(
551
- "/v1/actions/checkout/create-session",
552
- params,
553
- { idempotencyWindow: 60 }
554
- );
517
+ return this.http.post("/v1/actions/checkout/create-session", params, { idempotencyWindow: 60 });
555
518
  }
556
519
  };
557
520
 
@@ -585,14 +548,22 @@ var CheckoutAuthenticatedResource = class {
585
548
  validateRequired("buyerIdentity", params.buyerIdentity);
586
549
  const { buyerIdentity, buyerEmail, ...sessionFields } = params;
587
550
  const [tokenResult, sessionResult] = await Promise.all([
588
- this.http.post("/v1/actions/auth/issue-session-token", {
589
- productId: params.productId,
590
- buyerIdentity
591
- }, { idempotencyWindow: 60 }),
592
- this.http.post("/v1/actions/checkout/create-session", {
593
- ...sessionFields,
594
- buyerEmail: buyerEmail ?? buyerIdentity
595
- }, { idempotencyWindow: 60 })
551
+ this.http.post(
552
+ "/v1/actions/auth/issue-session-token",
553
+ {
554
+ productId: params.productId,
555
+ buyerIdentity
556
+ },
557
+ { idempotencyWindow: 60 }
558
+ ),
559
+ this.http.post(
560
+ "/v1/actions/checkout/create-session",
561
+ {
562
+ ...sessionFields,
563
+ buyerEmail: buyerEmail ?? buyerIdentity
564
+ },
565
+ { idempotencyWindow: 60 }
566
+ )
596
567
  ]);
597
568
  return {
598
569
  sessionId: sessionResult.sessionId,
@@ -1003,7 +974,8 @@ var SubscriptionProductsResource = class {
1003
974
  async update(params) {
1004
975
  validateShortId("id", params.id, "PROD");
1005
976
  if (params.name !== void 0) validateRequired("name", params.name);
1006
- if (params.billingPeriod !== void 0) validateEnum("billingPeriod", params.billingPeriod, ["weekly", "monthly", "quarterly", "yearly"]);
977
+ if (params.billingPeriod !== void 0)
978
+ validateEnum("billingPeriod", params.billingPeriod, ["weekly", "monthly", "quarterly", "yearly"]);
1007
979
  if (params.prices) validatePrices("prices", params.prices);
1008
980
  return this.http.post("/v1/actions/subscription-product/update-product", params);
1009
981
  }