@paykit-sdk/polar 1.0.1-alpha.4 → 1.0.1-alpha.6

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/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { PaykitProviderOptions, PayKitProvider, CreateCheckoutParams, Checkout, CreateCustomerParams, Customer, UpdateCustomerParams, Subscription, UpdateSubscriptionParams, WebhookProviderPayload, WebhookEventPayload } from '@paykit-sdk/core';
1
+ import { PaykitProviderOptions, PayKitProvider, CreateCheckoutParams, Checkout, CreateCustomerParams, Customer, UpdateCustomerParams, Subscription, UpdateSubscriptionParams, WebhookConfig, WebhookEventPayload } from '@paykit-sdk/core';
2
2
  import { SDKOptions } from '@polar-sh/sdk';
3
3
 
4
4
  interface PolarConfig extends PaykitProviderOptions<SDKOptions> {
@@ -29,7 +29,7 @@ declare class PolarProvider implements PayKitProvider {
29
29
  /**
30
30
  * Webhook management
31
31
  */
32
- handleWebhook: (params: WebhookProviderPayload) => Promise<WebhookEventPayload>;
32
+ handleWebhook: (params: WebhookConfig) => Promise<WebhookEventPayload>;
33
33
  }
34
34
 
35
35
  declare const createPolar: (config: PolarConfig) => PolarProvider;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { PaykitProviderOptions, PayKitProvider, CreateCheckoutParams, Checkout, CreateCustomerParams, Customer, UpdateCustomerParams, Subscription, UpdateSubscriptionParams, WebhookProviderPayload, WebhookEventPayload } from '@paykit-sdk/core';
1
+ import { PaykitProviderOptions, PayKitProvider, CreateCheckoutParams, Checkout, CreateCustomerParams, Customer, UpdateCustomerParams, Subscription, UpdateSubscriptionParams, WebhookConfig, WebhookEventPayload } from '@paykit-sdk/core';
2
2
  import { SDKOptions } from '@polar-sh/sdk';
3
3
 
4
4
  interface PolarConfig extends PaykitProviderOptions<SDKOptions> {
@@ -29,7 +29,7 @@ declare class PolarProvider implements PayKitProvider {
29
29
  /**
30
30
  * Webhook management
31
31
  */
32
- handleWebhook: (params: WebhookProviderPayload) => Promise<WebhookEventPayload>;
32
+ handleWebhook: (params: WebhookConfig) => Promise<WebhookEventPayload>;
33
33
  }
34
34
 
35
35
  declare const createPolar: (config: PolarConfig) => PolarProvider;
package/dist/index.js CHANGED
@@ -128,24 +128,27 @@ var PolarProvider = class {
128
128
  const timestamp = webhookHeaders["webhook-timestamp"];
129
129
  if (webhookEvent.type === "subscription.updated") {
130
130
  const subscription = await this.retrieveSubscription(webhookEvent.data.id);
131
- return (0, import_core2.toPaykitEvent)({ type: "subscription.updated", created: parseInt(timestamp), id, data: subscription });
131
+ return (0, import_core2.toPaykitEvent)({ type: "$subscriptionUpdated", created: parseInt(timestamp), id, data: subscription });
132
132
  } else if (webhookEvent.type === "subscription.created") {
133
133
  const subscription = await this.retrieveSubscription(webhookEvent.data.id);
134
- return (0, import_core2.toPaykitEvent)({ type: "subscription.created", created: parseInt(timestamp), id, data: subscription });
134
+ return (0, import_core2.toPaykitEvent)({ type: "$subscriptionCreated", created: parseInt(timestamp), id, data: subscription });
135
135
  } else if (webhookEvent.type === "subscription.revoked") {
136
136
  const subscription = await this.retrieveSubscription(webhookEvent.data.id);
137
- return (0, import_core2.toPaykitEvent)({ type: "subscription.canceled", created: parseInt(timestamp), id, data: subscription });
137
+ return (0, import_core2.toPaykitEvent)({ type: "$subscriptionCanceled", created: parseInt(timestamp), id, data: subscription });
138
138
  } else if (webhookEvent.type === "customer.created") {
139
139
  const customer = await this.retrieveCustomer(webhookEvent.data.id);
140
- return (0, import_core2.toPaykitEvent)({ type: "customer.created", created: parseInt(timestamp), id, data: customer });
140
+ return (0, import_core2.toPaykitEvent)({ type: "$customerCreated", created: parseInt(timestamp), id, data: customer });
141
141
  } else if (webhookEvent.type === "customer.updated") {
142
142
  const customer = await this.retrieveCustomer(webhookEvent.data.id);
143
- return (0, import_core2.toPaykitEvent)({ type: "customer.updated", created: parseInt(timestamp), id, data: customer });
143
+ return (0, import_core2.toPaykitEvent)({ type: "$customerUpdated", created: parseInt(timestamp), id, data: customer });
144
144
  } else if (webhookEvent.type === "customer.deleted") {
145
- return (0, import_core2.toPaykitEvent)({ type: "customer.deleted", created: parseInt(timestamp), id, data: null });
145
+ return (0, import_core2.toPaykitEvent)({ type: "$customerDeleted", created: parseInt(timestamp), id, data: null });
146
146
  } else if (webhookEvent.type === "checkout.created") {
147
147
  const checkout = await this.retrieveCheckout(webhookEvent.data.id);
148
- return (0, import_core2.toPaykitEvent)({ type: "checkout.created", created: parseInt(timestamp), id, data: checkout });
148
+ return (0, import_core2.toPaykitEvent)({ type: "$checkoutCreated", created: parseInt(timestamp), id, data: checkout });
149
+ } else if (webhookEvent.type === "order.created") {
150
+ const checkout = await this.retrieveCheckout(webhookEvent.data.id);
151
+ return (0, import_core2.toPaykitEvent)({ type: "$paymentReceived", created: parseInt(timestamp), id, data: checkout });
149
152
  }
150
153
  throw new Error(`Unknown event type: ${webhookEvent.type}`);
151
154
  };
package/dist/index.mjs CHANGED
@@ -106,24 +106,27 @@ var PolarProvider = class {
106
106
  const timestamp = webhookHeaders["webhook-timestamp"];
107
107
  if (webhookEvent.type === "subscription.updated") {
108
108
  const subscription = await this.retrieveSubscription(webhookEvent.data.id);
109
- return toPaykitEvent({ type: "subscription.updated", created: parseInt(timestamp), id, data: subscription });
109
+ return toPaykitEvent({ type: "$subscriptionUpdated", created: parseInt(timestamp), id, data: subscription });
110
110
  } else if (webhookEvent.type === "subscription.created") {
111
111
  const subscription = await this.retrieveSubscription(webhookEvent.data.id);
112
- return toPaykitEvent({ type: "subscription.created", created: parseInt(timestamp), id, data: subscription });
112
+ return toPaykitEvent({ type: "$subscriptionCreated", created: parseInt(timestamp), id, data: subscription });
113
113
  } else if (webhookEvent.type === "subscription.revoked") {
114
114
  const subscription = await this.retrieveSubscription(webhookEvent.data.id);
115
- return toPaykitEvent({ type: "subscription.canceled", created: parseInt(timestamp), id, data: subscription });
115
+ return toPaykitEvent({ type: "$subscriptionCanceled", created: parseInt(timestamp), id, data: subscription });
116
116
  } else if (webhookEvent.type === "customer.created") {
117
117
  const customer = await this.retrieveCustomer(webhookEvent.data.id);
118
- return toPaykitEvent({ type: "customer.created", created: parseInt(timestamp), id, data: customer });
118
+ return toPaykitEvent({ type: "$customerCreated", created: parseInt(timestamp), id, data: customer });
119
119
  } else if (webhookEvent.type === "customer.updated") {
120
120
  const customer = await this.retrieveCustomer(webhookEvent.data.id);
121
- return toPaykitEvent({ type: "customer.updated", created: parseInt(timestamp), id, data: customer });
121
+ return toPaykitEvent({ type: "$customerUpdated", created: parseInt(timestamp), id, data: customer });
122
122
  } else if (webhookEvent.type === "customer.deleted") {
123
- return toPaykitEvent({ type: "customer.deleted", created: parseInt(timestamp), id, data: null });
123
+ return toPaykitEvent({ type: "$customerDeleted", created: parseInt(timestamp), id, data: null });
124
124
  } else if (webhookEvent.type === "checkout.created") {
125
125
  const checkout = await this.retrieveCheckout(webhookEvent.data.id);
126
- return toPaykitEvent({ type: "checkout.created", created: parseInt(timestamp), id, data: checkout });
126
+ return toPaykitEvent({ type: "$checkoutCreated", created: parseInt(timestamp), id, data: checkout });
127
+ } else if (webhookEvent.type === "order.created") {
128
+ const checkout = await this.retrieveCheckout(webhookEvent.data.id);
129
+ return toPaykitEvent({ type: "$paymentReceived", created: parseInt(timestamp), id, data: checkout });
127
130
  }
128
131
  throw new Error(`Unknown event type: ${webhookEvent.type}`);
129
132
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paykit-sdk/polar",
3
- "version": "1.0.1-alpha.4",
3
+ "version": "1.0.1-alpha.6",
4
4
  "description": "Polar provider for PayKit",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.esm.js",