@medusajs/payment 0.0.1

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 (48) hide show
  1. package/README.md +3 -0
  2. package/dist/index.d.ts +4 -0
  3. package/dist/index.js +22 -0
  4. package/dist/initialize/index.d.ts +4 -0
  5. package/dist/initialize/index.js +16 -0
  6. package/dist/joiner-config.d.ts +8 -0
  7. package/dist/joiner-config.js +29 -0
  8. package/dist/loaders/connection.d.ts +4 -0
  9. package/dist/loaders/connection.js +41 -0
  10. package/dist/loaders/container.d.ts +2 -0
  11. package/dist/loaders/container.js +34 -0
  12. package/dist/loaders/index.d.ts +2 -0
  13. package/dist/loaders/index.js +18 -0
  14. package/dist/models/capture.d.ts +14 -0
  15. package/dist/models/capture.js +75 -0
  16. package/dist/models/index.d.ts +7 -0
  17. package/dist/models/index.js +20 -0
  18. package/dist/models/payment-collection.d.ts +27 -0
  19. package/dist/models/payment-collection.js +144 -0
  20. package/dist/models/payment-method-token.d.ts +11 -0
  21. package/dist/models/payment-method-token.js +71 -0
  22. package/dist/models/payment-provider.d.ts +6 -0
  23. package/dist/models/payment-provider.js +32 -0
  24. package/dist/models/payment-session.d.ts +16 -0
  25. package/dist/models/payment-session.js +97 -0
  26. package/dist/models/payment.d.ts +34 -0
  27. package/dist/models/payment.js +176 -0
  28. package/dist/models/refund.d.ts +10 -0
  29. package/dist/models/refund.js +75 -0
  30. package/dist/module-definition.d.ts +4 -0
  31. package/dist/module-definition.js +50 -0
  32. package/dist/repositories/index.d.ts +1 -0
  33. package/dist/repositories/index.js +5 -0
  34. package/dist/scripts/bin/run-seed.d.ts +3 -0
  35. package/dist/scripts/bin/run-seed.js +50 -0
  36. package/dist/scripts/seed-utils.d.ts +2 -0
  37. package/dist/scripts/seed-utils.js +7 -0
  38. package/dist/services/index.d.ts +2 -0
  39. package/dist/services/index.js +10 -0
  40. package/dist/services/payment-collection.d.ts +17 -0
  41. package/dist/services/payment-collection.js +11 -0
  42. package/dist/services/payment-module.d.ts +39 -0
  43. package/dist/services/payment-module.js +134 -0
  44. package/dist/types/index.d.ts +4 -0
  45. package/dist/types/index.js +2 -0
  46. package/dist/types/repositories.d.ts +7 -0
  47. package/dist/types/repositories.js +2 -0
  48. package/package.json +61 -0
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const core_1 = require("@mikro-orm/core");
16
+ const utils_1 = require("@medusajs/utils");
17
+ const payment_collection_1 = __importDefault(require("./payment-collection"));
18
+ const payment_1 = __importDefault(require("./payment"));
19
+ let PaymentSession = class PaymentSession {
20
+ constructor() {
21
+ this.data = null;
22
+ this.authorized_at = null;
23
+ }
24
+ onCreate() {
25
+ this.id = (0, utils_1.generateEntityId)(this.id, "payses");
26
+ }
27
+ onInit() {
28
+ this.id = (0, utils_1.generateEntityId)(this.id, "payses");
29
+ }
30
+ };
31
+ __decorate([
32
+ (0, core_1.PrimaryKey)({ columnType: "text" }),
33
+ __metadata("design:type", String)
34
+ ], PaymentSession.prototype, "id", void 0);
35
+ __decorate([
36
+ (0, core_1.Property)({ columnType: "text" }),
37
+ __metadata("design:type", String)
38
+ ], PaymentSession.prototype, "currency_code", void 0);
39
+ __decorate([
40
+ (0, core_1.Property)({
41
+ columnType: "numeric",
42
+ serializer: Number,
43
+ }),
44
+ __metadata("design:type", Number)
45
+ ], PaymentSession.prototype, "amount", void 0);
46
+ __decorate([
47
+ (0, core_1.Property)({ columnType: "text" }),
48
+ __metadata("design:type", String)
49
+ ], PaymentSession.prototype, "provider_id", void 0);
50
+ __decorate([
51
+ (0, core_1.Property)({ columnType: "jsonb", nullable: true }),
52
+ __metadata("design:type", Object)
53
+ ], PaymentSession.prototype, "data", void 0);
54
+ __decorate([
55
+ (0, core_1.Enum)({
56
+ items: () => utils_1.PaymentSessionStatus,
57
+ }),
58
+ __metadata("design:type", String)
59
+ ], PaymentSession.prototype, "status", void 0);
60
+ __decorate([
61
+ (0, core_1.Property)({
62
+ columnType: "timestamptz",
63
+ nullable: true,
64
+ }),
65
+ __metadata("design:type", Object)
66
+ ], PaymentSession.prototype, "authorized_at", void 0);
67
+ __decorate([
68
+ (0, core_1.ManyToOne)({
69
+ index: "IDX_payment_session_payment_collection_id",
70
+ fieldName: "payment_collection_id",
71
+ }),
72
+ __metadata("design:type", payment_collection_1.default)
73
+ ], PaymentSession.prototype, "payment_collection", void 0);
74
+ __decorate([
75
+ (0, core_1.OneToOne)({
76
+ entity: () => payment_1.default,
77
+ mappedBy: (payment) => payment.session,
78
+ cascade: ["soft-remove"],
79
+ }),
80
+ __metadata("design:type", payment_1.default)
81
+ ], PaymentSession.prototype, "payment", void 0);
82
+ __decorate([
83
+ (0, core_1.BeforeCreate)(),
84
+ __metadata("design:type", Function),
85
+ __metadata("design:paramtypes", []),
86
+ __metadata("design:returntype", void 0)
87
+ ], PaymentSession.prototype, "onCreate", null);
88
+ __decorate([
89
+ (0, core_1.OnInit)(),
90
+ __metadata("design:type", Function),
91
+ __metadata("design:paramtypes", []),
92
+ __metadata("design:returntype", void 0)
93
+ ], PaymentSession.prototype, "onInit", null);
94
+ PaymentSession = __decorate([
95
+ (0, core_1.Entity)({ tableName: "payment_session" })
96
+ ], PaymentSession);
97
+ exports.default = PaymentSession;
@@ -0,0 +1,34 @@
1
+ import { Collection, OptionalProps } from "@mikro-orm/core";
2
+ import { DAL } from "@medusajs/types";
3
+ import Refund from "./refund";
4
+ import Capture from "./capture";
5
+ import PaymentSession from "./payment-session";
6
+ import PaymentCollection from "./payment-collection";
7
+ type OptionalPaymentProps = DAL.EntityDateColumns;
8
+ export default class Payment {
9
+ [OptionalProps]?: OptionalPaymentProps;
10
+ id: string;
11
+ amount: number;
12
+ authorized_amount: number | null;
13
+ currency_code: string;
14
+ provider_id: string;
15
+ cart_id: string | null;
16
+ order_id: string | null;
17
+ order_edit_id: string | null;
18
+ customer_id: string | null;
19
+ data: Record<string, unknown> | null;
20
+ created_at: Date;
21
+ updated_at: Date;
22
+ deleted_at: Date | null;
23
+ captured_at: Date | null;
24
+ canceled_at: Date | null;
25
+ refunds: Collection<Refund, object>;
26
+ captures: Collection<Capture, object>;
27
+ payment_collection: PaymentCollection;
28
+ session: PaymentSession;
29
+ /** COMPUTED PROPERTIES START **/
30
+ /** COMPUTED PROPERTIES END **/
31
+ onCreate(): void;
32
+ onInit(): void;
33
+ }
34
+ export {};
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const core_1 = require("@mikro-orm/core");
16
+ const utils_1 = require("@medusajs/utils");
17
+ const refund_1 = __importDefault(require("./refund"));
18
+ const capture_1 = __importDefault(require("./capture"));
19
+ const payment_session_1 = __importDefault(require("./payment-session"));
20
+ const payment_collection_1 = __importDefault(require("./payment-collection"));
21
+ let Payment = class Payment {
22
+ constructor() {
23
+ this.authorized_amount = null;
24
+ this.cart_id = null;
25
+ this.order_id = null;
26
+ this.order_edit_id = null;
27
+ this.customer_id = null;
28
+ this.data = null;
29
+ this.deleted_at = null;
30
+ this.captured_at = null;
31
+ this.canceled_at = null;
32
+ this.refunds = new core_1.Collection(this);
33
+ this.captures = new core_1.Collection(this);
34
+ }
35
+ /** COMPUTED PROPERTIES START **/
36
+ // captured_amount: number // sum of the associated captures
37
+ // refunded_amount: number // sum of the associated refunds
38
+ /** COMPUTED PROPERTIES END **/
39
+ onCreate() {
40
+ this.id = (0, utils_1.generateEntityId)(this.id, "pay");
41
+ }
42
+ onInit() {
43
+ this.id = (0, utils_1.generateEntityId)(this.id, "pay");
44
+ }
45
+ };
46
+ __decorate([
47
+ (0, core_1.PrimaryKey)({ columnType: "text" }),
48
+ __metadata("design:type", String)
49
+ ], Payment.prototype, "id", void 0);
50
+ __decorate([
51
+ (0, core_1.Property)({
52
+ columnType: "numeric",
53
+ serializer: Number,
54
+ }),
55
+ __metadata("design:type", Number)
56
+ ], Payment.prototype, "amount", void 0);
57
+ __decorate([
58
+ (0, core_1.Property)({
59
+ columnType: "numeric",
60
+ nullable: true,
61
+ serializer: utils_1.optionalNumericSerializer,
62
+ }),
63
+ __metadata("design:type", Object)
64
+ ], Payment.prototype, "authorized_amount", void 0);
65
+ __decorate([
66
+ (0, core_1.Property)({ columnType: "text" }),
67
+ __metadata("design:type", String)
68
+ ], Payment.prototype, "currency_code", void 0);
69
+ __decorate([
70
+ (0, core_1.Property)({ columnType: "text" }),
71
+ __metadata("design:type", String)
72
+ ], Payment.prototype, "provider_id", void 0);
73
+ __decorate([
74
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
75
+ __metadata("design:type", Object)
76
+ ], Payment.prototype, "cart_id", void 0);
77
+ __decorate([
78
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
79
+ __metadata("design:type", Object)
80
+ ], Payment.prototype, "order_id", void 0);
81
+ __decorate([
82
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
83
+ __metadata("design:type", Object)
84
+ ], Payment.prototype, "order_edit_id", void 0);
85
+ __decorate([
86
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
87
+ __metadata("design:type", Object)
88
+ ], Payment.prototype, "customer_id", void 0);
89
+ __decorate([
90
+ (0, core_1.Property)({ columnType: "jsonb", nullable: true }),
91
+ __metadata("design:type", Object)
92
+ ], Payment.prototype, "data", void 0);
93
+ __decorate([
94
+ (0, core_1.Property)({
95
+ onCreate: () => new Date(),
96
+ columnType: "timestamptz",
97
+ defaultRaw: "now()",
98
+ }),
99
+ __metadata("design:type", Date)
100
+ ], Payment.prototype, "created_at", void 0);
101
+ __decorate([
102
+ (0, core_1.Property)({
103
+ onCreate: () => new Date(),
104
+ onUpdate: () => new Date(),
105
+ columnType: "timestamptz",
106
+ defaultRaw: "now()",
107
+ }),
108
+ __metadata("design:type", Date)
109
+ ], Payment.prototype, "updated_at", void 0);
110
+ __decorate([
111
+ (0, core_1.Property)({
112
+ columnType: "timestamptz",
113
+ nullable: true,
114
+ index: "IDX_payment_deleted_at",
115
+ }),
116
+ __metadata("design:type", Object)
117
+ ], Payment.prototype, "deleted_at", void 0);
118
+ __decorate([
119
+ (0, core_1.Property)({
120
+ columnType: "timestamptz",
121
+ nullable: true,
122
+ }),
123
+ __metadata("design:type", Object)
124
+ ], Payment.prototype, "captured_at", void 0);
125
+ __decorate([
126
+ (0, core_1.Property)({
127
+ columnType: "timestamptz",
128
+ nullable: true,
129
+ }),
130
+ __metadata("design:type", Object)
131
+ ], Payment.prototype, "canceled_at", void 0);
132
+ __decorate([
133
+ (0, core_1.OneToMany)(() => refund_1.default, (refund) => refund.payment, {
134
+ cascade: [core_1.Cascade.REMOVE],
135
+ }),
136
+ __metadata("design:type", Object)
137
+ ], Payment.prototype, "refunds", void 0);
138
+ __decorate([
139
+ (0, core_1.OneToMany)(() => capture_1.default, (capture) => capture.payment, {
140
+ cascade: [core_1.Cascade.REMOVE],
141
+ }),
142
+ __metadata("design:type", Object)
143
+ ], Payment.prototype, "captures", void 0);
144
+ __decorate([
145
+ (0, core_1.ManyToOne)({
146
+ index: "IDX_payment_payment_collection_id",
147
+ fieldName: "payment_collection_id",
148
+ }),
149
+ __metadata("design:type", payment_collection_1.default)
150
+ ], Payment.prototype, "payment_collection", void 0);
151
+ __decorate([
152
+ (0, core_1.OneToOne)({ owner: true, fieldName: "session_id" }),
153
+ __metadata("design:type", payment_session_1.default
154
+ /** COMPUTED PROPERTIES START **/
155
+ // captured_amount: number // sum of the associated captures
156
+ // refunded_amount: number // sum of the associated refunds
157
+ /** COMPUTED PROPERTIES END **/
158
+ )
159
+ ], Payment.prototype, "session", void 0);
160
+ __decorate([
161
+ (0, core_1.BeforeCreate)(),
162
+ __metadata("design:type", Function),
163
+ __metadata("design:paramtypes", []),
164
+ __metadata("design:returntype", void 0)
165
+ ], Payment.prototype, "onCreate", null);
166
+ __decorate([
167
+ (0, core_1.OnInit)(),
168
+ __metadata("design:type", Function),
169
+ __metadata("design:paramtypes", []),
170
+ __metadata("design:returntype", void 0)
171
+ ], Payment.prototype, "onInit", null);
172
+ Payment = __decorate([
173
+ (0, core_1.Entity)({ tableName: "payment" }),
174
+ (0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
175
+ ], Payment);
176
+ exports.default = Payment;
@@ -0,0 +1,10 @@
1
+ import Payment from "./payment";
2
+ export default class Refund {
3
+ id: string;
4
+ amount: number;
5
+ payment: Payment;
6
+ created_at: Date;
7
+ created_by: string | null;
8
+ onCreate(): void;
9
+ onInit(): void;
10
+ }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const core_1 = require("@mikro-orm/core");
16
+ const utils_1 = require("@medusajs/utils");
17
+ const payment_1 = __importDefault(require("./payment"));
18
+ let Refund = class Refund {
19
+ constructor() {
20
+ this.created_by = null;
21
+ }
22
+ onCreate() {
23
+ this.id = (0, utils_1.generateEntityId)(this.id, "ref");
24
+ }
25
+ onInit() {
26
+ this.id = (0, utils_1.generateEntityId)(this.id, "ref");
27
+ }
28
+ };
29
+ __decorate([
30
+ (0, core_1.PrimaryKey)({ columnType: "text" }),
31
+ __metadata("design:type", String)
32
+ ], Refund.prototype, "id", void 0);
33
+ __decorate([
34
+ (0, core_1.Property)({
35
+ columnType: "numeric",
36
+ serializer: Number,
37
+ }),
38
+ __metadata("design:type", Number)
39
+ ], Refund.prototype, "amount", void 0);
40
+ __decorate([
41
+ (0, core_1.ManyToOne)(() => payment_1.default, {
42
+ onDelete: "cascade",
43
+ index: "IDX_refund_payment_id",
44
+ fieldName: "payment_id",
45
+ }),
46
+ __metadata("design:type", payment_1.default)
47
+ ], Refund.prototype, "payment", void 0);
48
+ __decorate([
49
+ (0, core_1.Property)({
50
+ onCreate: () => new Date(),
51
+ columnType: "timestamptz",
52
+ defaultRaw: "now()",
53
+ }),
54
+ __metadata("design:type", Date)
55
+ ], Refund.prototype, "created_at", void 0);
56
+ __decorate([
57
+ (0, core_1.Property)({ columnType: "text", nullable: true }),
58
+ __metadata("design:type", Object)
59
+ ], Refund.prototype, "created_by", void 0);
60
+ __decorate([
61
+ (0, core_1.BeforeCreate)(),
62
+ __metadata("design:type", Function),
63
+ __metadata("design:paramtypes", []),
64
+ __metadata("design:returntype", void 0)
65
+ ], Refund.prototype, "onCreate", null);
66
+ __decorate([
67
+ (0, core_1.OnInit)(),
68
+ __metadata("design:type", Function),
69
+ __metadata("design:paramtypes", []),
70
+ __metadata("design:returntype", void 0)
71
+ ], Refund.prototype, "onInit", null);
72
+ Refund = __decorate([
73
+ (0, core_1.Entity)({ tableName: "refund" })
74
+ ], Refund);
75
+ exports.default = Refund;
@@ -0,0 +1,4 @@
1
+ import { ModuleExports } from "@medusajs/types";
2
+ export declare const runMigrations: ({ options, logger, }?: Pick<import("@medusajs/types").LoaderOptions<import("@medusajs/types").ModuleServiceInitializeOptions>, "options" | "logger"> | undefined) => Promise<void>;
3
+ export declare const revertMigration: ({ options, logger, }?: Pick<import("@medusajs/types").LoaderOptions<import("@medusajs/types").ModuleServiceInitializeOptions>, "options" | "logger"> | undefined) => Promise<void>;
4
+ export declare const moduleDefinition: ModuleExports;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.moduleDefinition = exports.revertMigration = exports.runMigrations = void 0;
30
+ const _services_1 = require("./services");
31
+ const connection_1 = __importDefault(require("./loaders/connection"));
32
+ const container_1 = __importDefault(require("./loaders/container"));
33
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
34
+ const utils_1 = require("@medusajs/utils");
35
+ const PaymentModels = __importStar(require("./models"));
36
+ const migrationScriptOptions = {
37
+ moduleName: modules_sdk_1.Modules.PAYMENT,
38
+ models: PaymentModels,
39
+ pathToMigrations: __dirname + "/migrations",
40
+ };
41
+ exports.runMigrations = utils_1.ModulesSdkUtils.buildMigrationScript(migrationScriptOptions);
42
+ exports.revertMigration = utils_1.ModulesSdkUtils.buildRevertMigrationScript(migrationScriptOptions);
43
+ const service = _services_1.PaymentModuleService;
44
+ const loaders = [container_1.default, connection_1.default];
45
+ exports.moduleDefinition = {
46
+ service,
47
+ loaders,
48
+ runMigrations: exports.runMigrations,
49
+ revertMigration: exports.revertMigration,
50
+ };
@@ -0,0 +1 @@
1
+ export { MikroOrmBaseRepository as BaseRepository } from "@medusajs/utils";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseRepository = void 0;
4
+ var utils_1 = require("@medusajs/utils");
5
+ Object.defineProperty(exports, "BaseRepository", { enumerable: true, get: function () { return utils_1.MikroOrmBaseRepository; } });
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ declare const _default: Promise<void>;
3
+ export default _default;
@@ -0,0 +1,50 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || function (mod) {
20
+ if (mod && mod.__esModule) return mod;
21
+ var result = {};
22
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
+ __setModuleDefault(result, mod);
24
+ return result;
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ const os_1 = require("os");
28
+ const utils_1 = require("@medusajs/utils");
29
+ const modules_sdk_1 = require("@medusajs/modules-sdk");
30
+ const PaymentModels = __importStar(require("../../models"));
31
+ const seed_utils_1 = require("../seed-utils");
32
+ const args = process.argv;
33
+ const path = args.pop();
34
+ exports.default = (async () => {
35
+ const { config } = await Promise.resolve().then(() => __importStar(require("dotenv")));
36
+ config();
37
+ if (!path) {
38
+ throw new Error(`filePath is required.${os_1.EOL}Example: medusa-payment-seed <filePath>`);
39
+ }
40
+ const run = utils_1.ModulesSdkUtils.buildSeedScript({
41
+ moduleName: modules_sdk_1.Modules.PAYMENT,
42
+ models: PaymentModels,
43
+ pathToMigrations: __dirname + "/../../migrations",
44
+ seedHandler: async ({ manager, data }) => {
45
+ const { paymentsData } = data;
46
+ await (0, seed_utils_1.createPayments)(manager, paymentsData);
47
+ },
48
+ });
49
+ await run({ path });
50
+ })();
@@ -0,0 +1,2 @@
1
+ import { SqlEntityManager } from "@mikro-orm/postgresql";
2
+ export declare function createPayments(manager: SqlEntityManager, paymentsData: any[]): Promise<any[]>;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createPayments = void 0;
4
+ async function createPayments(manager, paymentsData) {
5
+ return [];
6
+ }
7
+ exports.createPayments = createPayments;
@@ -0,0 +1,2 @@
1
+ export { default as PaymentModuleService } from "./payment-module";
2
+ export { default as PaymentCollectionService } from "./payment-collection";
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.PaymentCollectionService = exports.PaymentModuleService = void 0;
7
+ var payment_module_1 = require("./payment-module");
8
+ Object.defineProperty(exports, "PaymentModuleService", { enumerable: true, get: function () { return __importDefault(payment_module_1).default; } });
9
+ var payment_collection_1 = require("./payment-collection");
10
+ Object.defineProperty(exports, "PaymentCollectionService", { enumerable: true, get: function () { return __importDefault(payment_collection_1).default; } });
@@ -0,0 +1,17 @@
1
+ import { PaymentCollection } from "../models";
2
+ import { CreatePaymentCollectionDTO, DAL, UpdatePaymentCollectionDTO } from "@medusajs/types";
3
+ import { ModulesSdkUtils } from "@medusajs/utils";
4
+ type InjectedDependencies = {
5
+ paymentCollectionRepository: DAL.RepositoryService;
6
+ };
7
+ declare const PaymentCollectionService_base: new <TEntity_1 extends object = any>(container: InjectedDependencies) => ModulesSdkUtils.AbstractService<TEntity_1, InjectedDependencies, {
8
+ create: CreatePaymentCollectionDTO;
9
+ update: UpdatePaymentCollectionDTO;
10
+ }, {
11
+ list?: any;
12
+ listAndCount?: any;
13
+ }>;
14
+ export default class PaymentCollectionService<TEntity extends PaymentCollection = PaymentCollection> extends PaymentCollectionService_base<TEntity> {
15
+ constructor(container: InjectedDependencies);
16
+ }
17
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const _models_1 = require("../models");
4
+ const utils_1 = require("@medusajs/utils");
5
+ class PaymentCollectionService extends utils_1.ModulesSdkUtils.abstractServiceFactory(_models_1.PaymentCollection) {
6
+ constructor(container) {
7
+ // @ts-ignore
8
+ super(...arguments);
9
+ }
10
+ }
11
+ exports.default = PaymentCollectionService;
@@ -0,0 +1,39 @@
1
+ import { Context, CreatePaymentCollectionDTO, CreatePaymentDTO, CreatePaymentSessionDTO, DAL, FilterablePaymentCollectionProps, FindConfig, InternalModuleDeclaration, IPaymentModuleService, ModuleJoinerConfig, PaymentCollectionDTO, PaymentDTO, SetPaymentSessionsDTO, UpdatePaymentCollectionDTO, UpdatePaymentDTO } from "@medusajs/types";
2
+ import * as services from ".";
3
+ type InjectedDependencies = {
4
+ baseRepository: DAL.RepositoryService;
5
+ paymentCollectionService: services.PaymentCollectionService;
6
+ };
7
+ export default class PaymentModuleService implements IPaymentModuleService {
8
+ protected readonly moduleDeclaration: InternalModuleDeclaration;
9
+ protected baseRepository_: DAL.RepositoryService;
10
+ protected paymentCollectionService_: services.PaymentCollectionService;
11
+ constructor({ baseRepository, paymentCollectionService }: InjectedDependencies, moduleDeclaration: InternalModuleDeclaration);
12
+ __joinerConfig(): ModuleJoinerConfig;
13
+ createPaymentCollection(data: CreatePaymentCollectionDTO, sharedContext?: Context): Promise<PaymentCollectionDTO>;
14
+ createPaymentCollection(data: CreatePaymentCollectionDTO[], sharedContext?: Context): Promise<PaymentCollectionDTO[]>;
15
+ updatePaymentCollection(data: UpdatePaymentCollectionDTO[], sharedContext?: Context): Promise<PaymentCollectionDTO[]>;
16
+ updatePaymentCollection(data: UpdatePaymentCollectionDTO, sharedContext?: Context): Promise<PaymentCollectionDTO>;
17
+ deletePaymentCollection(paymentCollectionId: string[], sharedContext?: Context): Promise<void>;
18
+ deletePaymentCollection(paymentCollectionId: string, sharedContext?: Context): Promise<void>;
19
+ retrievePaymentCollection(paymentCollectionId: string, config?: FindConfig<PaymentCollectionDTO>, sharedContext?: Context): Promise<PaymentCollectionDTO>;
20
+ listPaymentCollections(filters?: FilterablePaymentCollectionProps, config?: FindConfig<PaymentCollectionDTO>, sharedContext?: Context): Promise<PaymentCollectionDTO[]>;
21
+ listAndCountPaymentCollections(filters?: FilterablePaymentCollectionProps, config?: FindConfig<PaymentCollectionDTO>, sharedContext?: Context): Promise<[PaymentCollectionDTO[], number]>;
22
+ /**
23
+ * TODO
24
+ */
25
+ authorizePaymentCollection(paymentCollectionId: string, sharedContext?: Context | undefined): Promise<PaymentCollectionDTO>;
26
+ completePaymentCollection(paymentCollectionId: string, sharedContext?: Context | undefined): Promise<PaymentCollectionDTO>;
27
+ createPayment(data: CreatePaymentDTO): Promise<PaymentDTO>;
28
+ createPayment(data: CreatePaymentDTO[]): Promise<PaymentDTO[]>;
29
+ capturePayment(paymentId: string, amount: number, sharedContext?: Context | undefined): Promise<PaymentDTO>;
30
+ refundPayment(paymentId: string, amount: number, sharedContext?: Context | undefined): Promise<PaymentDTO>;
31
+ updatePayment(data: UpdatePaymentDTO, sharedContext?: Context | undefined): Promise<PaymentDTO>;
32
+ updatePayment(data: UpdatePaymentDTO[], sharedContext?: Context | undefined): Promise<PaymentDTO[]>;
33
+ createPaymentSession(paymentCollectionId: string, data: CreatePaymentSessionDTO, sharedContext?: Context | undefined): Promise<PaymentCollectionDTO>;
34
+ createPaymentSession(paymentCollectionId: string, data: CreatePaymentSessionDTO[], sharedContext?: Context | undefined): Promise<PaymentCollectionDTO>;
35
+ authorizePaymentSessions(paymentCollectionId: string, sessionIds: string[], sharedContext?: Context | undefined): Promise<PaymentCollectionDTO>;
36
+ completePaymentSessions(paymentCollectionId: string, sessionIds: string[], sharedContext?: Context | undefined): Promise<PaymentCollectionDTO>;
37
+ setPaymentSessions(paymentCollectionId: string, data: SetPaymentSessionsDTO[], sharedContext?: Context | undefined): Promise<PaymentCollectionDTO>;
38
+ }
39
+ export {};