@paykit-sdk/stripe 1.1.104 → 1.1.105

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
  }
@@ -107,7 +116,10 @@ export async function POST(request: NextRequest) {
107
116
 
108
117
  ```typescript
109
118
  import { paykit, endpoints } from '@/lib/paykit';
110
- import { createEndpointHandlers, EndpointPath } from '@paykit-sdk/core';
119
+ import {
120
+ createEndpointHandlers,
121
+ EndpointPath,
122
+ } from '@paykit-sdk/core';
111
123
  import express from 'express';
112
124
 
113
125
  const app = express();
@@ -122,7 +134,9 @@ app.post(
122
134
  const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET;
123
135
 
124
136
  if (!webhookSecret) {
125
- return res.status(500).json({ error: 'Webhook secret not configured' });
137
+ return res
138
+ .status(500)
139
+ .json({ error: 'Webhook secret not configured' });
126
140
  }
127
141
 
128
142
  const webhook = paykit.webhooks
@@ -153,7 +167,10 @@ app.post(
153
167
  } catch (error) {
154
168
  console.error('Webhook error:', error);
155
169
  res.status(500).json({
156
- message: error instanceof Error ? error.message : 'Webhook processing failed',
170
+ message:
171
+ error instanceof Error
172
+ ? error.message
173
+ : 'Webhook processing failed',
157
174
  });
158
175
  }
159
176
  },
@@ -164,7 +181,10 @@ app.use(express.json());
164
181
 
165
182
  app.post('/api/paykit/*', async (req, res) => {
166
183
  try {
167
- const endpoint = req.path.replace('/api/paykit', '') as EndpointPath;
184
+ const endpoint = req.path.replace(
185
+ '/api/paykit',
186
+ '',
187
+ ) as EndpointPath;
168
188
  const handler = endpoints[endpoint];
169
189
 
170
190
  if (!handler) {
@@ -177,7 +197,10 @@ app.post('/api/paykit/*', async (req, res) => {
177
197
  res.json({ result });
178
198
  } catch (error) {
179
199
  res.status(500).json({
180
- message: error instanceof Error ? error.message : 'Internal server error',
200
+ message:
201
+ error instanceof Error
202
+ ? error.message
203
+ : 'Internal server error',
181
204
  });
182
205
  }
183
206
  });