@waffo/pancake-ts 0.4.1 → 0.5.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 +18 -10
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -1
- package/dist/index.d.ts +47 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/docs/webhook-guide.md +60 -8
- package/package.json +1 -1
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.5.0] - 2026-04-18
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- **Enriched `WebhookEventData`** — webhook payloads now include full transaction chain data. New optional fields organized by section:
|
|
12
|
+
- **Order**: `orderStatus`, `merchantProvidedBuyerIdentity`, `billingDetail`, `orderMetadata`
|
|
13
|
+
- **Amount**: `taxRate`, `taxName`, `subtotal`, `total`
|
|
14
|
+
- **Product**: `productDescription`, `productMetadata`
|
|
15
|
+
- **Payment** (payment events only): `paymentId`, `paymentStatus`, `paymentMethod`, `paymentLast4`, `paymentFailureReason`, `paymentDate`
|
|
16
|
+
- **Subscription** (subscription events only): `billingPeriod`, `currentPeriodStart`, `currentPeriodEnd`, `canceledAt`
|
|
17
|
+
- **Refund** (refund events only): `refundStatus`, `refundReason`, `refundCreatedAt`
|
|
18
|
+
- All new fields are optional — existing webhook handlers continue to work without changes.
|
|
19
|
+
|
|
20
|
+
### Documentation
|
|
21
|
+
|
|
22
|
+
- **Webhook guide** — updated `WebhookEventData` field reference with sectioned layout and conditional field documentation.
|
|
23
|
+
- **README** — expanded webhook verification example showing new fields.
|
|
24
|
+
|
|
25
|
+
## [0.4.2] - 2026-04-16
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- **`merchantId` validated at construction** — `WaffoPancake` constructor now validates that `merchantId` matches `MER_{base62}` format (exactly 22 base62 characters after prefix). Previously, malformed values like `MER_1XdxrN8hqc5jBMAnWvVm1W1` (23 chars) or `merchant-123` were silently accepted, passed through to the gateway, and caused cryptic 500 errors from the database layer. Invalid formats now throw `WaffoPancakeError` (`status: 400`, `layer: "sdk"`) immediately.
|
|
30
|
+
- **Short ID regex tightened** — All `validateShortId()` checks (affecting `storeId`, `productId`, `orderId`, `paymentId`, `ticketId`, `merchantId`) now enforce exactly 22 base62 characters after the prefix, matching the server-side format. The previous regex (`/[A-Za-z0-9]+/`) accepted any length.
|
|
31
|
+
|
|
7
32
|
## [0.4.1] - 2026-04-15
|
|
8
33
|
|
|
9
34
|
### Changed
|
package/README.md
CHANGED
|
@@ -158,7 +158,7 @@ See [API Reference — Checkout](docs/api-reference.md#checkout) for full parame
|
|
|
158
158
|
|
|
159
159
|
## Webhook Verification
|
|
160
160
|
|
|
161
|
-
After a buyer completes payment, Waffo sends webhook events to your server. The SDK provides two ways to verify signatures:
|
|
161
|
+
After a buyer completes payment, Waffo sends webhook events to your server with rich data including order details, amounts, product info, and event-specific fields (payment, subscription, or refund). The SDK provides two ways to verify signatures:
|
|
162
162
|
|
|
163
163
|
### Standalone Function (built-in keys)
|
|
164
164
|
|
|
@@ -175,10 +175,17 @@ app.post("/webhooks", express.raw({ type: "application/json" }), (req, res) => {
|
|
|
175
175
|
|
|
176
176
|
switch (event.eventType) {
|
|
177
177
|
case WebhookEventType.OrderCompleted:
|
|
178
|
-
|
|
178
|
+
// Rich data: order, amount, product, payment fields
|
|
179
|
+
console.log(`Order ${event.data.orderId} completed — ${event.data.total} ${event.data.currency}`);
|
|
180
|
+
console.log(`Product: ${event.data.productName}, Buyer: ${event.data.buyerEmail}`);
|
|
181
|
+
if (event.data.orderMetadata) console.log("Metadata:", event.data.orderMetadata);
|
|
179
182
|
break;
|
|
180
183
|
case WebhookEventType.SubscriptionActivated:
|
|
181
184
|
console.log(`Subscription activated for ${event.data.buyerEmail}`);
|
|
185
|
+
console.log(`Period: ${event.data.billingPeriod}, ends ${event.data.currentPeriodEnd}`);
|
|
186
|
+
break;
|
|
187
|
+
case WebhookEventType.RefundSucceeded:
|
|
188
|
+
console.log(`Refund succeeded: ${event.data.refundReason}`);
|
|
182
189
|
break;
|
|
183
190
|
}
|
|
184
191
|
} catch {
|
|
@@ -213,7 +220,7 @@ const client = new WaffoPancake({
|
|
|
213
220
|
const event = client.webhooks.verify(rawBody, sig, { environment: "prod" });
|
|
214
221
|
```
|
|
215
222
|
|
|
216
|
-
See [Webhook Guide](docs/webhook-guide.md) for event types, dual-environment key architecture, key resolution chain, retry mechanism, and best practices.
|
|
223
|
+
See [Webhook Guide](docs/webhook-guide.md) for event types, `WebhookEventData` field reference, dual-environment key architecture, key resolution chain, retry mechanism, and best practices.
|
|
217
224
|
|
|
218
225
|
## Buyer Self-Service
|
|
219
226
|
|
|
@@ -446,12 +453,12 @@ try {
|
|
|
446
453
|
|
|
447
454
|
## Documentation
|
|
448
455
|
|
|
449
|
-
| Document | Content
|
|
450
|
-
| -------------------------------------- |
|
|
451
|
-
| [API Reference](docs/api-reference.md) | Complete method reference — parameters, return types, `BillingDetail` fields
|
|
452
|
-
| [GraphQL Guide](docs/graphql-guide.md) | Queries, filters, analytics, introspection, delivery logs
|
|
453
|
-
| [Webhook Guide](docs/webhook-guide.md) | Signature verification, event types, key resolution, retry mechanism
|
|
454
|
-
| [Changelog](CHANGELOG.md) | Version history and migration guides
|
|
456
|
+
| Document | Content |
|
|
457
|
+
| -------------------------------------- | --------------------------------------------------------------------------------------- |
|
|
458
|
+
| [API Reference](docs/api-reference.md) | Complete method reference — parameters, return types, `BillingDetail` fields |
|
|
459
|
+
| [GraphQL Guide](docs/graphql-guide.md) | Queries, filters, analytics, introspection, delivery logs |
|
|
460
|
+
| [Webhook Guide](docs/webhook-guide.md) | Signature verification, event types, event data fields, key resolution, retry mechanism |
|
|
461
|
+
| [Changelog](CHANGELOG.md) | Version history and migration guides |
|
|
455
462
|
|
|
456
463
|
## Exports
|
|
457
464
|
|
|
@@ -485,7 +492,7 @@ try {
|
|
|
485
492
|
|
|
486
493
|
### Types
|
|
487
494
|
|
|
488
|
-
Key types: `WaffoPancakeConfig`, `AuthenticatedCheckoutParams`, `AuthenticatedCheckoutResult`, `AnonymousCheckoutParams`, `CheckoutSessionResult`, `Store`, `OnetimeProductDetail`, `SubscriptionProductDetail`, `WebhookEvent<T>`, `GraphQLResponse<T>`, and 30+ more. See [API Reference](docs/api-reference.md#types) for the full list.
|
|
495
|
+
Key types: `WaffoPancakeConfig`, `AuthenticatedCheckoutParams`, `AuthenticatedCheckoutResult`, `AnonymousCheckoutParams`, `CheckoutSessionResult`, `Store`, `OnetimeProductDetail`, `SubscriptionProductDetail`, `WebhookEvent<T>`, `WebhookEventData`, `GraphQLResponse<T>`, and 30+ more. `WebhookEventData` includes rich fields organized by section: order info, amounts, product, payment, subscription, and refund (conditional by event type). See [API Reference](docs/api-reference.md#types) for the full list.
|
|
489
496
|
|
|
490
497
|
## Development
|
|
491
498
|
|
|
@@ -508,6 +515,7 @@ src/
|
|
|
508
515
|
├── signing.ts # RSA-SHA256 request signing
|
|
509
516
|
├── errors.ts # WaffoPancakeError
|
|
510
517
|
├── webhooks.ts # Webhook verification (embedded keys)
|
|
518
|
+
├── validation.ts # Client-side input validation
|
|
511
519
|
├── types.ts # Type definitions & enums
|
|
512
520
|
├── __tests__/ # Test suite
|
|
513
521
|
└── resources/ # API resource classes
|
package/dist/index.cjs
CHANGED
|
@@ -245,7 +245,7 @@ var HttpClient = class {
|
|
|
245
245
|
};
|
|
246
246
|
|
|
247
247
|
// src/validation.ts
|
|
248
|
-
var SHORT_ID_REGEX = /^[A-Z]{2,
|
|
248
|
+
var SHORT_ID_REGEX = /^[A-Z]{2,5}_[0-9A-Za-z]{22}$/;
|
|
249
249
|
var CURRENCY_CODE_REGEX = /^[A-Z]{3}$/;
|
|
250
250
|
var COUNTRY_CODE_REGEX = /^[A-Z]{2}$/;
|
|
251
251
|
var AMOUNT_STRING_REGEX = /^\d+(\.\d+)?$/;
|
|
@@ -1187,6 +1187,7 @@ var WaffoPancake = class {
|
|
|
1187
1187
|
graphql;
|
|
1188
1188
|
webhooks;
|
|
1189
1189
|
constructor(config) {
|
|
1190
|
+
validateShortId("merchantId", config.merchantId, "MER");
|
|
1190
1191
|
this.config = config;
|
|
1191
1192
|
this.http = new HttpClient(config);
|
|
1192
1193
|
this.auth = new AuthResource(this.http);
|