@waffo/pancake-nextjs 0.1.6 → 0.1.7

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-nextjs` 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.1.7] - 2026-05-21
8
+
9
+ ### Changed
10
+
11
+ - **Bumped peer `@waffo/pancake-ts` to `^0.9.0`** to pick up the new flat dual-key external-id fields. The wrapper surfaces these transparently — `CheckoutButton` / `useCheckout` now accept `orderMerchantExternalId`; `useBuyer().createRefundTicket` accepts `refundTicketMerchantExternalId`. See [`@waffo/pancake-ts@0.9.0` CHANGELOG](https://github.com/waffo-com/waffo-pancake-sdk-ts/blob/main/CHANGELOG.md#090---2026-05-21) for the full additive surface.
12
+
7
13
  ## [0.1.6] - 2026-05-17
8
14
 
9
15
  ### Changed
package/README.md CHANGED
@@ -118,6 +118,8 @@ import { checkout } from "./lib/waffo";
118
118
  </CheckoutButton>
119
119
  ```
120
120
 
121
+ Pass an optional `orderMerchantExternalId` to attach your internal order reference — see [Business-Side Identifiers](#business-side-identifiers).
122
+
121
123
  ### Authenticated Checkout (Recommended)
122
124
 
123
125
  Creates a session **and** a token bound to the buyer you provide. `buyerIdentity` is for order attribution and trial tracking — it is not rendered on the checkout page. To pre-fill the email field on the checkout form, pass `buyerEmail` explicitly.
@@ -146,7 +148,7 @@ import { checkout } from "./lib/waffo";
146
148
  Upgrade — $7.99/mo
147
149
  </CheckoutButton>
148
150
 
149
- // Full pre-fill — identity + email + billing + skip trial
151
+ // Full pre-fill — identity + email + billing + skip trial + your internal order ref
150
152
  <CheckoutButton
151
153
  type="authenticated"
152
154
  action={checkout}
@@ -157,6 +159,7 @@ import { checkout } from "./lib/waffo";
157
159
  billingDetail={{ country: "US", isBusiness: true, state: "CA" }}
158
160
  withTrial={false}
159
161
  successUrl="https://example.com/dashboard?upgraded=true"
162
+ orderMerchantExternalId={internalOrderId} // optional, see Business-Side Identifiers below
160
163
  >
161
164
  Skip Trial, Start Now
162
165
  </CheckoutButton>
@@ -217,6 +220,11 @@ export const POST = Webhook({
217
220
  await revokeAccess(event.data.orderId);
218
221
  },
219
222
  onRefundSucceeded: async (event) => {
223
+ // refund.* events carry both business identifiers (see Business-Side Identifiers section)
224
+ await markRefunded({
225
+ orderRef: event.data.orderMerchantExternalId,
226
+ refundTicketRef: event.data.refundTicketMerchantExternalId,
227
+ });
220
228
  await revokeAccess(event.data.orderId);
221
229
  },
222
230
 
@@ -276,6 +284,19 @@ function AccountPage() {
276
284
  {order.product?.name} — {order.status}
277
285
  </p>
278
286
  ))}
287
+
288
+ <button
289
+ onClick={() =>
290
+ buyer.createRefundTicket.execute({
291
+ paymentId: "PAY_xxx",
292
+ reason: "Product not as described",
293
+ requestedAmount: { amount: "29.00", currency: "USD" },
294
+ refundTicketMerchantExternalId: `REF-${Date.now()}`, // optional, see Business-Side Identifiers below
295
+ })
296
+ }
297
+ >
298
+ Request Refund
299
+ </button>
279
300
  </div>
280
301
  );
281
302
  }
@@ -292,6 +313,55 @@ function AccountPage() {
292
313
 
293
314
  Action hooks return `{ execute, isLoading, error, data }`. Data hooks return `{ data, isLoading, error, refetch }`.
294
315
 
316
+ ## Business-Side Identifiers
317
+
318
+ Attach your own internal references to a checkout or a refund ticket so cross-system reconciliation does not require Waffo IDs. Two flat keys, both optional (max 128 chars):
319
+
320
+ | Field | Attach via | Inherited by |
321
+ | -------------------------------- | -------------------------------- | --------------------------------------------- |
322
+ | `orderMerchantExternalId` | `CheckoutButton` / `useCheckout` | `Order`, `Payment` (incl. renewals), `Refund` |
323
+ | `refundTicketMerchantExternalId` | `useBuyer().createRefundTicket` | `RefundTicket`, `Refund` |
324
+
325
+ The same field name appears at every layer: prop / hook param, webhook payload (`event.data.orderMerchantExternalId` / `event.data.refundTicketMerchantExternalId`), and GraphQL types. A `refund.*` webhook event carries **both** keys (order key inherited from the originating order).
326
+
327
+ ```tsx
328
+ // 1. Attach at checkout — value is bound to the order, every payment, and any
329
+ // later refund of this order.
330
+ <CheckoutButton action={checkout} productId="PROD_xxx" currency="USD" orderMerchantExternalId={internalOrderId}>
331
+ Pay {internalOrderId}
332
+ </CheckoutButton>;
333
+
334
+ // 2. Attach at refund-ticket creation — value is bound to the ticket and the
335
+ // refund record once the PSP confirms.
336
+ const buyer = useBuyer();
337
+ await buyer.createRefundTicket.execute({
338
+ paymentId: "PAY_xxx",
339
+ reason: "Product not as described",
340
+ requestedAmount: { amount: "29.00", currency: "USD" },
341
+ refundTicketMerchantExternalId: internalRefundSlipId,
342
+ });
343
+
344
+ // 3. Read back from webhooks — same field name as you wrote.
345
+ export const POST = Webhook({
346
+ onRefundSucceeded: async (event) => {
347
+ await ledger.markRefunded({
348
+ orderRef: event.data.orderMerchantExternalId, // from the originating order
349
+ refundTicketRef: event.data.refundTicketMerchantExternalId, // from the originating refund ticket
350
+ });
351
+ },
352
+ });
353
+
354
+ // 4. Query by reference via the buyer's GraphQL surface — same field name on every type.
355
+ const result = await buyer.query({
356
+ query: `query ($ref: String!) {
357
+ onetimeOrders(filter: { orderMerchantExternalId: { eq: $ref } }) {
358
+ id status orderMerchantExternalId
359
+ }
360
+ }`,
361
+ variables: { ref: internalOrderId },
362
+ });
363
+ ```
364
+
295
365
  ## Merchant Data
296
366
 
297
367
  Pre-built hooks for merchant dashboards. Pass a server action and store ID:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@waffo/pancake-nextjs",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Next.js SDK for Waffo Pancake — checkout components and hooks",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "license": "MIT",
50
50
  "dependencies": {
51
- "@waffo/pancake-ts": "^0.8.0",
51
+ "@waffo/pancake-ts": "^0.9.0",
52
52
  "next": ">=14.0.0",
53
53
  "react": ">=18.0.0",
54
54
  "react-dom": ">=18.0.0"