@paykit-sdk/stripe 1.1.6 → 1.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/README.md CHANGED
@@ -177,4 +177,4 @@ STRIPE_WEBHOOK_SECRET=whsec_...
177
177
 
178
178
  ## License
179
179
 
180
- ISC
180
+ GPL-3.0
package/dist/index.js CHANGED
@@ -42,20 +42,20 @@ var import_stripe = __toESM(require("stripe"));
42
42
 
43
43
  // lib/mapper.ts
44
44
  var import_core = require("@paykit-sdk/core");
45
- var toPaykitCheckout = (checkout) => {
45
+ var paykitCheckout$InboundSchema = (checkout) => {
46
46
  return {
47
47
  id: checkout.id,
48
- customer_id: checkout.customer,
48
+ customer_id: typeof checkout.customer === "string" ? checkout.customer.toString() : checkout.customer?.id ?? "",
49
49
  session_type: checkout.mode === "subscription" ? "recurring" : "one_time",
50
- // todo: handle `setup` mode
51
50
  payment_url: checkout.url,
52
51
  products: checkout.line_items.data.map((item) => ({ id: item.price.id, quantity: item.quantity })),
53
52
  currency: checkout.currency,
54
53
  amount: checkout.amount_total,
55
- metadata: checkout.metadata
54
+ subscription: null,
55
+ metadata: (0, import_core.stringifyObjectValues)(checkout.metadata ?? {})
56
56
  };
57
57
  };
58
- var toPaykitCustomer = (customer) => {
58
+ var paykitCustomer$InboundSchema = (customer) => {
59
59
  return {
60
60
  id: customer.id,
61
61
  email: customer.email ?? void 0,
@@ -63,31 +63,60 @@ var toPaykitCustomer = (customer) => {
63
63
  metadata: (0, import_core.stringifyObjectValues)(customer.metadata ?? {})
64
64
  };
65
65
  };
66
- var toPaykitSubscriptionStatus = (status) => {
67
- if (["active", "trialing"].includes(status)) return "active";
68
- if (["incomplete_expired", "incomplete", "past_due"].includes(status)) return "past_due";
69
- if (["canceled"].includes(status)) return "canceled";
70
- if (["expired"].includes(status)) return "expired";
71
- throw new Error(`Unknown status: ${status}`);
72
- };
73
- var toPaykitSubscription = (subscription) => {
66
+ var paykitSubscription$InboundSchema = (subscription) => {
67
+ const status = (() => {
68
+ if (["active", "trialing"].includes(subscription.status)) return "active";
69
+ if (["incomplete_expired", "incomplete", "past_due"].includes(subscription.status)) return "past_due";
70
+ if (["canceled"].includes(subscription.status)) return "canceled";
71
+ if (["expired"].includes(subscription.status)) return "expired";
72
+ throw new Error(`Unknown status: ${subscription.status}`);
73
+ })();
74
74
  return {
75
75
  id: subscription.id,
76
+ status,
76
77
  customer_id: subscription.customer?.toString(),
77
- status: toPaykitSubscriptionStatus(subscription.status),
78
+ amount: subscription.items.data[0].price.unit_amount,
79
+ currency: subscription.items.data[0].price.currency,
80
+ item_id: subscription.items.data[0].id,
81
+ billing_interval: subscription.items.data[0].price.recurring?.interval,
82
+ billing_interval_count: subscription.items.data[0].price.recurring?.interval_count ?? 1,
78
83
  current_period_start: new Date(subscription.start_date),
79
84
  current_period_end: new Date(subscription.cancel_at),
80
- metadata: (0, import_core.stringifyObjectValues)(subscription.metadata ?? {})
85
+ metadata: (0, import_core.stringifyObjectValues)(subscription.metadata ?? {}),
86
+ /**
87
+ * todo: fix
88
+ */
89
+ custom_fields: null,
90
+ current_cycle: 0,
91
+ total_cycles: 0
81
92
  };
82
93
  };
83
- var toPaykitInvoice = (invoice) => {
94
+ var paykitInvoice$InboundSchema = (invoice) => {
95
+ const status = (() => {
96
+ if (invoice.status == "paid") return "paid";
97
+ if (["draft", "open", "uncollectible", "void"].includes(invoice.status)) return "open";
98
+ throw new Error(`Unknown status: ${invoice.status}`);
99
+ })();
100
+ const subscriptionId = /* @__PURE__ */ (() => {
101
+ return null;
102
+ })();
103
+ const customerId = (() => {
104
+ if (typeof invoice.customer === "string") return invoice.customer;
105
+ if (invoice.customer?.id) return invoice.customer.id;
106
+ throw new Error(`Unknown customer ID: ${invoice.customer}`);
107
+ })();
84
108
  return {
85
109
  id: invoice.id,
86
- amount: invoice.amount_paid,
87
110
  currency: invoice.currency,
111
+ customer_id: customerId,
112
+ billing_mode: invoice.billingMode,
113
+ amount_paid: invoice.amount_paid,
114
+ line_items: invoice.lines.data.map((line) => ({ id: line.id, quantity: line.quantity })),
115
+ subscription_id: subscriptionId,
116
+ status,
117
+ paid_at: new Date(invoice.created * 1e3).toISOString(),
88
118
  metadata: (0, import_core.stringifyObjectValues)(invoice.metadata ?? {}),
89
- customer_id: invoice.customer?.toString() ?? "",
90
- billing_mode: invoice.billingMode
119
+ custom_fields: invoice.custom_fields ?? null
91
120
  };
92
121
  };
93
122
 
@@ -98,31 +127,30 @@ var StripeProvider = class {
98
127
  * Checkout management
99
128
  */
100
129
  this.createCheckout = async (params) => {
101
- const { customer_id, item_id, metadata, session_type, provider_metadata } = params;
102
130
  const checkout = await this.stripe.checkout.sessions.create({
103
- customer: customer_id,
104
- mode: session_type === "one_time" ? "payment" : "subscription",
105
- ...session_type == "one_time" && { metadata },
106
- ...session_type == "recurring" && { subscription_data: { metadata } },
107
- line_items: [{ price: item_id }],
108
- ...provider_metadata
131
+ customer: params.customer_id,
132
+ mode: params.session_type === "one_time" ? "payment" : "subscription",
133
+ ...params.session_type == "one_time" && { metadata: (0, import_core2.stringifyObjectValues)(params.metadata ?? {}) },
134
+ ...params.session_type == "recurring" && { subscription_data: { metadata: (0, import_core2.stringifyObjectValues)(params.metadata ?? {}) } },
135
+ line_items: [{ price: params.item_id, quantity: params.quantity }],
136
+ ...params.provider_metadata
109
137
  });
110
- return toPaykitCheckout(checkout);
138
+ return paykitCheckout$InboundSchema(checkout);
111
139
  };
112
140
  this.retrieveCheckout = async (id) => {
113
141
  const checkout = await this.stripe.checkout.sessions.retrieve(id);
114
- return toPaykitCheckout(checkout);
142
+ return paykitCheckout$InboundSchema(checkout);
115
143
  };
116
144
  /**
117
145
  * Customer management
118
146
  */
119
147
  this.createCustomer = async (params) => {
120
148
  const customer = await this.stripe.customers.create(params);
121
- return toPaykitCustomer(customer);
149
+ return paykitCustomer$InboundSchema(customer);
122
150
  };
123
151
  this.updateCustomer = async (id, params) => {
124
152
  const customer = await this.stripe.customers.update(id, params);
125
- return toPaykitCustomer(customer);
153
+ return paykitCustomer$InboundSchema(customer);
126
154
  };
127
155
  this.deleteCustomer = async (id) => {
128
156
  await this.stripe.customers.del(id);
@@ -131,7 +159,7 @@ var StripeProvider = class {
131
159
  this.retrieveCustomer = async (id) => {
132
160
  const customer = await this.stripe.customers.retrieve(id);
133
161
  if ("deleted" in customer) return null;
134
- return toPaykitCustomer(customer);
162
+ return paykitCustomer$InboundSchema(customer);
135
163
  };
136
164
  /**
137
165
  * Subscription management
@@ -141,12 +169,12 @@ var StripeProvider = class {
141
169
  return null;
142
170
  };
143
171
  this.updateSubscription = async (id, params) => {
144
- const subscription = await this.stripe.subscriptions.update(id, { metadata: params.metadata });
145
- return toPaykitSubscription(subscription);
172
+ const subscription = await this.stripe.subscriptions.update(id, { metadata: (0, import_core2.stringifyObjectValues)(params.metadata ?? {}) });
173
+ return paykitSubscription$InboundSchema(subscription);
146
174
  };
147
175
  this.retrieveSubscription = async (id) => {
148
176
  const subscription = await this.stripe.subscriptions.retrieve(id);
149
- return toPaykitSubscription(subscription);
177
+ return paykitSubscription$InboundSchema(subscription);
150
178
  };
151
179
  /**
152
180
  * Webhook management
@@ -160,7 +188,7 @@ var StripeProvider = class {
160
188
  /**
161
189
  * Invoice
162
190
  */
163
- "checkout.session.completed": (event2) => {
191
+ "checkout.session.completed": async (event2) => {
164
192
  const data = event2.data.object;
165
193
  if (data.mode !== "payment") return null;
166
194
  return (0, import_core2.toPaykitEvent)({
@@ -169,58 +197,72 @@ var StripeProvider = class {
169
197
  id: event2.id,
170
198
  data: {
171
199
  id: data.id,
172
- amount: data.amount_total ?? 0,
200
+ status: "paid",
201
+ paid_at: new Date(event2.created * 1e3).toISOString(),
202
+ amount_paid: data.amount_total ?? 0,
173
203
  currency: data.currency ?? "",
174
- metadata: (0, import_core2.stringifyObjectValues)({ ...data.metadata ?? {}, $mode: data.mode }),
204
+ metadata: (0, import_core2.stringifyObjectValues)({ ...data.metadata ?? {} }),
175
205
  customer_id: data.customer?.toString() ?? "",
176
- billing_mode: "one_time"
206
+ billing_mode: "one_time",
207
+ subscription_id: null,
208
+ custom_fields: data.custom_fields ?? null,
209
+ line_items: data.line_items?.data.map((item) => ({ id: item.price.id, quantity: item.quantity })) ?? []
177
210
  }
178
211
  });
179
212
  },
180
- "invoice.paid": (event2) => {
213
+ "invoice.paid": async (event2) => {
181
214
  const data = event2.data.object;
182
- if (data.status !== "paid" && !["subscription_create", "subscription_cycle"].includes(data.billing_reason)) {
183
- return null;
184
- }
215
+ const relevantBillingReasons = ["subscription_create", "subscription_cycle"];
216
+ if (data.status !== "paid" && !relevantBillingReasons.includes(data.billing_reason)) return null;
185
217
  return (0, import_core2.toPaykitEvent)({
186
218
  type: "$invoicePaid",
187
219
  created: event2.created,
188
220
  id: event2.id,
189
- data: toPaykitInvoice({ ...data, billingMode: "recurring" })
221
+ data: paykitInvoice$InboundSchema({ ...data, billingMode: "recurring" })
190
222
  });
191
223
  },
192
224
  /**
193
225
  * Customer
194
226
  */
195
- "customer.created": (event2) => {
227
+ "customer.created": async (event2) => {
196
228
  const data = event2.data.object;
197
- return (0, import_core2.toPaykitEvent)({ type: "$customerCreated", created: event2.created, id: event2.id, data: toPaykitCustomer(data) });
229
+ return (0, import_core2.toPaykitEvent)({ type: "$customerCreated", created: event2.created, id: event2.id, data: paykitCustomer$InboundSchema(data) });
198
230
  },
199
- "customer.updated": (event2) => {
231
+ "customer.updated": async (event2) => {
200
232
  const data = event2.data.object;
201
- return (0, import_core2.toPaykitEvent)({ type: "$customerUpdated", created: event2.created, id: event2.id, data: toPaykitCustomer(data) });
233
+ return (0, import_core2.toPaykitEvent)({ type: "$customerUpdated", created: event2.created, id: event2.id, data: paykitCustomer$InboundSchema(data) });
202
234
  },
203
- "customer.deleted": (event2) => {
235
+ "customer.deleted": async (event2) => {
204
236
  return (0, import_core2.toPaykitEvent)({ type: "$customerDeleted", created: event2.created, id: event2.id, data: null });
205
237
  },
206
238
  /**
207
239
  * Subscription
208
240
  */
209
- "customer.subscription.created": (event2) => {
241
+ "customer.subscription.created": async (event2) => {
210
242
  const data = event2.data.object;
211
- return (0, import_core2.toPaykitEvent)({ type: "$subscriptionCreated", created: event2.created, id: event2.id, data: toPaykitSubscription(data) });
243
+ return (0, import_core2.toPaykitEvent)({
244
+ type: "$subscriptionCreated",
245
+ created: event2.created,
246
+ id: event2.id,
247
+ data: paykitSubscription$InboundSchema(data)
248
+ });
212
249
  },
213
- "customer.subscription.updated": (event2) => {
250
+ "customer.subscription.updated": async (event2) => {
214
251
  const data = event2.data.object;
215
- return (0, import_core2.toPaykitEvent)({ type: "$subscriptionUpdated", created: event2.created, id: event2.id, data: toPaykitSubscription(data) });
252
+ return (0, import_core2.toPaykitEvent)({
253
+ type: "$subscriptionUpdated",
254
+ created: event2.created,
255
+ id: event2.id,
256
+ data: paykitSubscription$InboundSchema(data)
257
+ });
216
258
  },
217
- "customer.subscription.deleted": (event2) => {
259
+ "customer.subscription.deleted": async (event2) => {
218
260
  return (0, import_core2.toPaykitEvent)({ type: "$subscriptionCancelled", created: event2.created, id: event2.id, data: null });
219
261
  }
220
262
  };
221
263
  const handler = webhookHandlers[event.type];
222
264
  if (!handler) throw new Error(`Unhandled event type: ${event.type}`);
223
- const result = handler(event);
265
+ const result = await handler(event);
224
266
  if (!result) throw new Error(`Unhandled event type: ${event.type}`);
225
267
  return result;
226
268
  };
package/dist/index.mjs CHANGED
@@ -10,21 +10,23 @@ import {
10
10
  import Stripe from "stripe";
11
11
 
12
12
  // lib/mapper.ts
13
- import { stringifyObjectValues } from "@paykit-sdk/core";
14
- var toPaykitCheckout = (checkout) => {
13
+ import {
14
+ stringifyObjectValues
15
+ } from "@paykit-sdk/core";
16
+ var paykitCheckout$InboundSchema = (checkout) => {
15
17
  return {
16
18
  id: checkout.id,
17
- customer_id: checkout.customer,
19
+ customer_id: typeof checkout.customer === "string" ? checkout.customer.toString() : checkout.customer?.id ?? "",
18
20
  session_type: checkout.mode === "subscription" ? "recurring" : "one_time",
19
- // todo: handle `setup` mode
20
21
  payment_url: checkout.url,
21
22
  products: checkout.line_items.data.map((item) => ({ id: item.price.id, quantity: item.quantity })),
22
23
  currency: checkout.currency,
23
24
  amount: checkout.amount_total,
24
- metadata: checkout.metadata
25
+ subscription: null,
26
+ metadata: stringifyObjectValues(checkout.metadata ?? {})
25
27
  };
26
28
  };
27
- var toPaykitCustomer = (customer) => {
29
+ var paykitCustomer$InboundSchema = (customer) => {
28
30
  return {
29
31
  id: customer.id,
30
32
  email: customer.email ?? void 0,
@@ -32,31 +34,60 @@ var toPaykitCustomer = (customer) => {
32
34
  metadata: stringifyObjectValues(customer.metadata ?? {})
33
35
  };
34
36
  };
35
- var toPaykitSubscriptionStatus = (status) => {
36
- if (["active", "trialing"].includes(status)) return "active";
37
- if (["incomplete_expired", "incomplete", "past_due"].includes(status)) return "past_due";
38
- if (["canceled"].includes(status)) return "canceled";
39
- if (["expired"].includes(status)) return "expired";
40
- throw new Error(`Unknown status: ${status}`);
41
- };
42
- var toPaykitSubscription = (subscription) => {
37
+ var paykitSubscription$InboundSchema = (subscription) => {
38
+ const status = (() => {
39
+ if (["active", "trialing"].includes(subscription.status)) return "active";
40
+ if (["incomplete_expired", "incomplete", "past_due"].includes(subscription.status)) return "past_due";
41
+ if (["canceled"].includes(subscription.status)) return "canceled";
42
+ if (["expired"].includes(subscription.status)) return "expired";
43
+ throw new Error(`Unknown status: ${subscription.status}`);
44
+ })();
43
45
  return {
44
46
  id: subscription.id,
47
+ status,
45
48
  customer_id: subscription.customer?.toString(),
46
- status: toPaykitSubscriptionStatus(subscription.status),
49
+ amount: subscription.items.data[0].price.unit_amount,
50
+ currency: subscription.items.data[0].price.currency,
51
+ item_id: subscription.items.data[0].id,
52
+ billing_interval: subscription.items.data[0].price.recurring?.interval,
53
+ billing_interval_count: subscription.items.data[0].price.recurring?.interval_count ?? 1,
47
54
  current_period_start: new Date(subscription.start_date),
48
55
  current_period_end: new Date(subscription.cancel_at),
49
- metadata: stringifyObjectValues(subscription.metadata ?? {})
56
+ metadata: stringifyObjectValues(subscription.metadata ?? {}),
57
+ /**
58
+ * todo: fix
59
+ */
60
+ custom_fields: null,
61
+ current_cycle: 0,
62
+ total_cycles: 0
50
63
  };
51
64
  };
52
- var toPaykitInvoice = (invoice) => {
65
+ var paykitInvoice$InboundSchema = (invoice) => {
66
+ const status = (() => {
67
+ if (invoice.status == "paid") return "paid";
68
+ if (["draft", "open", "uncollectible", "void"].includes(invoice.status)) return "open";
69
+ throw new Error(`Unknown status: ${invoice.status}`);
70
+ })();
71
+ const subscriptionId = /* @__PURE__ */ (() => {
72
+ return null;
73
+ })();
74
+ const customerId = (() => {
75
+ if (typeof invoice.customer === "string") return invoice.customer;
76
+ if (invoice.customer?.id) return invoice.customer.id;
77
+ throw new Error(`Unknown customer ID: ${invoice.customer}`);
78
+ })();
53
79
  return {
54
80
  id: invoice.id,
55
- amount: invoice.amount_paid,
56
81
  currency: invoice.currency,
82
+ customer_id: customerId,
83
+ billing_mode: invoice.billingMode,
84
+ amount_paid: invoice.amount_paid,
85
+ line_items: invoice.lines.data.map((line) => ({ id: line.id, quantity: line.quantity })),
86
+ subscription_id: subscriptionId,
87
+ status,
88
+ paid_at: new Date(invoice.created * 1e3).toISOString(),
57
89
  metadata: stringifyObjectValues(invoice.metadata ?? {}),
58
- customer_id: invoice.customer?.toString() ?? "",
59
- billing_mode: invoice.billingMode
90
+ custom_fields: invoice.custom_fields ?? null
60
91
  };
61
92
  };
62
93
 
@@ -67,31 +98,30 @@ var StripeProvider = class {
67
98
  * Checkout management
68
99
  */
69
100
  this.createCheckout = async (params) => {
70
- const { customer_id, item_id, metadata, session_type, provider_metadata } = params;
71
101
  const checkout = await this.stripe.checkout.sessions.create({
72
- customer: customer_id,
73
- mode: session_type === "one_time" ? "payment" : "subscription",
74
- ...session_type == "one_time" && { metadata },
75
- ...session_type == "recurring" && { subscription_data: { metadata } },
76
- line_items: [{ price: item_id }],
77
- ...provider_metadata
102
+ customer: params.customer_id,
103
+ mode: params.session_type === "one_time" ? "payment" : "subscription",
104
+ ...params.session_type == "one_time" && { metadata: stringifyObjectValues2(params.metadata ?? {}) },
105
+ ...params.session_type == "recurring" && { subscription_data: { metadata: stringifyObjectValues2(params.metadata ?? {}) } },
106
+ line_items: [{ price: params.item_id, quantity: params.quantity }],
107
+ ...params.provider_metadata
78
108
  });
79
- return toPaykitCheckout(checkout);
109
+ return paykitCheckout$InboundSchema(checkout);
80
110
  };
81
111
  this.retrieveCheckout = async (id) => {
82
112
  const checkout = await this.stripe.checkout.sessions.retrieve(id);
83
- return toPaykitCheckout(checkout);
113
+ return paykitCheckout$InboundSchema(checkout);
84
114
  };
85
115
  /**
86
116
  * Customer management
87
117
  */
88
118
  this.createCustomer = async (params) => {
89
119
  const customer = await this.stripe.customers.create(params);
90
- return toPaykitCustomer(customer);
120
+ return paykitCustomer$InboundSchema(customer);
91
121
  };
92
122
  this.updateCustomer = async (id, params) => {
93
123
  const customer = await this.stripe.customers.update(id, params);
94
- return toPaykitCustomer(customer);
124
+ return paykitCustomer$InboundSchema(customer);
95
125
  };
96
126
  this.deleteCustomer = async (id) => {
97
127
  await this.stripe.customers.del(id);
@@ -100,7 +130,7 @@ var StripeProvider = class {
100
130
  this.retrieveCustomer = async (id) => {
101
131
  const customer = await this.stripe.customers.retrieve(id);
102
132
  if ("deleted" in customer) return null;
103
- return toPaykitCustomer(customer);
133
+ return paykitCustomer$InboundSchema(customer);
104
134
  };
105
135
  /**
106
136
  * Subscription management
@@ -110,12 +140,12 @@ var StripeProvider = class {
110
140
  return null;
111
141
  };
112
142
  this.updateSubscription = async (id, params) => {
113
- const subscription = await this.stripe.subscriptions.update(id, { metadata: params.metadata });
114
- return toPaykitSubscription(subscription);
143
+ const subscription = await this.stripe.subscriptions.update(id, { metadata: stringifyObjectValues2(params.metadata ?? {}) });
144
+ return paykitSubscription$InboundSchema(subscription);
115
145
  };
116
146
  this.retrieveSubscription = async (id) => {
117
147
  const subscription = await this.stripe.subscriptions.retrieve(id);
118
- return toPaykitSubscription(subscription);
148
+ return paykitSubscription$InboundSchema(subscription);
119
149
  };
120
150
  /**
121
151
  * Webhook management
@@ -129,7 +159,7 @@ var StripeProvider = class {
129
159
  /**
130
160
  * Invoice
131
161
  */
132
- "checkout.session.completed": (event2) => {
162
+ "checkout.session.completed": async (event2) => {
133
163
  const data = event2.data.object;
134
164
  if (data.mode !== "payment") return null;
135
165
  return toPaykitEvent({
@@ -138,58 +168,72 @@ var StripeProvider = class {
138
168
  id: event2.id,
139
169
  data: {
140
170
  id: data.id,
141
- amount: data.amount_total ?? 0,
171
+ status: "paid",
172
+ paid_at: new Date(event2.created * 1e3).toISOString(),
173
+ amount_paid: data.amount_total ?? 0,
142
174
  currency: data.currency ?? "",
143
- metadata: stringifyObjectValues2({ ...data.metadata ?? {}, $mode: data.mode }),
175
+ metadata: stringifyObjectValues2({ ...data.metadata ?? {} }),
144
176
  customer_id: data.customer?.toString() ?? "",
145
- billing_mode: "one_time"
177
+ billing_mode: "one_time",
178
+ subscription_id: null,
179
+ custom_fields: data.custom_fields ?? null,
180
+ line_items: data.line_items?.data.map((item) => ({ id: item.price.id, quantity: item.quantity })) ?? []
146
181
  }
147
182
  });
148
183
  },
149
- "invoice.paid": (event2) => {
184
+ "invoice.paid": async (event2) => {
150
185
  const data = event2.data.object;
151
- if (data.status !== "paid" && !["subscription_create", "subscription_cycle"].includes(data.billing_reason)) {
152
- return null;
153
- }
186
+ const relevantBillingReasons = ["subscription_create", "subscription_cycle"];
187
+ if (data.status !== "paid" && !relevantBillingReasons.includes(data.billing_reason)) return null;
154
188
  return toPaykitEvent({
155
189
  type: "$invoicePaid",
156
190
  created: event2.created,
157
191
  id: event2.id,
158
- data: toPaykitInvoice({ ...data, billingMode: "recurring" })
192
+ data: paykitInvoice$InboundSchema({ ...data, billingMode: "recurring" })
159
193
  });
160
194
  },
161
195
  /**
162
196
  * Customer
163
197
  */
164
- "customer.created": (event2) => {
198
+ "customer.created": async (event2) => {
165
199
  const data = event2.data.object;
166
- return toPaykitEvent({ type: "$customerCreated", created: event2.created, id: event2.id, data: toPaykitCustomer(data) });
200
+ return toPaykitEvent({ type: "$customerCreated", created: event2.created, id: event2.id, data: paykitCustomer$InboundSchema(data) });
167
201
  },
168
- "customer.updated": (event2) => {
202
+ "customer.updated": async (event2) => {
169
203
  const data = event2.data.object;
170
- return toPaykitEvent({ type: "$customerUpdated", created: event2.created, id: event2.id, data: toPaykitCustomer(data) });
204
+ return toPaykitEvent({ type: "$customerUpdated", created: event2.created, id: event2.id, data: paykitCustomer$InboundSchema(data) });
171
205
  },
172
- "customer.deleted": (event2) => {
206
+ "customer.deleted": async (event2) => {
173
207
  return toPaykitEvent({ type: "$customerDeleted", created: event2.created, id: event2.id, data: null });
174
208
  },
175
209
  /**
176
210
  * Subscription
177
211
  */
178
- "customer.subscription.created": (event2) => {
212
+ "customer.subscription.created": async (event2) => {
179
213
  const data = event2.data.object;
180
- return toPaykitEvent({ type: "$subscriptionCreated", created: event2.created, id: event2.id, data: toPaykitSubscription(data) });
214
+ return toPaykitEvent({
215
+ type: "$subscriptionCreated",
216
+ created: event2.created,
217
+ id: event2.id,
218
+ data: paykitSubscription$InboundSchema(data)
219
+ });
181
220
  },
182
- "customer.subscription.updated": (event2) => {
221
+ "customer.subscription.updated": async (event2) => {
183
222
  const data = event2.data.object;
184
- return toPaykitEvent({ type: "$subscriptionUpdated", created: event2.created, id: event2.id, data: toPaykitSubscription(data) });
223
+ return toPaykitEvent({
224
+ type: "$subscriptionUpdated",
225
+ created: event2.created,
226
+ id: event2.id,
227
+ data: paykitSubscription$InboundSchema(data)
228
+ });
185
229
  },
186
- "customer.subscription.deleted": (event2) => {
230
+ "customer.subscription.deleted": async (event2) => {
187
231
  return toPaykitEvent({ type: "$subscriptionCancelled", created: event2.created, id: event2.id, data: null });
188
232
  }
189
233
  };
190
234
  const handler = webhookHandlers[event.type];
191
235
  if (!handler) throw new Error(`Unhandled event type: ${event.type}`);
192
- const result = handler(event);
236
+ const result = await handler(event);
193
237
  if (!result) throw new Error(`Unhandled event type: ${event.type}`);
194
238
  return result;
195
239
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paykit-sdk/stripe",
3
- "version": "1.1.6",
3
+ "version": "1.1.7",
4
4
  "description": "Stripe provider for PayKit",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",
@@ -19,12 +19,12 @@
19
19
  "typescript"
20
20
  ],
21
21
  "author": "Emmanuel Odii",
22
- "license": "ISC",
22
+ "license": "GPL-3.0",
23
23
  "dependencies": {
24
24
  "stripe": "^18.2.1"
25
25
  },
26
26
  "peerDependencies": {
27
- "@paykit-sdk/core": "^1.1.7"
27
+ "@paykit-sdk/core": "^1.1.8"
28
28
  },
29
29
  "devDependencies": {
30
30
  "tsup": "^8.0.0",