@chevre/domain
Version:
Chevre Domain Library for Node.js
84 lines (83 loc) • 3.32 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.payFaceToFace = payFaceToFace;
exports.refundFaceToFace = refundFaceToFace;
exports.voidTransaction = voidTransaction;
/**
* 対面決済サービス
*/
const factory = require("../../factory");
const onPayActionCompleted_1 = require("./any/onPayActionCompleted");
const onRefundActionCompletedOrFailed_1 = require("./any/onRefundActionCompletedOrFailed");
function voidTransaction(__) {
return (___) => __awaiter(this, void 0, void 0, function* () {
// no op
});
}
function payFaceToFace(params) {
return (repos) => __awaiter(this, void 0, void 0, function* () {
const action = yield repos.action.start(params);
try {
// no op
}
catch (error) {
try {
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
}
catch (__) {
// 失敗したら仕方ない
}
throw error;
}
const actionResult = {};
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
yield (0, onPayActionCompleted_1.onPayActionCompleted)({
// actionStatus: factory.actionStatusType.CompletedActionStatus,
id: action.id,
object: params.object,
potentialActions: params.potentialActions,
project: params.project,
purpose: params.purpose,
typeOf: action.typeOf
})(repos);
// return action;
});
}
function refundFaceToFace(params) {
return (repos) => __awaiter(this, void 0, void 0, function* () {
const action = yield repos.action.start(params);
try {
// no op
}
catch (error) {
try {
yield repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
}
catch (__) {
// no op
}
throw error;
}
const actionResult = {};
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
yield (0, onRefundActionCompletedOrFailed_1.onRefundActionCompletedOrFailed)({
actionStatus: factory.actionStatusType.CompletedActionStatus,
id: action.id,
object: params.object,
potentialActions: params.potentialActions,
project: params.project,
purpose: params.purpose,
typeOf: action.typeOf
})(repos);
// return action;
});
}
;