@stacksjs/commerce 0.75.76 → 0.75.78

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.
@@ -59,14 +59,13 @@ export {
59
59
  updateDeliveryInfo,
60
60
  updateStatus,
61
61
  } from './update';
62
- // Stripe webhook handlers (stacksjs/stacks#1879 Co-17). Call
63
- // registerCommerceWebhookHandlers() once at boot; the payments
64
- // package's processWebhook() verifies signatures + dispatches.
62
+ // Payment webhook handling (stacksjs/stacks#1879 Co-17, #665): pass each event
63
+ // the payment driver's verifyWebhook() returns to handleCommercePaymentEvent().
65
64
  export {
66
- handleChargeRefunded,
67
- handlePaymentIntentFailed,
68
- handlePaymentIntentSucceeded,
69
- registerCommerceWebhookHandlers,
65
+ handleCommercePaymentEvent,
66
+ handlePaymentFailed,
67
+ handlePaymentSucceeded,
68
+ handleRefundSucceeded,
70
69
  } from './webhook';
71
70
  // Server-side cart-to-order total recompute (stacksjs/stacks#1879 Co-13).
72
71
  // Apps pre-flight the cart through this before placeOrder to detect
@@ -1,31 +1,35 @@
1
+ import type { PaymentEvent } from '@stacksjs/payments';
1
2
  /**
2
- * Handler for `payment_intent.succeeded`. Marks the linked payment
3
- * row + order row as paid in a single transaction. Idempotent via
4
- * `recordEventOrSkip`.
3
+ * A payment succeeded. Marks the linked payment row and order row in a single
4
+ * transaction. Idempotent via `recordEventOrSkip`.
5
5
  */
6
- declare function handlePaymentIntentSucceeded(event: { id: string, data: { object: any } }): Promise<void>;
6
+ declare function handlePaymentSucceeded(event: PaymentEvent): Promise<void>;
7
7
  /**
8
- * Handler for `payment_intent.payment_failed`. Marks the payment
9
- * as failed and cancels the linked order. Records the failure
10
- * reason on the payment row for ops triage.
8
+ * A payment failed. Marks the payment failed and cancels the linked order,
9
+ * recording the provider's reason on the payment row for ops triage.
11
10
  */
12
- declare function handlePaymentIntentFailed(event: { id: string, data: { object: any } }): Promise<void>;
11
+ declare function handlePaymentFailed(event: PaymentEvent): Promise<void>;
13
12
  /**
14
- * Handler for `charge.refunded`. Marks the order REFUNDED and
15
- * records the refund amount on the linked payment.
13
+ * A refund succeeded. Adds it to the payment's refunded amount; a refund that
14
+ * covers what is left marks the payment `refunded` and the order REFUNDED,
15
+ * and a smaller one marks the payment `partiallyRefunded` and leaves the order
16
+ * where it is, since REFUNDED is terminal. It used to mark both refunded on any
17
+ * refund at all, and to overwrite the refunded amount rather than add to it.
18
+ *
19
+ * A refund larger than what is left is not recorded and is logged: the
20
+ * provider has refunded more than this database thinks was taken, which a
21
+ * person needs to look at - most likely the same refund recorded by hand in
22
+ * the dashboard as well.
16
23
  */
17
- declare function handleChargeRefunded(event: { id: string, data: { object: any } }): Promise<void>;
24
+ declare function handleRefundSucceeded(event: PaymentEvent): Promise<void>;
18
25
  /**
19
- * Wire commerce's Stripe webhook handlers into the payments
20
- * package's event router. Call once at boot.
21
- *
22
- * Returns an unregister callback for tests that want to swap the
23
- * handler set between cases.
26
+ * Apply a verified payment event to the order it concerns. Answers whether
27
+ * commerce acted on it; events it has no use for are left alone.
24
28
  */
25
- export declare function registerCommerceWebhookHandlers(): Promise<() => void>;
29
+ export declare function handleCommercePaymentEvent(event: PaymentEvent): Promise<boolean>;
26
30
  // Export the individual handlers for direct testing.
27
31
  export {
28
- handleChargeRefunded,
29
- handlePaymentIntentFailed,
30
- handlePaymentIntentSucceeded,
32
+ handlePaymentFailed,
33
+ handlePaymentSucceeded,
34
+ handleRefundSucceeded,
31
35
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/commerce",
3
3
  "type": "module",
4
- "version": "0.75.76",
4
+ "version": "0.75.78",
5
5
  "description": "Stacks commerce utilities.",
6
6
  "author": "Chris Breuer",
7
7
  "contributors": [
@@ -57,17 +57,17 @@
57
57
  "prepublishOnly": "bun run build"
58
58
  },
59
59
  "dependencies": {
60
- "@stacksjs/cache": "0.75.76",
61
- "@stacksjs/config": "0.75.76",
62
- "@stacksjs/database": "0.75.76",
63
- "@stacksjs/env": "0.75.76",
64
- "@stacksjs/error-handling": "0.75.76",
65
- "@stacksjs/events": "0.75.76",
66
- "@stacksjs/logging": "0.75.76",
67
- "@stacksjs/orm": "0.75.76",
68
- "@stacksjs/payments": "0.75.76",
69
- "@stacksjs/realtime": "0.75.76",
70
- "@stacksjs/strings": "0.75.76",
60
+ "@stacksjs/cache": "0.75.78",
61
+ "@stacksjs/config": "0.75.78",
62
+ "@stacksjs/database": "0.75.78",
63
+ "@stacksjs/env": "0.75.78",
64
+ "@stacksjs/error-handling": "0.75.78",
65
+ "@stacksjs/events": "0.75.78",
66
+ "@stacksjs/logging": "0.75.78",
67
+ "@stacksjs/orm": "0.75.78",
68
+ "@stacksjs/payments": "0.75.78",
69
+ "@stacksjs/realtime": "0.75.78",
70
+ "@stacksjs/strings": "0.75.78",
71
71
  "ts-spreadsheets": "^0.2.0"
72
72
  },
73
73
  "devDependencies": {