@medusajs/medusa 1.6.0 → 1.6.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/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +13 -0
- package/dist/commands/migrate.js +17 -13
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/seed.js +15 -11
- package/dist/commands/seed.js.map +1 -1
- package/dist/commands/utils/get-migrations.js +9 -5
- package/dist/commands/utils/get-migrations.js.map +1 -1
- package/dist/interfaces/payment-service.d.ts +3 -0
- package/dist/interfaces/payment-service.js.map +1 -1
- package/dist/loaders/config.d.ts +1 -0
- package/dist/loaders/config.js +17 -1
- package/dist/loaders/config.js.map +1 -1
- package/dist/loaders/feature-flags/analytics.js +1 -1
- package/dist/loaders/feature-flags/analytics.js.map +1 -1
- package/dist/loaders/index.js +4 -1
- package/dist/loaders/index.js.map +1 -1
- package/dist/migrations/1664880666982-payment-collection.js +2 -2
- package/dist/migrations/1664880666982-payment-collection.js.map +1 -1
- package/dist/models/payment-collection.d.ts +1 -0
- package/dist/models/payment-collection.js +4 -0
- package/dist/models/payment-collection.js.map +1 -1
- package/dist/models/payment-session.d.ts +1 -0
- package/dist/models/payment-session.js +7 -1
- package/dist/models/payment-session.js.map +1 -1
- package/dist/models/refund.d.ts +3 -0
- package/dist/models/refund.js +21 -1
- package/dist/models/refund.js.map +1 -1
- package/dist/repositories/payment-collection.d.ts +4 -0
- package/dist/repositories/payment-collection.js +108 -0
- package/dist/repositories/payment-collection.js.map +1 -1
- package/dist/services/draft-order.d.ts +4 -1
- package/dist/services/draft-order.js +22 -10
- package/dist/services/draft-order.js.map +1 -1
- package/dist/services/payment-collection.d.ts +23 -4
- package/dist/services/payment-collection.js +602 -7
- package/dist/services/payment-collection.js.map +1 -1
- package/dist/services/payment-provider.d.ts +6 -0
- package/dist/services/payment-provider.js +187 -8
- package/dist/services/payment-provider.js.map +1 -1
- package/dist/types/payment-collection.d.ts +19 -1
- package/dist/types/payment-collection.js.map +1 -1
- package/dist/utils/db-aware-column.js +6 -16
- package/dist/utils/db-aware-column.js.map +1 -1
- package/dist/utils/manual-auto-increment.js +7 -12
- package/dist/utils/manual-auto-increment.js.map +1 -1
- package/package.json +2 -2
package/dist/models/refund.js
CHANGED
|
@@ -23,6 +23,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
23
23
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
24
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
25
|
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
26
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
30
|
exports.Refund = exports.RefundReason = void 0;
|
|
28
31
|
var typeorm_1 = require("typeorm");
|
|
@@ -30,6 +33,9 @@ var base_entity_1 = require("../interfaces/models/base-entity");
|
|
|
30
33
|
var db_aware_column_1 = require("../utils/db-aware-column");
|
|
31
34
|
var order_1 = require("./order");
|
|
32
35
|
var generate_entity_id_1 = require("../utils/generate-entity-id");
|
|
36
|
+
var payment_1 = require("./payment");
|
|
37
|
+
var feature_flag_decorators_1 = require("../utils/feature-flag-decorators");
|
|
38
|
+
var order_editing_1 = __importDefault(require("../loaders/feature-flags/order-editing"));
|
|
33
39
|
var RefundReason;
|
|
34
40
|
(function (RefundReason) {
|
|
35
41
|
RefundReason["DISCOUNT"] = "discount";
|
|
@@ -48,14 +54,28 @@ var Refund = /** @class */ (function (_super) {
|
|
|
48
54
|
};
|
|
49
55
|
__decorate([
|
|
50
56
|
(0, typeorm_1.Index)(),
|
|
51
|
-
(0, typeorm_1.Column)(),
|
|
57
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
52
58
|
__metadata("design:type", String)
|
|
53
59
|
], Refund.prototype, "order_id", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
(0, feature_flag_decorators_1.FeatureFlagDecorators)(order_editing_1.default.key, [
|
|
62
|
+
(0, typeorm_1.Index)(),
|
|
63
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
64
|
+
]),
|
|
65
|
+
__metadata("design:type", String)
|
|
66
|
+
], Refund.prototype, "payment_id", void 0);
|
|
54
67
|
__decorate([
|
|
55
68
|
(0, typeorm_1.ManyToOne)(function () { return order_1.Order; }, function (order) { return order.payments; }),
|
|
56
69
|
(0, typeorm_1.JoinColumn)({ name: "order_id" }),
|
|
57
70
|
__metadata("design:type", order_1.Order)
|
|
58
71
|
], Refund.prototype, "order", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, feature_flag_decorators_1.FeatureFlagDecorators)(order_editing_1.default.key, [
|
|
74
|
+
(0, typeorm_1.OneToOne)(function () { return payment_1.Payment; }, { nullable: true }),
|
|
75
|
+
(0, typeorm_1.JoinColumn)({ name: "payment_id" }),
|
|
76
|
+
]),
|
|
77
|
+
__metadata("design:type", payment_1.Payment)
|
|
78
|
+
], Refund.prototype, "payment", void 0);
|
|
59
79
|
__decorate([
|
|
60
80
|
(0, typeorm_1.Column)({ type: "int" }),
|
|
61
81
|
__metadata("design:type", Number)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refund.js","sourceRoot":"","sources":["../../src/models/refund.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"refund.js","sourceRoot":"","sources":["../../src/models/refund.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAQgB;AAEhB,gEAA6D;AAC7D,4DAAwD;AACxD,iCAA+B;AAC/B,kEAA8D;AAC9D,qCAAmC;AACnC,4EAAwE;AACxE,yFAA4E;AAE5E,IAAY,YAMX;AAND,WAAY,YAAY;IACtB,qCAAqB,CAAA;IACrB,iCAAiB,CAAA;IACjB,6BAAa,CAAA;IACb,+BAAe,CAAA;IACf,+BAAe,CAAA;AACjB,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,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;4CAChB;IAGjC;QADC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mDACJ;IAGvB;QADC,IAAA,sBAAY,GAAE;;;;8CAGd;IAvCU,MAAM;QADlB,IAAA,gBAAM,GAAE;OACI,MAAM,CAwClB;IAAD,aAAC;CAAA,AAxCD,CAA4B,wBAAU,GAwCrC;AAxCY,wBAAM;AA0CnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { PaymentCollection } from "./../models/payment-collection";
|
|
2
2
|
import { Repository } from "typeorm";
|
|
3
|
+
import { FindConfig } from "../types/common";
|
|
3
4
|
export declare class PaymentCollectionRepository extends Repository<PaymentCollection> {
|
|
5
|
+
getPaymentCollectionIdBySessionId(sessionId: string, config?: FindConfig<PaymentCollection>): Promise<PaymentCollection>;
|
|
6
|
+
getPaymentCollectionIdByPaymentId(paymentId: string, config?: FindConfig<PaymentCollection>): Promise<PaymentCollection>;
|
|
7
|
+
deleteMultiple(ids: string[]): Promise<void>;
|
|
4
8
|
}
|
|
@@ -20,16 +20,124 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
20
20
|
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;
|
|
21
21
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
22
|
};
|
|
23
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
24
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
27
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
28
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
33
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
34
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
35
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
36
|
+
function step(op) {
|
|
37
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
38
|
+
while (_) try {
|
|
39
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
40
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
41
|
+
switch (op[0]) {
|
|
42
|
+
case 0: case 1: t = op; break;
|
|
43
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
44
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
45
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
46
|
+
default:
|
|
47
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
48
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
49
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
50
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
51
|
+
if (t[2]) _.ops.pop();
|
|
52
|
+
_.trys.pop(); continue;
|
|
53
|
+
}
|
|
54
|
+
op = body.call(thisArg, _);
|
|
55
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
56
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
57
|
+
}
|
|
58
|
+
};
|
|
23
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
60
|
exports.PaymentCollectionRepository = void 0;
|
|
61
|
+
var medusa_core_utils_1 = require("medusa-core-utils");
|
|
25
62
|
var payment_collection_1 = require("./../models/payment-collection");
|
|
26
63
|
var typeorm_1 = require("typeorm");
|
|
64
|
+
var models_1 = require("../models");
|
|
27
65
|
var PaymentCollectionRepository = /** @class */ (function (_super) {
|
|
28
66
|
__extends(PaymentCollectionRepository, _super);
|
|
29
67
|
// eslint-disable-next-line max-len
|
|
30
68
|
function PaymentCollectionRepository() {
|
|
31
69
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
32
70
|
}
|
|
71
|
+
PaymentCollectionRepository.prototype.getPaymentCollectionIdBySessionId = function (sessionId, config) {
|
|
72
|
+
if (config === void 0) { config = {}; }
|
|
73
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
+
var paymentCollection;
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
switch (_a.label) {
|
|
77
|
+
case 0: return [4 /*yield*/, this.find({
|
|
78
|
+
join: {
|
|
79
|
+
alias: "payment_col",
|
|
80
|
+
innerJoin: { payment_sessions: "payment_col.payment_sessions" },
|
|
81
|
+
},
|
|
82
|
+
where: function (qb) {
|
|
83
|
+
qb.where("payment_col_payment_sessions.payment_session_id = :sessionId", { sessionId: sessionId });
|
|
84
|
+
},
|
|
85
|
+
relations: config.relations,
|
|
86
|
+
select: config.select,
|
|
87
|
+
})];
|
|
88
|
+
case 1:
|
|
89
|
+
paymentCollection = _a.sent();
|
|
90
|
+
if (!paymentCollection.length) {
|
|
91
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Payment collection related to Payment Session id ".concat(sessionId, " was not found"));
|
|
92
|
+
}
|
|
93
|
+
return [2 /*return*/, paymentCollection[0]];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
PaymentCollectionRepository.prototype.getPaymentCollectionIdByPaymentId = function (paymentId, config) {
|
|
99
|
+
if (config === void 0) { config = {}; }
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
var paymentCollection;
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
switch (_a.label) {
|
|
104
|
+
case 0: return [4 /*yield*/, this.find({
|
|
105
|
+
join: {
|
|
106
|
+
alias: "payment_col",
|
|
107
|
+
innerJoin: { payments: "payment_col.payments" },
|
|
108
|
+
},
|
|
109
|
+
where: function (qb) {
|
|
110
|
+
qb.where("payment_col_payments.payment_id = :paymentId", { paymentId: paymentId });
|
|
111
|
+
},
|
|
112
|
+
relations: config.relations,
|
|
113
|
+
select: config.select,
|
|
114
|
+
})];
|
|
115
|
+
case 1:
|
|
116
|
+
paymentCollection = _a.sent();
|
|
117
|
+
if (!paymentCollection.length) {
|
|
118
|
+
throw new medusa_core_utils_1.MedusaError(medusa_core_utils_1.MedusaError.Types.NOT_FOUND, "Payment collection related to Payment id ".concat(paymentId, " was not found"));
|
|
119
|
+
}
|
|
120
|
+
return [2 /*return*/, paymentCollection[0]];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
PaymentCollectionRepository.prototype.deleteMultiple = function (ids) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
127
|
+
return __generator(this, function (_a) {
|
|
128
|
+
switch (_a.label) {
|
|
129
|
+
case 0: return [4 /*yield*/, this.createQueryBuilder()
|
|
130
|
+
.delete()
|
|
131
|
+
.from(models_1.PaymentSession)
|
|
132
|
+
.where("id IN (:...ids)", { ids: ids })
|
|
133
|
+
.execute()];
|
|
134
|
+
case 1:
|
|
135
|
+
_a.sent();
|
|
136
|
+
return [2 /*return*/];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
};
|
|
33
141
|
PaymentCollectionRepository = __decorate([
|
|
34
142
|
(0, typeorm_1.EntityRepository)(payment_collection_1.PaymentCollection)
|
|
35
143
|
// eslint-disable-next-line max-len
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payment-collection.js","sourceRoot":"","sources":["../../src/repositories/payment-collection.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"payment-collection.js","sourceRoot":"","sources":["../../src/repositories/payment-collection.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAC/C,qEAAkE;AAClE,mCAAsD;AAEtD,oCAA0C;AAI1C;IAAiD,+CAA6B;IAD9E,mCAAmC;IACnC;;IA+DA,CAAC;IA9DO,uEAAiC,GAAvC,UACE,SAAiB,EACjB,MAA0C;QAA1C,uBAAA,EAAA,WAA0C;;;;;4BAEhB,qBAAM,IAAI,CAAC,IAAI,CAAC;4BACxC,IAAI,EAAE;gCACJ,KAAK,EAAE,aAAa;gCACpB,SAAS,EAAE,EAAE,gBAAgB,EAAE,8BAA8B,EAAE;6BAChE;4BACD,KAAK,EAAE,UAAC,EAAE;gCACR,EAAE,CAAC,KAAK,CACN,8DAA8D,EAC9D,EAAE,SAAS,WAAA,EAAE,CACd,CAAA;4BACH,CAAC;4BACD,SAAS,EAAE,MAAM,CAAC,SAAS;4BAC3B,MAAM,EAAE,MAAM,CAAC,MAAM;yBACtB,CAAC,EAAA;;wBAbI,iBAAiB,GAAG,SAaxB;wBAEF,IAAI,CAAC,iBAAiB,CAAC,MAAM,EAAE;4BAC7B,MAAM,IAAI,+BAAW,CACnB,+BAAW,CAAC,KAAK,CAAC,SAAS,EAC3B,2DAAoD,SAAS,mBAAgB,CAC9E,CA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indConfig } from "../types/common";
|
|
8
8
|
import { DraftOrderCreateProps } from "../types/draft-orders";
|
|
9
9
|
import CartService from "./cart";
|
|
10
|
+
import CustomShippingOptionService from "./custom-shipping-option";
|
|
10
11
|
import EventBusService from "./event-bus";
|
|
11
12
|
import LineItemService from "./line-item";
|
|
12
13
|
import ProductVariantService from "./product-variant";
|
|
@@ -21,6 +22,7 @@ declare type InjectedDependencies = {
|
|
|
21
22
|
lineItemService: LineItemService;
|
|
22
23
|
productVariantService: ProductVariantService;
|
|
23
24
|
shippingOptionService: ShippingOptionService;
|
|
25
|
+
customShippingOptionService: CustomShippingOptionService;
|
|
24
26
|
};
|
|
25
27
|
/**
|
|
26
28
|
* Handles draft orders
|
|
@@ -41,7 +43,8 @@ declare class DraftOrderService extends TransactionBaseService {
|
|
|
41
43
|
protected readonly lineItemService_: LineItemService;
|
|
42
44
|
protected readonly productVariantService_: ProductVariantService;
|
|
43
45
|
protected readonly shippingOptionService_: ShippingOptionService;
|
|
44
|
-
|
|
46
|
+
protected readonly customShippingOptionService_: CustomShippingOptionService;
|
|
47
|
+
constructor({ manager, draftOrderRepository, paymentRepository, orderRepository, eventBusService, cartService, lineItemService, productVariantService, shippingOptionService, customShippingOptionService, }: InjectedDependencies);
|
|
45
48
|
/**
|
|
46
49
|
* Retrieves a draft order with the given id.
|
|
47
50
|
* @param id - id of the draft order to retrieve
|
|
@@ -96,7 +96,7 @@ var utils_1 = require("../utils");
|
|
|
96
96
|
var DraftOrderService = /** @class */ (function (_super) {
|
|
97
97
|
__extends(DraftOrderService, _super);
|
|
98
98
|
function DraftOrderService(_a) {
|
|
99
|
-
var manager = _a.manager, draftOrderRepository = _a.draftOrderRepository, paymentRepository = _a.paymentRepository, orderRepository = _a.orderRepository, eventBusService = _a.eventBusService, cartService = _a.cartService, lineItemService = _a.lineItemService, productVariantService = _a.productVariantService, shippingOptionService = _a.shippingOptionService;
|
|
99
|
+
var manager = _a.manager, draftOrderRepository = _a.draftOrderRepository, paymentRepository = _a.paymentRepository, orderRepository = _a.orderRepository, eventBusService = _a.eventBusService, cartService = _a.cartService, lineItemService = _a.lineItemService, productVariantService = _a.productVariantService, shippingOptionService = _a.shippingOptionService, customShippingOptionService = _a.customShippingOptionService;
|
|
100
100
|
var _this =
|
|
101
101
|
// eslint-disable-next-line prefer-rest-params
|
|
102
102
|
_super.call(this, arguments[0]) || this;
|
|
@@ -108,6 +108,7 @@ var DraftOrderService = /** @class */ (function (_super) {
|
|
|
108
108
|
_this.cartService_ = cartService;
|
|
109
109
|
_this.productVariantService_ = productVariantService;
|
|
110
110
|
_this.shippingOptionService_ = shippingOptionService;
|
|
111
|
+
_this.customShippingOptionService_ = customShippingOptionService;
|
|
111
112
|
_this.eventBus_ = eventBusService;
|
|
112
113
|
return _this;
|
|
113
114
|
}
|
|
@@ -400,31 +401,42 @@ var DraftOrderService = /** @class */ (function (_super) {
|
|
|
400
401
|
finally { if (e_2) throw e_2.error; }
|
|
401
402
|
return [7 /*endfinally*/];
|
|
402
403
|
case 22:
|
|
403
|
-
_d.trys.push([22,
|
|
404
|
+
_d.trys.push([22, 29, 30, 31]);
|
|
404
405
|
shipping_methods_1 = __values(shipping_methods), shipping_methods_1_1 = shipping_methods_1.next();
|
|
405
406
|
_d.label = 23;
|
|
406
407
|
case 23:
|
|
407
|
-
if (!!shipping_methods_1_1.done) return [3 /*break*/,
|
|
408
|
+
if (!!shipping_methods_1_1.done) return [3 /*break*/, 28];
|
|
408
409
|
method = shipping_methods_1_1.value;
|
|
409
|
-
return [
|
|
410
|
+
if (!(typeof method.price !== "undefined")) return [3 /*break*/, 25];
|
|
411
|
+
return [4 /*yield*/, this.customShippingOptionService_
|
|
412
|
+
.withTransaction(transactionManager)
|
|
413
|
+
.create({
|
|
414
|
+
shipping_option_id: method.option_id,
|
|
415
|
+
cart_id: createdCart.id,
|
|
416
|
+
price: method.price,
|
|
417
|
+
})];
|
|
410
418
|
case 24:
|
|
411
419
|
_d.sent();
|
|
412
420
|
_d.label = 25;
|
|
413
|
-
case 25:
|
|
421
|
+
case 25: return [4 /*yield*/, cartServiceTx.addShippingMethod(createdCart.id, method.option_id, method.data)];
|
|
422
|
+
case 26:
|
|
423
|
+
_d.sent();
|
|
424
|
+
_d.label = 27;
|
|
425
|
+
case 27:
|
|
414
426
|
shipping_methods_1_1 = shipping_methods_1.next();
|
|
415
427
|
return [3 /*break*/, 23];
|
|
416
|
-
case
|
|
417
|
-
case
|
|
428
|
+
case 28: return [3 /*break*/, 31];
|
|
429
|
+
case 29:
|
|
418
430
|
e_3_1 = _d.sent();
|
|
419
431
|
e_3 = { error: e_3_1 };
|
|
420
|
-
return [3 /*break*/,
|
|
421
|
-
case
|
|
432
|
+
return [3 /*break*/, 31];
|
|
433
|
+
case 30:
|
|
422
434
|
try {
|
|
423
435
|
if (shipping_methods_1_1 && !shipping_methods_1_1.done && (_c = shipping_methods_1.return)) _c.call(shipping_methods_1);
|
|
424
436
|
}
|
|
425
437
|
finally { if (e_3) throw e_3.error; }
|
|
426
438
|
return [7 /*endfinally*/];
|
|
427
|
-
case
|
|
439
|
+
case 31: return [2 /*return*/, result];
|
|
428
440
|
}
|
|
429
441
|
});
|
|
430
442
|
}); })];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draft-order.js","sourceRoot":"","sources":["../../src/services/draft-order.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAC/C,mCAAgF;AAChF,4CAAsD;AACtD,oCAAwE;AAMxE,kCAAqC;
|
|
1
|
+
{"version":3,"file":"draft-order.js","sourceRoot":"","sources":["../../src/services/draft-order.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA+C;AAC/C,mCAAgF;A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Ac,CAAC,IAAI,CAAC,UAAU,CAAC,EAAA;;wCAArC,SAAqC,CAAA;wCAErC,qBAAM,IAAI,CAAC,SAAS;iDACjB,eAAe,CAAC,kBAAkB,CAAC;iDACnC,IAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,OAAO,EAAE;gDACtC,EAAE,EAAE,UAAU,CAAC,EAAE;6CAClB,CAAC,EAAA;;wCAJJ,SAII,CAAA;;4CAGN,sBAAO,UAAU,EAAA;;;6BAClB,CACF,EAAA;4BAhCD,sBAAO,SAgCN,EAAA;;;;KACF;IAzYe,wBAAM,GAAG;QACvB,OAAO,EAAE,qBAAqB;QAC9B,OAAO,EAAE,qBAAqB;KAC/B,CAAA;IAuYH,wBAAC;CAAA,AA3YD,CAAgC,mCAAsB,GA2YrD;AAED,kBAAe,iBAAiB,CAAA"}
|
|
@@ -1,29 +1,48 @@
|
|
|
1
1
|
import { DeepPartial, EntityManager } from "typeorm";
|
|
2
2
|
import { FindConfig } from "../types/common";
|
|
3
3
|
import { PaymentCollectionRepository } from "../repositories/payment-collection";
|
|
4
|
-
import { PaymentCollection } from "../models";
|
|
4
|
+
import { Payment, PaymentCollection, PaymentSession, Refund } from "../models";
|
|
5
5
|
import { TransactionBaseService } from "../interfaces";
|
|
6
|
-
import { EventBusService } from "./index";
|
|
7
|
-
import { CreatePaymentCollectionInput } from "../types/payment-collection";
|
|
6
|
+
import { CustomerService, EventBusService, PaymentProviderService } from "./index";
|
|
7
|
+
import { CreatePaymentCollectionInput, PaymentCollectionSessionInput } from "../types/payment-collection";
|
|
8
8
|
declare type InjectedDependencies = {
|
|
9
9
|
manager: EntityManager;
|
|
10
10
|
paymentCollectionRepository: typeof PaymentCollectionRepository;
|
|
11
|
+
paymentProviderService: PaymentProviderService;
|
|
11
12
|
eventBusService: EventBusService;
|
|
13
|
+
customerService: CustomerService;
|
|
12
14
|
};
|
|
13
15
|
export default class PaymentCollectionService extends TransactionBaseService {
|
|
14
16
|
static readonly Events: {
|
|
15
17
|
CREATED: string;
|
|
16
18
|
UPDATED: string;
|
|
17
19
|
DELETED: string;
|
|
20
|
+
PAYMENT_AUTHORIZED: string;
|
|
21
|
+
PAYMENT_CAPTURED: string;
|
|
22
|
+
PAYMENT_CAPTURE_FAILED: string;
|
|
23
|
+
REFUND_CREATED: string;
|
|
24
|
+
REFUND_FAILED: string;
|
|
18
25
|
};
|
|
19
26
|
protected readonly manager_: EntityManager;
|
|
20
27
|
protected transactionManager_: EntityManager | undefined;
|
|
21
28
|
protected readonly eventBusService_: EventBusService;
|
|
29
|
+
protected readonly paymentProviderService_: PaymentProviderService;
|
|
30
|
+
protected readonly customerService_: CustomerService;
|
|
22
31
|
protected readonly paymentCollectionRepository_: typeof PaymentCollectionRepository;
|
|
23
|
-
constructor({ manager, paymentCollectionRepository, eventBusService, }: InjectedDependencies);
|
|
32
|
+
constructor({ manager, paymentCollectionRepository, paymentProviderService, customerService, eventBusService, }: InjectedDependencies);
|
|
24
33
|
retrieve(paymentCollectionId: string, config?: FindConfig<PaymentCollection>): Promise<PaymentCollection>;
|
|
25
34
|
create(data: CreatePaymentCollectionInput): Promise<PaymentCollection>;
|
|
26
35
|
update(paymentCollectionId: string, data: DeepPartial<PaymentCollection>): Promise<PaymentCollection>;
|
|
27
36
|
delete(paymentCollectionId: string): Promise<PaymentCollection | undefined>;
|
|
37
|
+
private isValidTotalAmount;
|
|
38
|
+
setPaymentSessions(paymentCollectionId: string, sessions: PaymentCollectionSessionInput[] | PaymentCollectionSessionInput): Promise<PaymentCollection>;
|
|
39
|
+
refreshPaymentSession(paymentCollectionId: string, sessionId: string, sessionInput: PaymentCollectionSessionInput): Promise<PaymentSession>;
|
|
40
|
+
authorize(paymentCollectionId: string, context?: Record<string, unknown>): Promise<PaymentCollection>;
|
|
41
|
+
private capturePayment;
|
|
42
|
+
capture(paymentId: string): Promise<Payment>;
|
|
43
|
+
captureAll(paymentCollectionId: string): Promise<Payment[]>;
|
|
44
|
+
private refundPayment;
|
|
45
|
+
refund(paymentId: string, amount: number, reason: string, note?: string): Promise<Refund>;
|
|
46
|
+
refundAll(paymentCollectionId: string, reason: string, note?: string): Promise<Refund[]>;
|
|
28
47
|
}
|
|
29
48
|
export {};
|