@waffo/pancake-ts 0.3.4 → 0.4.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/CHANGELOG.md CHANGED
@@ -4,6 +4,31 @@ 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.4.1] - 2026-04-15
8
+
9
+ ### Changed
10
+
11
+ - **`RefundTicket.versionData` is now structured** — tightened from `Record<string, unknown> | null` to a new `RefundTicketVersionData | null` type matching the GraphQL `RefundTicketVersionData` shape: `{ reason: string; requestedAmount: RequestedAmount | null }`. Aligns with `waffo-pancake-graphql-service` v2026.04.15.1.
12
+
13
+ ### Added
14
+
15
+ - **`RefundTicketVersionData`** — exported type. Reuses the existing `RequestedAmount` for the nested amount field.
16
+
17
+ ## [0.4.0] - 2026-04-15
18
+
19
+ ### Breaking Changes
20
+
21
+ - **`buyerEmail` no longer falls back to `buyerIdentity`** — `checkout.authenticated.create({ buyerIdentity, ... })` used to silently copy `buyerIdentity` into the outgoing `buyerEmail` when the caller omitted `buyerEmail`. It no longer does. `buyerIdentity` is for the JWT (merchant-side buyer identification) and `buyerEmail` is for pre-filling the checkout page's email input; the two fields are fully independent. Migration: if you were passing a non-email `buyerIdentity` (e.g. an internal user ID) and relying on the email input being pre-filled, pass `buyerEmail: user.email` explicitly alongside `buyerIdentity`.
22
+
23
+ ### Changed
24
+
25
+ - **`AnonymousCheckoutParams` widened to full session params** — now accepts `buyerEmail` and `billingDetail` so merchants can pre-fill the checkout page without issuing a session token. Equivalent to `CreateCheckoutSessionParams`.
26
+ - **`AuthenticatedCheckoutParams` restructured** — now extends `CreateCheckoutSessionParams` with a single extra field `buyerIdentity`. Implementation uses destructure-and-forward so `buyerIdentity` can never leak into the create-session payload.
27
+
28
+ ### Documentation
29
+
30
+ - **JSDoc rewrites** — `IssueSessionTokenParams.buyerIdentity`, `AuthenticatedCheckoutParams.buyerIdentity`, and both checkout wrappers now clearly state that `buyerIdentity` is JWT-only and is never rendered on the checkout page.
31
+
7
32
  ## [0.3.4] - 2026-04-14
8
33
 
9
34
  ### Changed
package/README.md CHANGED
@@ -80,19 +80,22 @@ Both modes support **dynamic pricing** and **trial control** at checkout time:
80
80
 
81
81
  The merchant provides buyer identity — the SDK issues a session token, creates a checkout session, and returns a checkout URL with the token appended as a URL fragment. One call does everything.
82
82
 
83
+ `buyerIdentity` is for order attribution and trial tracking only — it is not rendered on the checkout page. To pre-fill the email field on the checkout form, pass `buyerEmail` explicitly.
84
+
83
85
  ```typescript
84
- // Basic — buyer identity only
86
+ // Basic — buyer identity only (checkout page email field stays empty)
85
87
  const result = await client.checkout.authenticated.create({
86
88
  productId: "PROD_xxx",
87
89
  currency: "USD",
88
- buyerIdentity: "customer@example.com",
90
+ buyerIdentity: "userIdInYourSystem",
89
91
  });
90
92
 
91
93
  // With dynamic pricing — override stored price (e.g., coupon, volume discount)
92
94
  const result = await client.checkout.authenticated.create({
93
95
  productId: "PROD_xxx",
94
96
  currency: "USD",
95
- buyerIdentity: "customer@example.com",
97
+ buyerIdentity: "userIdInYourSystem",
98
+ buyerEmail: "customer@example.com",
96
99
  priceSnapshot: { amount: "19.99", taxCategory: "digital_goods" },
97
100
  });
98
101
 
@@ -100,7 +103,8 @@ const result = await client.checkout.authenticated.create({
100
103
  const result = await client.checkout.authenticated.create({
101
104
  productId: "PROD_xxx",
102
105
  currency: "USD",
103
- buyerIdentity: "customer@example.com",
106
+ buyerIdentity: "userIdInYourSystem",
107
+ buyerEmail: "customer@example.com",
104
108
  withTrial: true, // force enable trial (false = skip, omit = default rules)
105
109
  billingDetail: { country: "US", isBusiness: false },
106
110
  });
package/dist/index.cjs CHANGED
@@ -506,11 +506,20 @@ var CheckoutAnonymousResource = class {
506
506
  * @returns Session ID, checkout URL, and expiration
507
507
  *
508
508
  * @example
509
+ * // Minimal — buyer fills everything on the page
509
510
  * const result = await client.checkout.anonymous.create({
510
511
  * productId: "PROD_xxx",
511
512
  * currency: "USD",
512
513
  * });
513
- * // Redirect to result.checkoutUrl
514
+ *
515
+ * @example
516
+ * // Pre-fill email and billing without issuing a session token
517
+ * const result = await client.checkout.anonymous.create({
518
+ * productId: "PROD_xxx",
519
+ * currency: "USD",
520
+ * buyerEmail: "customer@example.com",
521
+ * billingDetail: { country: "US", isBusiness: false, postcode: "10001" },
522
+ * });
514
523
  */
515
524
  async create(params) {
516
525
  validateCheckoutCommon(params);
@@ -527,10 +536,12 @@ var CheckoutAuthenticatedResource = class {
527
536
  * Create an authenticated checkout session.
528
537
  *
529
538
  * Behavior:
530
- * - Issues a session token via `issue-session-token`
531
- * - Creates a checkout session via `create-session`
532
- * - Appends the token to the checkout URL as a URL fragment
533
- * - Defaults `buyerEmail` to `buyerIdentity` when omitted
539
+ * - Issues a session token via `issue-session-token` (receives `buyerIdentity` + `productId` only)
540
+ * - Creates a checkout session via `create-session` (receives every other field unchanged)
541
+ * - Appends the token to the checkout URL as a URL fragment (`#token=...`)
542
+ *
543
+ * `buyerIdentity` and `buyerEmail` are independent inputs: identity is for the JWT,
544
+ * email is for pre-filling the checkout page. The SDK forwards each to its own endpoint.
534
545
  *
535
546
  * @param params - Checkout parameters including buyer identity
536
547
  * @returns Session details with token-appended checkout URL
@@ -539,14 +550,15 @@ var CheckoutAuthenticatedResource = class {
539
550
  * const result = await client.checkout.authenticated.create({
540
551
  * productId: "PROD_xxx",
541
552
  * currency: "USD",
542
- * buyerIdentity: "customer@example.com",
553
+ * buyerIdentity: "user-123",
554
+ * buyerEmail: "customer@example.com",
543
555
  * });
544
556
  * // Redirect to result.checkoutUrl (includes #token=...)
545
557
  */
546
558
  async create(params) {
547
559
  validateCheckoutCommon(params);
548
560
  validateRequired("buyerIdentity", params.buyerIdentity);
549
- const { buyerIdentity, buyerEmail, ...sessionFields } = params;
561
+ const { buyerIdentity, ...sessionParams } = params;
550
562
  const [tokenResult, sessionResult] = await Promise.all([
551
563
  this.http.post(
552
564
  "/v1/actions/auth/issue-session-token",
@@ -556,14 +568,7 @@ var CheckoutAuthenticatedResource = class {
556
568
  },
557
569
  { idempotencyWindow: 60 }
558
570
  ),
559
- this.http.post(
560
- "/v1/actions/checkout/create-session",
561
- {
562
- ...sessionFields,
563
- buyerEmail: buyerEmail ?? buyerIdentity
564
- },
565
- { idempotencyWindow: 60 }
566
- )
571
+ this.http.post("/v1/actions/checkout/create-session", sessionParams, { idempotencyWindow: 60 })
567
572
  ]);
568
573
  return {
569
574
  sessionId: sessionResult.sessionId,