@chevre/domain
Version:
Chevre Domain Library for Node.js
52 lines (51 loc) • 2.77 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.fixInformAction = fixInformAction;
const factory = require("../../factory");
function fixInformAction(params) {
return (repos) => __awaiter(this, void 0, void 0, function* () {
var _a, _b;
let informPaymentParams = [];
// プロダクト設定を適用 // discontinue(2025-02-06~)
// const informPaymentParamsByProduct = params.paymentService?.availableChannel?.onPaymentStatusChanged?.informPayment;
// if (Array.isArray(informPaymentParamsByProduct)) {
// informPaymentParams.push(...informPaymentParamsByProduct.map(({ recipient }) => {
// return {
// recipient,
// id: ''
// };
// }));
// }
// support potentialAction(2025-02-05~)
const potentialActionByProduct = (_a = params.paymentService) === null || _a === void 0 ? void 0 : _a.potentialAction;
if (Array.isArray(potentialActionByProduct)) {
const potentialInformActionId = (_b = potentialActionByProduct.filter(({ typeOf }) => typeOf === factory.actionType.InformAction)
.at(0)) === null || _b === void 0 ? void 0 : _b.id;
if (typeof potentialInformActionId === 'string') {
const potentialInformAction = (yield repos.potentialAction.projectFields({
limit: 1,
page: 1,
project: { id: { $in: [params.project.id, '*'] } },
id: { $eq: potentialInformActionId }
}, ['target'])).shift();
if (potentialInformAction === undefined) {
throw new factory.errors.NotFound(factory.actionType.InformAction);
}
informPaymentParams = [{
// recipient: { url: potentialInformAction.target.urlTemplate },
id: potentialInformActionId
}];
}
}
return informPaymentParams;
});
}
;