@chevre/domain 21.34.0-alpha.13 → 21.34.0-alpha.15
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/example/src/chevre/migratePayTransactionRecipes.ts +251 -0
- package/lib/chevre/repo/action.d.ts +1 -0
- package/lib/chevre/repo/action.js +36 -0
- package/lib/chevre/service/assetTransaction/pay.js +3 -2
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.d.ts +3 -0
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard.js +17 -23
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.d.ts +3 -0
- package/lib/chevre/service/payment/creditCard/authorize/processAuthorizeCreditCard3ds.js +14 -20
- package/lib/chevre/service/payment/creditCard/authorize.d.ts +11 -1
- package/lib/chevre/service/payment/creditCard/authorize.js +14 -8
- package/lib/chevre/service/payment/creditCard/voidTransaction.d.ts +2 -0
- package/lib/chevre/service/payment/creditCard/voidTransaction.js +17 -0
- package/package.json +3 -3
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as moment from 'moment';
|
|
3
|
+
import * as mongoose from 'mongoose';
|
|
4
|
+
|
|
5
|
+
import { chevre } from '../../../lib/index';
|
|
6
|
+
|
|
7
|
+
// tslint:disable-next-line:max-func-body-length
|
|
8
|
+
async function main() {
|
|
9
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
10
|
+
|
|
11
|
+
const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
|
|
12
|
+
const assetTransactionRepo = await chevre.repository.AssetTransaction.createInstance(mongoose.connection);
|
|
13
|
+
const cursor = assetTransactionRepo.getCursor(
|
|
14
|
+
{
|
|
15
|
+
// transactionNumber: { $eq: '792921546706869' },
|
|
16
|
+
typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
|
|
17
|
+
status: { $eq: chevre.factory.transactionStatusType.Confirmed },
|
|
18
|
+
startDate: {
|
|
19
|
+
// $lte: moment()
|
|
20
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
21
|
+
// .add(-28, 'days'),
|
|
22
|
+
$gte: moment()
|
|
23
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
24
|
+
.add(-180, 'days')
|
|
25
|
+
},
|
|
26
|
+
'object.typeOf': { $exists: true, $eq: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
__id: 1, startDate: 1, object: 1, project: 1, typeOf: 1, status: 1, transactionNumber: 1
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
console.log('transactions found');
|
|
33
|
+
|
|
34
|
+
let i = 0;
|
|
35
|
+
let updateCount = 0;
|
|
36
|
+
let saveRecipeCount = 0;
|
|
37
|
+
let saveActionCount = 0;
|
|
38
|
+
// tslint:disable-next-line:max-func-body-length
|
|
39
|
+
await cursor.eachAsync(async (doc) => {
|
|
40
|
+
i += 1;
|
|
41
|
+
const payTransaction = <Pick<
|
|
42
|
+
chevre.factory.assetTransaction.pay.ITransaction,
|
|
43
|
+
'id' | 'startDate' | 'object' | 'project' | 'typeOf' | 'status' | 'transactionNumber'
|
|
44
|
+
>>doc.toObject();
|
|
45
|
+
let authorizeInvoiceAction: chevre.factory.action.authorize.invoice.IAction | undefined;
|
|
46
|
+
authorizeInvoiceAction = (<chevre.factory.action.authorize.invoice.IAction[]>await actionRepo.search(
|
|
47
|
+
{
|
|
48
|
+
limit: 1,
|
|
49
|
+
page: 1,
|
|
50
|
+
project: { id: { $eq: payTransaction.project.id } },
|
|
51
|
+
agent: {
|
|
52
|
+
id: { $in: [payTransaction.project.id] },
|
|
53
|
+
typeOf: { $in: [chevre.factory.organizationType.Project] }
|
|
54
|
+
},
|
|
55
|
+
object: {
|
|
56
|
+
typeOf: { $eq: 'Invoice' },
|
|
57
|
+
paymentMethodId: { $eq: payTransaction.transactionNumber }
|
|
58
|
+
},
|
|
59
|
+
typeOf: { $eq: chevre.factory.actionType.AuthorizeAction }
|
|
60
|
+
},
|
|
61
|
+
[],
|
|
62
|
+
[]
|
|
63
|
+
)).shift();
|
|
64
|
+
// authorizeInvoiceAction = undefined;
|
|
65
|
+
|
|
66
|
+
const entryTranArgs: chevre.factory.action.authorize.invoice.IEntryTranArgs = (<any>payTransaction.object).entryTranArgs;
|
|
67
|
+
const entryTranResult: chevre.factory.action.authorize.invoice.IEntryTranResult = (<any>payTransaction.object).entryTranResult;
|
|
68
|
+
const execTranArgs: chevre.factory.action.authorize.invoice.IExecTranArgs = (<any>payTransaction.object).execTranArgs;
|
|
69
|
+
const execTranResult: chevre.factory.action.authorize.invoice.IExecTranResult = (<any>payTransaction.object).execTranResult;
|
|
70
|
+
const secureTran2Result: chevre.factory.action.authorize.invoice.ISecureTran2Result =
|
|
71
|
+
(<any>payTransaction.object).secureTran2Result;
|
|
72
|
+
|
|
73
|
+
if (authorizeInvoiceAction !== undefined) {
|
|
74
|
+
console.log(
|
|
75
|
+
'authorizeInvoiceAction already exists. step:',
|
|
76
|
+
authorizeInvoiceAction.object.paymentMethodId,
|
|
77
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const actionRecipe = await actionRepo.findRecipeByAction<chevre.factory.recipe.RecipeCategory.checkMovieTicket>({
|
|
81
|
+
project: { id: authorizeInvoiceAction.project.id },
|
|
82
|
+
recipeFor: { id: authorizeInvoiceAction.id }
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
if (actionRecipe !== null) {
|
|
86
|
+
console.log(
|
|
87
|
+
'actionRecipe already exists. step:',
|
|
88
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
// optimize payTransaction.object
|
|
92
|
+
let unsetResult: any;
|
|
93
|
+
if (secureTran2Result !== undefined) {
|
|
94
|
+
unsetResult = await assetTransactionRepo.unsetUnnecessaryFields({
|
|
95
|
+
filter: { _id: { $eq: payTransaction.id } },
|
|
96
|
+
$unset: {
|
|
97
|
+
'object.secureTran2Result': 1
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
updateCount += 1;
|
|
101
|
+
} else if (entryTranArgs !== undefined && execTranResult !== undefined) {
|
|
102
|
+
if (typeof (<any>execTranResult).redirectUrl !== 'string') {
|
|
103
|
+
unsetResult = await assetTransactionRepo.unsetUnnecessaryFields({
|
|
104
|
+
filter: { _id: { $eq: payTransaction.id } },
|
|
105
|
+
$unset: {
|
|
106
|
+
'object.entryTranArgs': 1,
|
|
107
|
+
'object.entryTranResult': 1,
|
|
108
|
+
'object.execTranArgs': 1,
|
|
109
|
+
'object.execTranResult': 1
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
updateCount += 1;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
console.log(
|
|
116
|
+
'result unset. unsetResult:', unsetResult,
|
|
117
|
+
actionRecipe.step.length,
|
|
118
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i
|
|
119
|
+
);
|
|
120
|
+
} else {
|
|
121
|
+
console.log(
|
|
122
|
+
'creating recipe...',
|
|
123
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i
|
|
124
|
+
);
|
|
125
|
+
if (entryTranArgs === undefined) {
|
|
126
|
+
throw new Error('entryTranArgs undefined');
|
|
127
|
+
}
|
|
128
|
+
if (entryTranResult === undefined) {
|
|
129
|
+
throw new Error('entryTranResult undefined');
|
|
130
|
+
}
|
|
131
|
+
if (execTranArgs === undefined) {
|
|
132
|
+
throw new Error('execTranArgs undefined');
|
|
133
|
+
}
|
|
134
|
+
if (execTranResult === undefined) {
|
|
135
|
+
throw new Error('execTranResult undefined');
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
let recipe: (chevre.factory.action.authorize.invoice.IAuthorizeInvoiceRecipe
|
|
139
|
+
| chevre.factory.action.authorize.invoice.IAuthorizeInvoice3dsRecipe) & {
|
|
140
|
+
recipeFor: { id: string; typeOf: chevre.factory.actionType };
|
|
141
|
+
dateCreated: Date;
|
|
142
|
+
dateModified: Date;
|
|
143
|
+
};
|
|
144
|
+
if (secureTran2Result !== undefined) {
|
|
145
|
+
recipe = {
|
|
146
|
+
project: { id: payTransaction.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
147
|
+
typeOf: 'Recipe',
|
|
148
|
+
recipeCategory: chevre.factory.recipe.RecipeCategory.authorizeInvoice3ds,
|
|
149
|
+
recipeFor: { id: authorizeInvoiceAction.id, typeOf: authorizeInvoiceAction.typeOf },
|
|
150
|
+
step: [{
|
|
151
|
+
typeOf: 'HowToSection',
|
|
152
|
+
itemListElement: [
|
|
153
|
+
{
|
|
154
|
+
typeOf: 'HowToStep',
|
|
155
|
+
identifier: chevre.factory.recipe.StepIdentifier.secureTran2,
|
|
156
|
+
itemListElement: [{
|
|
157
|
+
typeOf: 'HowToDirection',
|
|
158
|
+
afterMedia: secureTran2Result
|
|
159
|
+
}]
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
}],
|
|
163
|
+
dateCreated: moment(authorizeInvoiceAction.endDate)
|
|
164
|
+
.toDate(),
|
|
165
|
+
dateModified: moment(authorizeInvoiceAction.endDate)
|
|
166
|
+
.toDate()
|
|
167
|
+
};
|
|
168
|
+
} else {
|
|
169
|
+
recipe = {
|
|
170
|
+
project: { id: payTransaction.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
171
|
+
typeOf: 'Recipe',
|
|
172
|
+
recipeCategory: chevre.factory.recipe.RecipeCategory.authorizeInvoice,
|
|
173
|
+
recipeFor: { id: authorizeInvoiceAction.id, typeOf: authorizeInvoiceAction.typeOf },
|
|
174
|
+
step: [{
|
|
175
|
+
typeOf: 'HowToSection',
|
|
176
|
+
itemListElement: [
|
|
177
|
+
{
|
|
178
|
+
typeOf: 'HowToStep',
|
|
179
|
+
identifier: chevre.factory.recipe.StepIdentifier.entryTran,
|
|
180
|
+
itemListElement: [{
|
|
181
|
+
typeOf: 'HowToDirection',
|
|
182
|
+
beforeMedia: entryTranArgs,
|
|
183
|
+
afterMedia: entryTranResult
|
|
184
|
+
}]
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
typeOf: 'HowToStep',
|
|
188
|
+
identifier: chevre.factory.recipe.StepIdentifier.execTran,
|
|
189
|
+
itemListElement: [{
|
|
190
|
+
typeOf: 'HowToDirection',
|
|
191
|
+
beforeMedia: execTranArgs,
|
|
192
|
+
afterMedia: execTranResult
|
|
193
|
+
}]
|
|
194
|
+
}
|
|
195
|
+
]
|
|
196
|
+
}],
|
|
197
|
+
dateCreated: moment(authorizeInvoiceAction.endDate)
|
|
198
|
+
.toDate(),
|
|
199
|
+
dateModified: moment(authorizeInvoiceAction.endDate)
|
|
200
|
+
.toDate()
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
console.log(
|
|
204
|
+
'saving recipe...',
|
|
205
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i);
|
|
206
|
+
// tslint:disable-next-line:no-null-keyword
|
|
207
|
+
console.dir(recipe, { depth: null });
|
|
208
|
+
await actionRepo.saveRecipeWithDateCreated(recipe);
|
|
209
|
+
saveRecipeCount += 1;
|
|
210
|
+
console.log('recipe saved.', payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i);
|
|
211
|
+
}
|
|
212
|
+
} else {
|
|
213
|
+
const creatingAction: Omit<chevre.factory.action.authorize.invoice.IAction, 'id'> = {
|
|
214
|
+
project: { id: payTransaction.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
215
|
+
typeOf: chevre.factory.actionType.AuthorizeAction,
|
|
216
|
+
agent: { id: payTransaction.project.id, typeOf: chevre.factory.organizationType.Project },
|
|
217
|
+
object: {
|
|
218
|
+
typeOf: 'Invoice',
|
|
219
|
+
paymentMethodId: payTransaction.transactionNumber
|
|
220
|
+
},
|
|
221
|
+
startDate: moment(payTransaction.startDate)
|
|
222
|
+
.toDate(),
|
|
223
|
+
endDate: moment(payTransaction.startDate)
|
|
224
|
+
.toDate(),
|
|
225
|
+
actionStatus: chevre.factory.actionStatusType.CompletedActionStatus,
|
|
226
|
+
result: {},
|
|
227
|
+
sameAs: { id: payTransaction.id, typeOf: payTransaction.typeOf }
|
|
228
|
+
};
|
|
229
|
+
console.log(
|
|
230
|
+
'creating action...',
|
|
231
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i
|
|
232
|
+
);
|
|
233
|
+
// tslint:disable-next-line:no-null-keyword
|
|
234
|
+
console.dir(creatingAction, { depth: null });
|
|
235
|
+
const saveActionResult = await actionRepo.saveActionWithEndDate(creatingAction);
|
|
236
|
+
saveActionCount += 1;
|
|
237
|
+
console.log(
|
|
238
|
+
'action saved.', saveActionResult,
|
|
239
|
+
payTransaction.project.id, payTransaction.transactionNumber, payTransaction.startDate, i);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
console.log(i, 'transactions checked');
|
|
244
|
+
console.log(updateCount, 'transactions updated');
|
|
245
|
+
console.log(saveRecipeCount, 'recipe saved');
|
|
246
|
+
console.log(saveActionCount, 'action saved');
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
main()
|
|
250
|
+
.then()
|
|
251
|
+
.catch(console.error);
|
|
@@ -303,6 +303,7 @@ export declare class MongoRepository {
|
|
|
303
303
|
saveRecipeWithDateCreated(savingRecipe: IRecipeAsDocument & {
|
|
304
304
|
dateModified: Date;
|
|
305
305
|
}): Promise<import("mongodb").UpdateResult>;
|
|
306
|
+
saveActionWithEndDate(savingAction: Omit<factory.action.authorize.invoice.IAction, 'id'>): Promise<import("mongodb").UpdateResult>;
|
|
306
307
|
findRecipeByAction<T extends factory.recipe.RecipeCategory>(params: {
|
|
307
308
|
project: {
|
|
308
309
|
id: string;
|
|
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
23
|
exports.MongoRepository = void 0;
|
|
13
24
|
const factory = require("../factory");
|
|
@@ -1115,6 +1126,31 @@ class MongoRepository {
|
|
|
1115
1126
|
.exec();
|
|
1116
1127
|
});
|
|
1117
1128
|
}
|
|
1129
|
+
saveActionWithEndDate(savingAction) {
|
|
1130
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1131
|
+
const { typeOf, project, agent, object } = savingAction, updateFields = __rest(savingAction, ["typeOf", "project", "agent", "object"]);
|
|
1132
|
+
const filter = {
|
|
1133
|
+
'project.id': { $eq: project.id },
|
|
1134
|
+
'agent.id': { $exists: true, $eq: agent.id },
|
|
1135
|
+
'object.typeOf': { $exists: true, $eq: object.typeOf },
|
|
1136
|
+
'object.paymentMethodId': { $exists: true, $eq: object.paymentMethodId },
|
|
1137
|
+
typeOf: { $eq: typeOf }
|
|
1138
|
+
// 'sameAs.id': { $exists: true, $eq: sameAs.id }
|
|
1139
|
+
};
|
|
1140
|
+
const setOnInsert = { typeOf, project, agent, object };
|
|
1141
|
+
const setKeys = updateFields;
|
|
1142
|
+
const update = {
|
|
1143
|
+
$setOnInsert: setOnInsert,
|
|
1144
|
+
$set: setKeys
|
|
1145
|
+
};
|
|
1146
|
+
const options = {
|
|
1147
|
+
upsert: true,
|
|
1148
|
+
rawResult: true
|
|
1149
|
+
};
|
|
1150
|
+
return this.actionModel.updateOne(filter, update, options)
|
|
1151
|
+
.exec();
|
|
1152
|
+
});
|
|
1153
|
+
}
|
|
1118
1154
|
findRecipeByAction(params) {
|
|
1119
1155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1120
1156
|
return this.actionRecipeModel.findOne({
|
|
@@ -88,7 +88,8 @@ function publishPaymentUrl(params, options) {
|
|
|
88
88
|
try {
|
|
89
89
|
switch (paymentServiceType) {
|
|
90
90
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
91
|
-
const authorizeResult = yield CreditCardPayment.authorize(
|
|
91
|
+
const authorizeResult = yield CreditCardPayment.authorize(Object.assign(Object.assign({}, params), { id: '' // 決済URL発行プロセスにおいては決済取引IDは使用しないので空文字でok
|
|
92
|
+
}), paymentServiceId, {
|
|
92
93
|
processPublishPaymentUrl: true,
|
|
93
94
|
executor: (typeof ((_d = options.executor) === null || _d === void 0 ? void 0 : _d.id) === 'string') ? { id: options.executor.id } : {} // タスク関連付け(2024-05-22~)
|
|
94
95
|
})(repos);
|
|
@@ -378,7 +379,7 @@ function processAuthorizeAccount(params, transaction, paymentServiceId) {
|
|
|
378
379
|
function processAuthorizeCreditCard(params, transaction, paymentServiceId, options) {
|
|
379
380
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
380
381
|
var _a;
|
|
381
|
-
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, Object.assign({ processPublishPaymentUrl: false, executor: (typeof ((_a = options.executor) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { id: options.executor.id } : {} }, (options.pendingPaymentAgencyTransaction !== undefined)
|
|
382
|
+
const authorizeResult = yield CreditCardPayment.authorize(Object.assign(Object.assign({}, params), { id: transaction.id }), paymentServiceId, Object.assign({ processPublishPaymentUrl: false, executor: (typeof ((_a = options.executor) === null || _a === void 0 ? void 0 : _a.id) === 'string') ? { id: options.executor.id } : {} }, (options.pendingPaymentAgencyTransaction !== undefined)
|
|
382
383
|
? { pendingPaymentAgencyTransaction: options.pendingPaymentAgencyTransaction }
|
|
383
384
|
: undefined))(repos);
|
|
384
385
|
return saveAuthorizeResult({
|
|
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.processAuthorizeCreditCard = void 0;
|
|
13
13
|
const GMO = require("@motionpicture/gmo-service");
|
|
14
14
|
const factory = require("../../../../factory");
|
|
15
|
-
const settings_1 = require("../../../../settings");
|
|
16
15
|
const processAuthorizeCreditCardResult2recipe_1 = require("./processAuthorizeCreditCardResult2recipe");
|
|
17
16
|
function processAuthorizeCreditCard(params) {
|
|
18
17
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
@@ -82,39 +81,34 @@ function processAuthorizeCreditCard(params) {
|
|
|
82
81
|
object: {
|
|
83
82
|
paymentMethodId: orderId,
|
|
84
83
|
typeOf: 'Invoice'
|
|
85
|
-
}
|
|
84
|
+
},
|
|
85
|
+
sameAs: { id: params.payTransaction.id, typeOf: factory.assetTransactionType.Pay }
|
|
86
86
|
};
|
|
87
87
|
// add action(2024-06-12~)
|
|
88
|
-
|
|
89
|
-
action = (yield repos.action.start(actionAttributes, { recipe }));
|
|
90
|
-
}
|
|
88
|
+
action = (yield repos.action.start(actionAttributes, { recipe }));
|
|
91
89
|
try {
|
|
92
90
|
entryTranResult = yield repos.creditCardService.entryTran(entryTranArgs);
|
|
93
91
|
execTranArgs = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ accessId: entryTranResult.accessId, accessPass: entryTranResult.accessPass, orderId, method: params.object.method, siteId: (_e = params.availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.siteId, sitePass: (_f = params.availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.sitePass, seqMode: GMO.utils.util.SeqMode.Physics }, (typeof cardNo === 'string') ? { cardNo } : undefined), (typeof cardPass === 'string') ? { cardPass } : undefined), (typeof expire === 'string') ? { expire } : undefined), (typeof token === 'string') ? { token } : undefined), (typeof memberId === 'string') ? { memberId } : undefined), (typeof cardSeq === 'number') ? { cardSeq } : undefined);
|
|
94
92
|
execTranResult = yield repos.creditCardService.execTran(execTranArgs);
|
|
95
93
|
}
|
|
96
94
|
catch (error) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
// 失敗したら仕方ない
|
|
103
|
-
}
|
|
95
|
+
try {
|
|
96
|
+
yield repos.action.giveUp({ typeOf: actionAttributes.typeOf, id: action.id, error });
|
|
97
|
+
}
|
|
98
|
+
catch (__) {
|
|
99
|
+
// 失敗したら仕方ない
|
|
104
100
|
}
|
|
105
101
|
throw error;
|
|
106
102
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
yield repos.action.completeWithVoid({ typeOf: actionAttributes.typeOf, id: action.id, result: actionResult, recipe });
|
|
117
|
-
}
|
|
103
|
+
recipe = (0, processAuthorizeCreditCardResult2recipe_1.processAuthorizeCreditCardResult2recipe)({
|
|
104
|
+
project: { id: params.project.id },
|
|
105
|
+
result: {
|
|
106
|
+
entryTranArgs, entryTranResult, execTranArgs,
|
|
107
|
+
execTranResult: execTranResult
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
const actionResult = {};
|
|
111
|
+
yield repos.action.completeWithVoid({ typeOf: actionAttributes.typeOf, id: action.id, result: actionResult, recipe });
|
|
118
112
|
}
|
|
119
113
|
return { entryTranArgs, entryTranResult, execTranArgs, execTranResult };
|
|
120
114
|
});
|
|
@@ -12,6 +12,9 @@ declare function processAuthorizeCreditCard3ds(params: {
|
|
|
12
12
|
project: {
|
|
13
13
|
id: string;
|
|
14
14
|
};
|
|
15
|
+
payTransaction: {
|
|
16
|
+
id: string;
|
|
17
|
+
};
|
|
15
18
|
availableChannel: factory.product.IAvailableChannel;
|
|
16
19
|
pendingPaymentAgencyTransaction: Pick<ICreditCardPaymentAgencyTransaction3ds, 'entryTranArgs' | 'entryTranResult' | 'execTranArgs' | 'execTranResult'>;
|
|
17
20
|
}): (repos: {
|
|
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.processAuthorizeCreditCard3ds = void 0;
|
|
13
13
|
const factory = require("../../../../factory");
|
|
14
|
-
const settings_1 = require("../../../../settings");
|
|
15
14
|
const processAuthorizeCreditCard3dsResult2recipe_1 = require("./processAuthorizeCreditCard3dsResult2recipe");
|
|
16
15
|
function processAuthorizeCreditCard3ds(params) {
|
|
17
16
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -31,34 +30,29 @@ function processAuthorizeCreditCard3ds(params) {
|
|
|
31
30
|
object: {
|
|
32
31
|
paymentMethodId: entryTranArgs.orderId,
|
|
33
32
|
typeOf: 'Invoice'
|
|
34
|
-
}
|
|
33
|
+
},
|
|
34
|
+
sameAs: { id: params.payTransaction.id, typeOf: factory.assetTransactionType.Pay }
|
|
35
35
|
};
|
|
36
36
|
// add action(2024-06-12~)
|
|
37
|
-
|
|
38
|
-
action = (yield repos.action.start(actionAttributes, { recipe }));
|
|
39
|
-
}
|
|
37
|
+
action = (yield repos.action.start(actionAttributes, { recipe }));
|
|
40
38
|
try {
|
|
41
39
|
secureTran2Result = yield repos.creditCardService.secureTran2(secureTran2Args);
|
|
42
40
|
}
|
|
43
41
|
catch (error) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// 失敗したら仕方ない
|
|
50
|
-
}
|
|
42
|
+
try {
|
|
43
|
+
yield repos.action.giveUp({ typeOf: actionAttributes.typeOf, id: action.id, error });
|
|
44
|
+
}
|
|
45
|
+
catch (__) {
|
|
46
|
+
// 失敗したら仕方ない
|
|
51
47
|
}
|
|
52
48
|
throw error;
|
|
53
49
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
yield repos.action.completeWithVoid({ typeOf: actionAttributes.typeOf, id: action.id, result: actionResult, recipe });
|
|
61
|
-
}
|
|
50
|
+
recipe = (0, processAuthorizeCreditCard3dsResult2recipe_1.processAuthorizeCreditCard3dsResult2recipe)({
|
|
51
|
+
project: { id: params.project.id },
|
|
52
|
+
result: { secureTran2Args, secureTran2Result }
|
|
53
|
+
});
|
|
54
|
+
const actionResult = {};
|
|
55
|
+
yield repos.action.completeWithVoid({ typeOf: actionAttributes.typeOf, id: action.id, result: actionResult, recipe });
|
|
62
56
|
return { entryTranArgs, entryTranResult, execTranArgs, execTranResult, secureTran2Result };
|
|
63
57
|
});
|
|
64
58
|
}
|
|
@@ -10,10 +10,20 @@ type IAuthorizeResult = IPaymentAgencyTransaction & {
|
|
|
10
10
|
accountId: string;
|
|
11
11
|
paymentMethodId: string;
|
|
12
12
|
};
|
|
13
|
+
type IPayTransactionAsAuthorizeInvoiceAction = Pick<factory.assetTransaction.pay.IStartParamsWithoutDetail, 'object' | 'project' | 'recipient' | 'transactionNumber'> & {
|
|
14
|
+
/**
|
|
15
|
+
* 決済取引ID
|
|
16
|
+
*/
|
|
17
|
+
id: string;
|
|
18
|
+
};
|
|
13
19
|
/**
|
|
14
20
|
* クレジットカード決済承認
|
|
15
21
|
*/
|
|
16
|
-
declare function authorize(
|
|
22
|
+
declare function authorize(
|
|
23
|
+
/**
|
|
24
|
+
* 承認開始元の決済取引
|
|
25
|
+
*/
|
|
26
|
+
payTransaction: IPayTransactionAsAuthorizeInvoiceAction, paymentServiceId: string, options: {
|
|
17
27
|
pendingPaymentAgencyTransaction?: Pick<IPaymentAgencyTransaction, 'entryTranArgs' | 'entryTranResult' | 'execTranArgs' | 'execTranResult'>;
|
|
18
28
|
/**
|
|
19
29
|
* 決済URL発行処理かどうか
|
|
@@ -22,26 +22,30 @@ const debug = createDebug('chevre-domain:service:payment');
|
|
|
22
22
|
/**
|
|
23
23
|
* クレジットカード決済承認
|
|
24
24
|
*/
|
|
25
|
-
function authorize(
|
|
25
|
+
function authorize(
|
|
26
|
+
/**
|
|
27
|
+
* 承認開始元の決済取引
|
|
28
|
+
*/
|
|
29
|
+
payTransaction, paymentServiceId, options) {
|
|
26
30
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
27
31
|
var _a, _b, _c, _d, _e;
|
|
28
32
|
// CreditCard系統の決済方法タイプは動的
|
|
29
|
-
const paymentMethodType = (_a =
|
|
33
|
+
const paymentMethodType = (_a = payTransaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
30
34
|
if (typeof paymentMethodType !== 'string') {
|
|
31
35
|
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
32
36
|
}
|
|
33
37
|
const availableChannel = yield repos.paymentService.findAvailableChannel({
|
|
34
|
-
project:
|
|
38
|
+
project: payTransaction.project,
|
|
35
39
|
typeOf: factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
36
40
|
id: paymentServiceId
|
|
37
41
|
});
|
|
38
|
-
const sellerId = (_b =
|
|
42
|
+
const sellerId = (_b = payTransaction.recipient) === null || _b === void 0 ? void 0 : _b.id;
|
|
39
43
|
if (typeof sellerId !== 'string') {
|
|
40
44
|
throw new factory.errors.ArgumentNull('recipient.id');
|
|
41
45
|
}
|
|
42
46
|
const { shopId, shopPass, returnUrls3ds, callbackType3ds } = yield (0, getGMOInfoFromSeller_1.getGMOInfoFromSeller)({ paymentMethodType, seller: { id: sellerId }, paymentServiceId })(repos);
|
|
43
47
|
// GMOオーダーIDはカスタム指定可能
|
|
44
|
-
const orderId =
|
|
48
|
+
const orderId = payTransaction.transactionNumber;
|
|
45
49
|
if (typeof orderId !== 'string') {
|
|
46
50
|
throw new factory.errors.ArgumentNull('transactionNumber');
|
|
47
51
|
}
|
|
@@ -63,16 +67,18 @@ function authorize(params, paymentServiceId, options) {
|
|
|
63
67
|
if (pendingPaymentAgencyTransaction !== undefined
|
|
64
68
|
&& typeof redirectUrl === 'string' && redirectUrl.length > 0) {
|
|
65
69
|
authorizeResult = yield (0, processAuthorizeCreditCard3ds_1.processAuthorizeCreditCard3ds)({
|
|
66
|
-
project: { id:
|
|
70
|
+
project: { id: payTransaction.project.id },
|
|
71
|
+
payTransaction: { id: payTransaction.id },
|
|
67
72
|
availableChannel,
|
|
68
73
|
pendingPaymentAgencyTransaction
|
|
69
74
|
})({ action: repos.action, creditCardService });
|
|
70
75
|
}
|
|
71
76
|
else {
|
|
72
77
|
authorizeResult = yield (0, processAuthorizeCreditCard_1.processAuthorizeCreditCard)({
|
|
73
|
-
project: { id:
|
|
78
|
+
project: { id: payTransaction.project.id },
|
|
79
|
+
payTransaction: { id: payTransaction.id },
|
|
74
80
|
shopId, shopPass, returnUrls3ds, callbackType3ds, orderId, availableChannel,
|
|
75
|
-
object:
|
|
81
|
+
object: payTransaction.object.paymentMethod,
|
|
76
82
|
processPublishPaymentUrl: options.processPublishPaymentUrl
|
|
77
83
|
})({ action: repos.action, creditCardService });
|
|
78
84
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
|
+
import type { MongoRepository as ActionRepo } from '../../../repo/action';
|
|
2
3
|
import type { MongoRepository as PaymentServiceRepo } from '../../../repo/paymentService';
|
|
3
4
|
import type { MongoRepository as PaymentServiceProviderRepo } from '../../../repo/paymentServiceProvider';
|
|
4
5
|
import type { MongoRepository as PaymentAcceptedRepo } from '../../../repo/sellerPaymentAccepted';
|
|
@@ -6,6 +7,7 @@ import type { MongoRepository as PaymentAcceptedRepo } from '../../../repo/selle
|
|
|
6
7
|
* クレジットカード決済中止
|
|
7
8
|
*/
|
|
8
9
|
declare function voidTransaction(params: factory.task.voidPayment.IData): (repos: {
|
|
10
|
+
action: ActionRepo;
|
|
9
11
|
paymentAccepted: PaymentAcceptedRepo;
|
|
10
12
|
paymentService: PaymentServiceRepo;
|
|
11
13
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
@@ -18,6 +18,7 @@ const gmoError_1 = require("./gmoError");
|
|
|
18
18
|
/**
|
|
19
19
|
* クレジットカード決済中止
|
|
20
20
|
*/
|
|
21
|
+
// tslint:disable-next-line:max-func-body-length
|
|
21
22
|
function voidTransaction(params) {
|
|
22
23
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
23
24
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -42,6 +43,22 @@ function voidTransaction(params) {
|
|
|
42
43
|
throw new factory.errors.ArgumentNull('object.recipient.id');
|
|
43
44
|
}
|
|
44
45
|
const { shopId, shopPass } = yield (0, getGMOInfoFromSeller_1.getGMOInfoFromSeller)({ paymentMethodType, seller: { id: sellerId }, paymentServiceId })(repos);
|
|
46
|
+
// authorizeInvoiceActionが存在すれば取消(2024-06-13~)
|
|
47
|
+
const authorizeInvoiceAction = (yield repos.action.search({
|
|
48
|
+
limit: 1,
|
|
49
|
+
page: 1,
|
|
50
|
+
typeOf: { $eq: factory.actionType.AuthorizeAction },
|
|
51
|
+
object: { paymentMethodId: { $eq: paymentMethodId } },
|
|
52
|
+
sameAs: { id: { $eq: transaction.id } }
|
|
53
|
+
}, ['_id', 'typeOf', 'project'], [])).shift();
|
|
54
|
+
if (authorizeInvoiceAction !== undefined) {
|
|
55
|
+
const cancelAction = {
|
|
56
|
+
startTime: new Date(),
|
|
57
|
+
agent: { id: authorizeInvoiceAction.project.id, typeOf: factory.organizationType.Project }
|
|
58
|
+
// ...(typeof params.sameAs?.id === 'string') ? { sameAs: { id: params.sameAs.id, typeOf: 'Task' } } : undefined
|
|
59
|
+
};
|
|
60
|
+
yield repos.action.cancelWithVoid({ typeOf: authorizeInvoiceAction.typeOf, id: authorizeInvoiceAction.id, cancelAction });
|
|
61
|
+
}
|
|
45
62
|
const creditCardService = new GMO.service.Credit({
|
|
46
63
|
endpoint: String(availableChannel.serviceUrl),
|
|
47
64
|
useFetch: credentials_1.credentials.gmo.useFetch
|
package/package.json
CHANGED
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/credential-providers": "3.433.0",
|
|
13
|
-
"@chevre/factory": "4.374.0-alpha.
|
|
13
|
+
"@chevre/factory": "4.374.0-alpha.23",
|
|
14
14
|
"@cinerino/sdk": "7.1.0",
|
|
15
15
|
"@motionpicture/coa-service": "9.4.0",
|
|
16
16
|
"@motionpicture/gmo-service": "5.3.0",
|
|
17
17
|
"@sendgrid/mail": "6.4.0",
|
|
18
|
-
"@surfrock/sdk": "1.3.0
|
|
18
|
+
"@surfrock/sdk": "1.3.0",
|
|
19
19
|
"cdigit": "2.6.7",
|
|
20
20
|
"debug": "^3.2.7",
|
|
21
21
|
"google-libphonenumber": "^3.2.18",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"postversion": "git push origin --tags",
|
|
111
111
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
112
112
|
},
|
|
113
|
-
"version": "21.34.0-alpha.
|
|
113
|
+
"version": "21.34.0-alpha.15"
|
|
114
114
|
}
|