@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.
- package/README.md +3 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +22 -0
- package/dist/initialize/index.d.ts +4 -0
- package/dist/initialize/index.js +16 -0
- package/dist/joiner-config.d.ts +8 -0
- package/dist/joiner-config.js +29 -0
- package/dist/loaders/connection.d.ts +4 -0
- package/dist/loaders/connection.js +41 -0
- package/dist/loaders/container.d.ts +2 -0
- package/dist/loaders/container.js +34 -0
- package/dist/loaders/index.d.ts +2 -0
- package/dist/loaders/index.js +18 -0
- package/dist/models/capture.d.ts +14 -0
- package/dist/models/capture.js +75 -0
- package/dist/models/index.d.ts +7 -0
- package/dist/models/index.js +20 -0
- package/dist/models/payment-collection.d.ts +27 -0
- package/dist/models/payment-collection.js +144 -0
- package/dist/models/payment-method-token.d.ts +11 -0
- package/dist/models/payment-method-token.js +71 -0
- package/dist/models/payment-provider.d.ts +6 -0
- package/dist/models/payment-provider.js +32 -0
- package/dist/models/payment-session.d.ts +16 -0
- package/dist/models/payment-session.js +97 -0
- package/dist/models/payment.d.ts +34 -0
- package/dist/models/payment.js +176 -0
- package/dist/models/refund.d.ts +10 -0
- package/dist/models/refund.js +75 -0
- package/dist/module-definition.d.ts +4 -0
- package/dist/module-definition.js +50 -0
- package/dist/repositories/index.d.ts +1 -0
- package/dist/repositories/index.js +5 -0
- package/dist/scripts/bin/run-seed.d.ts +3 -0
- package/dist/scripts/bin/run-seed.js +50 -0
- package/dist/scripts/seed-utils.d.ts +2 -0
- package/dist/scripts/seed-utils.js +7 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +10 -0
- package/dist/services/payment-collection.d.ts +17 -0
- package/dist/services/payment-collection.js +11 -0
- package/dist/services/payment-module.d.ts +39 -0
- package/dist/services/payment-module.js +134 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +2 -0
- package/dist/types/repositories.d.ts +7 -0
- package/dist/types/repositories.js +2 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# Payment Module
|
|
2
|
+
|
|
3
|
+
A Payment is the result of a series of financial transactions performed as part of collecting a payment of a purchase. The Payment holds information about the payment provider as well as the state of it. You can associate a Payment with a Cart, an Order, an OrderEdit, or any other resource you’d like to have your customers pay for.
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.runMigrations = exports.revertMigration = void 0;
|
|
18
|
+
const module_definition_1 = require("./module-definition");
|
|
19
|
+
Object.defineProperty(exports, "revertMigration", { enumerable: true, get: function () { return module_definition_1.revertMigration; } });
|
|
20
|
+
Object.defineProperty(exports, "runMigrations", { enumerable: true, get: function () { return module_definition_1.runMigrations; } });
|
|
21
|
+
exports.default = module_definition_1.moduleDefinition;
|
|
22
|
+
__exportStar(require("./initialize"), exports);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ExternalModuleDeclaration, InternalModuleDeclaration } from "@medusajs/modules-sdk";
|
|
2
|
+
import { IPaymentModuleService, ModulesSdkTypes } from "@medusajs/types";
|
|
3
|
+
import { InitializeModuleInjectableDependencies } from "../types";
|
|
4
|
+
export declare const initialize: (options?: ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions | ExternalModuleDeclaration | InternalModuleDeclaration, injectedDependencies?: InitializeModuleInjectableDependencies) => Promise<IPaymentModuleService>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initialize = void 0;
|
|
4
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
|
5
|
+
const module_definition_1 = require("../module-definition");
|
|
6
|
+
const initialize = async (options, injectedDependencies) => {
|
|
7
|
+
const loaded = await modules_sdk_1.MedusaModule.bootstrap({
|
|
8
|
+
moduleKey: modules_sdk_1.Modules.PAYMENT,
|
|
9
|
+
defaultPath: modules_sdk_1.MODULE_PACKAGE_NAMES[modules_sdk_1.Modules.PAYMENT],
|
|
10
|
+
declaration: options,
|
|
11
|
+
injectedDependencies,
|
|
12
|
+
moduleExports: module_definition_1.moduleDefinition,
|
|
13
|
+
});
|
|
14
|
+
return loaded[modules_sdk_1.Modules.PAYMENT];
|
|
15
|
+
};
|
|
16
|
+
exports.initialize = initialize;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ModuleJoinerConfig } from "@medusajs/types";
|
|
2
|
+
import { MapToConfig } from "@medusajs/utils";
|
|
3
|
+
export declare const LinkableKeys: {
|
|
4
|
+
payment_id: string;
|
|
5
|
+
payment_collection_id: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const entityNameToLinkableKeysMap: MapToConfig;
|
|
8
|
+
export declare const joinerConfig: ModuleJoinerConfig;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.joinerConfig = exports.entityNameToLinkableKeysMap = exports.LinkableKeys = void 0;
|
|
4
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
|
5
|
+
const _models_1 = require("./models");
|
|
6
|
+
exports.LinkableKeys = {
|
|
7
|
+
payment_id: _models_1.Payment.name,
|
|
8
|
+
payment_collection_id: _models_1.PaymentCollection.name,
|
|
9
|
+
};
|
|
10
|
+
const entityLinkableKeysMap = {};
|
|
11
|
+
Object.entries(exports.LinkableKeys).forEach(([key, value]) => {
|
|
12
|
+
entityLinkableKeysMap[value] ?? (entityLinkableKeysMap[value] = []);
|
|
13
|
+
entityLinkableKeysMap[value].push({
|
|
14
|
+
mapTo: key,
|
|
15
|
+
valueFrom: key.split("_").pop(),
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
exports.entityNameToLinkableKeysMap = entityLinkableKeysMap;
|
|
19
|
+
exports.joinerConfig = {
|
|
20
|
+
serviceName: modules_sdk_1.Modules.PAYMENT,
|
|
21
|
+
primaryKeys: ["id"],
|
|
22
|
+
linkableKeys: exports.LinkableKeys,
|
|
23
|
+
alias: {
|
|
24
|
+
name: ["payment", "payments"],
|
|
25
|
+
args: {
|
|
26
|
+
entity: _models_1.Payment.name,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { InternalModuleDeclaration, LoaderOptions } from "@medusajs/modules-sdk";
|
|
2
|
+
import { ModulesSdkTypes } from "@medusajs/types";
|
|
3
|
+
declare const _default: ({ options, container, logger, }: LoaderOptions<ModulesSdkTypes.ModuleServiceInitializeOptions | ModulesSdkTypes.ModuleServiceInitializeCustomDataLayerOptions>, moduleDeclaration?: InternalModuleDeclaration) => Promise<void>;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const modules_sdk_1 = require("@medusajs/modules-sdk");
|
|
27
|
+
const utils_1 = require("@medusajs/utils");
|
|
28
|
+
const PaymentModels = __importStar(require("../models"));
|
|
29
|
+
exports.default = async ({ options, container, logger, }, moduleDeclaration) => {
|
|
30
|
+
const entities = Object.values(PaymentModels);
|
|
31
|
+
const pathToMigrations = __dirname + "/../migrations";
|
|
32
|
+
await utils_1.ModulesSdkUtils.mikroOrmConnectionLoader({
|
|
33
|
+
moduleName: modules_sdk_1.Modules.PAYMENT,
|
|
34
|
+
entities,
|
|
35
|
+
container,
|
|
36
|
+
options,
|
|
37
|
+
moduleDeclaration,
|
|
38
|
+
logger,
|
|
39
|
+
pathToMigrations,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const utils_1 = require("@medusajs/utils");
|
|
27
|
+
const ModuleModels = __importStar(require("../models"));
|
|
28
|
+
const ModuleRepositories = __importStar(require("../repositories"));
|
|
29
|
+
const ModuleServices = __importStar(require("../services"));
|
|
30
|
+
exports.default = utils_1.ModulesSdkUtils.moduleContainerLoaderFactory({
|
|
31
|
+
moduleModels: ModuleModels,
|
|
32
|
+
moduleRepositories: ModuleRepositories,
|
|
33
|
+
moduleServices: ModuleServices,
|
|
34
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./connection"), exports);
|
|
18
|
+
__exportStar(require("./container"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OptionalProps } from "@mikro-orm/core";
|
|
2
|
+
import Payment from "./payment";
|
|
3
|
+
type OptionalCaptureProps = "created_at";
|
|
4
|
+
export default class Capture {
|
|
5
|
+
[OptionalProps]?: OptionalCaptureProps;
|
|
6
|
+
id: string;
|
|
7
|
+
amount: number;
|
|
8
|
+
payment: Payment;
|
|
9
|
+
created_at: Date;
|
|
10
|
+
created_by: string | null;
|
|
11
|
+
onCreate(): void;
|
|
12
|
+
onInit(): void;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -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 Capture = class Capture {
|
|
19
|
+
constructor() {
|
|
20
|
+
this.created_by = null;
|
|
21
|
+
}
|
|
22
|
+
onCreate() {
|
|
23
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "capt");
|
|
24
|
+
}
|
|
25
|
+
onInit() {
|
|
26
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "capt");
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
|
31
|
+
__metadata("design:type", String)
|
|
32
|
+
], Capture.prototype, "id", void 0);
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, core_1.Property)({
|
|
35
|
+
columnType: "numeric",
|
|
36
|
+
serializer: Number,
|
|
37
|
+
}),
|
|
38
|
+
__metadata("design:type", Number)
|
|
39
|
+
], Capture.prototype, "amount", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, core_1.ManyToOne)(() => payment_1.default, {
|
|
42
|
+
onDelete: "cascade",
|
|
43
|
+
index: "IDX_capture_payment_id",
|
|
44
|
+
fieldName: "payment_id",
|
|
45
|
+
}),
|
|
46
|
+
__metadata("design:type", payment_1.default)
|
|
47
|
+
], Capture.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
|
+
], Capture.prototype, "created_at", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
58
|
+
__metadata("design:type", Object)
|
|
59
|
+
], Capture.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
|
+
], Capture.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
|
+
], Capture.prototype, "onInit", null);
|
|
72
|
+
Capture = __decorate([
|
|
73
|
+
(0, core_1.Entity)({ tableName: "capture" })
|
|
74
|
+
], Capture);
|
|
75
|
+
exports.default = Capture;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { default as Capture } from "./capture";
|
|
2
|
+
export { default as Payment } from "./payment";
|
|
3
|
+
export { default as PaymentCollection } from "./payment-collection";
|
|
4
|
+
export { default as PaymentMethodToken } from "./payment-method-token";
|
|
5
|
+
export { default as PaymentProvider } from "./payment-provider";
|
|
6
|
+
export { default as PaymentSession } from "./payment-session";
|
|
7
|
+
export { default as Refund } from "./refund";
|
|
@@ -0,0 +1,20 @@
|
|
|
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.Refund = exports.PaymentSession = exports.PaymentProvider = exports.PaymentMethodToken = exports.PaymentCollection = exports.Payment = exports.Capture = void 0;
|
|
7
|
+
var capture_1 = require("./capture");
|
|
8
|
+
Object.defineProperty(exports, "Capture", { enumerable: true, get: function () { return __importDefault(capture_1).default; } });
|
|
9
|
+
var payment_1 = require("./payment");
|
|
10
|
+
Object.defineProperty(exports, "Payment", { enumerable: true, get: function () { return __importDefault(payment_1).default; } });
|
|
11
|
+
var payment_collection_1 = require("./payment-collection");
|
|
12
|
+
Object.defineProperty(exports, "PaymentCollection", { enumerable: true, get: function () { return __importDefault(payment_collection_1).default; } });
|
|
13
|
+
var payment_method_token_1 = require("./payment-method-token");
|
|
14
|
+
Object.defineProperty(exports, "PaymentMethodToken", { enumerable: true, get: function () { return __importDefault(payment_method_token_1).default; } });
|
|
15
|
+
var payment_provider_1 = require("./payment-provider");
|
|
16
|
+
Object.defineProperty(exports, "PaymentProvider", { enumerable: true, get: function () { return __importDefault(payment_provider_1).default; } });
|
|
17
|
+
var payment_session_1 = require("./payment-session");
|
|
18
|
+
Object.defineProperty(exports, "PaymentSession", { enumerable: true, get: function () { return __importDefault(payment_session_1).default; } });
|
|
19
|
+
var refund_1 = require("./refund");
|
|
20
|
+
Object.defineProperty(exports, "Refund", { enumerable: true, get: function () { return __importDefault(refund_1).default; } });
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Collection, OptionalProps } from "@mikro-orm/core";
|
|
2
|
+
import { DAL } from "@medusajs/types";
|
|
3
|
+
import { PaymentCollectionStatus } from "@medusajs/utils";
|
|
4
|
+
import PaymentProvider from "./payment-provider";
|
|
5
|
+
import PaymentSession from "./payment-session";
|
|
6
|
+
import Payment from "./payment";
|
|
7
|
+
type OptionalPaymentCollectionProps = "status" | DAL.EntityDateColumns;
|
|
8
|
+
export default class PaymentCollection {
|
|
9
|
+
[OptionalProps]?: OptionalPaymentCollectionProps;
|
|
10
|
+
id: string;
|
|
11
|
+
currency_code: string;
|
|
12
|
+
amount: number;
|
|
13
|
+
authorized_amount: number | null;
|
|
14
|
+
refunded_amount: number | null;
|
|
15
|
+
region_id: string;
|
|
16
|
+
created_at: Date;
|
|
17
|
+
updated_at: Date;
|
|
18
|
+
deleted_at: Date | null;
|
|
19
|
+
completed_at: Date | null;
|
|
20
|
+
status: PaymentCollectionStatus;
|
|
21
|
+
payment_providers: Collection<PaymentProvider, object>;
|
|
22
|
+
payment_sessions: Collection<PaymentSession, object>;
|
|
23
|
+
payments: Collection<Payment, object>;
|
|
24
|
+
onCreate(): void;
|
|
25
|
+
onInit(): void;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,144 @@
|
|
|
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_provider_1 = __importDefault(require("./payment-provider"));
|
|
18
|
+
const payment_session_1 = __importDefault(require("./payment-session"));
|
|
19
|
+
const payment_1 = __importDefault(require("./payment"));
|
|
20
|
+
let PaymentCollection = class PaymentCollection {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.authorized_amount = null;
|
|
23
|
+
this.refunded_amount = null;
|
|
24
|
+
this.deleted_at = null;
|
|
25
|
+
this.completed_at = null;
|
|
26
|
+
this.status = utils_1.PaymentCollectionStatus.NOT_PAID;
|
|
27
|
+
this.payment_providers = new core_1.Collection(this);
|
|
28
|
+
this.payment_sessions = new core_1.Collection(this);
|
|
29
|
+
this.payments = new core_1.Collection(this);
|
|
30
|
+
}
|
|
31
|
+
onCreate() {
|
|
32
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "pay_col");
|
|
33
|
+
}
|
|
34
|
+
onInit() {
|
|
35
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "pay_col");
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], PaymentCollection.prototype, "id", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, core_1.Property)({ columnType: "text" }),
|
|
44
|
+
__metadata("design:type", String)
|
|
45
|
+
], PaymentCollection.prototype, "currency_code", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, core_1.Property)({
|
|
48
|
+
columnType: "numeric",
|
|
49
|
+
serializer: Number,
|
|
50
|
+
}),
|
|
51
|
+
__metadata("design:type", Number)
|
|
52
|
+
], PaymentCollection.prototype, "amount", void 0);
|
|
53
|
+
__decorate([
|
|
54
|
+
(0, core_1.Property)({
|
|
55
|
+
columnType: "numeric",
|
|
56
|
+
nullable: true,
|
|
57
|
+
serializer: utils_1.optionalNumericSerializer,
|
|
58
|
+
}),
|
|
59
|
+
__metadata("design:type", Object)
|
|
60
|
+
], PaymentCollection.prototype, "authorized_amount", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, core_1.Property)({
|
|
63
|
+
columnType: "numeric",
|
|
64
|
+
nullable: true,
|
|
65
|
+
serializer: utils_1.optionalNumericSerializer,
|
|
66
|
+
}),
|
|
67
|
+
__metadata("design:type", Object)
|
|
68
|
+
], PaymentCollection.prototype, "refunded_amount", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
(0, core_1.Property)({ columnType: "text", index: "IDX_payment_collection_region_id" }),
|
|
71
|
+
__metadata("design:type", String)
|
|
72
|
+
], PaymentCollection.prototype, "region_id", void 0);
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, core_1.Property)({
|
|
75
|
+
onCreate: () => new Date(),
|
|
76
|
+
columnType: "timestamptz",
|
|
77
|
+
defaultRaw: "now()",
|
|
78
|
+
}),
|
|
79
|
+
__metadata("design:type", Date)
|
|
80
|
+
], PaymentCollection.prototype, "created_at", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
(0, core_1.Property)({
|
|
83
|
+
onCreate: () => new Date(),
|
|
84
|
+
onUpdate: () => new Date(),
|
|
85
|
+
columnType: "timestamptz",
|
|
86
|
+
defaultRaw: "now()",
|
|
87
|
+
}),
|
|
88
|
+
__metadata("design:type", Date)
|
|
89
|
+
], PaymentCollection.prototype, "updated_at", void 0);
|
|
90
|
+
__decorate([
|
|
91
|
+
(0, core_1.Property)({
|
|
92
|
+
columnType: "timestamptz",
|
|
93
|
+
nullable: true,
|
|
94
|
+
index: "IDX_payment_collection_deleted_at",
|
|
95
|
+
}),
|
|
96
|
+
__metadata("design:type", Object)
|
|
97
|
+
], PaymentCollection.prototype, "deleted_at", void 0);
|
|
98
|
+
__decorate([
|
|
99
|
+
(0, core_1.Property)({
|
|
100
|
+
columnType: "timestamptz",
|
|
101
|
+
nullable: true,
|
|
102
|
+
}),
|
|
103
|
+
__metadata("design:type", Object)
|
|
104
|
+
], PaymentCollection.prototype, "completed_at", void 0);
|
|
105
|
+
__decorate([
|
|
106
|
+
(0, core_1.Enum)({
|
|
107
|
+
items: () => utils_1.PaymentCollectionStatus,
|
|
108
|
+
default: utils_1.PaymentCollectionStatus.NOT_PAID,
|
|
109
|
+
}),
|
|
110
|
+
__metadata("design:type", String)
|
|
111
|
+
], PaymentCollection.prototype, "status", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, core_1.ManyToMany)(() => payment_provider_1.default),
|
|
114
|
+
__metadata("design:type", Object)
|
|
115
|
+
], PaymentCollection.prototype, "payment_providers", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
(0, core_1.OneToMany)(() => payment_session_1.default, (ps) => ps.payment_collection, {
|
|
118
|
+
cascade: [core_1.Cascade.REMOVE],
|
|
119
|
+
}),
|
|
120
|
+
__metadata("design:type", Object)
|
|
121
|
+
], PaymentCollection.prototype, "payment_sessions", void 0);
|
|
122
|
+
__decorate([
|
|
123
|
+
(0, core_1.OneToMany)(() => payment_1.default, (payment) => payment.payment_collection, {
|
|
124
|
+
cascade: [core_1.Cascade.REMOVE],
|
|
125
|
+
}),
|
|
126
|
+
__metadata("design:type", Object)
|
|
127
|
+
], PaymentCollection.prototype, "payments", void 0);
|
|
128
|
+
__decorate([
|
|
129
|
+
(0, core_1.BeforeCreate)(),
|
|
130
|
+
__metadata("design:type", Function),
|
|
131
|
+
__metadata("design:paramtypes", []),
|
|
132
|
+
__metadata("design:returntype", void 0)
|
|
133
|
+
], PaymentCollection.prototype, "onCreate", null);
|
|
134
|
+
__decorate([
|
|
135
|
+
(0, core_1.OnInit)(),
|
|
136
|
+
__metadata("design:type", Function),
|
|
137
|
+
__metadata("design:paramtypes", []),
|
|
138
|
+
__metadata("design:returntype", void 0)
|
|
139
|
+
], PaymentCollection.prototype, "onInit", null);
|
|
140
|
+
PaymentCollection = __decorate([
|
|
141
|
+
(0, core_1.Entity)({ tableName: "payment_collection" }),
|
|
142
|
+
(0, core_1.Filter)(utils_1.DALUtils.mikroOrmSoftDeletableFilterOptions)
|
|
143
|
+
], PaymentCollection);
|
|
144
|
+
exports.default = PaymentCollection;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export default class PaymentMethodToken {
|
|
2
|
+
id: string;
|
|
3
|
+
provider_id: string;
|
|
4
|
+
data: Record<string, unknown> | null;
|
|
5
|
+
name: string;
|
|
6
|
+
type_detail: string | null;
|
|
7
|
+
description_detail: string | null;
|
|
8
|
+
metadata: Record<string, unknown> | null;
|
|
9
|
+
onCreate(): void;
|
|
10
|
+
onInit(): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const core_1 = require("@mikro-orm/core");
|
|
13
|
+
const utils_1 = require("@medusajs/utils");
|
|
14
|
+
let PaymentMethodToken = class PaymentMethodToken {
|
|
15
|
+
constructor() {
|
|
16
|
+
this.data = null;
|
|
17
|
+
this.type_detail = null;
|
|
18
|
+
this.description_detail = null;
|
|
19
|
+
this.metadata = null;
|
|
20
|
+
}
|
|
21
|
+
onCreate() {
|
|
22
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "paymttok");
|
|
23
|
+
}
|
|
24
|
+
onInit() {
|
|
25
|
+
this.id = (0, utils_1.generateEntityId)(this.id, "paymttok");
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], PaymentMethodToken.prototype, "id", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, core_1.Property)({ columnType: "text" }),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], PaymentMethodToken.prototype, "provider_id", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, core_1.Property)({ columnType: "jsonb", nullable: true }),
|
|
38
|
+
__metadata("design:type", Object)
|
|
39
|
+
], PaymentMethodToken.prototype, "data", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, core_1.Property)({ columnType: "text" }),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], PaymentMethodToken.prototype, "name", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
46
|
+
__metadata("design:type", Object)
|
|
47
|
+
], PaymentMethodToken.prototype, "type_detail", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, core_1.Property)({ columnType: "text", nullable: true }),
|
|
50
|
+
__metadata("design:type", Object)
|
|
51
|
+
], PaymentMethodToken.prototype, "description_detail", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, core_1.Property)({ columnType: "jsonb", nullable: true }),
|
|
54
|
+
__metadata("design:type", Object)
|
|
55
|
+
], PaymentMethodToken.prototype, "metadata", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, core_1.BeforeCreate)(),
|
|
58
|
+
__metadata("design:type", Function),
|
|
59
|
+
__metadata("design:paramtypes", []),
|
|
60
|
+
__metadata("design:returntype", void 0)
|
|
61
|
+
], PaymentMethodToken.prototype, "onCreate", null);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, core_1.OnInit)(),
|
|
64
|
+
__metadata("design:type", Function),
|
|
65
|
+
__metadata("design:paramtypes", []),
|
|
66
|
+
__metadata("design:returntype", void 0)
|
|
67
|
+
], PaymentMethodToken.prototype, "onInit", null);
|
|
68
|
+
PaymentMethodToken = __decorate([
|
|
69
|
+
(0, core_1.Entity)({ tableName: "payment_method_token" })
|
|
70
|
+
], PaymentMethodToken);
|
|
71
|
+
exports.default = PaymentMethodToken;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
const core_1 = require("@mikro-orm/core");
|
|
13
|
+
let PaymentProvider = class PaymentProvider {
|
|
14
|
+
constructor() {
|
|
15
|
+
this.is_enabled = true;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, core_1.PrimaryKey)({ columnType: "text" }),
|
|
20
|
+
__metadata("design:type", String)
|
|
21
|
+
], PaymentProvider.prototype, "id", void 0);
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, core_1.Property)({
|
|
24
|
+
default: true,
|
|
25
|
+
columnType: "boolean",
|
|
26
|
+
}),
|
|
27
|
+
__metadata("design:type", Boolean)
|
|
28
|
+
], PaymentProvider.prototype, "is_enabled", void 0);
|
|
29
|
+
PaymentProvider = __decorate([
|
|
30
|
+
(0, core_1.Entity)({ tableName: "payment_provider" })
|
|
31
|
+
], PaymentProvider);
|
|
32
|
+
exports.default = PaymentProvider;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { PaymentSessionStatus } from "@medusajs/utils";
|
|
2
|
+
import PaymentCollection from "./payment-collection";
|
|
3
|
+
import Payment from "./payment";
|
|
4
|
+
export default class PaymentSession {
|
|
5
|
+
id: string;
|
|
6
|
+
currency_code: string;
|
|
7
|
+
amount: number;
|
|
8
|
+
provider_id: string;
|
|
9
|
+
data: Record<string, unknown> | null;
|
|
10
|
+
status: PaymentSessionStatus;
|
|
11
|
+
authorized_at: Date | null;
|
|
12
|
+
payment_collection: PaymentCollection;
|
|
13
|
+
payment: Payment;
|
|
14
|
+
onCreate(): void;
|
|
15
|
+
onInit(): void;
|
|
16
|
+
}
|