75 lines
3.4 KiB
JavaScript
75 lines
3.4 KiB
JavaScript
"use strict";
|
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
};
|
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.BillingController = void 0;
|
|
const common_1 = require("@nestjs/common");
|
|
const mock_data_service_1 = require("../services/mock-data.service");
|
|
let BillingController = class BillingController {
|
|
constructor(mockData) {
|
|
this.mockData = mockData;
|
|
}
|
|
chargeUser(ise2, mco, body) {
|
|
console.log('[MOCK] Charge request:', { ise2, mco, body });
|
|
const { amountTransaction } = body;
|
|
if (!amountTransaction) {
|
|
throw new common_1.HttpException({
|
|
requestError: {
|
|
serviceException: {
|
|
messageId: 'SVC0002',
|
|
text: 'Invalid input value for message part amountTransaction'
|
|
}
|
|
}
|
|
}, common_1.HttpStatus.BAD_REQUEST);
|
|
}
|
|
const amount = parseFloat(amountTransaction.paymentAmount.chargingInformation.amount);
|
|
const result = this.mockData.createTransaction({
|
|
endUserId: ise2,
|
|
amount,
|
|
...amountTransaction,
|
|
});
|
|
if (!result.success) {
|
|
throw new common_1.HttpException({
|
|
requestError: {
|
|
policyException: {
|
|
messageId: result.error.code,
|
|
text: result.error.message
|
|
}
|
|
}
|
|
}, common_1.HttpStatus.FORBIDDEN);
|
|
}
|
|
return {
|
|
amountTransaction: {
|
|
...amountTransaction,
|
|
serverReferenceCode: result.transaction.serverReferenceCode,
|
|
transactionOperationStatus: 'Charged',
|
|
resourceURL: `http://localhost:3001/payment/mea/v1/transactions/${result.transaction.serverReferenceCode}`
|
|
}
|
|
};
|
|
}
|
|
};
|
|
exports.BillingController = BillingController;
|
|
__decorate([
|
|
(0, common_1.Post)('acr:X-Orange-ISE2/transactions/amount'),
|
|
__param(0, (0, common_1.Headers)('x-orange-ise2')),
|
|
__param(1, (0, common_1.Headers)('x-orange-mco')),
|
|
__param(2, (0, common_1.Body)()),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [String, String, Object]),
|
|
__metadata("design:returntype", void 0)
|
|
], BillingController.prototype, "chargeUser", null);
|
|
exports.BillingController = BillingController = __decorate([
|
|
(0, common_1.Controller)('payment/mea/v1'),
|
|
__metadata("design:paramtypes", [mock_data_service_1.MockDataService])
|
|
], BillingController);
|
|
//# sourceMappingURL=billing.controller.js.map
|