@chevre/domain 21.8.0-alpha.16 → 21.8.0-alpha.18
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/migrateOrderPaymentMethodIdentifier.ts +9 -4
- package/example/src/chevre/migratePayTransactionPaymentMethodId.ts +72 -0
- package/example/src/chevre/migratePayTransactionPaymentMethodIdentifier.ts +75 -0
- package/example/src/chevre/processPay.ts +3 -4
- package/lib/chevre/repo/assetTransaction.d.ts +16 -1
- package/lib/chevre/repo/assetTransaction.js +54 -2
- package/lib/chevre/repo/order.d.ts +4 -1
- package/lib/chevre/repo/order.js +4 -1
- package/lib/chevre/service/assetTransaction/pay/account/validation.js +2 -2
- package/lib/chevre/service/assetTransaction/pay/factory.js +5 -3
- package/lib/chevre/service/assetTransaction/pay/potentialActions.js +3 -3
- package/lib/chevre/service/assetTransaction/pay.js +50 -13
- package/lib/chevre/service/order/confirmPayTransaction.js +9 -10
- package/lib/chevre/service/order/onAssetTransactionStatusChanged.js +98 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +5 -0
- package/lib/chevre/service/payment/any/factory.js +16 -6
- package/lib/chevre/service/payment/creditCard.js +12 -12
- package/lib/chevre/service/payment/movieTicket/validation.js +2 -2
- package/lib/chevre/service/payment/movieTicket.js +10 -11
- package/lib/chevre/service/payment/paymentCard.js +9 -12
- package/package.json +2 -2
|
@@ -15,12 +15,16 @@ async function main() {
|
|
|
15
15
|
const cursor = orderRepo.getCursor(
|
|
16
16
|
{
|
|
17
17
|
// 'project.id': { $eq: project.id },
|
|
18
|
-
// orderNumber: { $eq: '
|
|
18
|
+
// orderNumber: { $eq: 'KNR1-3961294-9087043' },
|
|
19
19
|
orderDate: {
|
|
20
20
|
$gte: moment()
|
|
21
21
|
// tslint:disable-next-line:no-magic-numbers
|
|
22
22
|
.add(-12, 'months')
|
|
23
23
|
.toDate()
|
|
24
|
+
// $lte: moment()
|
|
25
|
+
// // tslint:disable-next-line:no-magic-numbers
|
|
26
|
+
// .add(-6, 'months')
|
|
27
|
+
// .toDate()
|
|
24
28
|
}
|
|
25
29
|
},
|
|
26
30
|
{
|
|
@@ -43,7 +47,8 @@ async function main() {
|
|
|
43
47
|
|
|
44
48
|
const noPayment = order.paymentMethods.length === 0;
|
|
45
49
|
const alreadyMigrated = order.paymentMethods.every((invoice) => {
|
|
46
|
-
return typeof invoice.paymentMethod?.identifier === 'string'
|
|
50
|
+
return typeof invoice.paymentMethod?.identifier === 'string'
|
|
51
|
+
&& invoice.paymentMethod.identifier === invoice.typeOf;
|
|
47
52
|
});
|
|
48
53
|
|
|
49
54
|
if (noPayment) {
|
|
@@ -51,9 +56,9 @@ async function main() {
|
|
|
51
56
|
} else if (alreadyMigrated) {
|
|
52
57
|
console.log('already exist.', order.project.id, order.orderNumber, order.orderDate, i);
|
|
53
58
|
} else {
|
|
54
|
-
console.log('updating
|
|
59
|
+
console.log('updating...', order.project.id, order.orderNumber, order.orderDate, i);
|
|
55
60
|
for (const invoice of order.paymentMethods) {
|
|
56
|
-
await orderRepo.
|
|
61
|
+
await orderRepo.fixPaymentMethodIdentifier({
|
|
57
62
|
project: { id: order.project.id },
|
|
58
63
|
orderNumber: order.orderNumber,
|
|
59
64
|
invoice: {
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const cursor = assetTransactionRepo.getCursor(
|
|
16
|
+
{
|
|
17
|
+
typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
|
|
18
|
+
// 'object.paymentMethodId': { $exists: false },
|
|
19
|
+
// 'project.id': { $eq: project.id },
|
|
20
|
+
startDate: {
|
|
21
|
+
$gte: moment()
|
|
22
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
23
|
+
.add(-12, 'months')
|
|
24
|
+
.toDate()
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
typeOf: 1,
|
|
29
|
+
project: 1,
|
|
30
|
+
object: 1,
|
|
31
|
+
transactionNumber: 1,
|
|
32
|
+
startDate: 1
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
console.log('transactions found');
|
|
36
|
+
|
|
37
|
+
let i = 0;
|
|
38
|
+
let updateCount = 0;
|
|
39
|
+
await cursor.eachAsync(async (doc) => {
|
|
40
|
+
i += 1;
|
|
41
|
+
const payTransaction: Pick<
|
|
42
|
+
chevre.factory.assetTransaction.pay.ITransaction,
|
|
43
|
+
'project' | 'object' | 'transactionNumber' | 'startDate' | 'typeOf'
|
|
44
|
+
> = doc.toObject();
|
|
45
|
+
|
|
46
|
+
const alreadyMigrated = typeof payTransaction.object.paymentMethodId === 'string'
|
|
47
|
+
&& payTransaction.object.paymentMethodId === (<any>payTransaction.object.paymentMethod).paymentMethodId;
|
|
48
|
+
|
|
49
|
+
if (alreadyMigrated) {
|
|
50
|
+
console.log(
|
|
51
|
+
'already exist.',
|
|
52
|
+
payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i);
|
|
53
|
+
} else {
|
|
54
|
+
const paymentMethodIdentifier = (<any>payTransaction.object.paymentMethod).typeOf;
|
|
55
|
+
console.log(
|
|
56
|
+
'updating...',
|
|
57
|
+
payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i,
|
|
58
|
+
paymentMethodIdentifier);
|
|
59
|
+
updateCount += 1;
|
|
60
|
+
console.log(
|
|
61
|
+
'updated.',
|
|
62
|
+
payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
console.log(i, 'transactions checked');
|
|
67
|
+
console.log(updateCount, 'transactions updated');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
main()
|
|
71
|
+
.then()
|
|
72
|
+
.catch(console.error);
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
|
|
14
|
+
|
|
15
|
+
const cursor = assetTransactionRepo.getCursor(
|
|
16
|
+
{
|
|
17
|
+
typeOf: { $eq: chevre.factory.assetTransactionType.Pay },
|
|
18
|
+
// 'project.id': { $eq: project.id },
|
|
19
|
+
startDate: {
|
|
20
|
+
$gte: moment()
|
|
21
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
22
|
+
.add(-24, 'months')
|
|
23
|
+
.toDate()
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
typeOf: 1,
|
|
28
|
+
project: 1,
|
|
29
|
+
object: 1,
|
|
30
|
+
transactionNumber: 1,
|
|
31
|
+
startDate: 1
|
|
32
|
+
}
|
|
33
|
+
);
|
|
34
|
+
console.log('transactions found');
|
|
35
|
+
|
|
36
|
+
let i = 0;
|
|
37
|
+
let updateCount = 0;
|
|
38
|
+
await cursor.eachAsync(async (doc) => {
|
|
39
|
+
i += 1;
|
|
40
|
+
const payTransaction: Pick<
|
|
41
|
+
chevre.factory.assetTransaction.pay.ITransaction,
|
|
42
|
+
'project' | 'object' | 'transactionNumber' | 'startDate' | 'typeOf'
|
|
43
|
+
> = doc.toObject();
|
|
44
|
+
|
|
45
|
+
const alreadyMigrated = payTransaction.object.paymentMethod.identifier
|
|
46
|
+
=== (<any>payTransaction.object.paymentMethod).typeOf;
|
|
47
|
+
|
|
48
|
+
if (alreadyMigrated) {
|
|
49
|
+
console.log(
|
|
50
|
+
'already exist.',
|
|
51
|
+
payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i);
|
|
52
|
+
} else {
|
|
53
|
+
const paymentMethodIdentifier = (<any>payTransaction.object.paymentMethod).typeOf;
|
|
54
|
+
console.log(
|
|
55
|
+
'updating...',
|
|
56
|
+
payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i,
|
|
57
|
+
paymentMethodIdentifier);
|
|
58
|
+
await assetTransactionRepo.migratePaymentMethodIdentifier({
|
|
59
|
+
transactionNumber: payTransaction.transactionNumber,
|
|
60
|
+
object: { paymentMethod: { identifier: paymentMethodIdentifier } }
|
|
61
|
+
});
|
|
62
|
+
updateCount += 1;
|
|
63
|
+
console.log(
|
|
64
|
+
'updated.',
|
|
65
|
+
payTransaction.project.id, payTransaction.typeOf, payTransaction.transactionNumber, payTransaction.startDate, i);
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
console.log(i, 'transactions checked');
|
|
70
|
+
console.log(updateCount, 'transactions updated');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
main()
|
|
74
|
+
.then()
|
|
75
|
+
.catch(console.error);
|
|
@@ -43,14 +43,13 @@ async function main() {
|
|
|
43
43
|
.toDate(),
|
|
44
44
|
object: {
|
|
45
45
|
typeOf: chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
46
|
-
id: '
|
|
46
|
+
id: 'xxx',
|
|
47
47
|
paymentMethod: {
|
|
48
48
|
amount: 1,
|
|
49
|
-
|
|
50
|
-
typeOf: 'CreditCard',
|
|
49
|
+
identifier: 'CreditCard',
|
|
51
50
|
method: '1',
|
|
52
51
|
creditCard: {
|
|
53
|
-
memberId: '
|
|
52
|
+
memberId: 'xxx',
|
|
54
53
|
cardSeq: 91
|
|
55
54
|
// cardPass?: string;
|
|
56
55
|
}
|
|
@@ -78,7 +78,14 @@ export declare class MongoRepository {
|
|
|
78
78
|
confirm<T extends factory.assetTransactionType>(params: {
|
|
79
79
|
typeOf: T;
|
|
80
80
|
id: string;
|
|
81
|
-
object?: Pick<factory.assetTransaction.reserve.IObject, 'underName'
|
|
81
|
+
object?: Pick<factory.assetTransaction.reserve.IObject, 'underName'> & {
|
|
82
|
+
/**
|
|
83
|
+
* 決済取引における決済方法区分指定
|
|
84
|
+
*/
|
|
85
|
+
paymentMethod?: {
|
|
86
|
+
identifier?: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
82
89
|
result: factory.assetTransaction.IResult<T>;
|
|
83
90
|
potentialActions: factory.assetTransaction.IPotentialActions<T>;
|
|
84
91
|
}): Promise<void>;
|
|
@@ -182,6 +189,14 @@ export declare class MongoRepository {
|
|
|
182
189
|
id: string;
|
|
183
190
|
update: any;
|
|
184
191
|
}): Promise<factory.assetTransaction.ITransaction<T>>;
|
|
192
|
+
migratePaymentMethodIdentifier(params: {
|
|
193
|
+
transactionNumber: string;
|
|
194
|
+
object: {
|
|
195
|
+
paymentMethod: {
|
|
196
|
+
identifier: string;
|
|
197
|
+
};
|
|
198
|
+
};
|
|
199
|
+
}): Promise<any>;
|
|
185
200
|
findByIdAndDelete(params: {
|
|
186
201
|
id: string;
|
|
187
202
|
}): Promise<void>;
|
|
@@ -344,14 +344,16 @@ class MongoRepository {
|
|
|
344
344
|
* 取引を確定する
|
|
345
345
|
*/
|
|
346
346
|
confirm(params) {
|
|
347
|
-
var _a, _b;
|
|
347
|
+
var _a, _b, _c, _d;
|
|
348
348
|
return __awaiter(this, void 0, void 0, function* () {
|
|
349
349
|
const doc = yield this.transactionModel.findOneAndUpdate({
|
|
350
350
|
_id: { $eq: params.id },
|
|
351
351
|
typeOf: { $eq: params.typeOf },
|
|
352
352
|
status: { $eq: factory.transactionStatusType.InProgress }
|
|
353
|
-
}, Object.assign({ status: factory.transactionStatusType.Confirmed, endDate: new Date(), result: params.result, potentialActions: params.potentialActions }, (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.underName) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
|
|
353
|
+
}, Object.assign(Object.assign({ status: factory.transactionStatusType.Confirmed, endDate: new Date(), result: params.result, potentialActions: params.potentialActions }, (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.underName) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
|
|
354
354
|
? { 'object.underName': params.object.underName }
|
|
355
|
+
: undefined), (typeof ((_d = (_c = params.object) === null || _c === void 0 ? void 0 : _c.paymentMethod) === null || _d === void 0 ? void 0 : _d.identifier) === 'string')
|
|
356
|
+
? { 'object.paymentMethod.identifier': params.object.paymentMethod.identifier }
|
|
355
357
|
: undefined), {
|
|
356
358
|
new: true,
|
|
357
359
|
projection: { _id: 1 }
|
|
@@ -704,6 +706,55 @@ class MongoRepository {
|
|
|
704
706
|
});
|
|
705
707
|
});
|
|
706
708
|
}
|
|
709
|
+
migratePaymentMethodIdentifier(params) {
|
|
710
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
711
|
+
return this.transactionModel.findOneAndUpdate({
|
|
712
|
+
typeOf: { $eq: factory.assetTransactionType.Pay },
|
|
713
|
+
transactionNumber: { $exists: true, $eq: params.transactionNumber }
|
|
714
|
+
}, { 'object.paymentMethod.identifier': params.object.paymentMethod.identifier }, {
|
|
715
|
+
new: true,
|
|
716
|
+
projection: { _id: 1 }
|
|
717
|
+
})
|
|
718
|
+
.exec()
|
|
719
|
+
.then((doc) => {
|
|
720
|
+
if (doc === null) {
|
|
721
|
+
throw new factory.errors.ArgumentNull(this.transactionModel.modelName);
|
|
722
|
+
}
|
|
723
|
+
return doc.toObject();
|
|
724
|
+
});
|
|
725
|
+
});
|
|
726
|
+
}
|
|
727
|
+
// public async migratePaymentMethodIdentifierMany() {
|
|
728
|
+
// // return this.transactionModel.updateMany(
|
|
729
|
+
// // {
|
|
730
|
+
// // typeOf: { $eq: factory.assetTransactionType.Pay }
|
|
731
|
+
// // // 'object.paymentMethod.identifier': { $exists: false }
|
|
732
|
+
// // },
|
|
733
|
+
// // { $set: { 'object.paymentMethod.identifier': '$object.paymentMethod.typeOf' } }
|
|
734
|
+
// // )
|
|
735
|
+
// // .exec();
|
|
736
|
+
// return this.transactionModel.aggregate([
|
|
737
|
+
// {
|
|
738
|
+
// $match: {
|
|
739
|
+
// typeOf: { $eq: factory.assetTransactionType.Pay }
|
|
740
|
+
// }
|
|
741
|
+
// },
|
|
742
|
+
// {
|
|
743
|
+
// $project: {
|
|
744
|
+
// paymentMethodIdentifier: '$object.paymentMethod.typeOf'
|
|
745
|
+
// }
|
|
746
|
+
// },
|
|
747
|
+
// {
|
|
748
|
+
// $unset: ['object.paymentMethod.identifier']
|
|
749
|
+
// }
|
|
750
|
+
// // {
|
|
751
|
+
// // $set: {
|
|
752
|
+
// // 'object.paymentMethod.identifier': '$paymentMethodIdentifier'
|
|
753
|
+
// // }
|
|
754
|
+
// // }
|
|
755
|
+
// ])
|
|
756
|
+
// .exec();
|
|
757
|
+
// }
|
|
707
758
|
findByIdAndDelete(params) {
|
|
708
759
|
return __awaiter(this, void 0, void 0, function* () {
|
|
709
760
|
yield this.transactionModel.findByIdAndDelete(params.id)
|
|
@@ -713,6 +764,7 @@ class MongoRepository {
|
|
|
713
764
|
getCursor(conditions, projection) {
|
|
714
765
|
return this.transactionModel.find(conditions, projection)
|
|
715
766
|
.sort({ startDate: factory.sortType.Ascending })
|
|
767
|
+
// .sort({ startDate: factory.sortType.Descending })
|
|
716
768
|
.cursor();
|
|
717
769
|
}
|
|
718
770
|
aggregateAssetTransaction(params) {
|
package/lib/chevre/repo/order.js
CHANGED
|
@@ -782,7 +782,10 @@ class MongoRepository {
|
|
|
782
782
|
return { updatedAt: doc.updatedAt };
|
|
783
783
|
});
|
|
784
784
|
}
|
|
785
|
-
|
|
785
|
+
/**
|
|
786
|
+
* 注文後に決済方法区分を確定する
|
|
787
|
+
*/
|
|
788
|
+
fixPaymentMethodIdentifier(params) {
|
|
786
789
|
return __awaiter(this, void 0, void 0, function* () {
|
|
787
790
|
const doc = yield this.orderModel.findOneAndUpdate({
|
|
788
791
|
orderNumber: { $eq: params.orderNumber },
|
|
@@ -15,9 +15,9 @@ function validateAccount(params) {
|
|
|
15
15
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
16
16
|
var _a, _b, _c, _d;
|
|
17
17
|
// 引き出し口座の存在を確認する
|
|
18
|
-
const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.
|
|
18
|
+
const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
19
19
|
if (typeof paymentMethodType !== 'string') {
|
|
20
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
20
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
21
21
|
}
|
|
22
22
|
const accountNumber = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.accountId;
|
|
23
23
|
if (typeof accountNumber !== 'string') {
|
|
@@ -15,9 +15,9 @@ function createStartParams(params) {
|
|
|
15
15
|
const paymentMethodType = (params.paymentService !== undefined)
|
|
16
16
|
// FaceToFace以外は、プロダクトから決済方法タイプを自動取得
|
|
17
17
|
? (_a = params.paymentService.serviceType) === null || _a === void 0 ? void 0 : _a.codeValue
|
|
18
|
-
: (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.
|
|
18
|
+
: (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
19
19
|
if (typeof paymentMethodType !== 'string') {
|
|
20
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
20
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
21
21
|
}
|
|
22
22
|
let totalPaymentDue;
|
|
23
23
|
switch (params.paymentServiceType) {
|
|
@@ -85,7 +85,9 @@ function createStartParams(params) {
|
|
|
85
85
|
? params.object.paymentMethod.name
|
|
86
86
|
: paymentMethodType,
|
|
87
87
|
// MonetaryAmount対応(2023-08-14~)
|
|
88
|
-
amount: (settings_1.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT) ? paymentMethodAmount : params.amount,
|
|
88
|
+
amount: (settings_1.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT) ? paymentMethodAmount : params.amount,
|
|
89
|
+
// paymentMethodId: params.transactionNumber, // object.paymentMethodIdへ完全移行(2023-08-30~)
|
|
90
|
+
identifier: paymentMethodType }, (typeof ((_t = params.object.paymentMethod) === null || _t === void 0 ? void 0 : _t.description) === 'string')
|
|
89
91
|
? { description: (_u = params.object.paymentMethod) === null || _u === void 0 ? void 0 : _u.description }
|
|
90
92
|
: undefined), (totalPaymentDue !== undefined)
|
|
91
93
|
? { totalPaymentDue: totalPaymentDue }
|
|
@@ -33,9 +33,9 @@ function createPayObject(params) {
|
|
|
33
33
|
var _a;
|
|
34
34
|
const transaction = params.transaction;
|
|
35
35
|
const paymentMethod = transaction.object.paymentMethod;
|
|
36
|
-
const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.
|
|
36
|
+
const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.identifier);
|
|
37
37
|
const additionalProperty = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.additionalProperty;
|
|
38
|
-
const paymentMethodId =
|
|
38
|
+
const paymentMethodId = transaction.object.paymentMethodId;
|
|
39
39
|
const paymentMethodName = (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name) === 'string') ? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name : paymentMethodType;
|
|
40
40
|
// MonetaryAmount対応(2023-08-13~)
|
|
41
41
|
const paymentMethodAmountValue = (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.amount) === 'number')
|
|
@@ -139,7 +139,7 @@ function createPayObjectServiceOutput(params) {
|
|
|
139
139
|
// }
|
|
140
140
|
break;
|
|
141
141
|
case factory.service.paymentService.PaymentServiceType.MovieTicket:
|
|
142
|
-
const paymentMethodType = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.
|
|
142
|
+
const paymentMethodType = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.identifier;
|
|
143
143
|
const movieTickets = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets;
|
|
144
144
|
if (Array.isArray(movieTickets)) {
|
|
145
145
|
paymentServiceOutput = movieTickets.map((movieTicket) => {
|
|
@@ -219,9 +219,9 @@ function validateSeller(params) {
|
|
|
219
219
|
if (seller === undefined) {
|
|
220
220
|
throw new factory.errors.NotFound(factory.organizationType.Corporation);
|
|
221
221
|
}
|
|
222
|
-
const paymentMethodType = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.
|
|
222
|
+
const paymentMethodType = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
223
223
|
if (typeof paymentMethodType !== 'string') {
|
|
224
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
224
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
225
225
|
}
|
|
226
226
|
// FaceToFaceの場合、決済方法区分未指定に対応(2023-08-29~)
|
|
227
227
|
if (params.object.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace) {
|
|
@@ -229,7 +229,7 @@ function validateSeller(params) {
|
|
|
229
229
|
// 販売者の対応決済方法かどうか確認
|
|
230
230
|
const paymentAccepted = (_c = seller.paymentAccepted) === null || _c === void 0 ? void 0 : _c.some((a) => a.paymentMethodType === paymentMethodType);
|
|
231
231
|
if (paymentAccepted !== true) {
|
|
232
|
-
throw new factory.errors.Argument('object.paymentMethod.
|
|
232
|
+
throw new factory.errors.Argument('object.paymentMethod.identifier', `payment not accepted`);
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
}
|
|
@@ -237,7 +237,7 @@ function validateSeller(params) {
|
|
|
237
237
|
// 販売者の対応決済方法かどうか確認
|
|
238
238
|
const paymentAccepted = (_d = seller.paymentAccepted) === null || _d === void 0 ? void 0 : _d.some((a) => a.paymentMethodType === paymentMethodType);
|
|
239
239
|
if (paymentAccepted !== true) {
|
|
240
|
-
throw new factory.errors.Argument('object.paymentMethod.
|
|
240
|
+
throw new factory.errors.Argument('object.paymentMethod.identifier', `payment not accepted`);
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
243
|
});
|
|
@@ -313,6 +313,7 @@ function saveAuthorizeResult(params) {
|
|
|
313
313
|
*/
|
|
314
314
|
function confirm(params) {
|
|
315
315
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
316
|
+
var _a, _b;
|
|
316
317
|
let transaction;
|
|
317
318
|
// 取引存在確認
|
|
318
319
|
if (typeof params.id === 'string') {
|
|
@@ -330,21 +331,28 @@ function confirm(params) {
|
|
|
330
331
|
else {
|
|
331
332
|
throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
|
|
332
333
|
}
|
|
334
|
+
let overwritingPaymentMethodIdentifier;
|
|
335
|
+
if (transaction.object.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace) {
|
|
336
|
+
const specifiedPaymentMethodIdentifire = (_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
337
|
+
if (typeof specifiedPaymentMethodIdentifire === 'string' && specifiedPaymentMethodIdentifire.length > 0) {
|
|
338
|
+
overwritingPaymentMethodIdentifier = specifiedPaymentMethodIdentifire;
|
|
339
|
+
transaction.object.paymentMethod.identifier = overwritingPaymentMethodIdentifier;
|
|
340
|
+
// transaction.object.paymentMethod.typeOf = overwritingPaymentMethodIdentifier;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
333
343
|
const order = yield fixOrderAsPurpose(params, transaction)(repos);
|
|
334
344
|
const potentialActions = (0, potentialActions_1.createPotentialActions)({
|
|
335
345
|
transaction: transaction,
|
|
336
346
|
potentialActions: params.potentialActions,
|
|
337
347
|
order
|
|
338
348
|
});
|
|
339
|
-
yield repos.assetTransaction.confirm({
|
|
340
|
-
typeOf: factory.assetTransactionType.Pay,
|
|
341
|
-
id: transaction.id,
|
|
342
|
-
result: {},
|
|
349
|
+
yield repos.assetTransaction.confirm(Object.assign({ typeOf: factory.assetTransactionType.Pay, id: transaction.id, result: {},
|
|
343
350
|
// sync対応(2023-01-14~)
|
|
344
351
|
potentialActions: (settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING)
|
|
345
352
|
? { pay: [] }
|
|
346
|
-
: potentialActions
|
|
347
|
-
|
|
353
|
+
: potentialActions }, (typeof overwritingPaymentMethodIdentifier === 'string')
|
|
354
|
+
? { object: { paymentMethod: { identifier: overwritingPaymentMethodIdentifier } } }
|
|
355
|
+
: undefined));
|
|
348
356
|
// sync対応(2023-01-14~)
|
|
349
357
|
if (settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING) {
|
|
350
358
|
if (Array.isArray(potentialActions.pay)) {
|
|
@@ -416,6 +424,9 @@ function exportTasksById(params) {
|
|
|
416
424
|
id: params.id
|
|
417
425
|
});
|
|
418
426
|
const potentialActions = transaction.potentialActions;
|
|
427
|
+
if (transaction.status === factory.transactionStatusType.InProgress) {
|
|
428
|
+
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
429
|
+
}
|
|
419
430
|
const taskAttributes = [];
|
|
420
431
|
// タスク実行日時バッファの指定があれば調整
|
|
421
432
|
let taskRunsAt = new Date();
|
|
@@ -442,6 +453,31 @@ function exportTasksById(params) {
|
|
|
442
453
|
executionResults: [],
|
|
443
454
|
data: { object: payTransactionAsObject }
|
|
444
455
|
};
|
|
456
|
+
// OnAssetTransactionStatusChangedを追加(2023-08-30~)
|
|
457
|
+
const onAssetTransactionStatusChangedTaskData = {
|
|
458
|
+
project: transaction.project,
|
|
459
|
+
object: {
|
|
460
|
+
typeOf: factory.assetTransactionType.Pay,
|
|
461
|
+
transactionNumber: transaction.transactionNumber,
|
|
462
|
+
status: transaction.status
|
|
463
|
+
},
|
|
464
|
+
purpose: {
|
|
465
|
+
confirmationNumber: '',
|
|
466
|
+
orderNumber: '',
|
|
467
|
+
typeOf: 'Order'
|
|
468
|
+
},
|
|
469
|
+
useOnOrderStatusChanged: true
|
|
470
|
+
};
|
|
471
|
+
const onAssetTransactionStatusChangedTask = {
|
|
472
|
+
project: transaction.project,
|
|
473
|
+
name: factory.taskName.OnAssetTransactionStatusChanged,
|
|
474
|
+
status: factory.taskStatus.Ready,
|
|
475
|
+
runsAt: taskRunsAt,
|
|
476
|
+
remainingNumberOfTries: 10,
|
|
477
|
+
numberOfTried: 0,
|
|
478
|
+
executionResults: [],
|
|
479
|
+
data: onAssetTransactionStatusChangedTaskData
|
|
480
|
+
};
|
|
445
481
|
switch (transaction.status) {
|
|
446
482
|
case factory.transactionStatusType.Confirmed:
|
|
447
483
|
const payActions = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.pay;
|
|
@@ -466,9 +502,10 @@ function exportTasksById(params) {
|
|
|
466
502
|
if (!settings_1.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING) {
|
|
467
503
|
taskAttributes.push(voidPaymentTasks);
|
|
468
504
|
}
|
|
505
|
+
taskAttributes.push(onAssetTransactionStatusChangedTask);
|
|
469
506
|
break;
|
|
470
507
|
case factory.transactionStatusType.Expired:
|
|
471
|
-
taskAttributes.push(voidPaymentTasks);
|
|
508
|
+
taskAttributes.push(voidPaymentTasks, onAssetTransactionStatusChangedTask);
|
|
472
509
|
break;
|
|
473
510
|
default:
|
|
474
511
|
throw new factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
@@ -494,9 +531,9 @@ function searchGMOTrade(params) {
|
|
|
494
531
|
// throw new factory.errors.Argument('transactionNumber', 'must be confirmed');
|
|
495
532
|
// }
|
|
496
533
|
// CreditCard系統の決済方法タイプは動的
|
|
497
|
-
const paymentMethodType = (_a = assetTransaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.
|
|
534
|
+
const paymentMethodType = (_a = assetTransaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
498
535
|
if (typeof paymentMethodType !== 'string') {
|
|
499
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
536
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
500
537
|
}
|
|
501
538
|
const paymentServiceId = String(assetTransaction.object.id);
|
|
502
539
|
const availableChannel = yield repos.product.findAvailableChannel({
|
|
@@ -14,13 +14,12 @@ const factory = require("../../factory");
|
|
|
14
14
|
const PayTransactionService = require("../assetTransaction/pay");
|
|
15
15
|
function confirmPayTransaction(data) {
|
|
16
16
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
var _a, _b;
|
|
17
18
|
// アクション開始
|
|
18
19
|
const action = yield repos.action.start(data);
|
|
19
20
|
try {
|
|
20
21
|
for (const confirmingTransaction of data.object) {
|
|
21
|
-
yield PayTransactionService.confirm({
|
|
22
|
-
transactionNumber: confirmingTransaction.transactionNumber,
|
|
23
|
-
potentialActions: {
|
|
22
|
+
yield PayTransactionService.confirm(Object.assign({ transactionNumber: confirmingTransaction.transactionNumber, potentialActions: {
|
|
24
23
|
pay: {
|
|
25
24
|
purpose: {
|
|
26
25
|
typeOf: data.purpose.typeOf,
|
|
@@ -28,8 +27,9 @@ function confirmPayTransaction(data) {
|
|
|
28
27
|
orderNumber: data.purpose.orderNumber
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
|
-
}
|
|
32
|
-
|
|
30
|
+
} }, (typeof ((_b = (_a = confirmingTransaction.object) === null || _a === void 0 ? void 0 : _a.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier) === 'string')
|
|
31
|
+
? { object: { paymentMethod: { identifier: confirmingTransaction.object.paymentMethod.identifier } } }
|
|
32
|
+
: undefined))({
|
|
33
33
|
action: repos.action,
|
|
34
34
|
accountingReport: repos.accountingReport,
|
|
35
35
|
assetTransaction: repos.assetTransaction,
|
|
@@ -65,16 +65,15 @@ function confirmPayTransaction(data) {
|
|
|
65
65
|
exports.confirmPayTransaction = confirmPayTransaction;
|
|
66
66
|
function onConfirmed(params) {
|
|
67
67
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
var _a, _b;
|
|
68
69
|
if (params.processOrder === true) {
|
|
69
70
|
for (const confirmingTransaction of params.object) {
|
|
70
71
|
// タスク冪等作成
|
|
71
72
|
const onAssetTransactionStatusChangedTaskData = {
|
|
72
73
|
project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
73
|
-
object: {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
status: factory.transactionStatusType.Confirmed
|
|
77
|
-
},
|
|
74
|
+
object: Object.assign({ typeOf: factory.assetTransactionType.Pay, transactionNumber: confirmingTransaction.transactionNumber, status: factory.transactionStatusType.Confirmed }, (typeof ((_b = (_a = confirmingTransaction.object) === null || _a === void 0 ? void 0 : _a.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier) === 'string')
|
|
75
|
+
? { object: { paymentMethod: { identifier: confirmingTransaction.object.paymentMethod.identifier } } }
|
|
76
|
+
: undefined),
|
|
78
77
|
purpose: {
|
|
79
78
|
confirmationNumber: params.purpose.confirmationNumber,
|
|
80
79
|
orderNumber: params.purpose.orderNumber,
|
|
@@ -15,7 +15,7 @@ const onOrderStatusChanged_1 = require("./onOrderStatusChanged");
|
|
|
15
15
|
const factory = require("../../factory");
|
|
16
16
|
function onAssetTransactionStatusChanged(params) {
|
|
17
17
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
var _a, _b;
|
|
18
|
+
var _a, _b, _c, _d, _e;
|
|
19
19
|
if (typeof params.useOnOrderStatusChanged !== 'boolean') {
|
|
20
20
|
throw new factory.errors.Argument('useOnOrderStatusChanged', 'must be boolean');
|
|
21
21
|
}
|
|
@@ -25,6 +25,16 @@ function onAssetTransactionStatusChanged(params) {
|
|
|
25
25
|
case factory.assetTransactionType.Pay:
|
|
26
26
|
const orderNumber = (_a = params.purpose) === null || _a === void 0 ? void 0 : _a.orderNumber;
|
|
27
27
|
const confirmationNumber = (_b = params.purpose) === null || _b === void 0 ? void 0 : _b.confirmationNumber;
|
|
28
|
+
// 確定時の決済方法区分指定(2023-08-29~)
|
|
29
|
+
const specifiedPaymentMethodIdentifire = (_e = (_d = (_c = params.object) === null || _c === void 0 ? void 0 : _c.object) === null || _d === void 0 ? void 0 : _d.paymentMethod) === null || _e === void 0 ? void 0 : _e.identifier;
|
|
30
|
+
if (typeof specifiedPaymentMethodIdentifire === 'string' && specifiedPaymentMethodIdentifire.length > 0) {
|
|
31
|
+
yield fixPaymentMethodIdentifierIfPossible({
|
|
32
|
+
project: { id: params.project.id },
|
|
33
|
+
paymentMethodId: params.object.transactionNumber,
|
|
34
|
+
paymentMethod: { identifier: specifiedPaymentMethodIdentifire },
|
|
35
|
+
referencesOrder: { orderNumber }
|
|
36
|
+
})(repos);
|
|
37
|
+
}
|
|
28
38
|
if (typeof orderNumber === 'string' && typeof confirmationNumber === 'string') {
|
|
29
39
|
// PayTransactionのステータス検証
|
|
30
40
|
const processable = yield isProcessable({ project: { id: params.project.id }, orderNumber })(repos);
|
|
@@ -42,12 +52,53 @@ function onAssetTransactionStatusChanged(params) {
|
|
|
42
52
|
// no op
|
|
43
53
|
}
|
|
44
54
|
break;
|
|
55
|
+
case factory.transactionStatusType.Canceled:
|
|
56
|
+
case factory.transactionStatusType.Expired:
|
|
57
|
+
switch (params.object.typeOf) {
|
|
58
|
+
case factory.assetTransactionType.Pay:
|
|
59
|
+
// 注文が存在すればキャンセル(2023-08-30~)
|
|
60
|
+
yield cancelOrderIfExist({
|
|
61
|
+
project: { id: params.project.id },
|
|
62
|
+
paymentMethodId: params.object.transactionNumber,
|
|
63
|
+
useOnOrderStatusChanged: params.useOnOrderStatusChanged
|
|
64
|
+
})(repos);
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
// no op
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
45
70
|
default:
|
|
46
71
|
// no op
|
|
47
72
|
}
|
|
48
73
|
});
|
|
49
74
|
}
|
|
50
75
|
exports.onAssetTransactionStatusChanged = onAssetTransactionStatusChanged;
|
|
76
|
+
function fixPaymentMethodIdentifierIfPossible(params) {
|
|
77
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
const referencedPayTransactions = yield repos.assetTransaction.search({
|
|
79
|
+
project: { id: { $eq: params.project.id } },
|
|
80
|
+
typeOf: factory.assetTransactionType.Pay,
|
|
81
|
+
statuses: [factory.transactionStatusType.Confirmed],
|
|
82
|
+
transactionNumber: { $in: [params.paymentMethodId] }
|
|
83
|
+
}, ['object']);
|
|
84
|
+
const referencedPayTransaction = referencedPayTransactions.shift();
|
|
85
|
+
if (referencedPayTransaction === undefined) {
|
|
86
|
+
throw new factory.errors.NotFound(factory.assetTransactionType.Pay);
|
|
87
|
+
}
|
|
88
|
+
// 対面決済かつ決済取引上の決済方法区分と一致すれば、注文を変更
|
|
89
|
+
if (referencedPayTransaction.object.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace
|
|
90
|
+
&& referencedPayTransaction.object.paymentMethod.identifier === params.paymentMethod.identifier) {
|
|
91
|
+
yield repos.order.fixPaymentMethodIdentifier({
|
|
92
|
+
project: { id: params.project.id },
|
|
93
|
+
orderNumber: params.referencesOrder.orderNumber,
|
|
94
|
+
invoice: {
|
|
95
|
+
paymentMethodId: params.paymentMethodId,
|
|
96
|
+
paymentMethod: { identifier: params.paymentMethod.identifier }
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
51
102
|
function isProcessable(params) {
|
|
52
103
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
53
104
|
// 注文のpaymentMethodIdを取得
|
|
@@ -127,3 +178,49 @@ function paymentDue2Processing(params) {
|
|
|
127
178
|
});
|
|
128
179
|
}
|
|
129
180
|
exports.paymentDue2Processing = paymentDue2Processing;
|
|
181
|
+
function cancelOrderIfExist(params) {
|
|
182
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
183
|
+
if (params.paymentMethodId.length === 0) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
// 注文のpaymentMethodIdを取得
|
|
187
|
+
const ordersByPaymentMethodId = yield repos.order.search({
|
|
188
|
+
limit: 1,
|
|
189
|
+
page: 1,
|
|
190
|
+
paymentMethods: {
|
|
191
|
+
paymentMethodIds: [params.paymentMethodId]
|
|
192
|
+
},
|
|
193
|
+
project: { id: { $eq: params.project.id } }
|
|
194
|
+
}, { confirmationNumber: 1, orderNumber: 1 });
|
|
195
|
+
const orderByPaymentMethodId = ordersByPaymentMethodId.shift();
|
|
196
|
+
if (orderByPaymentMethodId !== undefined) {
|
|
197
|
+
const placeOrderTransaction = yield (0, findPlaceOrderTransaction_1.findPlaceOrderTransaction)({
|
|
198
|
+
project: { id: params.project.id },
|
|
199
|
+
confirmationNumber: orderByPaymentMethodId.confirmationNumber,
|
|
200
|
+
orderNumber: orderByPaymentMethodId.orderNumber
|
|
201
|
+
})({ transaction: repos.transaction });
|
|
202
|
+
let order;
|
|
203
|
+
try {
|
|
204
|
+
order = yield repos.order.changeStatus({
|
|
205
|
+
project: { id: params.project.id },
|
|
206
|
+
orderNumber: orderByPaymentMethodId.orderNumber,
|
|
207
|
+
orderStatus: factory.orderStatus.OrderCancelled,
|
|
208
|
+
previousOrderStatus: factory.orderStatus.OrderPaymentDue
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
catch (error) {
|
|
212
|
+
throw error;
|
|
213
|
+
}
|
|
214
|
+
if (params.useOnOrderStatusChanged) {
|
|
215
|
+
yield (0, onOrderStatusChanged_1.onOrderStatusChanged)({
|
|
216
|
+
order: Object.assign(Object.assign({}, order), { orderStatus: factory.orderStatus.OrderCancelled // 強制的にOrderCancelledとして処理する
|
|
217
|
+
}),
|
|
218
|
+
placeOrderTransaction
|
|
219
|
+
})({
|
|
220
|
+
registerActionInProgress: repos.registerActionInProgress,
|
|
221
|
+
task: repos.task
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
}
|
|
@@ -116,6 +116,11 @@ function onOrderStatusChanged(params) {
|
|
|
116
116
|
...(0, factory_1.createOnOrderReturnedTasksByTransaction)({ potentialActions: potentialActionsByTransaction })
|
|
117
117
|
];
|
|
118
118
|
break;
|
|
119
|
+
// OrderCancelled追加(2023-08-30~)
|
|
120
|
+
case factory.orderStatus.OrderCancelled:
|
|
121
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
122
|
+
// TODO 注文取引中止時と同様の処理か
|
|
123
|
+
break;
|
|
119
124
|
default:
|
|
120
125
|
}
|
|
121
126
|
yield repos.task.saveMany(tasks, { emitImmediately: true });
|
|
@@ -5,9 +5,17 @@ const moment = require("moment");
|
|
|
5
5
|
const factory = require("../../../factory");
|
|
6
6
|
function creatPayTransactionStartParams(params) {
|
|
7
7
|
var _a, _b, _c, _d;
|
|
8
|
-
|
|
8
|
+
let expires = moment(params.transaction.expires)
|
|
9
9
|
.add(1, 'month')
|
|
10
10
|
.toDate(); // 余裕を持って
|
|
11
|
+
// 実験的にPaymentDueに対応(2023-08-30~)
|
|
12
|
+
if (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.FaceToFace) {
|
|
13
|
+
if (params.object.paymentMethod.length === 0) {
|
|
14
|
+
expires = moment(params.transaction.expires)
|
|
15
|
+
.add(1, 'hour')
|
|
16
|
+
.toDate();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
11
19
|
const confirmationNumber = params.transaction.object.confirmationNumber;
|
|
12
20
|
const issuedThroughId = (_a = params.object.issuedThrough) === null || _a === void 0 ? void 0 : _a.id;
|
|
13
21
|
const accountId = (typeof params.accountId === 'string')
|
|
@@ -39,7 +47,9 @@ function creatPayTransactionStartParams(params) {
|
|
|
39
47
|
typeOf: params.paymentServiceType,
|
|
40
48
|
// 決済サービスIDを連携(2022-04-12~)
|
|
41
49
|
id: issuedThroughId,
|
|
42
|
-
paymentMethod: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ identifier: params.object.paymentMethod,
|
|
50
|
+
paymentMethod: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ identifier: params.object.paymentMethod,
|
|
51
|
+
// typeOf: params.object.paymentMethod, // identifierへ移行(2023-08-30~)
|
|
52
|
+
amount: params.object.amount, additionalProperty: (Array.isArray(params.object.additionalProperty)) ? params.object.additionalProperty : [] }, (typeof params.object.method === 'string') ? { method: params.object.method } : undefined), (typeof params.object.name === 'string') ? { name: params.object.name } : undefined), (typeof accountId === 'string') ? { accountId } : undefined), (typeof params.object.description === 'string') ? { description: params.object.description } : undefined), (typeof params.object.fromLocation === 'string') ? { fromLocation: params.object.fromLocation } : undefined), (params.object.creditCard !== undefined) ? { creditCard: params.object.creditCard } : undefined), (Array.isArray(movieTickets)) ? { movieTickets } : undefined)
|
|
43
53
|
}, expires: expires }, (typeof confirmationNumber === 'string')
|
|
44
54
|
? {
|
|
45
55
|
purpose: {
|
|
@@ -80,7 +90,7 @@ function createMovieTicket(params) {
|
|
|
80
90
|
};
|
|
81
91
|
}
|
|
82
92
|
function createAuthorizeResult(params) {
|
|
83
|
-
var _a, _b, _c, _d, _e, _f
|
|
93
|
+
var _a, _b, _c, _d, _e, _f;
|
|
84
94
|
const payTransactionObject = params.payTransaction.object;
|
|
85
95
|
const totalPaymentDue = (_a = payTransactionObject.paymentMethod) === null || _a === void 0 ? void 0 : _a.totalPaymentDue;
|
|
86
96
|
if (typeof (totalPaymentDue === null || totalPaymentDue === void 0 ? void 0 : totalPaymentDue.typeOf) !== 'string') {
|
|
@@ -116,10 +126,10 @@ function createAuthorizeResult(params) {
|
|
|
116
126
|
// paymentMethod: params.object.paymentMethod,
|
|
117
127
|
paymentMethodAsObject,
|
|
118
128
|
paymentStatus,
|
|
119
|
-
paymentMethodId: (typeof
|
|
120
|
-
? payTransactionObject.
|
|
129
|
+
paymentMethodId: (typeof payTransactionObject.paymentMethodId === 'string')
|
|
130
|
+
? payTransactionObject.paymentMethodId
|
|
121
131
|
: '',
|
|
122
|
-
name: (typeof ((
|
|
132
|
+
name: (typeof ((_f = payTransactionObject.paymentMethod) === null || _f === void 0 ? void 0 : _f.name) === 'string')
|
|
123
133
|
? payTransactionObject.paymentMethod.name
|
|
124
134
|
: params.object.paymentMethod,
|
|
125
135
|
totalPaymentDue: totalPaymentDue,
|
|
@@ -34,9 +34,9 @@ function authorize(params, paymentServiceId, searchTrade4accountId) {
|
|
|
34
34
|
exclusion: []
|
|
35
35
|
});
|
|
36
36
|
// CreditCard系統の決済方法タイプは動的
|
|
37
|
-
const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.
|
|
37
|
+
const paymentMethodType = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
38
38
|
if (typeof paymentMethodType !== 'string') {
|
|
39
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
39
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
40
40
|
}
|
|
41
41
|
const availableChannel = yield repos.product.findAvailableChannel({
|
|
42
42
|
project: params.project,
|
|
@@ -205,16 +205,16 @@ function handleAuthorizeError(error) {
|
|
|
205
205
|
*/
|
|
206
206
|
function voidTransaction(params) {
|
|
207
207
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
208
|
-
var _a, _b, _c, _d, _e, _f
|
|
208
|
+
var _a, _b, _c, _d, _e, _f;
|
|
209
209
|
const transaction = params.object;
|
|
210
210
|
// CreditCard系統の決済方法タイプは動的
|
|
211
|
-
const paymentMethodType = (_a = transaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.
|
|
211
|
+
const paymentMethodType = (_a = transaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
212
212
|
if (typeof paymentMethodType !== 'string') {
|
|
213
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
213
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
214
214
|
}
|
|
215
|
-
const paymentMethodId =
|
|
215
|
+
const paymentMethodId = transaction.object.paymentMethodId;
|
|
216
216
|
if (typeof paymentMethodId !== 'string') {
|
|
217
|
-
throw new factory.errors.ArgumentNull('object.
|
|
217
|
+
throw new factory.errors.ArgumentNull('object.paymentMethodId');
|
|
218
218
|
}
|
|
219
219
|
const paymentServiceId = String(transaction.object.id);
|
|
220
220
|
const availableChannel = yield repos.product.findAvailableChannel({
|
|
@@ -222,7 +222,7 @@ function voidTransaction(params) {
|
|
|
222
222
|
typeOf: factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
223
223
|
id: paymentServiceId
|
|
224
224
|
});
|
|
225
|
-
const sellerId = (
|
|
225
|
+
const sellerId = (_b = transaction.recipient) === null || _b === void 0 ? void 0 : _b.id;
|
|
226
226
|
if (typeof sellerId !== 'string') {
|
|
227
227
|
throw new factory.errors.ArgumentNull('object.recipient.id');
|
|
228
228
|
}
|
|
@@ -236,8 +236,8 @@ function voidTransaction(params) {
|
|
|
236
236
|
shopId: shopId,
|
|
237
237
|
shopPass: shopPass,
|
|
238
238
|
orderId: paymentMethodId,
|
|
239
|
-
siteId: (
|
|
240
|
-
sitePass: (
|
|
239
|
+
siteId: (_c = availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.siteId,
|
|
240
|
+
sitePass: (_d = availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.sitePass
|
|
241
241
|
});
|
|
242
242
|
debug('searchTradeResult:', searchTradeResult);
|
|
243
243
|
// 仮売上であれば取消
|
|
@@ -248,8 +248,8 @@ function voidTransaction(params) {
|
|
|
248
248
|
accessId: searchTradeResult.accessId,
|
|
249
249
|
accessPass: searchTradeResult.accessPass,
|
|
250
250
|
jobCd: GMO.utils.util.JobCd.Void,
|
|
251
|
-
siteId: (
|
|
252
|
-
sitePass: (
|
|
251
|
+
siteId: (_e = availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.siteId,
|
|
252
|
+
sitePass: (_f = availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.sitePass
|
|
253
253
|
});
|
|
254
254
|
debug('alterTran processed', alterTranResult);
|
|
255
255
|
}
|
|
@@ -39,9 +39,9 @@ function validateMovieTicket(params, paymentServiceId, useCheckMovieTicketBefore
|
|
|
39
39
|
throw new factory.errors.Argument('movieTickets', 'Number of movie ticket accessCodes must be 1');
|
|
40
40
|
}
|
|
41
41
|
// ムビチケ系統の決済方法タイプは動的
|
|
42
|
-
const paymentMethodType = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.
|
|
42
|
+
const paymentMethodType = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.identifier;
|
|
43
43
|
if (typeof paymentMethodType !== 'string') {
|
|
44
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
44
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
45
45
|
}
|
|
46
46
|
// イベント取得属性最適化(2023-01-23~)
|
|
47
47
|
const screeningEvent = yield repos.event.findMinimizedIndividualEventById({
|
|
@@ -122,11 +122,9 @@ function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBef
|
|
|
122
122
|
const validateMovieTicketResult = yield (0, validation_1.validateMovieTicket)(params, paymentServiceId, useCheckMovieTicketBeforePay, useCheckByIdentifierIfNotYet)(repos);
|
|
123
123
|
accountsReceivablesByServiceType = validateMovieTicketResult.accountsReceivablesByServiceType;
|
|
124
124
|
const paymentMethod = transaction.object.paymentMethod;
|
|
125
|
-
const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.
|
|
125
|
+
const paymentMethodType = String(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.identifier);
|
|
126
126
|
const additionalProperty = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.additionalProperty;
|
|
127
|
-
const paymentMethodId =
|
|
128
|
-
? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.paymentMethodId
|
|
129
|
-
: transaction.id;
|
|
127
|
+
const paymentMethodId = transaction.object.paymentMethodId;
|
|
130
128
|
const paymentMethodName = (typeof (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name) === 'string') ? paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.name : paymentMethodType;
|
|
131
129
|
accountId = (Array.isArray(paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets)) ? (_a = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.movieTickets[0]) === null || _a === void 0 ? void 0 : _a.identifier : undefined;
|
|
132
130
|
if (typeof accountId !== 'string' || accountId.length === 0) {
|
|
@@ -157,15 +155,16 @@ function authorize(params, transaction, paymentServiceId, useCheckMovieTicketBef
|
|
|
157
155
|
exports.authorize = authorize;
|
|
158
156
|
function voidTransaction(params) {
|
|
159
157
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
var _a, _b, _c
|
|
158
|
+
var _a, _b, _c;
|
|
161
159
|
const transaction = params.object;
|
|
162
|
-
const paymentMethodType = (_a = transaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.
|
|
160
|
+
const paymentMethodType = (_a = transaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
|
|
163
161
|
if (typeof paymentMethodType !== 'string') {
|
|
164
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
162
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
165
163
|
}
|
|
166
|
-
const paymentMethodId =
|
|
164
|
+
// const paymentMethodId = transaction.object.paymentMethod?.paymentMethodId;
|
|
165
|
+
const paymentMethodId = transaction.object.paymentMethodId;
|
|
167
166
|
if (typeof paymentMethodId !== 'string') {
|
|
168
|
-
throw new factory.errors.ArgumentNull('object.
|
|
167
|
+
throw new factory.errors.ArgumentNull('object.paymentMethodId');
|
|
169
168
|
}
|
|
170
169
|
// 決済開始時に着券していれば、取消
|
|
171
170
|
// 例えばtimeoutが原因でCompletedActionStatusでない場合、外部サービス側では着券済の可能性もあるので、そこを考慮する
|
|
@@ -192,14 +191,14 @@ function voidTransaction(params) {
|
|
|
192
191
|
paymentMethod: {
|
|
193
192
|
paymentMethodId: paymentMethodId,
|
|
194
193
|
typeOf: paymentMethodType,
|
|
195
|
-
name: (typeof ((
|
|
194
|
+
name: (typeof ((_b = transaction.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.name) === 'string')
|
|
196
195
|
? transaction.object.paymentMethod.name
|
|
197
196
|
: paymentMethodType,
|
|
198
197
|
additionalProperty: []
|
|
199
198
|
}
|
|
200
199
|
}], agent: {
|
|
201
200
|
id: seller.id,
|
|
202
|
-
name: (typeof seller.name === 'string') ? seller.name : String((
|
|
201
|
+
name: (typeof seller.name === 'string') ? seller.name : String((_c = seller.name) === null || _c === void 0 ? void 0 : _c.ja),
|
|
203
202
|
typeOf: seller.typeOf
|
|
204
203
|
}, recipient: transaction.recipient }, ((payAction === null || payAction === void 0 ? void 0 : payAction.purpose) !== undefined)
|
|
205
204
|
? { purpose: payAction.purpose }
|
|
@@ -68,7 +68,7 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
68
68
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
69
69
|
const serviceOutputIdentifier = (_a = params.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.accountId;
|
|
70
70
|
const amount = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.amount;
|
|
71
|
-
const paymentMethodType = (_c = params.object.paymentMethod) === null || _c === void 0 ? void 0 : _c.
|
|
71
|
+
const paymentMethodType = (_c = params.object.paymentMethod) === null || _c === void 0 ? void 0 : _c.identifier;
|
|
72
72
|
if (typeof serviceOutputIdentifier !== 'string') {
|
|
73
73
|
throw new factory.errors.ArgumentNull('object.paymentMethod.accountId');
|
|
74
74
|
}
|
|
@@ -76,7 +76,7 @@ function validatePaymentMethod(params, paymentServiceId) {
|
|
|
76
76
|
throw new factory.errors.ArgumentNull('object.paymentMethod.amount');
|
|
77
77
|
}
|
|
78
78
|
if (typeof paymentMethodType !== 'string') {
|
|
79
|
-
throw new factory.errors.ArgumentNull('object.paymentMethod.
|
|
79
|
+
throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
|
|
80
80
|
}
|
|
81
81
|
// プロダクトから通貨区分を取得
|
|
82
82
|
const paymentCatdProduct = yield repos.product.findById({ id: paymentServiceId }, ['serviceOutput'], []);
|
|
@@ -182,15 +182,12 @@ function processAccountTransaction(params) {
|
|
|
182
182
|
}
|
|
183
183
|
function voidTransaction(params) {
|
|
184
184
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
185
|
-
var _a, _b, _c
|
|
185
|
+
var _a, _b, _c;
|
|
186
186
|
const transaction = params.object;
|
|
187
|
-
// const
|
|
188
|
-
const paymentMethodId =
|
|
189
|
-
// if (typeof paymentMethodType !== 'string') {
|
|
190
|
-
// throw new factory.errors.ArgumentNull('object.paymentMethod.typeOf');
|
|
191
|
-
// }
|
|
187
|
+
// const paymentMethodId = transaction.object.paymentMethod?.paymentMethodId;
|
|
188
|
+
const paymentMethodId = transaction.object.paymentMethodId;
|
|
192
189
|
if (typeof paymentMethodId !== 'string') {
|
|
193
|
-
throw new factory.errors.ArgumentNull('object.
|
|
190
|
+
throw new factory.errors.ArgumentNull('object.paymentMethodId');
|
|
194
191
|
}
|
|
195
192
|
const paymentServiceId = String(transaction.object.id);
|
|
196
193
|
// アクションステータスに関係なく取消処理実行
|
|
@@ -204,9 +201,9 @@ function voidTransaction(params) {
|
|
|
204
201
|
const accountTransactionService = new pecorinoapi.service.AccountTransaction({
|
|
205
202
|
endpoint: String(availableChannel.serviceUrl),
|
|
206
203
|
auth: new pecorinoapi.auth.ClientCredentials({
|
|
207
|
-
domain: String((
|
|
208
|
-
clientId: String((
|
|
209
|
-
clientSecret: String((
|
|
204
|
+
domain: String((_a = availableChannel.credentials) === null || _a === void 0 ? void 0 : _a.authorizeServerDomain),
|
|
205
|
+
clientId: String((_b = availableChannel.credentials) === null || _b === void 0 ? void 0 : _b.clientId),
|
|
206
|
+
clientSecret: String((_c = availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.clientSecret),
|
|
210
207
|
scopes: [],
|
|
211
208
|
state: ''
|
|
212
209
|
})
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.327.0-alpha.
|
|
12
|
+
"@chevre/factory": "4.327.0-alpha.8",
|
|
13
13
|
"@cinerino/sdk": "3.165.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.8.0-alpha.
|
|
120
|
+
"version": "21.8.0-alpha.18"
|
|
121
121
|
}
|