@waffo/pancake-ts 0.19.0 → 0.20.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 +20 -0
- package/README.md +17 -17
- package/dist/index.cjs +22 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +39 -10
- package/dist/index.d.ts +39 -10
- package/dist/index.js +22 -4
- package/dist/index.js.map +1 -1
- package/docs/webhook-guide.md +45 -13
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -177,7 +177,7 @@ declare enum OnetimeOrderStatus {
|
|
|
177
177
|
* - pending -> active, canceled, closed (PSP CLOSE from never-activated)
|
|
178
178
|
* - active -> canceling, past_due, canceled, expired
|
|
179
179
|
* - canceling -> active, canceled
|
|
180
|
-
* - past_due -> active, canceled
|
|
180
|
+
* - past_due -> active, canceling, canceled
|
|
181
181
|
* - closed -> terminal (never-activated subscription closed by PSP)
|
|
182
182
|
* - canceled -> terminal
|
|
183
183
|
* - expired -> terminal
|
|
@@ -353,6 +353,8 @@ interface NotificationSettings {
|
|
|
353
353
|
emailTrialStarted: boolean;
|
|
354
354
|
emailTrialEnding: boolean;
|
|
355
355
|
emailUpcomingCharge: boolean;
|
|
356
|
+
/** One toggle for all three plan-change customer emails (scheduled / failed / applied) */
|
|
357
|
+
emailSubscriptionPlanChanged: boolean;
|
|
356
358
|
notifyNewOrders: boolean;
|
|
357
359
|
notifyNewSubscriptions: boolean;
|
|
358
360
|
notifySubscriptionCanceled: boolean;
|
|
@@ -360,7 +362,7 @@ interface NotificationSettings {
|
|
|
360
362
|
notifySubscriptionPastDue: boolean;
|
|
361
363
|
notifySubscriptionRenewed: boolean;
|
|
362
364
|
notifySubscriptionUncanceled: boolean;
|
|
363
|
-
|
|
365
|
+
notifySubscriptionPlanChanged: boolean;
|
|
364
366
|
notifyChargeback: boolean;
|
|
365
367
|
}
|
|
366
368
|
/**
|
|
@@ -371,7 +373,7 @@ interface NotificationSettings {
|
|
|
371
373
|
* endpoint if included. Payout result notifications are platform-managed and always
|
|
372
374
|
* delivered — they have no toggle key. Use this type for any merchant-side update.
|
|
373
375
|
*/
|
|
374
|
-
type MerchantWritableNotificationSettings = Pick<NotificationSettings, "notifyNewOrders" | "notifyNewSubscriptions" | "notifySubscriptionCanceled" | "notifySubscriptionEnded" | "notifySubscriptionPastDue" | "notifySubscriptionRenewed" | "notifySubscriptionUncanceled" | "
|
|
376
|
+
type MerchantWritableNotificationSettings = Pick<NotificationSettings, "notifyNewOrders" | "notifyNewSubscriptions" | "notifySubscriptionCanceled" | "notifySubscriptionEnded" | "notifySubscriptionPastDue" | "notifySubscriptionRenewed" | "notifySubscriptionUncanceled" | "notifySubscriptionPlanChanged" | "notifyChargeback">;
|
|
375
377
|
/**
|
|
376
378
|
* Single-theme checkout page styling.
|
|
377
379
|
* @see docs/api-reference/endpoints/stores/overview.mdx
|
|
@@ -1034,14 +1036,22 @@ declare enum WebhookEventType {
|
|
|
1034
1036
|
OrderCompleted = "order.completed",
|
|
1035
1037
|
/** Subscription first payment succeeded (newly activated) */
|
|
1036
1038
|
SubscriptionActivated = "subscription.activated",
|
|
1037
|
-
/** Subscription
|
|
1039
|
+
/** Subscription payment succeeded — a pure payment event, carries no subscription period or status */
|
|
1038
1040
|
SubscriptionPaymentSucceeded = "subscription.payment_succeeded",
|
|
1041
|
+
/** Current billing period rolled forward (renewal) */
|
|
1042
|
+
SubscriptionRenewed = "subscription.renewed",
|
|
1043
|
+
/** Subscription recovered from past due (a retried charge succeeded) */
|
|
1044
|
+
SubscriptionRecovered = "subscription.recovered",
|
|
1045
|
+
/** Plan change took effect (upgrade/downgrade) */
|
|
1046
|
+
SubscriptionPlanChanged = "subscription.plan_changed",
|
|
1047
|
+
/** Plan change confirmed, takes effect next billing period */
|
|
1048
|
+
SubscriptionPlanChangeScheduled = "subscription.plan_change_scheduled",
|
|
1049
|
+
/** Plan change did not complete, the current plan stays in effect */
|
|
1050
|
+
SubscriptionPlanChangeFailed = "subscription.plan_change_failed",
|
|
1039
1051
|
/** Customer initiated cancellation (expires at end of current period) */
|
|
1040
1052
|
SubscriptionCanceling = "subscription.canceling",
|
|
1041
1053
|
/** Customer withdrew cancellation (subscription restored) */
|
|
1042
1054
|
SubscriptionUncanceled = "subscription.uncanceled",
|
|
1043
|
-
/** Subscription product changed (upgrade/downgrade) */
|
|
1044
|
-
SubscriptionUpdated = "subscription.updated",
|
|
1045
1055
|
/** Subscription fully terminated */
|
|
1046
1056
|
SubscriptionCanceled = "subscription.canceled",
|
|
1047
1057
|
/** Renewal payment failed (past due) */
|
|
@@ -1057,7 +1067,12 @@ declare enum WebhookEventType {
|
|
|
1057
1067
|
*/
|
|
1058
1068
|
interface WebhookEventData {
|
|
1059
1069
|
orderId: string;
|
|
1060
|
-
/**
|
|
1070
|
+
/**
|
|
1071
|
+
* Order status (e.g., "completed", "active", "canceling").
|
|
1072
|
+
*
|
|
1073
|
+
* Absent on `subscription.payment_succeeded` — that event describes one charge only.
|
|
1074
|
+
* Read the subscription's status from the subscription events instead.
|
|
1075
|
+
*/
|
|
1061
1076
|
orderStatus?: string;
|
|
1062
1077
|
buyerEmail: string;
|
|
1063
1078
|
/** Merchant-provided customer identity from checkout session */
|
|
@@ -1571,7 +1586,9 @@ declare class CustomerSession {
|
|
|
1571
1586
|
*
|
|
1572
1587
|
* @example
|
|
1573
1588
|
* const { orderId, status } = await customer.cancelSubscription({ orderId: "ORD_xxx" });
|
|
1574
|
-
* // status: "canceled" (was pending)
|
|
1589
|
+
* // status: "canceled" (was pending)
|
|
1590
|
+
* // or "canceling" (was active — stops at the end of the current period)
|
|
1591
|
+
* // or "canceling" (was past_due — stops immediately)
|
|
1575
1592
|
*/
|
|
1576
1593
|
cancelSubscription(params: CancelSubscriptionParams): Promise<CancelSubscriptionResult & {
|
|
1577
1594
|
warnings?: Notice[];
|
|
@@ -1591,6 +1608,12 @@ declare class CustomerSession {
|
|
|
1591
1608
|
/**
|
|
1592
1609
|
* Reactivate a subscription that is in `canceling` status.
|
|
1593
1610
|
*
|
|
1611
|
+
* A subscription that had an unpaid charge at the moment cancellation was
|
|
1612
|
+
* requested is refused with 400 (`Subscription with an unpaid balance cannot
|
|
1613
|
+
* be reactivated`), which is worded differently from the 400 returned when
|
|
1614
|
+
* the order is not in `canceling` status. Cancelling a `past_due`
|
|
1615
|
+
* subscription always falls into the former category.
|
|
1616
|
+
*
|
|
1594
1617
|
* @param params - Order to reactivate
|
|
1595
1618
|
* @returns Order ID and resulting status
|
|
1596
1619
|
*
|
|
@@ -1766,8 +1789,14 @@ declare class OrdersResource {
|
|
|
1766
1789
|
/**
|
|
1767
1790
|
* Cancel a subscription order.
|
|
1768
1791
|
*
|
|
1769
|
-
* - pending -> canceled (immediate)
|
|
1770
|
-
* - active/trialing -> canceling (PSP cancel
|
|
1792
|
+
* - pending -> canceled (immediate, no PSP call)
|
|
1793
|
+
* - active/trialing -> canceling (PSP cancel scheduled for the end of the
|
|
1794
|
+
* current billing period; the subscription stays usable until then)
|
|
1795
|
+
* - past_due -> canceling (PSP cancel dispatched immediately; the billing
|
|
1796
|
+
* period has already lapsed, so nothing is left to use)
|
|
1797
|
+
*
|
|
1798
|
+
* In both canceling cases the terminal `canceled` status is written when the
|
|
1799
|
+
* PSP cancellation webhook arrives, not by this call.
|
|
1771
1800
|
*
|
|
1772
1801
|
* @param params - Order to cancel
|
|
1773
1802
|
* @returns Order ID and resulting status
|
package/dist/index.d.ts
CHANGED
|
@@ -177,7 +177,7 @@ declare enum OnetimeOrderStatus {
|
|
|
177
177
|
* - pending -> active, canceled, closed (PSP CLOSE from never-activated)
|
|
178
178
|
* - active -> canceling, past_due, canceled, expired
|
|
179
179
|
* - canceling -> active, canceled
|
|
180
|
-
* - past_due -> active, canceled
|
|
180
|
+
* - past_due -> active, canceling, canceled
|
|
181
181
|
* - closed -> terminal (never-activated subscription closed by PSP)
|
|
182
182
|
* - canceled -> terminal
|
|
183
183
|
* - expired -> terminal
|
|
@@ -353,6 +353,8 @@ interface NotificationSettings {
|
|
|
353
353
|
emailTrialStarted: boolean;
|
|
354
354
|
emailTrialEnding: boolean;
|
|
355
355
|
emailUpcomingCharge: boolean;
|
|
356
|
+
/** One toggle for all three plan-change customer emails (scheduled / failed / applied) */
|
|
357
|
+
emailSubscriptionPlanChanged: boolean;
|
|
356
358
|
notifyNewOrders: boolean;
|
|
357
359
|
notifyNewSubscriptions: boolean;
|
|
358
360
|
notifySubscriptionCanceled: boolean;
|
|
@@ -360,7 +362,7 @@ interface NotificationSettings {
|
|
|
360
362
|
notifySubscriptionPastDue: boolean;
|
|
361
363
|
notifySubscriptionRenewed: boolean;
|
|
362
364
|
notifySubscriptionUncanceled: boolean;
|
|
363
|
-
|
|
365
|
+
notifySubscriptionPlanChanged: boolean;
|
|
364
366
|
notifyChargeback: boolean;
|
|
365
367
|
}
|
|
366
368
|
/**
|
|
@@ -371,7 +373,7 @@ interface NotificationSettings {
|
|
|
371
373
|
* endpoint if included. Payout result notifications are platform-managed and always
|
|
372
374
|
* delivered — they have no toggle key. Use this type for any merchant-side update.
|
|
373
375
|
*/
|
|
374
|
-
type MerchantWritableNotificationSettings = Pick<NotificationSettings, "notifyNewOrders" | "notifyNewSubscriptions" | "notifySubscriptionCanceled" | "notifySubscriptionEnded" | "notifySubscriptionPastDue" | "notifySubscriptionRenewed" | "notifySubscriptionUncanceled" | "
|
|
376
|
+
type MerchantWritableNotificationSettings = Pick<NotificationSettings, "notifyNewOrders" | "notifyNewSubscriptions" | "notifySubscriptionCanceled" | "notifySubscriptionEnded" | "notifySubscriptionPastDue" | "notifySubscriptionRenewed" | "notifySubscriptionUncanceled" | "notifySubscriptionPlanChanged" | "notifyChargeback">;
|
|
375
377
|
/**
|
|
376
378
|
* Single-theme checkout page styling.
|
|
377
379
|
* @see docs/api-reference/endpoints/stores/overview.mdx
|
|
@@ -1034,14 +1036,22 @@ declare enum WebhookEventType {
|
|
|
1034
1036
|
OrderCompleted = "order.completed",
|
|
1035
1037
|
/** Subscription first payment succeeded (newly activated) */
|
|
1036
1038
|
SubscriptionActivated = "subscription.activated",
|
|
1037
|
-
/** Subscription
|
|
1039
|
+
/** Subscription payment succeeded — a pure payment event, carries no subscription period or status */
|
|
1038
1040
|
SubscriptionPaymentSucceeded = "subscription.payment_succeeded",
|
|
1041
|
+
/** Current billing period rolled forward (renewal) */
|
|
1042
|
+
SubscriptionRenewed = "subscription.renewed",
|
|
1043
|
+
/** Subscription recovered from past due (a retried charge succeeded) */
|
|
1044
|
+
SubscriptionRecovered = "subscription.recovered",
|
|
1045
|
+
/** Plan change took effect (upgrade/downgrade) */
|
|
1046
|
+
SubscriptionPlanChanged = "subscription.plan_changed",
|
|
1047
|
+
/** Plan change confirmed, takes effect next billing period */
|
|
1048
|
+
SubscriptionPlanChangeScheduled = "subscription.plan_change_scheduled",
|
|
1049
|
+
/** Plan change did not complete, the current plan stays in effect */
|
|
1050
|
+
SubscriptionPlanChangeFailed = "subscription.plan_change_failed",
|
|
1039
1051
|
/** Customer initiated cancellation (expires at end of current period) */
|
|
1040
1052
|
SubscriptionCanceling = "subscription.canceling",
|
|
1041
1053
|
/** Customer withdrew cancellation (subscription restored) */
|
|
1042
1054
|
SubscriptionUncanceled = "subscription.uncanceled",
|
|
1043
|
-
/** Subscription product changed (upgrade/downgrade) */
|
|
1044
|
-
SubscriptionUpdated = "subscription.updated",
|
|
1045
1055
|
/** Subscription fully terminated */
|
|
1046
1056
|
SubscriptionCanceled = "subscription.canceled",
|
|
1047
1057
|
/** Renewal payment failed (past due) */
|
|
@@ -1057,7 +1067,12 @@ declare enum WebhookEventType {
|
|
|
1057
1067
|
*/
|
|
1058
1068
|
interface WebhookEventData {
|
|
1059
1069
|
orderId: string;
|
|
1060
|
-
/**
|
|
1070
|
+
/**
|
|
1071
|
+
* Order status (e.g., "completed", "active", "canceling").
|
|
1072
|
+
*
|
|
1073
|
+
* Absent on `subscription.payment_succeeded` — that event describes one charge only.
|
|
1074
|
+
* Read the subscription's status from the subscription events instead.
|
|
1075
|
+
*/
|
|
1061
1076
|
orderStatus?: string;
|
|
1062
1077
|
buyerEmail: string;
|
|
1063
1078
|
/** Merchant-provided customer identity from checkout session */
|
|
@@ -1571,7 +1586,9 @@ declare class CustomerSession {
|
|
|
1571
1586
|
*
|
|
1572
1587
|
* @example
|
|
1573
1588
|
* const { orderId, status } = await customer.cancelSubscription({ orderId: "ORD_xxx" });
|
|
1574
|
-
* // status: "canceled" (was pending)
|
|
1589
|
+
* // status: "canceled" (was pending)
|
|
1590
|
+
* // or "canceling" (was active — stops at the end of the current period)
|
|
1591
|
+
* // or "canceling" (was past_due — stops immediately)
|
|
1575
1592
|
*/
|
|
1576
1593
|
cancelSubscription(params: CancelSubscriptionParams): Promise<CancelSubscriptionResult & {
|
|
1577
1594
|
warnings?: Notice[];
|
|
@@ -1591,6 +1608,12 @@ declare class CustomerSession {
|
|
|
1591
1608
|
/**
|
|
1592
1609
|
* Reactivate a subscription that is in `canceling` status.
|
|
1593
1610
|
*
|
|
1611
|
+
* A subscription that had an unpaid charge at the moment cancellation was
|
|
1612
|
+
* requested is refused with 400 (`Subscription with an unpaid balance cannot
|
|
1613
|
+
* be reactivated`), which is worded differently from the 400 returned when
|
|
1614
|
+
* the order is not in `canceling` status. Cancelling a `past_due`
|
|
1615
|
+
* subscription always falls into the former category.
|
|
1616
|
+
*
|
|
1594
1617
|
* @param params - Order to reactivate
|
|
1595
1618
|
* @returns Order ID and resulting status
|
|
1596
1619
|
*
|
|
@@ -1766,8 +1789,14 @@ declare class OrdersResource {
|
|
|
1766
1789
|
/**
|
|
1767
1790
|
* Cancel a subscription order.
|
|
1768
1791
|
*
|
|
1769
|
-
* - pending -> canceled (immediate)
|
|
1770
|
-
* - active/trialing -> canceling (PSP cancel
|
|
1792
|
+
* - pending -> canceled (immediate, no PSP call)
|
|
1793
|
+
* - active/trialing -> canceling (PSP cancel scheduled for the end of the
|
|
1794
|
+
* current billing period; the subscription stays usable until then)
|
|
1795
|
+
* - past_due -> canceling (PSP cancel dispatched immediately; the billing
|
|
1796
|
+
* period has already lapsed, so nothing is left to use)
|
|
1797
|
+
*
|
|
1798
|
+
* In both canceling cases the terminal `canceled` status is written when the
|
|
1799
|
+
* PSP cancellation webhook arrives, not by this call.
|
|
1771
1800
|
*
|
|
1772
1801
|
* @param params - Order to cancel
|
|
1773
1802
|
* @returns Order ID and resulting status
|
package/dist/index.js
CHANGED
|
@@ -541,7 +541,9 @@ var CustomerSession = class {
|
|
|
541
541
|
*
|
|
542
542
|
* @example
|
|
543
543
|
* const { orderId, status } = await customer.cancelSubscription({ orderId: "ORD_xxx" });
|
|
544
|
-
* // status: "canceled" (was pending)
|
|
544
|
+
* // status: "canceled" (was pending)
|
|
545
|
+
* // or "canceling" (was active — stops at the end of the current period)
|
|
546
|
+
* // or "canceling" (was past_due — stops immediately)
|
|
545
547
|
*/
|
|
546
548
|
async cancelSubscription(params) {
|
|
547
549
|
validateShortId("orderId", params.orderId, "ORD");
|
|
@@ -563,6 +565,12 @@ var CustomerSession = class {
|
|
|
563
565
|
/**
|
|
564
566
|
* Reactivate a subscription that is in `canceling` status.
|
|
565
567
|
*
|
|
568
|
+
* A subscription that had an unpaid charge at the moment cancellation was
|
|
569
|
+
* requested is refused with 400 (`Subscription with an unpaid balance cannot
|
|
570
|
+
* be reactivated`), which is worded differently from the 400 returned when
|
|
571
|
+
* the order is not in `canceling` status. Cancelling a `past_due`
|
|
572
|
+
* subscription always falls into the former category.
|
|
573
|
+
*
|
|
566
574
|
* @param params - Order to reactivate
|
|
567
575
|
* @returns Order ID and resulting status
|
|
568
576
|
*
|
|
@@ -761,8 +769,14 @@ var OrdersResource = class {
|
|
|
761
769
|
/**
|
|
762
770
|
* Cancel a subscription order.
|
|
763
771
|
*
|
|
764
|
-
* - pending -> canceled (immediate)
|
|
765
|
-
* - active/trialing -> canceling (PSP cancel
|
|
772
|
+
* - pending -> canceled (immediate, no PSP call)
|
|
773
|
+
* - active/trialing -> canceling (PSP cancel scheduled for the end of the
|
|
774
|
+
* current billing period; the subscription stays usable until then)
|
|
775
|
+
* - past_due -> canceling (PSP cancel dispatched immediately; the billing
|
|
776
|
+
* period has already lapsed, so nothing is left to use)
|
|
777
|
+
*
|
|
778
|
+
* In both canceling cases the terminal `canceled` status is written when the
|
|
779
|
+
* PSP cancellation webhook arrives, not by this call.
|
|
766
780
|
*
|
|
767
781
|
* @param params - Order to cancel
|
|
768
782
|
* @returns Order ID and resulting status
|
|
@@ -1503,9 +1517,13 @@ var WebhookEventType = /* @__PURE__ */ ((WebhookEventType2) => {
|
|
|
1503
1517
|
WebhookEventType2["OrderCompleted"] = "order.completed";
|
|
1504
1518
|
WebhookEventType2["SubscriptionActivated"] = "subscription.activated";
|
|
1505
1519
|
WebhookEventType2["SubscriptionPaymentSucceeded"] = "subscription.payment_succeeded";
|
|
1520
|
+
WebhookEventType2["SubscriptionRenewed"] = "subscription.renewed";
|
|
1521
|
+
WebhookEventType2["SubscriptionRecovered"] = "subscription.recovered";
|
|
1522
|
+
WebhookEventType2["SubscriptionPlanChanged"] = "subscription.plan_changed";
|
|
1523
|
+
WebhookEventType2["SubscriptionPlanChangeScheduled"] = "subscription.plan_change_scheduled";
|
|
1524
|
+
WebhookEventType2["SubscriptionPlanChangeFailed"] = "subscription.plan_change_failed";
|
|
1506
1525
|
WebhookEventType2["SubscriptionCanceling"] = "subscription.canceling";
|
|
1507
1526
|
WebhookEventType2["SubscriptionUncanceled"] = "subscription.uncanceled";
|
|
1508
|
-
WebhookEventType2["SubscriptionUpdated"] = "subscription.updated";
|
|
1509
1527
|
WebhookEventType2["SubscriptionCanceled"] = "subscription.canceled";
|
|
1510
1528
|
WebhookEventType2["SubscriptionPastDue"] = "subscription.past_due";
|
|
1511
1529
|
WebhookEventType2["RefundSucceeded"] = "refund.succeeded";
|