@actuate-media/plugin-commerce 0.0.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.
Files changed (61) hide show
  1. package/dist/admin/CommerceDashboard.d.ts +35 -0
  2. package/dist/admin/CommerceDashboard.d.ts.map +1 -0
  3. package/dist/admin/CommerceDashboard.js +20 -0
  4. package/dist/admin/CommerceDashboard.js.map +1 -0
  5. package/dist/admin/DiscountManager.d.ts +24 -0
  6. package/dist/admin/DiscountManager.d.ts.map +1 -0
  7. package/dist/admin/DiscountManager.js +53 -0
  8. package/dist/admin/DiscountManager.js.map +1 -0
  9. package/dist/admin/OrderDetail.d.ts +62 -0
  10. package/dist/admin/OrderDetail.d.ts.map +1 -0
  11. package/dist/admin/OrderDetail.js +26 -0
  12. package/dist/admin/OrderDetail.js.map +1 -0
  13. package/dist/admin/OrderList.d.ts +29 -0
  14. package/dist/admin/OrderList.d.ts.map +1 -0
  15. package/dist/admin/OrderList.js +30 -0
  16. package/dist/admin/OrderList.js.map +1 -0
  17. package/dist/admin/ProductEdit.d.ts +43 -0
  18. package/dist/admin/ProductEdit.d.ts.map +1 -0
  19. package/dist/admin/ProductEdit.js +58 -0
  20. package/dist/admin/ProductEdit.js.map +1 -0
  21. package/dist/admin/ProductList.d.ts +21 -0
  22. package/dist/admin/ProductList.d.ts.map +1 -0
  23. package/dist/admin/ProductList.js +29 -0
  24. package/dist/admin/ProductList.js.map +1 -0
  25. package/dist/client.d.ts +107 -0
  26. package/dist/client.d.ts.map +1 -0
  27. package/dist/client.js +70 -0
  28. package/dist/client.js.map +1 -0
  29. package/dist/collections.d.ts +4 -0
  30. package/dist/collections.d.ts.map +1 -0
  31. package/dist/collections.js +341 -0
  32. package/dist/collections.js.map +1 -0
  33. package/dist/fields.d.ts +4 -0
  34. package/dist/fields.d.ts.map +1 -0
  35. package/dist/fields.js +3 -0
  36. package/dist/fields.js.map +1 -0
  37. package/dist/hooks.d.ts +5 -0
  38. package/dist/hooks.d.ts.map +1 -0
  39. package/dist/hooks.js +32 -0
  40. package/dist/hooks.js.map +1 -0
  41. package/dist/index.d.ts +37 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +27 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/stripe/checkout.d.ts +29 -0
  46. package/dist/stripe/checkout.d.ts.map +1 -0
  47. package/dist/stripe/checkout.js +48 -0
  48. package/dist/stripe/checkout.js.map +1 -0
  49. package/dist/stripe/customer.d.ts +11 -0
  50. package/dist/stripe/customer.d.ts.map +1 -0
  51. package/dist/stripe/customer.js +22 -0
  52. package/dist/stripe/customer.js.map +1 -0
  53. package/dist/stripe/products.d.ts +25 -0
  54. package/dist/stripe/products.d.ts.map +1 -0
  55. package/dist/stripe/products.js +27 -0
  56. package/dist/stripe/products.js.map +1 -0
  57. package/dist/stripe/webhooks.d.ts +8 -0
  58. package/dist/stripe/webhooks.d.ts.map +1 -0
  59. package/dist/stripe/webhooks.js +52 -0
  60. package/dist/stripe/webhooks.js.map +1 -0
  61. package/package.json +37 -0
@@ -0,0 +1,37 @@
1
+ import type { FieldDefinition, CollectionDefinition } from "@actuate/cms-core";
2
+ export interface CommercePluginConfig {
3
+ stripe?: {
4
+ secretKey: string;
5
+ webhookSecret: string;
6
+ currency?: string;
7
+ };
8
+ tax?: {
9
+ autoCalculate?: boolean;
10
+ };
11
+ shipping?: {
12
+ enabled?: boolean;
13
+ };
14
+ }
15
+ interface ActuatePlugin {
16
+ name: string;
17
+ fields?: Record<string, FieldDefinition>;
18
+ collections?: Record<string, CollectionDefinition>;
19
+ adminNavItems?: Array<{
20
+ label: string;
21
+ icon: string;
22
+ path: string;
23
+ }>;
24
+ hooks?: Array<{
25
+ event: string;
26
+ handler: (...args: unknown[]) => Promise<void> | void;
27
+ }>;
28
+ }
29
+ /** Creates the Actuate Commerce plugin with optional Stripe, tax, and shipping configuration. */
30
+ export declare function commercePlugin(config?: CommercePluginConfig): ActuatePlugin;
31
+ export type { CommercePluginConfig as CommerceConfig };
32
+ export { commerceFields } from "./fields.js";
33
+ export { commerceCollections } from "./collections.js";
34
+ export { commerceHooks } from "./hooks.js";
35
+ export { createCommerceClient } from "./client.js";
36
+ export type { CommerceClient } from "./client.js";
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAK/E,MAAM,WAAW,oBAAoB;IACnC,MAAM,CAAC,EAAE;QACP,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC;IACF,GAAG,CAAC,EAAE;QACJ,aAAa,CAAC,EAAE,OAAO,CAAC;KACzB,CAAC;IACF,QAAQ,CAAC,EAAE;QACT,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IACnD,aAAa,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACrE,KAAK,CAAC,EAAE,KAAK,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;KACvD,CAAC,CAAC;CACJ;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAC5B,MAAM,GAAE,oBAAyB,GAChC,aAAa,CAiBf;AAED,YAAY,EAAE,oBAAoB,IAAI,cAAc,EAAE,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ import { commerceFields } from "./fields.js";
2
+ import { commerceCollections } from "./collections.js";
3
+ import { commerceHooks } from "./hooks.js";
4
+ /** Creates the Actuate Commerce plugin with optional Stripe, tax, and shipping configuration. */
5
+ export function commercePlugin(config = {}) {
6
+ return {
7
+ name: "commerce",
8
+ fields: commerceFields,
9
+ collections: commerceCollections,
10
+ adminNavItems: [
11
+ { label: "Products", icon: "package", path: "/commerce/products" },
12
+ { label: "Orders", icon: "shopping-cart", path: "/commerce/orders" },
13
+ { label: "Discounts", icon: "percent", path: "/commerce/discounts" },
14
+ {
15
+ label: "Commerce Dashboard",
16
+ icon: "bar-chart",
17
+ path: "/commerce/dashboard",
18
+ },
19
+ ],
20
+ hooks: commerceHooks,
21
+ };
22
+ }
23
+ export { commerceFields } from "./fields.js";
24
+ export { commerceCollections } from "./collections.js";
25
+ export { commerceHooks } from "./hooks.js";
26
+ export { createCommerceClient } from "./client.js";
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA2B3C,iGAAiG;AACjG,MAAM,UAAU,cAAc,CAC5B,SAA+B,EAAE;IAEjC,OAAO;QACL,IAAI,EAAE,UAAU;QAChB,MAAM,EAAE,cAAc;QACtB,WAAW,EAAE,mBAAmB;QAChC,aAAa,EAAE;YACb,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,oBAAoB,EAAE;YAClE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,kBAAkB,EAAE;YACpE,EAAE,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,qBAAqB,EAAE;YACpE;gBACE,KAAK,EAAE,oBAAoB;gBAC3B,IAAI,EAAE,WAAW;gBACjB,IAAI,EAAE,qBAAqB;aAC5B;SACF;QACD,KAAK,EAAE,aAAa;KACrB,CAAC;AACJ,CAAC;AAGD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,29 @@
1
+ export interface CheckoutLineItem {
2
+ productId: string;
3
+ variantId?: string;
4
+ name: string;
5
+ quantity: number;
6
+ unitPrice: number;
7
+ image?: string;
8
+ }
9
+ export interface ShippingOption {
10
+ id: string;
11
+ label: string;
12
+ amount: number;
13
+ }
14
+ export interface CheckoutSessionOptions {
15
+ lineItems: CheckoutLineItem[];
16
+ successUrl: string;
17
+ cancelUrl: string;
18
+ customerEmail?: string;
19
+ shippingOptions?: ShippingOption[];
20
+ discountCode?: string;
21
+ }
22
+ export interface CheckoutSession {
23
+ id: string;
24
+ url: string;
25
+ expiresAt: Date;
26
+ }
27
+ /** Creates a Stripe Checkout session from cart line items and configuration. */
28
+ export declare function createCheckoutSession(options: CheckoutSessionOptions): Promise<CheckoutSession>;
29
+ //# sourceMappingURL=checkout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/stripe/checkout.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,gBAAgB,EAAE,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,cAAc,EAAE,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,gFAAgF;AAChF,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,eAAe,CAAC,CAkD1B"}
@@ -0,0 +1,48 @@
1
+ /** Creates a Stripe Checkout session from cart line items and configuration. */
2
+ export async function createCheckoutSession(options) {
3
+ const stripeLineItems = options.lineItems.map((item) => ({
4
+ price_data: {
5
+ currency: "usd",
6
+ product_data: {
7
+ name: item.name,
8
+ images: item.image ? [item.image] : [],
9
+ metadata: {
10
+ productId: item.productId,
11
+ ...(item.variantId ? { variantId: item.variantId } : {}),
12
+ },
13
+ },
14
+ unit_amount: Math.round(item.unitPrice * 100),
15
+ },
16
+ quantity: item.quantity,
17
+ }));
18
+ const sessionParams = {
19
+ mode: "payment",
20
+ line_items: stripeLineItems,
21
+ success_url: options.successUrl,
22
+ cancel_url: options.cancelUrl,
23
+ ...(options.customerEmail
24
+ ? { customer_email: options.customerEmail }
25
+ : {}),
26
+ };
27
+ if (options.shippingOptions?.length) {
28
+ sessionParams["shipping_options"] = options.shippingOptions.map((opt) => ({
29
+ shipping_rate_data: {
30
+ display_name: opt.label,
31
+ type: "fixed_amount",
32
+ fixed_amount: { amount: Math.round(opt.amount * 100), currency: "usd" },
33
+ },
34
+ }));
35
+ }
36
+ if (options.discountCode) {
37
+ sessionParams["discounts"] = [{ coupon: options.discountCode }];
38
+ }
39
+ // TODO: Call Stripe SDK — stripe.checkout.sessions.create(sessionParams)
40
+ const expiresAt = new Date();
41
+ expiresAt.setMinutes(expiresAt.getMinutes() + 30);
42
+ return {
43
+ id: `cs_stub_${Date.now()}`,
44
+ url: `https://checkout.stripe.com/pay/cs_stub_${Date.now()}`,
45
+ expiresAt,
46
+ };
47
+ }
48
+ //# sourceMappingURL=checkout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout.js","sourceRoot":"","sources":["../../src/stripe/checkout.ts"],"names":[],"mappings":"AA8BA,gFAAgF;AAChF,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,OAA+B;IAE/B,MAAM,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACvD,UAAU,EAAE;YACV,QAAQ,EAAE,KAAK;YACf,YAAY,EAAE;gBACZ,IAAI,EAAE,IAAI,CAAC,IAAI;gBACf,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;gBACtC,QAAQ,EAAE;oBACR,SAAS,EAAE,IAAI,CAAC,SAAS;oBACzB,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,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ACL,EAAE,EAAE,WAAW,IAAI,CAAC,GAAG,EAAE,EAAE;QAC3B,GAAG,EAAE,2CAA2C,IAAI,CAAC,GAAG,EAAE,EAAE;QAC5D,SAAS;KACV,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ export interface StripeCustomer {
2
+ id: string;
3
+ email: string;
4
+ name?: string;
5
+ metadata: Record<string, string>;
6
+ }
7
+ /** Links an Actuate user to a Stripe customer, creating one if necessary. */
8
+ export declare function syncCustomer(userId: string, email: string): Promise<StripeCustomer>;
9
+ /** Retrieves an existing Stripe customer by email or creates a new one. */
10
+ export declare function getOrCreateCustomer(email: string): Promise<StripeCustomer>;
11
+ //# sourceMappingURL=customer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer.d.ts","sourceRoot":"","sources":["../../src/stripe/customer.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,6EAA6E;AAC7E,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,cAAc,CAAC,CAUzB;AAED,2EAA2E;AAC3E,wBAAsB,mBAAmB,CACvC,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,cAAc,CAAC,CASzB"}
@@ -0,0 +1,22 @@
1
+ /** Links an Actuate user to a Stripe customer, creating one if necessary. */
2
+ export async function syncCustomer(userId, email) {
3
+ // TODO: Search Stripe for existing customer by metadata.actuateUserId,
4
+ // then create or update accordingly
5
+ const existing = await getOrCreateCustomer(email);
6
+ // TODO: stripe.customers.update(existing.id, { metadata: { actuateUserId: userId } })
7
+ return {
8
+ ...existing,
9
+ metadata: { ...existing.metadata, actuateUserId: userId },
10
+ };
11
+ }
12
+ /** Retrieves an existing Stripe customer by email or creates a new one. */
13
+ export async function getOrCreateCustomer(email) {
14
+ // TODO: stripe.customers.list({ email, limit: 1 })
15
+ // If found, return mapped customer; otherwise stripe.customers.create({ email })
16
+ return {
17
+ id: `cus_stub_${Date.now()}`,
18
+ email,
19
+ metadata: {},
20
+ };
21
+ }
22
+ //# sourceMappingURL=customer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer.js","sourceRoot":"","sources":["../../src/stripe/customer.ts"],"names":[],"mappings":"AAOA,6EAA6E;AAC7E,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAc,EACd,KAAa;IAEb,uEAAuE;IACvE,0CAA0C;IAC1C,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAElD,sFAAsF;IACtF,OAAO;QACL,GAAG,QAAQ;QACX,QAAQ,EAAE,EAAE,GAAG,QAAQ,CAAC,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE;KAC1D,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,KAAa;IAEb,mDAAmD;IACnD,uFAAuF;IAEvF,OAAO;QACL,EAAE,EAAE,YAAY,IAAI,CAAC,GAAG,EAAE,EAAE;QAC5B,KAAK;QACL,QAAQ,EAAE,EAAE;KACb,CAAC;AACJ,CAAC"}
@@ -0,0 +1,25 @@
1
+ export interface ProductData {
2
+ id: string;
3
+ name: string;
4
+ description?: string;
5
+ images?: string[];
6
+ metadata?: Record<string, string>;
7
+ }
8
+ export interface StripeProduct {
9
+ id: string;
10
+ name: string;
11
+ active: boolean;
12
+ metadata: Record<string, string>;
13
+ }
14
+ export interface StripePrice {
15
+ id: string;
16
+ productId: string;
17
+ unitAmount: number;
18
+ currency: string;
19
+ active: boolean;
20
+ }
21
+ /** Creates or updates a Stripe product to mirror an Actuate product record. */
22
+ export declare function syncProduct(product: ProductData): Promise<StripeProduct>;
23
+ /** Creates or updates a Stripe price for a given Stripe product. */
24
+ export declare function syncPrice(productId: string, amount: number, currency: string): Promise<StripePrice>;
25
+ //# sourceMappingURL=products.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"products.d.ts","sourceRoot":"","sources":["../../src/stripe/products.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,+EAA+E;AAC/E,wBAAsB,WAAW,CAC/B,OAAO,EAAE,WAAW,GACnB,OAAO,CAAC,aAAa,CAAC,CAaxB;AAED,oEAAoE;AACpE,wBAAsB,SAAS,CAC7B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC,CAWtB"}
@@ -0,0 +1,27 @@
1
+ /** Creates or updates a Stripe product to mirror an Actuate product record. */
2
+ export async function syncProduct(product) {
3
+ // TODO: Search Stripe for product by metadata.actuateProductId,
4
+ // then create or update via stripe.products API
5
+ return {
6
+ id: `prod_stub_${Date.now()}`,
7
+ name: product.name,
8
+ active: true,
9
+ metadata: {
10
+ actuateProductId: product.id,
11
+ ...product.metadata,
12
+ },
13
+ };
14
+ }
15
+ /** Creates or updates a Stripe price for a given Stripe product. */
16
+ export async function syncPrice(productId, amount, currency) {
17
+ // TODO: stripe.prices.create({ product: productId, unit_amount, currency })
18
+ // Stripe prices are immutable — deactivate old price and create new one if changed
19
+ return {
20
+ id: `price_stub_${Date.now()}`,
21
+ productId,
22
+ unitAmount: Math.round(amount * 100),
23
+ currency: currency.toLowerCase(),
24
+ active: true,
25
+ };
26
+ }
27
+ //# sourceMappingURL=products.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"products.js","sourceRoot":"","sources":["../../src/stripe/products.ts"],"names":[],"mappings":"AAuBA,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAoB;IAEpB,gEAAgE;IAChE,sDAAsD;IAEtD,OAAO;QACL,EAAE,EAAE,aAAa,IAAI,CAAC,GAAG,EAAE,EAAE;QAC7B,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE;YACR,gBAAgB,EAAE,OAAO,CAAC,EAAE;YAC5B,GAAG,OAAO,CAAC,QAAQ;SACpB;KACF,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,SAAiB,EACjB,MAAc,EACd,QAAgB;IAEhB,4EAA4E;IAC5E,yFAAyF;IAEzF,OAAO;QACL,EAAE,EAAE,cAAc,IAAI,CAAC,GAAG,EAAE,EAAE;QAC9B,SAAS;QACT,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC;QACpC,QAAQ,EAAE,QAAQ,CAAC,WAAW,EAAE;QAChC,MAAM,EAAE,IAAI;KACb,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ export interface WebhookResult {
2
+ handled: boolean;
3
+ event: string;
4
+ error?: string;
5
+ }
6
+ /** Verifies and processes a Stripe webhook event payload. */
7
+ export declare function handleStripeWebhook(payload: string, signature: string, secret: string): Promise<WebhookResult>;
8
+ //# sourceMappingURL=webhooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/stripe/webhooks.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA6CD,6DAA6D;AAC7D,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,aAAa,CAAC,CAiCxB"}
@@ -0,0 +1,52 @@
1
+ async function handleCheckoutCompleted(session) {
2
+ const customerEmail = session["customer_email"];
3
+ const paymentIntentId = session["payment_intent"];
4
+ const amountTotal = session["amount_total"];
5
+ // TODO: Create order record from session data
6
+ console.info(`[commerce:webhook] Checkout completed — email=${customerEmail} payment=${paymentIntentId} total=${amountTotal}`);
7
+ }
8
+ async function handlePaymentSucceeded(paymentIntent) {
9
+ const intentId = paymentIntent["id"];
10
+ const amount = paymentIntent["amount"];
11
+ // TODO: Update payment record status to "succeeded"
12
+ console.info(`[commerce:webhook] Payment succeeded — intent=${intentId} amount=${amount}`);
13
+ }
14
+ async function handleChargeRefunded(charge) {
15
+ const chargeId = charge["id"];
16
+ const amountRefunded = charge["amount_refunded"];
17
+ const paymentIntentId = charge["payment_intent"];
18
+ // TODO: Update payment record status to "refunded", adjust order status
19
+ console.info(`[commerce:webhook] Charge refunded — charge=${chargeId} intent=${paymentIntentId} refunded=${amountRefunded}`);
20
+ }
21
+ /** Verifies and processes a Stripe webhook event payload. */
22
+ export async function handleStripeWebhook(payload, signature, secret) {
23
+ let event;
24
+ try {
25
+ // TODO: Replace with stripe.webhooks.constructEvent(payload, signature, secret)
26
+ if (!signature || !secret) {
27
+ throw new Error("Missing webhook signature or secret");
28
+ }
29
+ event = JSON.parse(payload);
30
+ }
31
+ catch (err) {
32
+ return {
33
+ handled: false,
34
+ event: "unknown",
35
+ error: `Webhook verification failed: ${err instanceof Error ? err.message : String(err)}`,
36
+ };
37
+ }
38
+ switch (event.type) {
39
+ case "checkout.session.completed":
40
+ await handleCheckoutCompleted(event.data.object);
41
+ return { handled: true, event: event.type };
42
+ case "payment_intent.succeeded":
43
+ await handlePaymentSucceeded(event.data.object);
44
+ return { handled: true, event: event.type };
45
+ case "charge.refunded":
46
+ await handleChargeRefunded(event.data.object);
47
+ return { handled: true, event: event.type };
48
+ default:
49
+ return { handled: false, event: event.type };
50
+ }
51
+ }
52
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/stripe/webhooks.ts"],"names":[],"mappings":"AAWA,KAAK,UAAU,uBAAuB,CACpC,OAAgC;IAEhC,MAAM,aAAa,GAAG,OAAO,CAAC,gBAAgB,CAAuB,CAAC;IACtE,MAAM,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAuB,CAAC;IACxE,MAAM,WAAW,GAAG,OAAO,CAAC,cAAc,CAAuB,CAAC;IAElE,8CAA8C;IAC9C,OAAO,CAAC,IAAI,CACV,iDAAiD,aAAa,YAAY,eAAe,UAAU,WAAW,EAAE,CACjH,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,sBAAsB,CACnC,aAAsC;IAEtC,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAuB,CAAC;IAC3D,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAuB,CAAC;IAE7D,oDAAoD;IACpD,OAAO,CAAC,IAAI,CACV,iDAAiD,QAAQ,WAAW,MAAM,EAAE,CAC7E,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,oBAAoB,CACjC,MAA+B;IAE/B,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAuB,CAAC;IACpD,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AAoB,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YAC9C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;QAE9C;YACE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;IACjD,CAAC;AACH,CAAC"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@actuate-media/plugin-commerce",
3
+ "version": "0.0.1",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/actuatecms/actuatecms.git",
7
+ "directory": "packages/plugin-commerce"
8
+ },
9
+ "publishConfig": {
10
+ "access": "restricted"
11
+ },
12
+ "type": "module",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js"
17
+ }
18
+ },
19
+ "main": "./dist/index.js",
20
+ "types": "./dist/index.d.ts",
21
+ "files": ["dist"],
22
+ "scripts": {
23
+ "build": "tsc --project tsconfig.json",
24
+ "type-check": "tsc --noEmit",
25
+ "clean": "rm -rf dist .turbo"
26
+ },
27
+ "dependencies": {
28
+ "@actuate-media/cms-core": "workspace:*"
29
+ },
30
+ "devDependencies": {
31
+ "@types/react": "^19.0.0",
32
+ "typescript": "^5.7.0"
33
+ },
34
+ "peerDependencies": {
35
+ "react": "^19.2.0"
36
+ }
37
+ }