@paykit-sdk/polar 1.1.99 → 1.1.100

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
@@ -33,11 +33,15 @@ export async function POST(
33
33
  ) {
34
34
  try {
35
35
  // Construct the endpoint path with full type safety
36
- const endpoint = ('/' + params.endpoint.join('/')) as EndpointPath;
36
+ const endpoint = ('/' +
37
+ params.endpoint.join('/')) as EndpointPath;
37
38
  const handler = endpoints[endpoint];
38
39
 
39
40
  if (!handler) {
40
- return NextResponse.json({ message: 'Endpoint not found' }, { status: 404 });
41
+ return NextResponse.json(
42
+ { message: 'Endpoint not found' },
43
+ { status: 404 },
44
+ );
41
45
  }
42
46
 
43
47
  // Parse request body
@@ -50,7 +54,12 @@ export async function POST(
50
54
  } catch (error) {
51
55
  console.error('PayKit API Error:', error);
52
56
  return NextResponse.json(
53
- { message: error instanceof Error ? error.message : 'Internal server error' },
57
+ {
58
+ message:
59
+ error instanceof Error
60
+ ? error.message
61
+ : 'Internal server error',
62
+ },
54
63
  { status: 500 },
55
64
  );
56
65
  }
@@ -67,7 +76,10 @@ export async function POST(request: NextRequest) {
67
76
  const webhookSecret = process.env.POLAR_WEBHOOK_SECRET;
68
77
 
69
78
  if (!webhookSecret) {
70
- return NextResponse.json({ error: 'Webhook secret not configured' }, { status: 500 });
79
+ return NextResponse.json(
80
+ { error: 'Webhook secret not configured' },
81
+ { status: 500 },
82
+ );
71
83
  }
72
84
 
73
85
  const webhook = paykit.webhooks
@@ -114,7 +126,9 @@ app.post(
114
126
  const webhookSecret = process.env.POLAR_WEBHOOK_SECRET;
115
127
 
116
128
  if (!webhookSecret) {
117
- return res.status(500).json({ error: 'Webhook secret not configured' });
129
+ return res
130
+ .status(500)
131
+ .json({ error: 'Webhook secret not configured' });
118
132
  }
119
133
 
120
134
  const webhook = paykit.webhooks
@@ -132,8 +146,13 @@ app.post(
132
146
  console.log('Refund created:', event.data);
133
147
  });
134
148
 
135
- const body = typeof req.body === 'string' ? req.body : JSON.stringify(req.body);
136
- const headers = new Headers(Object.entries(req.headers) as [string, string][]);
149
+ const body =
150
+ typeof req.body === 'string'
151
+ ? req.body
152
+ : JSON.stringify(req.body);
153
+ const headers = new Headers(
154
+ Object.entries(req.headers) as [string, string][],
155
+ );
137
156
  const fullUrl = `${req.protocol}://${req.get('host')}${req.originalUrl}`;
138
157
 
139
158
  await webhook.handle({ body, headers, fullUrl });
@@ -142,7 +161,10 @@ app.post(
142
161
  } catch (error) {
143
162
  console.error('Webhook error:', error);
144
163
  res.status(500).json({
145
- message: error instanceof Error ? error.message : 'Webhook processing failed',
164
+ message:
165
+ error instanceof Error
166
+ ? error.message
167
+ : 'Webhook processing failed',
146
168
  });
147
169
  }
148
170
  },
@@ -153,7 +175,10 @@ app.use(express.json());
153
175
 
154
176
  app.post('/api/paykit/*', async (req, res) => {
155
177
  try {
156
- const endpoint = req.path.replace('/api/paykit', '') as EndpointPath;
178
+ const endpoint = req.path.replace(
179
+ '/api/paykit',
180
+ '',
181
+ ) as EndpointPath;
157
182
  const handler = endpoints[endpoint];
158
183
 
159
184
  if (!handler) {
@@ -166,7 +191,10 @@ app.post('/api/paykit/*', async (req, res) => {
166
191
  res.json({ result });
167
192
  } catch (error) {
168
193
  res.status(500).json({
169
- message: error instanceof Error ? error.message : 'Internal server error',
194
+ message:
195
+ error instanceof Error
196
+ ? error.message
197
+ : 'Internal server error',
170
198
  });
171
199
  }
172
200
  });
package/dist/index.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { PolarOptions, PolarProvider } from './polar-provider.mjs';
2
2
  import '@paykit-sdk/core';
3
3
  import '@polar-sh/sdk';
4
+ import '@polar-sh/sdk/webhooks';
4
5
 
5
6
  declare const createPolar: (config: PolarOptions) => PolarProvider;
6
7
  declare const polar: () => PolarProvider;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { PolarOptions, PolarProvider } from './polar-provider.js';
2
2
  import '@paykit-sdk/core';
3
3
  import '@polar-sh/sdk';
4
+ import '@polar-sh/sdk/webhooks';
4
5
 
5
6
  declare const createPolar: (config: PolarOptions) => PolarProvider;
6
7
  declare const polar: () => PolarProvider;