@paykit-sdk/gopay 1.1.3 → 1.2.0

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
@@ -43,7 +43,10 @@ export async function POST(
43
43
  const handler = endpoints[endpoint];
44
44
 
45
45
  if (!handler) {
46
- return NextResponse.json({ message: 'Endpoint not found' }, { status: 404 });
46
+ return NextResponse.json(
47
+ { message: 'Endpoint not found' },
48
+ { status: 404 },
49
+ );
47
50
  }
48
51
 
49
52
  // Parse request body
@@ -56,7 +59,12 @@ export async function POST(
56
59
  } catch (error) {
57
60
  console.error('PayKit API Error:', error);
58
61
  return NextResponse.json(
59
- { message: error instanceof Error ? error.message : 'Internal server error' },
62
+ {
63
+ message:
64
+ error instanceof Error
65
+ ? error.message
66
+ : 'Internal server error',
67
+ },
60
68
  { status: 500 },
61
69
  );
62
70
  }
@@ -144,7 +152,10 @@ app.get('/api/webhooks/gopay', async (req, res) => {
144
152
  } catch (error) {
145
153
  console.error('Webhook error:', error);
146
154
  res.status(500).json({
147
- message: error instanceof Error ? error.message : 'Webhook processing failed',
155
+ message:
156
+ error instanceof Error
157
+ ? error.message
158
+ : 'Webhook processing failed',
148
159
  });
149
160
  }
150
161
  });
@@ -154,7 +165,10 @@ app.use(express.json());
154
165
 
155
166
  app.post('/api/paykit/*', async (req, res) => {
156
167
  try {
157
- const endpoint = req.path.replace('/api/paykit', '') as EndpointPath;
168
+ const endpoint = req.path.replace(
169
+ '/api/paykit',
170
+ '',
171
+ ) as EndpointPath;
158
172
  const handler = endpoints[endpoint];
159
173
 
160
174
  if (!handler) {
@@ -167,7 +181,10 @@ app.post('/api/paykit/*', async (req, res) => {
167
181
  res.json({ result });
168
182
  } catch (error) {
169
183
  res.status(500).json({
170
- message: error instanceof Error ? error.message : 'Internal server error',
184
+ message:
185
+ error instanceof Error
186
+ ? error.message
187
+ : 'Internal server error',
171
188
  });
172
189
  }
173
190
  });
@@ -217,7 +234,7 @@ GOPAY_WEBHOOK_URL=https://your-domain.com/api/paykit/webhooks
217
234
 
218
235
  ## Documentation
219
236
 
220
- For detailed documentation, including setup guides, webhook configuration, and provider metadata requirements, see the [GoPay Provider Documentation](https://usepaykit.com/docs/providers/gopay).
237
+ For detailed documentation, including setup guides, webhook configuration, and provider metadata requirements, see the [GoPay Provider Documentation](https://docs.usepaykit.com/providers/gopay).
221
238
 
222
239
  ## Support
223
240
 
@@ -1,5 +1,21 @@
1
- import { PaykitProviderOptions, AbstractPayKitProvider, PayKitProvider, CreateCheckoutSchema, Checkout, UpdateCheckoutSchema, CreateCustomerParams, Customer, UpdateCustomerParams, CreateSubscriptionSchema, Subscription, UpdateSubscriptionSchema, CreatePaymentSchema, Payment, CapturePaymentSchema, UpdatePaymentSchema, CreateRefundSchema, Refund, HandleWebhookParams, WebhookEventPayload } from '@paykit-sdk/core';
1
+ import { PaykitProviderOptions, AbstractPayKitProvider, PayKitProvider, ProviderMetadataRegistry, CreateCheckoutSchema, Checkout, UpdateCheckoutSchema, CreateCustomerParams, Customer, UpdateCustomerParams, CreateSubscriptionSchema, Subscription, UpdateSubscriptionSchema, CreatePaymentSchema, Payment, CapturePaymentSchema, UpdatePaymentSchema, CreateRefundSchema, Refund, WebhookHandlerConfig, WebhookEventPayload } from '@paykit-sdk/core';
2
2
 
3
+ interface GoPayMetadata extends ProviderMetadataRegistry {
4
+ checkout: {
5
+ amount: number | string;
6
+ currency: string;
7
+ language: string;
8
+ };
9
+ subscription: {
10
+ success_url: string;
11
+ recurrence_period?: number;
12
+ };
13
+ payments: {
14
+ success_url: string;
15
+ };
16
+ }
17
+ interface GoPayRawEvents extends Record<string, any> {
18
+ }
3
19
  interface GoPayOptions extends PaykitProviderOptions {
4
20
  /**
5
21
  * The client ID for the GoPay API
@@ -18,14 +34,17 @@ interface GoPayOptions extends PaykitProviderOptions {
18
34
  */
19
35
  webhookUrl: string;
20
36
  }
21
- declare class GoPayProvider extends AbstractPayKitProvider implements PayKitProvider {
37
+ declare class GoPayProvider extends AbstractPayKitProvider implements PayKitProvider<GoPayMetadata, null, GoPayRawEvents> {
22
38
  private readonly opts;
23
39
  readonly providerName = "gopay";
40
+ readonly providerVersion: string;
24
41
  private _client;
25
42
  private baseUrl;
43
+ readonly isSandbox: boolean;
26
44
  private tokenManager;
45
+ get _native(): null;
27
46
  constructor(opts: GoPayOptions);
28
- createCheckout: (params: CreateCheckoutSchema) => Promise<Checkout>;
47
+ createCheckout: (params: CreateCheckoutSchema<GoPayMetadata["checkout"]>) => Promise<Checkout>;
29
48
  retrieveCheckout: (id: string) => Promise<Checkout | null>;
30
49
  updateCheckout: (id: string, params: UpdateCheckoutSchema) => Promise<Checkout>;
31
50
  deleteCheckout: (id: string) => Promise<null>;
@@ -33,12 +52,12 @@ declare class GoPayProvider extends AbstractPayKitProvider implements PayKitProv
33
52
  updateCustomer: (id: string, params: UpdateCustomerParams) => Promise<Customer>;
34
53
  deleteCustomer: (id: string) => Promise<null>;
35
54
  retrieveCustomer: (id: string) => Promise<Customer | null>;
36
- createSubscription: (params: CreateSubscriptionSchema) => Promise<Subscription>;
55
+ createSubscription: (params: CreateSubscriptionSchema<GoPayMetadata["subscription"]>) => Promise<Subscription>;
37
56
  updateSubscription: (id: string, params: UpdateSubscriptionSchema) => Promise<Subscription>;
38
57
  cancelSubscription: (id: string) => Promise<Subscription>;
39
58
  deleteSubscription: (id: string) => Promise<null>;
40
59
  retrieveSubscription: (id: string) => Promise<Subscription | null>;
41
- createPayment: (params: CreatePaymentSchema) => Promise<Payment>;
60
+ createPayment: (params: CreatePaymentSchema<GoPayMetadata["payment"]>) => Promise<Payment>;
42
61
  retrievePayment: (id: string) => Promise<Payment | null>;
43
62
  deletePayment: (id: string) => Promise<null>;
44
63
  capturePayment: (id: string, params: CapturePaymentSchema) => Promise<Payment>;
@@ -48,7 +67,7 @@ declare class GoPayProvider extends AbstractPayKitProvider implements PayKitProv
48
67
  */
49
68
  updatePayment: (id: string, params: UpdatePaymentSchema) => Promise<Payment>;
50
69
  createRefund(params: CreateRefundSchema): Promise<Refund>;
51
- handleWebhook: (payload: HandleWebhookParams) => Promise<Array<WebhookEventPayload>>;
70
+ handleWebhook: (payload: WebhookHandlerConfig, webhookSecret: string | null) => Promise<Array<WebhookEventPayload<GoPayRawEvents>>>;
52
71
  }
53
72
 
54
73
  export { type GoPayOptions, GoPayProvider };
@@ -1,5 +1,21 @@
1
- import { PaykitProviderOptions, AbstractPayKitProvider, PayKitProvider, CreateCheckoutSchema, Checkout, UpdateCheckoutSchema, CreateCustomerParams, Customer, UpdateCustomerParams, CreateSubscriptionSchema, Subscription, UpdateSubscriptionSchema, CreatePaymentSchema, Payment, CapturePaymentSchema, UpdatePaymentSchema, CreateRefundSchema, Refund, HandleWebhookParams, WebhookEventPayload } from '@paykit-sdk/core';
1
+ import { PaykitProviderOptions, AbstractPayKitProvider, PayKitProvider, ProviderMetadataRegistry, CreateCheckoutSchema, Checkout, UpdateCheckoutSchema, CreateCustomerParams, Customer, UpdateCustomerParams, CreateSubscriptionSchema, Subscription, UpdateSubscriptionSchema, CreatePaymentSchema, Payment, CapturePaymentSchema, UpdatePaymentSchema, CreateRefundSchema, Refund, WebhookHandlerConfig, WebhookEventPayload } from '@paykit-sdk/core';
2
2
 
3
+ interface GoPayMetadata extends ProviderMetadataRegistry {
4
+ checkout: {
5
+ amount: number | string;
6
+ currency: string;
7
+ language: string;
8
+ };
9
+ subscription: {
10
+ success_url: string;
11
+ recurrence_period?: number;
12
+ };
13
+ payments: {
14
+ success_url: string;
15
+ };
16
+ }
17
+ interface GoPayRawEvents extends Record<string, any> {
18
+ }
3
19
  interface GoPayOptions extends PaykitProviderOptions {
4
20
  /**
5
21
  * The client ID for the GoPay API
@@ -18,14 +34,17 @@ interface GoPayOptions extends PaykitProviderOptions {
18
34
  */
19
35
  webhookUrl: string;
20
36
  }
21
- declare class GoPayProvider extends AbstractPayKitProvider implements PayKitProvider {
37
+ declare class GoPayProvider extends AbstractPayKitProvider implements PayKitProvider<GoPayMetadata, null, GoPayRawEvents> {
22
38
  private readonly opts;
23
39
  readonly providerName = "gopay";
40
+ readonly providerVersion: string;
24
41
  private _client;
25
42
  private baseUrl;
43
+ readonly isSandbox: boolean;
26
44
  private tokenManager;
45
+ get _native(): null;
27
46
  constructor(opts: GoPayOptions);
28
- createCheckout: (params: CreateCheckoutSchema) => Promise<Checkout>;
47
+ createCheckout: (params: CreateCheckoutSchema<GoPayMetadata["checkout"]>) => Promise<Checkout>;
29
48
  retrieveCheckout: (id: string) => Promise<Checkout | null>;
30
49
  updateCheckout: (id: string, params: UpdateCheckoutSchema) => Promise<Checkout>;
31
50
  deleteCheckout: (id: string) => Promise<null>;
@@ -33,12 +52,12 @@ declare class GoPayProvider extends AbstractPayKitProvider implements PayKitProv
33
52
  updateCustomer: (id: string, params: UpdateCustomerParams) => Promise<Customer>;
34
53
  deleteCustomer: (id: string) => Promise<null>;
35
54
  retrieveCustomer: (id: string) => Promise<Customer | null>;
36
- createSubscription: (params: CreateSubscriptionSchema) => Promise<Subscription>;
55
+ createSubscription: (params: CreateSubscriptionSchema<GoPayMetadata["subscription"]>) => Promise<Subscription>;
37
56
  updateSubscription: (id: string, params: UpdateSubscriptionSchema) => Promise<Subscription>;
38
57
  cancelSubscription: (id: string) => Promise<Subscription>;
39
58
  deleteSubscription: (id: string) => Promise<null>;
40
59
  retrieveSubscription: (id: string) => Promise<Subscription | null>;
41
- createPayment: (params: CreatePaymentSchema) => Promise<Payment>;
60
+ createPayment: (params: CreatePaymentSchema<GoPayMetadata["payment"]>) => Promise<Payment>;
42
61
  retrievePayment: (id: string) => Promise<Payment | null>;
43
62
  deletePayment: (id: string) => Promise<null>;
44
63
  capturePayment: (id: string, params: CapturePaymentSchema) => Promise<Payment>;
@@ -48,7 +67,7 @@ declare class GoPayProvider extends AbstractPayKitProvider implements PayKitProv
48
67
  */
49
68
  updatePayment: (id: string, params: UpdatePaymentSchema) => Promise<Payment>;
50
69
  createRefund(params: CreateRefundSchema): Promise<Refund>;
51
- handleWebhook: (payload: HandleWebhookParams) => Promise<Array<WebhookEventPayload>>;
70
+ handleWebhook: (payload: WebhookHandlerConfig, webhookSecret: string | null) => Promise<Array<WebhookEventPayload<GoPayRawEvents>>>;
52
71
  }
53
72
 
54
73
  export { type GoPayOptions, GoPayProvider };