@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
|
@@ -0,0 +1,134 @@
|
|
|
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 __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const utils_1 = require("@medusajs/utils");
|
|
16
|
+
const joiner_config_1 = require("../joiner-config");
|
|
17
|
+
class PaymentModuleService {
|
|
18
|
+
constructor({ baseRepository, paymentCollectionService }, moduleDeclaration) {
|
|
19
|
+
this.moduleDeclaration = moduleDeclaration;
|
|
20
|
+
this.baseRepository_ = baseRepository;
|
|
21
|
+
this.paymentCollectionService_ = paymentCollectionService;
|
|
22
|
+
}
|
|
23
|
+
__joinerConfig() {
|
|
24
|
+
return joiner_config_1.joinerConfig;
|
|
25
|
+
}
|
|
26
|
+
async createPaymentCollection(data, sharedContext) {
|
|
27
|
+
const input = Array.isArray(data) ? data : [data];
|
|
28
|
+
const collections = await this.paymentCollectionService_.create(input, sharedContext);
|
|
29
|
+
return await this.baseRepository_.serialize(Array.isArray(data) ? collections : collections[0], {
|
|
30
|
+
populate: true,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async updatePaymentCollection(data, sharedContext) {
|
|
34
|
+
const input = Array.isArray(data) ? data : [data];
|
|
35
|
+
const result = await this.paymentCollectionService_.update(input, sharedContext);
|
|
36
|
+
return await this.baseRepository_.serialize(Array.isArray(data) ? result : result[0], {
|
|
37
|
+
populate: true,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async deletePaymentCollection(ids, sharedContext) {
|
|
41
|
+
const paymentCollectionIds = Array.isArray(ids) ? ids : [ids];
|
|
42
|
+
await this.paymentCollectionService_.delete(paymentCollectionIds, sharedContext);
|
|
43
|
+
}
|
|
44
|
+
async retrievePaymentCollection(paymentCollectionId, config = {}, sharedContext = {}) {
|
|
45
|
+
const paymentCollection = await this.paymentCollectionService_.retrieve(paymentCollectionId, config, sharedContext);
|
|
46
|
+
return await this.baseRepository_.serialize(paymentCollection, { populate: true });
|
|
47
|
+
}
|
|
48
|
+
async listPaymentCollections(filters = {}, config = {}, sharedContext) {
|
|
49
|
+
const paymentCollections = await this.paymentCollectionService_.list(filters, config, sharedContext);
|
|
50
|
+
return await this.baseRepository_.serialize(paymentCollections, { populate: true });
|
|
51
|
+
}
|
|
52
|
+
async listAndCountPaymentCollections(filters = {}, config = {}, sharedContext) {
|
|
53
|
+
const [paymentCollections, count] = await this.paymentCollectionService_.listAndCount(filters, config, sharedContext);
|
|
54
|
+
return [
|
|
55
|
+
await this.baseRepository_.serialize(paymentCollections, { populate: true }),
|
|
56
|
+
count,
|
|
57
|
+
];
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* TODO
|
|
61
|
+
*/
|
|
62
|
+
authorizePaymentCollection(paymentCollectionId, sharedContext) {
|
|
63
|
+
throw new Error("Method not implemented.");
|
|
64
|
+
}
|
|
65
|
+
completePaymentCollection(paymentCollectionId, sharedContext) {
|
|
66
|
+
throw new Error("Method not implemented.");
|
|
67
|
+
}
|
|
68
|
+
createPayment(data) {
|
|
69
|
+
throw new Error("Method not implemented.");
|
|
70
|
+
}
|
|
71
|
+
capturePayment(paymentId, amount, sharedContext) {
|
|
72
|
+
throw new Error("Method not implemented.");
|
|
73
|
+
}
|
|
74
|
+
refundPayment(paymentId, amount, sharedContext) {
|
|
75
|
+
throw new Error("Method not implemented.");
|
|
76
|
+
}
|
|
77
|
+
updatePayment(data, sharedContext) {
|
|
78
|
+
throw new Error("Method not implemented.");
|
|
79
|
+
}
|
|
80
|
+
createPaymentSession(paymentCollectionId, data, sharedContext) {
|
|
81
|
+
throw new Error("Method not implemented.");
|
|
82
|
+
}
|
|
83
|
+
authorizePaymentSessions(paymentCollectionId, sessionIds, sharedContext) {
|
|
84
|
+
throw new Error("Method not implemented.");
|
|
85
|
+
}
|
|
86
|
+
completePaymentSessions(paymentCollectionId, sessionIds, sharedContext) {
|
|
87
|
+
throw new Error("Method not implemented.");
|
|
88
|
+
}
|
|
89
|
+
setPaymentSessions(paymentCollectionId, data, sharedContext) {
|
|
90
|
+
throw new Error("Method not implemented.");
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.default = PaymentModuleService;
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
|
96
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
97
|
+
__metadata("design:type", Function),
|
|
98
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
99
|
+
__metadata("design:returntype", Promise)
|
|
100
|
+
], PaymentModuleService.prototype, "createPaymentCollection", null);
|
|
101
|
+
__decorate([
|
|
102
|
+
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
|
103
|
+
__metadata("design:type", Function),
|
|
104
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
105
|
+
__metadata("design:returntype", Promise)
|
|
106
|
+
], PaymentModuleService.prototype, "updatePaymentCollection", null);
|
|
107
|
+
__decorate([
|
|
108
|
+
(0, utils_1.InjectTransactionManager)("baseRepository_"),
|
|
109
|
+
__param(1, (0, utils_1.MedusaContext)()),
|
|
110
|
+
__metadata("design:type", Function),
|
|
111
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
112
|
+
__metadata("design:returntype", Promise)
|
|
113
|
+
], PaymentModuleService.prototype, "deletePaymentCollection", null);
|
|
114
|
+
__decorate([
|
|
115
|
+
(0, utils_1.InjectManager)("baseRepository_"),
|
|
116
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
|
117
|
+
__metadata("design:type", Function),
|
|
118
|
+
__metadata("design:paramtypes", [String, Object, Object]),
|
|
119
|
+
__metadata("design:returntype", Promise)
|
|
120
|
+
], PaymentModuleService.prototype, "retrievePaymentCollection", null);
|
|
121
|
+
__decorate([
|
|
122
|
+
(0, utils_1.InjectManager)("baseRepository_"),
|
|
123
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
|
124
|
+
__metadata("design:type", Function),
|
|
125
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
126
|
+
__metadata("design:returntype", Promise)
|
|
127
|
+
], PaymentModuleService.prototype, "listPaymentCollections", null);
|
|
128
|
+
__decorate([
|
|
129
|
+
(0, utils_1.InjectManager)("baseRepository_"),
|
|
130
|
+
__param(2, (0, utils_1.MedusaContext)()),
|
|
131
|
+
__metadata("design:type", Function),
|
|
132
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
133
|
+
__metadata("design:returntype", Promise)
|
|
134
|
+
], PaymentModuleService.prototype, "listAndCountPaymentCollections", null);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DAL, CreatePaymentCollectionDTO, UpdatePaymentCollectionDTO } from "@medusajs/types";
|
|
2
|
+
import { PaymentCollection } from "../models";
|
|
3
|
+
export interface IPaymentCollectionRepository<TEntity extends PaymentCollection = PaymentCollection> extends DAL.RepositoryService<TEntity, {
|
|
4
|
+
create: CreatePaymentCollectionDTO;
|
|
5
|
+
update: UpdatePaymentCollectionDTO;
|
|
6
|
+
}> {
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@medusajs/payment",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Medusa Payment module",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=16"
|
|
12
|
+
},
|
|
13
|
+
"bin": {
|
|
14
|
+
"medusa-payment-seed": "dist/scripts/bin/run-seed.js"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/medusajs/medusa",
|
|
19
|
+
"directory": "packages/payment"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"author": "Medusa",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"scripts": {
|
|
27
|
+
"watch": "tsc --build --watch",
|
|
28
|
+
"watch:test": "tsc --build tsconfig.spec.json --watch",
|
|
29
|
+
"prepublishOnly": "cross-env NODE_ENV=production tsc --build && tsc-alias -p tsconfig.json",
|
|
30
|
+
"build": "rimraf dist && tsc --build && tsc-alias -p tsconfig.json",
|
|
31
|
+
"test": "jest --runInBand --bail --forceExit -- src/**/__tests__/**/*.ts",
|
|
32
|
+
"test:integration": "jest --runInBand --forceExit -- integration-tests/**/__tests__/**/*.ts",
|
|
33
|
+
"migration:generate": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:generate",
|
|
34
|
+
"migration:initial": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create --initial",
|
|
35
|
+
"migration:create": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:create",
|
|
36
|
+
"migration:up": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm migration:up",
|
|
37
|
+
"orm:cache:clear": " MIKRO_ORM_CLI=./mikro-orm.config.dev.ts mikro-orm cache:clear"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@mikro-orm/cli": "5.9.7",
|
|
41
|
+
"cross-env": "^5.2.1",
|
|
42
|
+
"jest": "^29.6.3",
|
|
43
|
+
"medusa-test-utils": "^1.1.40",
|
|
44
|
+
"rimraf": "^3.0.2",
|
|
45
|
+
"ts-jest": "^29.1.1",
|
|
46
|
+
"ts-node": "^10.9.1",
|
|
47
|
+
"tsc-alias": "^1.8.6",
|
|
48
|
+
"typescript": "^5.1.6"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@medusajs/modules-sdk": "^1.12.5",
|
|
52
|
+
"@medusajs/types": "^1.11.9",
|
|
53
|
+
"@medusajs/utils": "^1.11.2",
|
|
54
|
+
"@mikro-orm/core": "5.9.7",
|
|
55
|
+
"@mikro-orm/migrations": "5.9.7",
|
|
56
|
+
"@mikro-orm/postgresql": "5.9.7",
|
|
57
|
+
"awilix": "^8.0.0",
|
|
58
|
+
"dotenv": "^16.1.4",
|
|
59
|
+
"knex": "2.4.2"
|
|
60
|
+
}
|
|
61
|
+
}
|