@paykit-sdk/medusajs 1.0.12 → 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.
@@ -1,31 +1,37 @@
1
+ import * as _paykit_sdk_core from '@paykit-sdk/core';
2
+ import { PayKit } from '@paykit-sdk/core';
1
3
  import { InitiatePaymentInput, InitiatePaymentOutput, CapturePaymentInput, CapturePaymentOutput, AuthorizePaymentInput, AuthorizePaymentOutput, CancelPaymentInput, CancelPaymentOutput, DeletePaymentInput, DeletePaymentOutput, GetPaymentStatusInput, GetPaymentStatusOutput, RefundPaymentInput, RefundPaymentOutput, RetrievePaymentInput, RetrievePaymentOutput, UpdatePaymentInput, UpdatePaymentOutput, ProviderWebhookPayload, WebhookActionResult, CreateAccountHolderInput, CreateAccountHolderOutput, UpdateAccountHolderInput, UpdateAccountHolderOutput, DeleteAccountHolderInput, DeleteAccountHolderOutput } from '@medusajs/framework/types';
2
4
  import { AbstractPaymentProvider } from '@medusajs/framework/utils';
3
- import { PayKitProvider, PayKit } from '@paykit-sdk/core';
4
5
  import { z } from 'zod';
5
6
 
6
7
  declare const optionsSchema: z.ZodObject<{
7
8
  /**
8
9
  * The underlying PayKit provider instance (Stripe, PayPal, etc.)
9
- * This is required and must be a valid PayKit provider instance
10
10
  */
11
- provider: z.ZodType<PayKitProvider, z.ZodTypeDef, PayKitProvider>;
11
+ provider: z.ZodType<_paykit_sdk_core.PayKitProvider<_paykit_sdk_core.ProviderMetadataRegistry, any, Record<string, any>>, z.ZodTypeDef, _paykit_sdk_core.PayKitProvider<_paykit_sdk_core.ProviderMetadataRegistry, any, Record<string, any>>>;
12
12
  /**
13
- * The webhook secret for the provider
14
- * This is required and must be a valid webhook secret
13
+ * The webhook secret for the provider.
15
14
  */
16
- webhookSecret: z.ZodString;
15
+ webhookSecret: z.ZodDefault<z.ZodNullable<z.ZodString>>;
16
+ /**
17
+ * Multiplier applied to the amount before sending to the payment provider.
18
+ * Use this when your provider expects amounts in the smallest currency unit (e.g. cents)
19
+ * but Medusa is passing amounts in the major unit (e.g. euros).
20
+ */
21
+ amountToCentsMultiplier: z.ZodDefault<z.ZodNumber>;
17
22
  /**
18
23
  * Whether to enable debug mode
19
- * If enabled, the adapter will log debug information to the console
20
24
  */
21
25
  debug: z.ZodOptional<z.ZodBoolean>;
22
26
  }, "strip", z.ZodTypeAny, {
23
- provider: PayKitProvider;
24
- webhookSecret: string;
27
+ provider: _paykit_sdk_core.PayKitProvider<_paykit_sdk_core.ProviderMetadataRegistry, any, Record<string, any>>;
28
+ webhookSecret: string | null;
29
+ amountToCentsMultiplier: number;
25
30
  debug?: boolean | undefined;
26
31
  }, {
27
- provider: PayKitProvider;
28
- webhookSecret: string;
32
+ provider: _paykit_sdk_core.PayKitProvider<_paykit_sdk_core.ProviderMetadataRegistry, any, Record<string, any>>;
33
+ webhookSecret?: string | null | undefined;
34
+ amountToCentsMultiplier?: number | undefined;
29
35
  debug?: boolean | undefined;
30
36
  }>;
31
37
  type PaykitMedusaJSAdapterOptions = z.infer<typeof optionsSchema>;
@@ -35,17 +41,16 @@ declare class PaykitMedusaJSAdapter extends AbstractPaymentProvider<PaykitMedusa
35
41
  * Will be stored as `pp_paykit_{id}` in Medusa
36
42
  */
37
43
  static identifier: string;
38
- protected readonly paykit: PayKit;
39
- protected readonly provider: PayKitProvider;
44
+ private static readonly adapterMetadata;
45
+ protected readonly paykit: PayKit<PaykitMedusaJSAdapterOptions['provider']>;
40
46
  protected readonly options: PaykitMedusaJSAdapterOptions;
41
47
  static validateOptions(options: Record<string, any>): void | never;
42
48
  /**
43
- * Constructor receives Medusa's container and provider options
44
- *
45
49
  * @param cradle - Medusa's dependency injection container
46
50
  * @param options - PayKit provider configuration
47
51
  */
48
52
  constructor(cradle: Record<string, unknown>, options: PaykitMedusaJSAdapterOptions);
53
+ private exec;
49
54
  initiatePayment: ({ context, amount, currency_code, data, }: InitiatePaymentInput) => Promise<InitiatePaymentOutput>;
50
55
  capturePayment: (input: CapturePaymentInput) => Promise<CapturePaymentOutput>;
51
56
  authorizePayment: (input: AuthorizePaymentInput) => Promise<AuthorizePaymentOutput>;
@@ -1,31 +1,37 @@
1
+ import * as _paykit_sdk_core from '@paykit-sdk/core';
2
+ import { PayKit } from '@paykit-sdk/core';
1
3
  import { InitiatePaymentInput, InitiatePaymentOutput, CapturePaymentInput, CapturePaymentOutput, AuthorizePaymentInput, AuthorizePaymentOutput, CancelPaymentInput, CancelPaymentOutput, DeletePaymentInput, DeletePaymentOutput, GetPaymentStatusInput, GetPaymentStatusOutput, RefundPaymentInput, RefundPaymentOutput, RetrievePaymentInput, RetrievePaymentOutput, UpdatePaymentInput, UpdatePaymentOutput, ProviderWebhookPayload, WebhookActionResult, CreateAccountHolderInput, CreateAccountHolderOutput, UpdateAccountHolderInput, UpdateAccountHolderOutput, DeleteAccountHolderInput, DeleteAccountHolderOutput } from '@medusajs/framework/types';
2
4
  import { AbstractPaymentProvider } from '@medusajs/framework/utils';
3
- import { PayKitProvider, PayKit } from '@paykit-sdk/core';
4
5
  import { z } from 'zod';
5
6
 
6
7
  declare const optionsSchema: z.ZodObject<{
7
8
  /**
8
9
  * The underlying PayKit provider instance (Stripe, PayPal, etc.)
9
- * This is required and must be a valid PayKit provider instance
10
10
  */
11
- provider: z.ZodType<PayKitProvider, z.ZodTypeDef, PayKitProvider>;
11
+ provider: z.ZodType<_paykit_sdk_core.PayKitProvider<_paykit_sdk_core.ProviderMetadataRegistry, any, Record<string, any>>, z.ZodTypeDef, _paykit_sdk_core.PayKitProvider<_paykit_sdk_core.ProviderMetadataRegistry, any, Record<string, any>>>;
12
12
  /**
13
- * The webhook secret for the provider
14
- * This is required and must be a valid webhook secret
13
+ * The webhook secret for the provider.
15
14
  */
16
- webhookSecret: z.ZodString;
15
+ webhookSecret: z.ZodDefault<z.ZodNullable<z.ZodString>>;
16
+ /**
17
+ * Multiplier applied to the amount before sending to the payment provider.
18
+ * Use this when your provider expects amounts in the smallest currency unit (e.g. cents)
19
+ * but Medusa is passing amounts in the major unit (e.g. euros).
20
+ */
21
+ amountToCentsMultiplier: z.ZodDefault<z.ZodNumber>;
17
22
  /**
18
23
  * Whether to enable debug mode
19
- * If enabled, the adapter will log debug information to the console
20
24
  */
21
25
  debug: z.ZodOptional<z.ZodBoolean>;
22
26
  }, "strip", z.ZodTypeAny, {
23
- provider: PayKitProvider;
24
- webhookSecret: string;
27
+ provider: _paykit_sdk_core.PayKitProvider<_paykit_sdk_core.ProviderMetadataRegistry, any, Record<string, any>>;
28
+ webhookSecret: string | null;
29
+ amountToCentsMultiplier: number;
25
30
  debug?: boolean | undefined;
26
31
  }, {
27
- provider: PayKitProvider;
28
- webhookSecret: string;
32
+ provider: _paykit_sdk_core.PayKitProvider<_paykit_sdk_core.ProviderMetadataRegistry, any, Record<string, any>>;
33
+ webhookSecret?: string | null | undefined;
34
+ amountToCentsMultiplier?: number | undefined;
29
35
  debug?: boolean | undefined;
30
36
  }>;
31
37
  type PaykitMedusaJSAdapterOptions = z.infer<typeof optionsSchema>;
@@ -35,17 +41,16 @@ declare class PaykitMedusaJSAdapter extends AbstractPaymentProvider<PaykitMedusa
35
41
  * Will be stored as `pp_paykit_{id}` in Medusa
36
42
  */
37
43
  static identifier: string;
38
- protected readonly paykit: PayKit;
39
- protected readonly provider: PayKitProvider;
44
+ private static readonly adapterMetadata;
45
+ protected readonly paykit: PayKit<PaykitMedusaJSAdapterOptions['provider']>;
40
46
  protected readonly options: PaykitMedusaJSAdapterOptions;
41
47
  static validateOptions(options: Record<string, any>): void | never;
42
48
  /**
43
- * Constructor receives Medusa's container and provider options
44
- *
45
49
  * @param cradle - Medusa's dependency injection container
46
50
  * @param options - PayKit provider configuration
47
51
  */
48
52
  constructor(cradle: Record<string, unknown>, options: PaykitMedusaJSAdapterOptions);
53
+ private exec;
49
54
  initiatePayment: ({ context, amount, currency_code, data, }: InitiatePaymentInput) => Promise<InitiatePaymentOutput>;
50
55
  capturePayment: (input: CapturePaymentInput) => Promise<CapturePaymentOutput>;
51
56
  authorizePayment: (input: AuthorizePaymentInput) => Promise<AuthorizePaymentOutput>;