@unchainedshop/core-payment 4.3.3 → 4.4.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.
Files changed (75) hide show
  1. package/README.md +98 -2
  2. package/lib/db/PaymentCredentialsCollection.d.ts +1 -2
  3. package/lib/db/PaymentCredentialsCollection.js +1 -2
  4. package/lib/db/PaymentProvidersCollection.d.ts +6 -6
  5. package/lib/db/PaymentProvidersCollection.js +5 -7
  6. package/lib/module/configurePaymentCredentialsModule.d.ts +1 -2
  7. package/lib/module/configurePaymentCredentialsModule.js +1 -2
  8. package/lib/module/configurePaymentModule.d.ts +17 -18
  9. package/lib/module/configurePaymentModule.js +5 -6
  10. package/lib/module/configurePaymentProvidersModule.d.ts +3 -4
  11. package/lib/module/configurePaymentProvidersModule.js +1 -4
  12. package/lib/payment-index.d.ts +4 -5
  13. package/lib/payment-index.js +4 -5
  14. package/lib/payment-settings.d.ts +2 -3
  15. package/lib/payment-settings.js +0 -1
  16. package/package.json +11 -10
  17. package/lib/db/PaymentCredentialsCollection.d.ts.map +0 -1
  18. package/lib/db/PaymentCredentialsCollection.js.map +0 -1
  19. package/lib/db/PaymentCredentialsSchema.d.ts +0 -3
  20. package/lib/db/PaymentCredentialsSchema.d.ts.map +0 -1
  21. package/lib/db/PaymentCredentialsSchema.js +0 -11
  22. package/lib/db/PaymentCredentialsSchema.js.map +0 -1
  23. package/lib/db/PaymentProvidersCollection.d.ts.map +0 -1
  24. package/lib/db/PaymentProvidersCollection.js.map +0 -1
  25. package/lib/db/PaymentProvidersSchema.d.ts +0 -3
  26. package/lib/db/PaymentProvidersSchema.d.ts.map +0 -1
  27. package/lib/db/PaymentProvidersSchema.js +0 -12
  28. package/lib/db/PaymentProvidersSchema.js.map +0 -1
  29. package/lib/director/PaymentAdapter.d.ts +0 -3
  30. package/lib/director/PaymentAdapter.d.ts.map +0 -1
  31. package/lib/director/PaymentAdapter.js +0 -49
  32. package/lib/director/PaymentAdapter.js.map +0 -1
  33. package/lib/director/PaymentDirector.d.ts +0 -3
  34. package/lib/director/PaymentDirector.d.ts.map +0 -1
  35. package/lib/director/PaymentDirector.js +0 -84
  36. package/lib/director/PaymentDirector.js.map +0 -1
  37. package/lib/director/PaymentError.d.ts +0 -7
  38. package/lib/director/PaymentError.d.ts.map +0 -1
  39. package/lib/director/PaymentError.js +0 -8
  40. package/lib/director/PaymentError.js.map +0 -1
  41. package/lib/director/PaymentPricingAdapter.d.ts +0 -4
  42. package/lib/director/PaymentPricingAdapter.d.ts.map +0 -1
  43. package/lib/director/PaymentPricingAdapter.js +0 -25
  44. package/lib/director/PaymentPricingAdapter.js.map +0 -1
  45. package/lib/director/PaymentPricingDirector.d.ts +0 -3
  46. package/lib/director/PaymentPricingDirector.d.ts.map +0 -1
  47. package/lib/director/PaymentPricingDirector.js +0 -58
  48. package/lib/director/PaymentPricingDirector.js.map +0 -1
  49. package/lib/director/PaymentPricingSheet.d.ts +0 -4
  50. package/lib/director/PaymentPricingSheet.d.ts.map +0 -1
  51. package/lib/director/PaymentPricingSheet.js +0 -69
  52. package/lib/director/PaymentPricingSheet.js.map +0 -1
  53. package/lib/director/PaymentProviderType.d.ts +0 -6
  54. package/lib/director/PaymentProviderType.d.ts.map +0 -1
  55. package/lib/director/PaymentProviderType.js +0 -7
  56. package/lib/director/PaymentProviderType.js.map +0 -1
  57. package/lib/module/configurePaymentCredentialsModule.d.ts.map +0 -1
  58. package/lib/module/configurePaymentCredentialsModule.js.map +0 -1
  59. package/lib/module/configurePaymentModule.d.ts.map +0 -1
  60. package/lib/module/configurePaymentModule.js.map +0 -1
  61. package/lib/module/configurePaymentProvidersModule.d.ts.map +0 -1
  62. package/lib/module/configurePaymentProvidersModule.js.map +0 -1
  63. package/lib/payment-index.d.ts.map +0 -1
  64. package/lib/payment-index.js.map +0 -1
  65. package/lib/payment-settings.d.ts.map +0 -1
  66. package/lib/payment-settings.js.map +0 -1
  67. package/src/db/PaymentCredentialsCollection.ts +0 -21
  68. package/src/db/PaymentProvidersCollection.ts +0 -38
  69. package/src/module/configurePaymentCredentialsModule.ts +0 -141
  70. package/src/module/configurePaymentModule.ts +0 -26
  71. package/src/module/configurePaymentProvidersModule.ts +0 -134
  72. package/src/module/payment-index.test.ts +0 -19
  73. package/src/payment-index.ts +0 -4
  74. package/src/payment-settings.ts +0 -54
  75. package/tsconfig.json +0 -10
package/README.md CHANGED
@@ -1,3 +1,99 @@
1
- # Payment (Unchained Engine)
1
+ [![npm version](https://img.shields.io/npm/v/@unchainedshop/core-payment.svg)](https://npmjs.com/package/@unchainedshop/core-payment)
2
+ [![License: EUPL-1.2](https://img.shields.io/badge/License-EUPL--1.2-blue.svg)](https://opensource.org/licenses/EUPL-1.2)
2
3
 
3
- This package contains business logic and database abstraction for payment in Unchained.
4
+ # @unchainedshop/core-payment
5
+
6
+ Payment provider module for the Unchained Engine. Manages payment providers, credentials, and payment processing.
7
+
8
+ ## Installation
9
+
10
+ ```bash
11
+ npm install @unchainedshop/core-payment
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```typescript
17
+ import { configurePaymentModule, PaymentProviderType } from '@unchainedshop/core-payment';
18
+
19
+ const paymentModule = await configurePaymentModule({ db });
20
+
21
+ // Create a payment provider
22
+ const providerId = await paymentModule.create({
23
+ type: PaymentProviderType.CARD,
24
+ adapterKey: 'shop.unchained.payment.stripe',
25
+ });
26
+
27
+ // Find providers for a context
28
+ const providers = await paymentModule.findSupported({
29
+ order: orderObject,
30
+ });
31
+ ```
32
+
33
+ ## API Overview
34
+
35
+ ### Module Configuration
36
+
37
+ | Export | Description |
38
+ |--------|-------------|
39
+ | `configurePaymentModule` | Configure and return the payment module |
40
+
41
+ ### Queries
42
+
43
+ | Method | Description |
44
+ |--------|-------------|
45
+ | `findProvider` | Find provider by ID |
46
+ | `findProviders` | Find providers with filtering |
47
+ | `count` | Count providers |
48
+ | `providerExists` | Check if provider exists |
49
+ | `findSupported` | Find providers supported for context |
50
+ | `findInterface` | Get provider interface definition |
51
+
52
+ ### Mutations
53
+
54
+ | Method | Description |
55
+ |--------|-------------|
56
+ | `create` | Create a new payment provider |
57
+ | `update` | Update provider configuration |
58
+ | `delete` | Soft delete a provider |
59
+
60
+ ### Credentials
61
+
62
+ | Method | Description |
63
+ |--------|-------------|
64
+ | `findCredentials` | Find stored credentials for user |
65
+ | `createCredentials` | Store payment credentials |
66
+ | `deleteCredentials` | Remove stored credentials |
67
+ | `markPreferred` | Mark credentials as preferred |
68
+
69
+ ### Constants
70
+
71
+ | Export | Description |
72
+ |--------|-------------|
73
+ | `PaymentProviderType` | Provider types (CARD, INVOICE, GENERIC) |
74
+
75
+ ### Settings
76
+
77
+ | Export | Description |
78
+ |--------|-------------|
79
+ | `paymentSettings` | Access payment module settings |
80
+
81
+ ### Types
82
+
83
+ | Export | Description |
84
+ |--------|-------------|
85
+ | `PaymentProvider` | Provider document type |
86
+ | `PaymentCredentials` | Credentials document type |
87
+ | `PaymentModule` | Module interface type |
88
+
89
+ ## Events
90
+
91
+ | Event | Description |
92
+ |-------|-------------|
93
+ | `PAYMENT_PROVIDER_CREATE` | Provider created |
94
+ | `PAYMENT_PROVIDER_UPDATE` | Provider updated |
95
+ | `PAYMENT_PROVIDER_REMOVE` | Provider deleted |
96
+
97
+ ## License
98
+
99
+ EUPL-1.2
@@ -1,4 +1,4 @@
1
- import { mongodb, TimestampFields } from '@unchainedshop/mongodb';
1
+ import { mongodb, type TimestampFields } from '@unchainedshop/mongodb';
2
2
  export type PaymentCredentials = {
3
3
  _id: string;
4
4
  paymentProviderId: string;
@@ -8,4 +8,3 @@ export type PaymentCredentials = {
8
8
  meta: any;
9
9
  } & TimestampFields;
10
10
  export declare const PaymentCredentialsCollection: (db: mongodb.Db) => Promise<mongodb.Collection<PaymentCredentials>>;
11
- //# sourceMappingURL=PaymentCredentialsCollection.d.ts.map
@@ -1,4 +1,4 @@
1
- import { buildDbIndexes } from '@unchainedshop/mongodb';
1
+ import { mongodb, buildDbIndexes } from '@unchainedshop/mongodb';
2
2
  export const PaymentCredentialsCollection = async (db) => {
3
3
  const PaymentCredentialsCol = db.collection('payment_credentials');
4
4
  await buildDbIndexes(PaymentCredentialsCol, [
@@ -7,4 +7,3 @@ export const PaymentCredentialsCollection = async (db) => {
7
7
  ]);
8
8
  return PaymentCredentialsCol;
9
9
  };
10
- //# sourceMappingURL=PaymentCredentialsCollection.js.map
@@ -1,8 +1,9 @@
1
- import { mongodb, TimestampFields } from '@unchainedshop/mongodb';
2
- export declare enum PaymentProviderType {
3
- INVOICE = "INVOICE",
4
- GENERIC = "GENERIC"
5
- }
1
+ import { mongodb, type TimestampFields } from '@unchainedshop/mongodb';
2
+ export declare const PaymentProviderType: {
3
+ readonly INVOICE: "INVOICE";
4
+ readonly GENERIC: "GENERIC";
5
+ };
6
+ export type PaymentProviderType = (typeof PaymentProviderType)[keyof typeof PaymentProviderType];
6
7
  export type PaymentConfiguration = {
7
8
  key: string;
8
9
  value: string | null;
@@ -14,4 +15,3 @@ export type PaymentProvider = {
14
15
  configuration: PaymentConfiguration;
15
16
  } & TimestampFields;
16
17
  export declare const PaymentProvidersCollection: (db: mongodb.Db) => Promise<mongodb.Collection<PaymentProvider>>;
17
- //# sourceMappingURL=PaymentProvidersCollection.d.ts.map
@@ -1,9 +1,8 @@
1
- import { buildDbIndexes } from '@unchainedshop/mongodb';
2
- export var PaymentProviderType;
3
- (function (PaymentProviderType) {
4
- PaymentProviderType["INVOICE"] = "INVOICE";
5
- PaymentProviderType["GENERIC"] = "GENERIC";
6
- })(PaymentProviderType || (PaymentProviderType = {}));
1
+ import { mongodb, buildDbIndexes } from '@unchainedshop/mongodb';
2
+ export const PaymentProviderType = {
3
+ INVOICE: 'INVOICE',
4
+ GENERIC: 'GENERIC',
5
+ };
7
6
  export const PaymentProvidersCollection = async (db) => {
8
7
  const PaymentProviders = db.collection('payment-providers');
9
8
  await buildDbIndexes(PaymentProviders, [
@@ -21,4 +20,3 @@ export const PaymentProvidersCollection = async (db) => {
21
20
  ]);
22
21
  return PaymentProviders;
23
22
  };
24
- //# sourceMappingURL=PaymentProvidersCollection.js.map
@@ -1,5 +1,5 @@
1
1
  import { mongodb } from '@unchainedshop/mongodb';
2
- import { PaymentCredentials as PaymentCredentialsType } from '../db/PaymentCredentialsCollection.js';
2
+ import type { PaymentCredentials as PaymentCredentialsType } from '../db/PaymentCredentialsCollection.ts';
3
3
  export declare const configurePaymentCredentialsModule: (PaymentCredentials: mongodb.Collection<PaymentCredentialsType>) => {
4
4
  markPreferred: ({ userId, paymentCredentialsId, }: {
5
5
  userId: string;
@@ -20,4 +20,3 @@ export declare const configurePaymentCredentialsModule: (PaymentCredentials: mon
20
20
  deleteUserPaymentCredentials: (userId: string) => Promise<number>;
21
21
  };
22
22
  export type PaymentCredentialsModule = ReturnType<typeof configurePaymentCredentialsModule>;
23
- //# sourceMappingURL=configurePaymentCredentialsModule.d.ts.map
@@ -1,4 +1,4 @@
1
- import { generateDbFilterById, generateDbObjectId } from '@unchainedshop/mongodb';
1
+ import { mongodb, generateDbFilterById, generateDbObjectId } from '@unchainedshop/mongodb';
2
2
  export const configurePaymentCredentialsModule = (PaymentCredentials) => {
3
3
  const markPreferred = async ({ userId, paymentCredentialsId, }) => {
4
4
  const paymentCredentials = await PaymentCredentials.findOneAndUpdate({
@@ -78,4 +78,3 @@ export const configurePaymentCredentialsModule = (PaymentCredentials) => {
78
78
  },
79
79
  };
80
80
  };
81
- //# sourceMappingURL=configurePaymentCredentialsModule.js.map
@@ -1,28 +1,28 @@
1
- import { PaymentSettingsOptions } from '../payment-settings.js';
2
- import { ModuleInput } from '@unchainedshop/mongodb';
1
+ import { type PaymentSettingsOptions } from '../payment-settings.ts';
2
+ import type { ModuleInput } from '@unchainedshop/mongodb';
3
3
  export declare const configurePaymentModule: ({ db, options: paymentOptions, }: ModuleInput<PaymentSettingsOptions>) => Promise<{
4
4
  paymentProviders: {
5
- count: (query: import("mongodb").Filter<import("../db/PaymentProvidersCollection.js").PaymentProvider>) => Promise<number>;
6
- findProvider: ({ paymentProviderId, ...query }: import("mongodb").Filter<import("../db/PaymentProvidersCollection.js").PaymentProvider> & {
5
+ count: (query: import("mongodb").Filter<import("../db/PaymentProvidersCollection.ts").PaymentProvider>) => Promise<number>;
6
+ findProvider: ({ paymentProviderId, ...query }: import("mongodb").Filter<import("../db/PaymentProvidersCollection.ts").PaymentProvider> & {
7
7
  paymentProviderId: string;
8
- }, options?: import("mongodb").FindOptions) => Promise<import("../db/PaymentProvidersCollection.js").PaymentProvider | null>;
9
- findProviders: (query: import("mongodb").Filter<import("../db/PaymentProvidersCollection.js").PaymentProvider> & {
8
+ }, options?: import("mongodb").FindOptions) => Promise<import("../db/PaymentProvidersCollection.ts").PaymentProvider | null>;
9
+ findProviders: (query: import("mongodb").Filter<import("../db/PaymentProvidersCollection.ts").PaymentProvider> & {
10
10
  includeDeleted?: boolean;
11
- }, options?: import("mongodb").FindOptions) => Promise<import("../db/PaymentProvidersCollection.js").PaymentProvider[]>;
12
- allProviders: () => Promise<import("mongodb").WithId<import("../db/PaymentProvidersCollection.js").PaymentProvider>[]>;
11
+ }, options?: import("mongodb").FindOptions) => Promise<import("../db/PaymentProvidersCollection.ts").PaymentProvider[]>;
12
+ allProviders: () => Promise<import("mongodb").WithId<import("../db/PaymentProvidersCollection.ts").PaymentProvider>[]>;
13
13
  providerExists: ({ paymentProviderId }: {
14
14
  paymentProviderId: string;
15
15
  }) => Promise<boolean>;
16
- create: (doc: Omit<import("../db/PaymentProvidersCollection.js").PaymentProvider, "_id" | "created"> & Pick<Partial<import("../db/PaymentProvidersCollection.js").PaymentProvider>, "_id" | "created">) => Promise<import("../db/PaymentProvidersCollection.js").PaymentProvider>;
17
- update: (_id: string, doc: import("../db/PaymentProvidersCollection.js").PaymentProvider) => Promise<import("mongodb").WithId<import("../db/PaymentProvidersCollection.js").PaymentProvider> | null>;
18
- delete: (_id: string) => Promise<import("mongodb").WithId<import("../db/PaymentProvidersCollection.js").PaymentProvider> | null>;
16
+ create: (doc: Omit<import("../db/PaymentProvidersCollection.ts").PaymentProvider, "_id" | "created"> & Pick<Partial<import("../db/PaymentProvidersCollection.ts").PaymentProvider>, "_id" | "created">) => Promise<import("../db/PaymentProvidersCollection.ts").PaymentProvider>;
17
+ update: (_id: string, doc: import("../db/PaymentProvidersCollection.ts").PaymentProvider) => Promise<import("mongodb").WithId<import("../db/PaymentProvidersCollection.ts").PaymentProvider> | null>;
18
+ delete: (_id: string) => Promise<import("mongodb").WithId<import("../db/PaymentProvidersCollection.ts").PaymentProvider> | null>;
19
19
  };
20
20
  paymentCredentials: {
21
21
  markPreferred: ({ userId, paymentCredentialsId, }: {
22
22
  userId: string;
23
23
  paymentCredentialsId: string;
24
- }) => Promise<import("mongodb").WithId<import("../db/PaymentCredentialsCollection.js").PaymentCredentials> | null>;
25
- count(query: import("mongodb").Filter<import("../db/PaymentCredentialsCollection.js").PaymentCredentials>): Promise<number>;
24
+ }) => Promise<import("mongodb").WithId<import("../db/PaymentCredentialsCollection.ts").PaymentCredentials> | null>;
25
+ count(query: import("mongodb").Filter<import("../db/PaymentCredentialsCollection.ts").PaymentCredentials>): Promise<number>;
26
26
  credentialsExists: ({ paymentCredentialsId, }: {
27
27
  paymentCredentialsId: string;
28
28
  }) => Promise<boolean>;
@@ -30,12 +30,11 @@ export declare const configurePaymentModule: ({ db, options: paymentOptions, }:
30
30
  paymentCredentialsId?: string;
31
31
  userId?: string;
32
32
  paymentProviderId?: string;
33
- }, options?: import("mongodb").FindOptions) => Promise<import("../db/PaymentCredentialsCollection.js").PaymentCredentials | null>;
34
- findPaymentCredentials: (query: import("mongodb").Filter<import("../db/PaymentCredentialsCollection.js").PaymentCredentials>, options?: import("mongodb").FindOptions) => Promise<import("../db/PaymentCredentialsCollection.js").PaymentCredentials[]>;
35
- upsertCredentials: ({ userId, paymentProviderId, _id, token, ...meta }: Pick<import("../db/PaymentCredentialsCollection.js").PaymentCredentials, "userId" | "paymentProviderId" | "_id" | "token"> & Record<string, any>) => Promise<import("../db/PaymentCredentialsCollection.js").PaymentCredentials>;
36
- removeCredentials: (paymentCredentialsId: string) => Promise<import("mongodb").WithId<import("../db/PaymentCredentialsCollection.js").PaymentCredentials> | null>;
33
+ }, options?: import("mongodb").FindOptions) => Promise<import("../db/PaymentCredentialsCollection.ts").PaymentCredentials | null>;
34
+ findPaymentCredentials: (query: import("mongodb").Filter<import("../db/PaymentCredentialsCollection.ts").PaymentCredentials>, options?: import("mongodb").FindOptions) => Promise<import("../db/PaymentCredentialsCollection.ts").PaymentCredentials[]>;
35
+ upsertCredentials: ({ userId, paymentProviderId, _id, token, ...meta }: Pick<import("../db/PaymentCredentialsCollection.ts").PaymentCredentials, "userId" | "paymentProviderId" | "_id" | "token"> & Record<string, any>) => Promise<import("../db/PaymentCredentialsCollection.ts").PaymentCredentials>;
36
+ removeCredentials: (paymentCredentialsId: string) => Promise<import("mongodb").WithId<import("../db/PaymentCredentialsCollection.ts").PaymentCredentials> | null>;
37
37
  deleteUserPaymentCredentials: (userId: string) => Promise<number>;
38
38
  };
39
39
  }>;
40
40
  export type PaymentModule = Awaited<ReturnType<typeof configurePaymentModule>>;
41
- //# sourceMappingURL=configurePaymentModule.d.ts.map
@@ -1,8 +1,8 @@
1
- import { PaymentCredentialsCollection } from '../db/PaymentCredentialsCollection.js';
2
- import { PaymentProvidersCollection } from '../db/PaymentProvidersCollection.js';
3
- import { configurePaymentCredentialsModule } from './configurePaymentCredentialsModule.js';
4
- import { configurePaymentProvidersModule } from './configurePaymentProvidersModule.js';
5
- import { paymentSettings } from '../payment-settings.js';
1
+ import { PaymentCredentialsCollection } from "../db/PaymentCredentialsCollection.js";
2
+ import { PaymentProvidersCollection } from "../db/PaymentProvidersCollection.js";
3
+ import { configurePaymentCredentialsModule } from "./configurePaymentCredentialsModule.js";
4
+ import { configurePaymentProvidersModule } from "./configurePaymentProvidersModule.js";
5
+ import { paymentSettings } from "../payment-settings.js";
6
6
  export const configurePaymentModule = async ({ db, options: paymentOptions = {}, }) => {
7
7
  const PaymentProviders = await PaymentProvidersCollection(db);
8
8
  const PaymentCredentials = await PaymentCredentialsCollection(db);
@@ -14,4 +14,3 @@ export const configurePaymentModule = async ({ db, options: paymentOptions = {},
14
14
  paymentCredentials,
15
15
  };
16
16
  };
17
- //# sourceMappingURL=configurePaymentModule.js.map
@@ -1,5 +1,5 @@
1
1
  import { mongodb } from '@unchainedshop/mongodb';
2
- import { PaymentProvider } from '../db/PaymentProvidersCollection.js';
2
+ import type { PaymentProvider } from '../db/PaymentProvidersCollection.ts';
3
3
  export interface PaymentInterface {
4
4
  _id: string;
5
5
  label: string;
@@ -8,12 +8,12 @@ export interface PaymentInterface {
8
8
  export declare const buildFindSelector: ({ includeDeleted, ...rest }?: mongodb.Filter<PaymentProvider> & {
9
9
  includeDeleted?: boolean;
10
10
  }) => {
11
- type?: mongodb.Condition<import("../db/PaymentProvidersCollection.js").PaymentProviderType> | undefined;
11
+ type?: mongodb.Condition<import("../db/PaymentProvidersCollection.ts").PaymentProviderType> | undefined;
12
12
  created?: mongodb.Condition<Date> | undefined;
13
13
  deleted?: Date | mongodb.FilterOperators<Date | null | undefined> | null | undefined;
14
14
  updated?: mongodb.Condition<Date | undefined>;
15
15
  adapterKey?: mongodb.Condition<string> | undefined;
16
- configuration?: mongodb.Condition<import("../db/PaymentProvidersCollection.js").PaymentConfiguration> | undefined;
16
+ configuration?: mongodb.Condition<import("../db/PaymentProvidersCollection.ts").PaymentConfiguration> | undefined;
17
17
  _id?: mongodb.Condition<string> | undefined;
18
18
  $and?: mongodb.Filter<mongodb.WithId<PaymentProvider>>[] | undefined;
19
19
  $nor?: mongodb.Filter<mongodb.WithId<PaymentProvider>>[] | undefined;
@@ -44,4 +44,3 @@ export declare const configurePaymentProvidersModule: (PaymentProviders: mongodb
44
44
  delete: (_id: string) => Promise<mongodb.WithId<PaymentProvider> | null>;
45
45
  };
46
46
  export type PaymentProvidersModule = ReturnType<typeof configurePaymentProvidersModule>;
47
- //# sourceMappingURL=configurePaymentProvidersModule.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { emit, registerEvents } from '@unchainedshop/events';
2
- import { generateDbFilterById, generateDbObjectId } from '@unchainedshop/mongodb';
2
+ import { generateDbFilterById, generateDbObjectId, mongodb } from '@unchainedshop/mongodb';
3
3
  import pMemoize from 'p-memoize';
4
4
  import ExpiryMap from 'expiry-map';
5
5
  const PAYMENT_PROVIDER_EVENTS = [
@@ -14,7 +14,6 @@ export const buildFindSelector = ({ includeDeleted = false, ...rest } = {}) => {
14
14
  export const configurePaymentProvidersModule = (PaymentProviders) => {
15
15
  registerEvents(PAYMENT_PROVIDER_EVENTS);
16
16
  return {
17
- // Queries
18
17
  count: async (query) => {
19
18
  const providerCount = await PaymentProviders.countDocuments(buildFindSelector(query));
20
19
  return providerCount;
@@ -35,7 +34,6 @@ export const configurePaymentProvidersModule = (PaymentProviders) => {
35
34
  const providerCount = await PaymentProviders.countDocuments(generateDbFilterById(paymentProviderId, { deleted: null }), { limit: 1 });
36
35
  return !!providerCount;
37
36
  },
38
- // Mutations
39
37
  create: async (doc) => {
40
38
  const { insertedId: paymentProviderId } = await PaymentProviders.insertOne({
41
39
  _id: generateDbObjectId(),
@@ -74,4 +72,3 @@ export const configurePaymentProvidersModule = (PaymentProviders) => {
74
72
  },
75
73
  };
76
74
  };
77
- //# sourceMappingURL=configurePaymentProvidersModule.js.map
@@ -1,5 +1,4 @@
1
- export * from './module/configurePaymentModule.js';
2
- export * from './payment-settings.js';
3
- export * from './db/PaymentCredentialsCollection.js';
4
- export * from './db/PaymentProvidersCollection.js';
5
- //# sourceMappingURL=payment-index.d.ts.map
1
+ export * from './module/configurePaymentModule.ts';
2
+ export * from './payment-settings.ts';
3
+ export * from './db/PaymentCredentialsCollection.ts';
4
+ export * from './db/PaymentProvidersCollection.ts';
@@ -1,5 +1,4 @@
1
- export * from './module/configurePaymentModule.js';
2
- export * from './payment-settings.js';
3
- export * from './db/PaymentCredentialsCollection.js';
4
- export * from './db/PaymentProvidersCollection.js';
5
- //# sourceMappingURL=payment-index.js.map
1
+ export * from "./module/configurePaymentModule.js";
2
+ export * from "./payment-settings.js";
3
+ export * from "./db/PaymentCredentialsCollection.js";
4
+ export * from "./db/PaymentProvidersCollection.js";
@@ -1,5 +1,5 @@
1
- import { PaymentCredentials } from './db/PaymentCredentialsCollection.js';
2
- import { PaymentProvider } from './db/PaymentProvidersCollection.js';
1
+ import type { PaymentCredentials } from './db/PaymentCredentialsCollection.ts';
2
+ import type { PaymentProvider } from './db/PaymentProvidersCollection.ts';
3
3
  export type FilterProviders<Order = unknown, UnchainedAPI = unknown> = (params: {
4
4
  providers: PaymentProvider[];
5
5
  order: Order;
@@ -16,4 +16,3 @@ export interface PaymentSettings {
16
16
  }
17
17
  export type PaymentSettingsOptions = Omit<Partial<PaymentSettings>, 'configureSettings'>;
18
18
  export declare const paymentSettings: PaymentSettings;
19
- //# sourceMappingURL=payment-settings.d.ts.map
@@ -22,4 +22,3 @@ export const paymentSettings = {
22
22
  paymentSettings.determineDefaultProvider = determineDefaultProvider || firstProviderIsDefault;
23
23
  },
24
24
  };
25
- //# sourceMappingURL=payment-settings.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unchainedshop/core-payment",
3
- "version": "4.3.3",
3
+ "version": "4.4.0",
4
4
  "main": "lib/payment-index.js",
5
5
  "types": "lib/payment-index.d.ts",
6
6
  "type": "module",
@@ -9,8 +9,8 @@
9
9
  "build": "tsc -b",
10
10
  "prepublishOnly": "npm run clean && npm run build",
11
11
  "watch": "tsc -w",
12
- "test": "tsx --test",
13
- "test:watch": "tsx --test --watch"
12
+ "test": "node --test",
13
+ "test:watch": "node --test --watch"
14
14
  },
15
15
  "repository": {
16
16
  "type": "git",
@@ -22,8 +22,10 @@
22
22
  "core"
23
23
  ],
24
24
  "authors": [
25
- "Joël Meiller",
26
- "Pascal Kaufmann"
25
+ "Pascal Kaufmann",
26
+ "Mikael Araya",
27
+ "Vedran Rudelj",
28
+ "Joël Meiller"
27
29
  ],
28
30
  "license": "EUPL-1.2",
29
31
  "bugs": {
@@ -31,15 +33,14 @@
31
33
  },
32
34
  "homepage": "https://github.com/unchainedshop/unchained#readme",
33
35
  "dependencies": {
34
- "@unchainedshop/events": "^4.3.0",
35
- "@unchainedshop/logger": "^4.3.0",
36
- "@unchainedshop/utils": "^4.3.0",
36
+ "@unchainedshop/events": "^4.4.0",
37
+ "@unchainedshop/logger": "^4.4.0",
38
+ "@unchainedshop/utils": "^4.4.0",
37
39
  "expiry-map": "^2.0.0",
38
40
  "p-memoize": "^8.0.0"
39
41
  },
40
42
  "devDependencies": {
41
- "@types/node": "^24.0.13",
42
- "tsx": "^4.20.3",
43
+ "@types/node": "^25.0.0",
43
44
  "typescript": "^5.8.3"
44
45
  }
45
46
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"PaymentCredentialsCollection.d.ts","sourceRoot":"","sources":["../../src/db/PaymentCredentialsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAElF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,IAAI,EAAE,GAAG,CAAC;CACX,GAAG,eAAe,CAAC;AAEpB,eAAO,MAAM,4BAA4B,GAAU,IAAI,OAAO,CAAC,EAAE,oDAShE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PaymentCredentialsCollection.js","sourceRoot":"","sources":["../../src/db/PaymentCredentialsCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAmB,MAAM,wBAAwB,CAAC;AAWlF,MAAM,CAAC,MAAM,4BAA4B,GAAG,KAAK,EAAE,EAAc,EAAE,EAAE;IACnE,MAAM,qBAAqB,GAAG,EAAE,CAAC,UAAU,CAAqB,qBAAqB,CAAC,CAAC;IAEvF,MAAM,cAAc,CAAqB,qBAAqB,EAAE;QAC9D,EAAE,KAAK,EAAE,EAAE,iBAAiB,EAAE,CAAC,EAAE,EAAE;QACnC,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE;KACzB,CAAC,CAAC;IAEH,OAAO,qBAAqB,CAAC;AAC/B,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import SimpleSchema from 'simpl-schema';
2
- export declare const PaymentCredentialsSchema: SimpleSchema;
3
- //# sourceMappingURL=PaymentCredentialsSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PaymentCredentialsSchema.d.ts","sourceRoot":"","sources":["../../src/db/PaymentCredentialsSchema.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,eAAO,MAAM,wBAAwB,cAUpC,CAAC"}
@@ -1,11 +0,0 @@
1
- import { Schemas } from '@unchainedshop/utils';
2
- import SimpleSchema from 'simpl-schema';
3
- export const PaymentCredentialsSchema = new SimpleSchema({
4
- paymentProviderId: { type: String, required: true },
5
- userId: { type: String, required: true },
6
- token: String,
7
- isPreferred: Boolean,
8
- meta: { type: Object, blackbox: true },
9
- ...Schemas.timestampFields,
10
- }, { requiredByDefault: false });
11
- //# sourceMappingURL=PaymentCredentialsSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PaymentCredentialsSchema.js","sourceRoot":"","sources":["../../src/db/PaymentCredentialsSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,wBAAwB,GAAG,IAAI,YAAY,CACtD;IACE,iBAAiB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACnD,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACxC,KAAK,EAAE,MAAM;IACb,WAAW,EAAE,OAAO;IACpB,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACtC,GAAG,OAAO,CAAC,eAAe;CAC3B,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PaymentProvidersCollection.d.ts","sourceRoot":"","sources":["../../src/db/PaymentProvidersCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAkB,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAElF,oBAAY,mBAAmB;IAC7B,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB,EAAE,CAAC;AAEJ,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,mBAAmB,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,oBAAoB,CAAC;CACrC,GAAG,eAAe,CAAC;AAEpB,eAAO,MAAM,0BAA0B,GAAU,IAAI,OAAO,CAAC,EAAE,iDAkB9D,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"PaymentProvidersCollection.js","sourceRoot":"","sources":["../../src/db/PaymentProvidersCollection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,cAAc,EAAmB,MAAM,wBAAwB,CAAC;AAElF,MAAM,CAAN,IAAY,mBAGX;AAHD,WAAY,mBAAmB;IAC7B,0CAAmB,CAAA;IACnB,0CAAmB,CAAA;AACrB,CAAC,EAHW,mBAAmB,KAAnB,mBAAmB,QAG9B;AAcD,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,EAAE,EAAc,EAAE,EAAE;IACjE,MAAM,gBAAgB,GAAG,EAAE,CAAC,UAAU,CAAkB,mBAAmB,CAAC,CAAC;IAE7E,MAAM,cAAc,CAAkB,gBAAgB,EAAE;QACtD,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE;QACtB;YACE,KAAK,EAAE;gBACL,OAAO,EAAE,CAAC;aACX;SACF;QACD;YACE,KAAK,EAAE;gBACL,OAAO,EAAE,CAAC;aACX;SACF;KACF,CAAC,CAAC;IAEH,OAAO,gBAAgB,CAAC;AAC1B,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import SimpleSchema from 'simpl-schema';
2
- export declare const PaymentProvidersSchema: SimpleSchema;
3
- //# sourceMappingURL=PaymentProvidersSchema.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PaymentProvidersSchema.d.ts","sourceRoot":"","sources":["../../src/db/PaymentProvidersSchema.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,eAAO,MAAM,sBAAsB,cAWlC,CAAC"}
@@ -1,12 +0,0 @@
1
- import { Schemas } from '@unchainedshop/utils';
2
- import SimpleSchema from 'simpl-schema';
3
- export const PaymentProvidersSchema = new SimpleSchema({
4
- type: { type: String, required: true },
5
- adapterKey: { type: String, required: true },
6
- configuration: { type: Array },
7
- 'configuration.$': { type: Object },
8
- 'configuration.$.key': { type: String },
9
- 'configuration.$.value': { type: String },
10
- ...Schemas.timestampFields,
11
- }, { requiredByDefault: false });
12
- //# sourceMappingURL=PaymentProvidersSchema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PaymentProvidersSchema.js","sourceRoot":"","sources":["../../src/db/PaymentProvidersSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,YAAY,MAAM,cAAc,CAAC;AAExC,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,YAAY,CACpD;IACE,IAAI,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IACtC,UAAU,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;IAC5C,aAAa,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;IAC9B,iBAAiB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IACnC,qBAAqB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IACvC,uBAAuB,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IACzC,GAAG,OAAO,CAAC,eAAe;CAC3B,EACD,EAAE,iBAAiB,EAAE,KAAK,EAAE,CAC7B,CAAC"}
@@ -1,3 +0,0 @@
1
- import { IPaymentAdapter } from '@unchainedshop/types/payments.js';
2
- export declare const PaymentAdapter: Omit<IPaymentAdapter, 'key' | 'label' | 'version'>;
3
- //# sourceMappingURL=PaymentAdapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PaymentAdapter.d.ts","sourceRoot":"","sources":["../../src/director/PaymentAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAInE,eAAO,MAAM,cAAc,EAAE,IAAI,CAAC,eAAe,EAAE,KAAK,GAAG,OAAO,GAAG,SAAS,CA0D7E,CAAC"}
@@ -1,49 +0,0 @@
1
- import { log, LogLevel } from '@unchainedshop/logger';
2
- import { PaymentError } from './PaymentError.js';
3
- export const PaymentAdapter = {
4
- initialConfiguration: [],
5
- typeSupported: () => {
6
- return false;
7
- },
8
- actions: () => {
9
- return {
10
- configurationError: () => {
11
- return PaymentError.NOT_IMPLEMENTED;
12
- },
13
- isActive: () => {
14
- return false;
15
- },
16
- isPayLaterAllowed: () => {
17
- return false;
18
- },
19
- charge: async () => {
20
- // if you return true, the status will be changed to PAID
21
- // if you return false, the order payment status stays the
22
- // same but the order status might change
23
- // if you throw an error, you cancel the checkout process
24
- return false;
25
- },
26
- register: async () => {
27
- return {
28
- token: '',
29
- };
30
- },
31
- sign: async () => {
32
- return null;
33
- },
34
- validate: async () => {
35
- return false;
36
- },
37
- cancel: async () => {
38
- return false;
39
- },
40
- confirm: async () => {
41
- return false;
42
- },
43
- };
44
- },
45
- log(message, { level = LogLevel.Debug, ...options } = {}) {
46
- return log(message, { level, ...options });
47
- },
48
- };
49
- //# sourceMappingURL=PaymentAdapter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PaymentAdapter.js","sourceRoot":"","sources":["../../src/director/PaymentAdapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,cAAc,GAAuD;IAChF,oBAAoB,EAAE,EAAE;IAExB,aAAa,EAAE,GAAG,EAAE;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,EAAE,GAAG,EAAE;QACZ,OAAO;YACL,kBAAkB,EAAE,GAAG,EAAE;gBACvB,OAAO,YAAY,CAAC,eAAe,CAAC;YACtC,CAAC;YAED,QAAQ,EAAE,GAAG,EAAE;gBACb,OAAO,KAAK,CAAC;YACf,CAAC;YAED,iBAAiB,EAAE,GAAG,EAAE;gBACtB,OAAO,KAAK,CAAC;YACf,CAAC;YAED,MAAM,EAAE,KAAK,IAAI,EAAE;gBACjB,yDAAyD;gBAEzD,0DAA0D;gBAC1D,yCAAyC;gBAEzC,yDAAyD;gBACzD,OAAO,KAAK,CAAC;YACf,CAAC;YAED,QAAQ,EAAE,KAAK,IAAI,EAAE;gBACnB,OAAO;oBACL,KAAK,EAAE,EAAE;iBACV,CAAC;YACJ,CAAC;YAED,IAAI,EAAE,KAAK,IAAI,EAAE;gBACf,OAAO,IAAI,CAAC;YACd,CAAC;YAED,QAAQ,EAAE,KAAK,IAAI,EAAE;gBACnB,OAAO,KAAK,CAAC;YACf,CAAC;YAED,MAAM,EAAE,KAAK,IAAI,EAAE;gBACjB,OAAO,KAAK,CAAC;YACf,CAAC;YAED,OAAO,EAAE,KAAK,IAAI,EAAE;gBAClB,OAAO,KAAK,CAAC;YACf,CAAC;SACF,CAAC;IACJ,CAAC;IAED,GAAG,CAAC,OAAe,EAAE,EAAE,KAAK,GAAG,QAAQ,CAAC,KAAK,EAAE,GAAG,OAAO,EAAE,GAAG,EAAE;QAC9D,OAAO,GAAG,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF,CAAC"}
@@ -1,3 +0,0 @@
1
- import { IPaymentDirector } from '@unchainedshop/types/payments.js';
2
- export declare const PaymentDirector: IPaymentDirector;
3
- //# sourceMappingURL=PaymentDirector.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PaymentDirector.d.ts","sourceRoot":"","sources":["../../src/director/PaymentDirector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,gBAAgB,EAAkB,MAAM,kCAAkC,CAAC;AAQrG,eAAO,MAAM,eAAe,EAAE,gBA0F7B,CAAC"}