@chevre/domain 23.1.0-alpha.15 → 23.1.0-alpha.16
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/project/unsetProjectSettings.ts +67 -0
- package/lib/chevre/service/assetTransaction/pay.d.ts +1 -0
- package/lib/chevre/service/assetTransaction/pay.js +1 -1
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +5 -0
- package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.js +18 -11
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +18 -1
- package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +67 -4
- package/lib/chevre/service/payment/any/factory.d.ts +13 -0
- package/lib/chevre/service/payment/any/factory.js +16 -6
- package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +4 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.js +15 -11
- package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.d.ts +6 -3
- package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +6 -3
- package/lib/chevre/service/payment/any.js +5 -5
- package/package.json +3 -3
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// tslint:disable-next-line:max-func-body-length
|
|
7
|
+
async function main() {
|
|
8
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
9
|
+
|
|
10
|
+
const projectRepo = await chevre.repository.Project.createInstance(mongoose.connection);
|
|
11
|
+
|
|
12
|
+
const cursor = projectRepo.getCursor(
|
|
13
|
+
{
|
|
14
|
+
_id: { $nin: ['ttts-development', 'sskts-development'] }
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
_id: 1,
|
|
18
|
+
settings: 1,
|
|
19
|
+
typeOf: 1
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
console.log('docs found');
|
|
23
|
+
|
|
24
|
+
let i = 0;
|
|
25
|
+
let updateCount = 0;
|
|
26
|
+
await cursor.eachAsync(async (doc) => {
|
|
27
|
+
i += 1;
|
|
28
|
+
const project: Pick<chevre.factory.project.IProject, 'id' | 'typeOf' | 'settings'> = doc.toObject();
|
|
29
|
+
|
|
30
|
+
console.log(
|
|
31
|
+
'alreadyMigrated?', project.id, i);
|
|
32
|
+
const includeCustomerAsFindByConfirmationNumberResult = project.settings?.includeCustomerAsFindByConfirmationNumberResult;
|
|
33
|
+
let alreadyMigrated = true;
|
|
34
|
+
if (typeof includeCustomerAsFindByConfirmationNumberResult === 'boolean'
|
|
35
|
+
&& includeCustomerAsFindByConfirmationNumberResult === true) {
|
|
36
|
+
alreadyMigrated = false;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (alreadyMigrated) {
|
|
40
|
+
console.log(
|
|
41
|
+
'already migrated.', project.id, i);
|
|
42
|
+
} else {
|
|
43
|
+
console.log(
|
|
44
|
+
'updating project...',
|
|
45
|
+
project.id, i);
|
|
46
|
+
await projectRepo.unsetUnnecessaryFields({
|
|
47
|
+
filter: {
|
|
48
|
+
_id: { $eq: project.id }
|
|
49
|
+
},
|
|
50
|
+
$unset: {
|
|
51
|
+
'settings.includeCustomerAsFindByConfirmationNumberResult': 1
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
updateCount += 1;
|
|
55
|
+
console.log(
|
|
56
|
+
'updated.',
|
|
57
|
+
project.id, i);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
console.log(i, 'docs checked');
|
|
62
|
+
console.log(updateCount, 'docs updated');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
main()
|
|
66
|
+
.then()
|
|
67
|
+
.catch(console.error);
|
|
@@ -78,6 +78,7 @@ export declare function publishPaymentUrl(params: Pick<factory.assetTransaction.
|
|
|
78
78
|
* add identifier for an unique index(2025-02-25~)
|
|
79
79
|
*/
|
|
80
80
|
identifier?: string;
|
|
81
|
+
instrument: factory.action.accept.pay.IInstrument[];
|
|
81
82
|
}, options: {
|
|
82
83
|
purposeAsTransaction: {
|
|
83
84
|
id: string;
|
|
@@ -84,7 +84,7 @@ function publishPaymentUrl(params, options) {
|
|
|
84
84
|
object: params.object,
|
|
85
85
|
transactionNumber,
|
|
86
86
|
typeOf: params.typeOf
|
|
87
|
-
}, purpose: { typeOf: factory.transactionType.PlaceOrder, id: options.purposeAsTransaction.id } }, (typeof taskId === 'string')
|
|
87
|
+
}, purpose: { typeOf: factory.transactionType.PlaceOrder, id: options.purposeAsTransaction.id }, instrument: (Array.isArray(params.instrument)) ? params.instrument : [] }, (typeof taskId === 'string')
|
|
88
88
|
? { sameAs: { id: taskId, typeOf: 'Task' } } // タスク関連付け(2024-05-22~)
|
|
89
89
|
: undefined), (typeof ((_d = params.location) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string')
|
|
90
90
|
? { location: params.location }
|
|
@@ -5,6 +5,7 @@ import type { TicketRepo } from '../../../../repo/ticket';
|
|
|
5
5
|
import type { ITransactionInProgress, TransactionRepo } from '../../../../repo/transaction';
|
|
6
6
|
import type { TransactionNumberRepo } from '../../../../repo/transactionNumber';
|
|
7
7
|
import * as PayTransactionService from '../../../assetTransaction/pay';
|
|
8
|
+
import { IInvoiceByTicketToken } from '../factory';
|
|
8
9
|
interface IFixTransactionNumberRepos {
|
|
9
10
|
action: ActionRepo;
|
|
10
11
|
authorization: AuthorizationRepo;
|
|
@@ -27,6 +28,10 @@ declare function fixTransactionNumber(params: {
|
|
|
27
28
|
transactionNumber: string;
|
|
28
29
|
pendingPaymentAgencyTransaction?: PayTransactionService.IPaymentAgencyTransaction;
|
|
29
30
|
creditCard?: factory.action.authorize.paymentMethod.any.ICreditCard;
|
|
31
|
+
/**
|
|
32
|
+
* 承認時に指定のチケット、あるいは、決済採用時に指定のチケット
|
|
33
|
+
*/
|
|
34
|
+
invoiceByTicketToken?: IInvoiceByTicketToken;
|
|
30
35
|
permitOrInvoice?: never;
|
|
31
36
|
id?: never;
|
|
32
37
|
} | {
|
|
@@ -18,13 +18,15 @@ const handlePrePublishedPaymentMethodIdOnAuthorizing_1 = require("./handlePrePub
|
|
|
18
18
|
*/
|
|
19
19
|
function fixTransactionNumber(params) {
|
|
20
20
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
var _a, _b, _c, _d, _e, _f;
|
|
21
22
|
const { paymentServiceType, transaction, object } = params;
|
|
22
23
|
// 取引番号生成
|
|
23
24
|
let transactionNumber;
|
|
24
25
|
let pendingPaymentAgencyTransaction;
|
|
25
26
|
let creditCard = object.creditCard;
|
|
27
|
+
let invoiceByTicketToken;
|
|
26
28
|
// ticketTokenを解釈(2024-08-13~)
|
|
27
|
-
const {
|
|
29
|
+
const { verifyPaymentMethodTicketResult } = yield (0, verifyTicketTokenAsNeeded_1.verifyTicketTokenAsNeeded)({
|
|
28
30
|
project: { id: transaction.project.id },
|
|
29
31
|
object: object,
|
|
30
32
|
paymentServiceType,
|
|
@@ -34,18 +36,20 @@ function fixTransactionNumber(params) {
|
|
|
34
36
|
* ticketTokenによって指定された決済方法ID
|
|
35
37
|
*/
|
|
36
38
|
let paymentMethodIdByTicketToken;
|
|
37
|
-
if ((
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
if (((_a = verifyPaymentMethodTicketResult === null || verifyPaymentMethodTicketResult === void 0 ? void 0 : verifyPaymentMethodTicketResult.invoiceByTicketToken) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.permit.PermitType.Permit) {
|
|
40
|
+
throw new factory.errors.Argument('ticketToken', `typeOfGood.typeOf ${(_b = verifyPaymentMethodTicketResult === null || verifyPaymentMethodTicketResult === void 0 ? void 0 : verifyPaymentMethodTicketResult.invoiceByTicketToken) === null || _b === void 0 ? void 0 : _b.typeOf} discontinued`);
|
|
41
|
+
// paymentMethodIdByTicketToken = permitOrInvoice?.identifier;
|
|
42
|
+
// if (typeof paymentMethodIdByTicketToken === 'string') {
|
|
43
|
+
// transactionNumber = paymentMethodIdByTicketToken; // メンバーシップ指定の場合、取引番号に適用(2024-08-13~)
|
|
44
|
+
// }
|
|
42
45
|
}
|
|
43
|
-
else if ((
|
|
46
|
+
else if (((_c = verifyPaymentMethodTicketResult === null || verifyPaymentMethodTicketResult === void 0 ? void 0 : verifyPaymentMethodTicketResult.invoiceByTicketToken) === null || _c === void 0 ? void 0 : _c.typeOf) === 'Invoice') {
|
|
44
47
|
// support paymentServiceType.MovieTicket(2024-11-23~)
|
|
45
|
-
if (typeof (
|
|
46
|
-
paymentMethodIdByTicketToken =
|
|
48
|
+
if (typeof ((_d = verifyPaymentMethodTicketResult.invoiceByTicketToken) === null || _d === void 0 ? void 0 : _d.paymentMethodId) === 'string') {
|
|
49
|
+
paymentMethodIdByTicketToken = (_e = verifyPaymentMethodTicketResult.invoiceByTicketToken) === null || _e === void 0 ? void 0 : _e.paymentMethodId;
|
|
47
50
|
if (typeof paymentMethodIdByTicketToken === 'string') {
|
|
48
51
|
transactionNumber = paymentMethodIdByTicketToken;
|
|
52
|
+
invoiceByTicketToken = verifyPaymentMethodTicketResult.invoiceByTicketToken;
|
|
49
53
|
}
|
|
50
54
|
}
|
|
51
55
|
}
|
|
@@ -63,14 +67,17 @@ function fixTransactionNumber(params) {
|
|
|
63
67
|
transaction
|
|
64
68
|
})(repos);
|
|
65
69
|
if (existingCompletedAuthorizeAction !== undefined) {
|
|
70
|
+
// 既に承認済であれば何もしない
|
|
66
71
|
return { id: existingCompletedAuthorizeAction.id };
|
|
67
72
|
}
|
|
68
73
|
else if (authorizeParams !== undefined) {
|
|
69
74
|
// creditCardを決済URL発行時の情報で上書き(2024-01-08~)
|
|
70
|
-
// creditCard = authorizeParams.paymentMethodByTransaction.paymentMethod?.creditCard;
|
|
71
75
|
creditCard = authorizeParams.creditCard;
|
|
72
76
|
transactionNumber = object.paymentMethodId;
|
|
73
77
|
pendingPaymentAgencyTransaction = authorizeParams.pendingPaymentAgencyTransaction;
|
|
78
|
+
if (typeof ((_f = authorizeParams.acceptAction2ticketResult) === null || _f === void 0 ? void 0 : _f.ticketToken) === 'string') {
|
|
79
|
+
invoiceByTicketToken = authorizeParams.acceptAction2ticketResult.invoiceByTicketToken;
|
|
80
|
+
}
|
|
74
81
|
}
|
|
75
82
|
else {
|
|
76
83
|
throw new factory.errors.NotImplemented('pendingPaymentAgencyTransaction required on paymentMethodId specified');
|
|
@@ -81,7 +88,7 @@ function fixTransactionNumber(params) {
|
|
|
81
88
|
const publishTransactionNumberResult = yield repos.transactionNumber.publishByTimestamp({ startDate: new Date() });
|
|
82
89
|
transactionNumber = publishTransactionNumberResult.transactionNumber;
|
|
83
90
|
}
|
|
84
|
-
return Object.assign(Object.assign({ transactionNumber }, (pendingPaymentAgencyTransaction !== undefined) ? { pendingPaymentAgencyTransaction } : undefined), (creditCard !== undefined) ? { creditCard } : undefined
|
|
91
|
+
return Object.assign(Object.assign(Object.assign({ transactionNumber }, (pendingPaymentAgencyTransaction !== undefined) ? { pendingPaymentAgencyTransaction } : undefined), (creditCard !== undefined) ? { creditCard } : undefined), (invoiceByTicketToken !== undefined) ? { invoiceByTicketToken } : undefined
|
|
85
92
|
// ...(permitOrInvoice !== undefined) ? { permitOrInvoice } : undefined
|
|
86
93
|
);
|
|
87
94
|
});
|
package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts
CHANGED
|
@@ -1,23 +1,40 @@
|
|
|
1
1
|
import * as factory from '../../../../factory';
|
|
2
2
|
import type { ActionRepo } from '../../../../repo/action';
|
|
3
|
+
import type { AuthorizationRepo } from '../../../../repo/authorization';
|
|
4
|
+
import type { TicketRepo } from '../../../../repo/ticket';
|
|
3
5
|
import type { ITransactionInProgress, TransactionRepo } from '../../../../repo/transaction';
|
|
4
6
|
import * as PayTransactionService from '../../../assetTransaction/pay';
|
|
7
|
+
import type { IInvoiceByTicketToken } from '../factory';
|
|
5
8
|
type IObjectWithoutDetail = factory.action.authorize.paymentMethod.any.IObjectWithoutDetail;
|
|
9
|
+
interface IAcceptAction2ticketResult {
|
|
10
|
+
invoiceByTicketToken: IInvoiceByTicketToken;
|
|
11
|
+
ticketToken: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 決済承認前の決済採用アクションを参照する
|
|
15
|
+
*/
|
|
6
16
|
declare function handlePrePublishedPaymentMethodIdOnAuthorizing(params: {
|
|
7
17
|
object: Pick<IObjectWithoutDetail, 'amount' | 'issuedThrough' | 'paymentMethod'>;
|
|
8
18
|
prePublishedPaymentMethodId: string;
|
|
9
19
|
transaction: Pick<ITransactionInProgress<factory.transactionType.PlaceOrder>, 'agent' | 'expires' | 'id' | 'typeOf' | 'project' | 'seller'>;
|
|
10
20
|
}): (repos: {
|
|
11
21
|
action: ActionRepo;
|
|
22
|
+
authorization: AuthorizationRepo;
|
|
23
|
+
ticket: TicketRepo;
|
|
12
24
|
transaction: TransactionRepo;
|
|
13
25
|
}) => Promise<{
|
|
14
26
|
authorizeParams?: {
|
|
15
27
|
creditCard: factory.action.authorize.paymentMethod.any.ICreditCard;
|
|
16
28
|
paymentMethodByTransaction: factory.transaction.placeOrder.IPaymentMethodByPaymentUrl;
|
|
17
29
|
pendingPaymentAgencyTransaction: PayTransactionService.IPaymentAgencyTransaction;
|
|
30
|
+
acceptAction2ticketResult?: IAcceptAction2ticketResult;
|
|
18
31
|
};
|
|
19
|
-
existingCompletedAuthorizeAction?:
|
|
32
|
+
existingCompletedAuthorizeAction?: never;
|
|
33
|
+
} | {
|
|
34
|
+
existingCompletedAuthorizeAction: {
|
|
20
35
|
id: string;
|
|
21
36
|
};
|
|
37
|
+
authorizeParams?: never;
|
|
38
|
+
acceptAction2ticketResult?: never;
|
|
22
39
|
}>;
|
|
23
40
|
export { handlePrePublishedPaymentMethodIdOnAuthorizing };
|
package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js
CHANGED
|
@@ -47,17 +47,73 @@ function recipe2paymentAgencyTransaction(actionRecipe) {
|
|
|
47
47
|
}
|
|
48
48
|
return { entryTranArgs, entryTranResult, execTranArgs, execTranResult };
|
|
49
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* 決済採用アクションから決済方法チケットを参照する
|
|
52
|
+
*/
|
|
53
|
+
function acceptAction2ticket(params) {
|
|
54
|
+
// tslint:disable-next-line:cyclomatic-complexity
|
|
55
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
const { acceptPayAction, project } = params;
|
|
58
|
+
const ticketToken = (_b = (_a = acceptPayAction.instrument) === null || _a === void 0 ? void 0 : _a.find((ticketAsInstrument) => ticketAsInstrument.typeOf === 'Ticket')) === null || _b === void 0 ? void 0 : _b.ticketToken;
|
|
59
|
+
let acceptAction2ticketResult;
|
|
60
|
+
if (typeof ticketToken === 'string' && ticketToken !== '') {
|
|
61
|
+
const ticket = (yield repos.ticket.projectFields({
|
|
62
|
+
limit: 1,
|
|
63
|
+
page: 1,
|
|
64
|
+
project: { id: { $eq: project.id } },
|
|
65
|
+
ticketToken: { $eq: ticketToken }
|
|
66
|
+
}, ['ticketToken'])).shift();
|
|
67
|
+
if (ticket === undefined) {
|
|
68
|
+
throw new factory.errors.NotFound('Ticket');
|
|
69
|
+
}
|
|
70
|
+
// 承認を参照
|
|
71
|
+
const validAuthorization = yield repos.authorization.findValidOneByCode({
|
|
72
|
+
project: { id: params.project.id },
|
|
73
|
+
code: ticket.ticketToken
|
|
74
|
+
});
|
|
75
|
+
const authorizedObject = validAuthorization.object;
|
|
76
|
+
if (authorizedObject.typeOf === 'OwnershipInfo') {
|
|
77
|
+
const { typeOfGood } = authorizedObject;
|
|
78
|
+
if (typeOfGood.typeOf === factory.service.paymentService.PaymentServiceType.CreditCard
|
|
79
|
+
|| typeOfGood.typeOf === factory.service.paymentService.PaymentServiceType.MovieTicket
|
|
80
|
+
|| typeOfGood.typeOf === factory.service.paymentService.PaymentServiceType.FaceToFace) {
|
|
81
|
+
if (acceptPayAction.object.transactionNumber !== typeOfGood.serviceOutput.paymentMethodId) {
|
|
82
|
+
// 念のため決済方法IDの一致検証
|
|
83
|
+
throw new factory.errors.Internal('acceptPayAction.object.transactionNumber must be the same as typeOfGood.serviceOutput.paymentMethodId');
|
|
84
|
+
}
|
|
85
|
+
acceptAction2ticketResult = {
|
|
86
|
+
invoiceByTicketToken: typeOfGood.serviceOutput,
|
|
87
|
+
ticketToken
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
throw new factory.errors.Argument('ticketToken', `invalid typeOfGood.typeOf ${typeOfGood.typeOf}`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
throw new factory.errors.Argument('ticketToken', 'must be OwnershipInfo');
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return { acceptAction2ticketResult };
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* 決済承認前の決済採用アクションを参照する
|
|
103
|
+
*/
|
|
104
|
+
// tslint:disable-next-line:max-func-body-length
|
|
50
105
|
function handlePrePublishedPaymentMethodIdOnAuthorizing(params) {
|
|
51
106
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
52
107
|
let creditCard;
|
|
53
108
|
let pendingPaymentAgencyTransaction;
|
|
54
109
|
let existingCompletedAuthorizeAction;
|
|
110
|
+
let acceptPayAction;
|
|
55
111
|
// transaction.objectへのアクセス回避(2024-05-30~)
|
|
56
112
|
// const paymentMethodByTransaction = transaction.object.paymentMethods;
|
|
57
113
|
const paymentMethodByTransaction = yield repos.transaction.findInProgressPaymentMethodId({ id: params.transaction.id });
|
|
58
114
|
if (params.prePublishedPaymentMethodId === (paymentMethodByTransaction === null || paymentMethodByTransaction === void 0 ? void 0 : paymentMethodByTransaction.paymentMethodId)) {
|
|
59
115
|
// check existence of acceptAction when authorizing payment(2024-06-01~)
|
|
60
|
-
|
|
116
|
+
acceptPayAction = (yield repos.action.search({
|
|
61
117
|
limit: 1,
|
|
62
118
|
page: 1,
|
|
63
119
|
project: { id: { $eq: params.transaction.project.id } },
|
|
@@ -68,7 +124,7 @@ function handlePrePublishedPaymentMethodIdOnAuthorizing(params) {
|
|
|
68
124
|
transactionNumber: { $eq: params.prePublishedPaymentMethodId },
|
|
69
125
|
typeOf: { $eq: factory.assetTransactionType.Pay }
|
|
70
126
|
}
|
|
71
|
-
}, ['object', 'result'])).shift();
|
|
127
|
+
}, ['object', 'result', 'instrument'])).shift();
|
|
72
128
|
if (acceptPayAction === undefined) {
|
|
73
129
|
throw new factory.errors.NotFound(factory.actionType.AcceptAction);
|
|
74
130
|
}
|
|
@@ -113,10 +169,17 @@ function handlePrePublishedPaymentMethodIdOnAuthorizing(params) {
|
|
|
113
169
|
});
|
|
114
170
|
existingCompletedAuthorizeAction = existingCompletedAuthorizeActions.shift();
|
|
115
171
|
if (existingCompletedAuthorizeAction !== undefined) {
|
|
116
|
-
return {
|
|
172
|
+
return {
|
|
173
|
+
existingCompletedAuthorizeAction: { id: existingCompletedAuthorizeAction.id }
|
|
174
|
+
};
|
|
117
175
|
}
|
|
176
|
+
// 採用アクションのinstrumentから、決済方法チケットを参照する(2025-11-23~)
|
|
177
|
+
const { acceptAction2ticketResult } = yield acceptAction2ticket({
|
|
178
|
+
project: { id: params.transaction.project.id },
|
|
179
|
+
acceptPayAction
|
|
180
|
+
})(repos);
|
|
118
181
|
return {
|
|
119
|
-
authorizeParams: { creditCard, pendingPaymentAgencyTransaction, paymentMethodByTransaction }
|
|
182
|
+
authorizeParams: { creditCard, pendingPaymentAgencyTransaction, paymentMethodByTransaction, acceptAction2ticketResult }
|
|
120
183
|
};
|
|
121
184
|
}
|
|
122
185
|
else {
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
|
+
/**
|
|
3
|
+
* 決済方法チケットによって表現された請求情報
|
|
4
|
+
*/
|
|
5
|
+
export type IInvoiceByTicketToken = factory.authorization.IInvoiceAsPaymentMethodServiceOutput;
|
|
2
6
|
export type INotification = factory.notification.payAction.IPayAction4inform | factory.notification.refundAction.IRefundAction4inform;
|
|
3
7
|
export declare function creatPublishPaymentUrlParams(params: {
|
|
4
8
|
accountId?: string;
|
|
@@ -8,9 +12,14 @@ export declare function creatPublishPaymentUrlParams(params: {
|
|
|
8
12
|
transactionNumber: string;
|
|
9
13
|
location?: factory.action.trade.pay.ILocation;
|
|
10
14
|
identifier?: string;
|
|
15
|
+
/**
|
|
16
|
+
* 決済採用に使用される決済方法チケットトークン
|
|
17
|
+
*/
|
|
18
|
+
ticketToken?: string;
|
|
11
19
|
}): Pick<factory.assetTransaction.pay.IStartParamsWithoutDetail, 'agent' | 'location' | 'project' | 'recipient' | 'transactionNumber' | 'typeOf'> & {
|
|
12
20
|
object: factory.action.accept.pay.IPayObject;
|
|
13
21
|
identifier?: string;
|
|
22
|
+
instrument: factory.action.accept.pay.IInstrument[];
|
|
14
23
|
};
|
|
15
24
|
export declare function creatPayTransactionStartParams(params: {
|
|
16
25
|
accountId?: string;
|
|
@@ -34,6 +43,10 @@ export declare function createMovieTicket(params: factory.action.trade.pay.IMovi
|
|
|
34
43
|
export declare function createAuthorizeResult(params: {
|
|
35
44
|
object: factory.action.authorize.paymentMethod.any.IObjectIncludingPaymentMethodDetails;
|
|
36
45
|
payTransaction: Pick<factory.assetTransaction.pay.ITransaction, 'object'>;
|
|
46
|
+
/**
|
|
47
|
+
* 決済方法チケットの承認対象が必要(請求の関連注文情報の含むため)
|
|
48
|
+
*/
|
|
49
|
+
invoiceByTicketToken?: IInvoiceByTicketToken;
|
|
37
50
|
}): factory.action.authorize.paymentMethod.any.IResult;
|
|
38
51
|
/**
|
|
39
52
|
* 通知対象としてのアクションを最適化
|
|
@@ -24,7 +24,8 @@ function creatPublishPaymentUrlParams(params) {
|
|
|
24
24
|
id: issuedThroughId,
|
|
25
25
|
paymentMethod
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
const ticketAsInstrument = (typeof params.ticketToken === 'string') ? { ticketToken: params.ticketToken, typeOf: 'Ticket' } : undefined;
|
|
28
|
+
return Object.assign(Object.assign(Object.assign({ project: { id: params.transaction.project.id, typeOf: factory.organizationType.Project }, typeOf: factory.assetTransactionType.Pay, transactionNumber: params.transactionNumber, agent: {
|
|
28
29
|
typeOf: params.transaction.seller.typeOf,
|
|
29
30
|
id: params.transaction.seller.id,
|
|
30
31
|
name: (typeof params.transaction.seller.name === 'string')
|
|
@@ -38,7 +39,7 @@ function creatPublishPaymentUrlParams(params) {
|
|
|
38
39
|
typeOf: params.transaction.seller.typeOf
|
|
39
40
|
}, object }, (typeof ((_d = params.location) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string')
|
|
40
41
|
? { location: params.location }
|
|
41
|
-
: undefined), (typeof params.identifier === 'string')
|
|
42
|
+
: undefined), { instrument: (ticketAsInstrument !== undefined) ? [ticketAsInstrument] : [] }), (typeof params.identifier === 'string')
|
|
42
43
|
? { identifier: params.identifier }
|
|
43
44
|
: undefined);
|
|
44
45
|
}
|
|
@@ -131,7 +132,8 @@ function createMovieTicket(params) {
|
|
|
131
132
|
};
|
|
132
133
|
}
|
|
133
134
|
function createAuthorizeResult(params) {
|
|
134
|
-
var _a, _b, _c, _d, _e, _f;
|
|
135
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
136
|
+
const { invoiceByTicketToken } = params;
|
|
135
137
|
const payTransactionObject = params.payTransaction.object;
|
|
136
138
|
const totalPaymentDue = (_a = payTransactionObject.paymentMethod) === null || _a === void 0 ? void 0 : _a.totalPaymentDue;
|
|
137
139
|
if (typeof (totalPaymentDue === null || totalPaymentDue === void 0 ? void 0 : totalPaymentDue.typeOf) !== 'string') {
|
|
@@ -156,9 +158,16 @@ function createAuthorizeResult(params) {
|
|
|
156
158
|
paymentStatus = factory.paymentStatusType.PaymentDue;
|
|
157
159
|
}
|
|
158
160
|
}
|
|
161
|
+
let invoiceOrderItems;
|
|
162
|
+
if (typeof (invoiceByTicketToken === null || invoiceByTicketToken === void 0 ? void 0 : invoiceByTicketToken.paymentMethodId) === 'string') {
|
|
163
|
+
if (Array.isArray((_e = invoiceByTicketToken.referencesOrder) === null || _e === void 0 ? void 0 : _e.orderedItem)) {
|
|
164
|
+
invoiceOrderItems = invoiceByTicketToken.referencesOrder.orderedItem;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
const referencesOrder = Object.assign({ typeOf: factory.order.OrderType.Order }, (Array.isArray(invoiceOrderItems) && invoiceOrderItems.length > 0) ? { orderedItem: invoiceOrderItems } : undefined);
|
|
159
168
|
// Array対応(2023-09-02~)
|
|
160
169
|
const resultAsInvoice = {
|
|
161
|
-
accountId: (typeof ((
|
|
170
|
+
accountId: (typeof ((_f = payTransactionObject.paymentMethod) === null || _f === void 0 ? void 0 : _f.accountId) === 'string')
|
|
162
171
|
? payTransactionObject.paymentMethod.accountId
|
|
163
172
|
: '',
|
|
164
173
|
issuedThrough,
|
|
@@ -169,12 +178,13 @@ function createAuthorizeResult(params) {
|
|
|
169
178
|
paymentMethodId: (typeof payTransactionObject.paymentMethodId === 'string')
|
|
170
179
|
? payTransactionObject.paymentMethodId
|
|
171
180
|
: '',
|
|
172
|
-
name: (typeof ((
|
|
181
|
+
name: (typeof ((_g = payTransactionObject.paymentMethod) === null || _g === void 0 ? void 0 : _g.name) === 'string')
|
|
173
182
|
? payTransactionObject.paymentMethod.name
|
|
174
183
|
: params.object.paymentMethod,
|
|
175
184
|
totalPaymentDue: totalPaymentDue,
|
|
176
185
|
additionalProperty: (Array.isArray(params.object.additionalProperty)) ? params.object.additionalProperty : [],
|
|
177
|
-
typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment
|
|
186
|
+
typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment,
|
|
187
|
+
referencesOrder // add(2025-11-23~)
|
|
178
188
|
};
|
|
179
189
|
// tslint:disable-next-line:no-suspicious-comment
|
|
180
190
|
// TODO 保留 resultにメンバーシップを追加(2024-08-13~)
|
|
@@ -21,5 +21,9 @@ declare function fixTransactionNumberOnPublishPaymentUrl(params: {
|
|
|
21
21
|
paymentServiceType: factory.service.paymentService.PaymentServiceType;
|
|
22
22
|
}): IFixTransactionNumberOperation<{
|
|
23
23
|
transactionNumber: string;
|
|
24
|
+
/**
|
|
25
|
+
* 決済採用に使用される決済方法チケットトークン
|
|
26
|
+
*/
|
|
27
|
+
ticketToken?: string;
|
|
24
28
|
}>;
|
|
25
29
|
export { fixTransactionNumberOnPublishPaymentUrl };
|
package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.js
CHANGED
|
@@ -17,26 +17,30 @@ const verifyTicketTokenAsNeeded_1 = require("../verifyTicketTokenAsNeeded");
|
|
|
17
17
|
*/
|
|
18
18
|
function fixTransactionNumberOnPublishPaymentUrl(params) {
|
|
19
19
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
var _a, _b, _c, _d;
|
|
20
21
|
const { paymentServiceType, transaction, object } = params;
|
|
21
22
|
// 取引番号生成
|
|
22
23
|
let transactionNumber;
|
|
24
|
+
let ticketToken;
|
|
23
25
|
// support ticketToken(2024-08-21~)
|
|
24
|
-
const {
|
|
26
|
+
const { verifyPaymentMethodTicketResult } = yield (0, verifyTicketTokenAsNeeded_1.verifyTicketTokenAsNeeded)({
|
|
25
27
|
project: { id: transaction.project.id },
|
|
26
28
|
object,
|
|
27
29
|
paymentServiceType,
|
|
28
30
|
purpose: { id: transaction.id }
|
|
29
31
|
})(repos);
|
|
30
|
-
if ((
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
if (((_a = verifyPaymentMethodTicketResult === null || verifyPaymentMethodTicketResult === void 0 ? void 0 : verifyPaymentMethodTicketResult.invoiceByTicketToken) === null || _a === void 0 ? void 0 : _a.typeOf) === factory.permit.PermitType.Permit) {
|
|
33
|
+
throw new factory.errors.Argument('ticketToken', `typeOfGood.typeOf ${(_b = verifyPaymentMethodTicketResult === null || verifyPaymentMethodTicketResult === void 0 ? void 0 : verifyPaymentMethodTicketResult.invoiceByTicketToken) === null || _b === void 0 ? void 0 : _b.typeOf} discontinued`);
|
|
34
|
+
// const paymentMethodIdByPermit = permitOrInvoice?.identifier;
|
|
35
|
+
// if (typeof paymentMethodIdByPermit === 'string') {
|
|
36
|
+
// transactionNumber = paymentMethodIdByPermit;
|
|
37
|
+
// }
|
|
35
38
|
}
|
|
36
|
-
else if ((
|
|
39
|
+
else if (((_c = verifyPaymentMethodTicketResult === null || verifyPaymentMethodTicketResult === void 0 ? void 0 : verifyPaymentMethodTicketResult.invoiceByTicketToken) === null || _c === void 0 ? void 0 : _c.typeOf) === 'Invoice') {
|
|
37
40
|
// support Invoice ticket(2025-11-09~)
|
|
38
|
-
if (typeof (
|
|
39
|
-
transactionNumber =
|
|
41
|
+
if (typeof ((_d = verifyPaymentMethodTicketResult.invoiceByTicketToken) === null || _d === void 0 ? void 0 : _d.paymentMethodId) === 'string') {
|
|
42
|
+
transactionNumber = verifyPaymentMethodTicketResult.invoiceByTicketToken.paymentMethodId;
|
|
43
|
+
ticketToken = verifyPaymentMethodTicketResult.ticketToken;
|
|
40
44
|
}
|
|
41
45
|
}
|
|
42
46
|
if (typeof transactionNumber !== 'string') {
|
|
@@ -44,8 +48,8 @@ function fixTransactionNumberOnPublishPaymentUrl(params) {
|
|
|
44
48
|
transactionNumber = publishTransactionNumberResult.transactionNumber;
|
|
45
49
|
}
|
|
46
50
|
return {
|
|
47
|
-
transactionNumber
|
|
48
|
-
|
|
51
|
+
transactionNumber,
|
|
52
|
+
ticketToken
|
|
49
53
|
};
|
|
50
54
|
});
|
|
51
55
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as factory from '../../../factory';
|
|
2
2
|
import type { AuthorizationRepo } from '../../../repo/authorization';
|
|
3
3
|
import type { TicketRepo } from '../../../repo/ticket';
|
|
4
|
-
type
|
|
4
|
+
import type { IInvoiceByTicketToken } from './factory';
|
|
5
5
|
declare function verifyTicketTokenAsNeeded(params: {
|
|
6
6
|
project: {
|
|
7
7
|
id: string;
|
|
@@ -13,6 +13,9 @@ declare function verifyTicketTokenAsNeeded(params: {
|
|
|
13
13
|
authorization: AuthorizationRepo;
|
|
14
14
|
ticket: TicketRepo;
|
|
15
15
|
}) => Promise<{
|
|
16
|
-
|
|
16
|
+
verifyPaymentMethodTicketResult?: {
|
|
17
|
+
invoiceByTicketToken: IInvoiceByTicketToken;
|
|
18
|
+
ticketToken: string;
|
|
19
|
+
};
|
|
17
20
|
}>;
|
|
18
|
-
export {
|
|
21
|
+
export { verifyTicketTokenAsNeeded };
|
|
@@ -18,7 +18,7 @@ function verifyTicketTokenAsNeeded(params) {
|
|
|
18
18
|
var _a;
|
|
19
19
|
const { paymentServiceType, object, project } = params;
|
|
20
20
|
const { issuedThrough, ticketToken } = object;
|
|
21
|
-
let
|
|
21
|
+
let verifyPaymentMethodTicketResult;
|
|
22
22
|
// メンバーシップチケットが指定された場合、メンバーシップコードへ変換する
|
|
23
23
|
if (typeof ticketToken === 'string' && ticketToken !== '') {
|
|
24
24
|
switch (paymentServiceType) {
|
|
@@ -64,7 +64,10 @@ function verifyTicketTokenAsNeeded(params) {
|
|
|
64
64
|
throw new factory.errors.Argument('ticketToken', 'issuedThrough.id not matched');
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
verifyPaymentMethodTicketResult = {
|
|
68
|
+
invoiceByTicketToken: { paymentMethodId: typeOfGood.serviceOutput.paymentMethodId, typeOf: 'Invoice' },
|
|
69
|
+
ticketToken
|
|
70
|
+
};
|
|
68
71
|
}
|
|
69
72
|
else {
|
|
70
73
|
throw new factory.errors.Argument('ticketToken', `invalid typeOfGood.typeOf ${typeOfGood.typeOf}`);
|
|
@@ -79,6 +82,6 @@ function verifyTicketTokenAsNeeded(params) {
|
|
|
79
82
|
throw new factory.errors.NotImplemented(`ticketToken issued through ${paymentServiceType} not implemented`);
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
|
-
return {
|
|
85
|
+
return { verifyPaymentMethodTicketResult };
|
|
83
86
|
});
|
|
84
87
|
}
|
|
@@ -340,7 +340,7 @@ function publishPaymentUrl(params) {
|
|
|
340
340
|
object: { orderDate: new Date() }
|
|
341
341
|
})(repos);
|
|
342
342
|
// 取引番号生成
|
|
343
|
-
const { transactionNumber } = yield (0, fixTransactionNumberOnPublishPaymentUrl_1.fixTransactionNumberOnPublishPaymentUrl)({
|
|
343
|
+
const { transactionNumber, ticketToken } = yield (0, fixTransactionNumberOnPublishPaymentUrl_1.fixTransactionNumberOnPublishPaymentUrl)({
|
|
344
344
|
object: params.object,
|
|
345
345
|
transaction,
|
|
346
346
|
paymentServiceType
|
|
@@ -362,7 +362,7 @@ function publishPaymentUrl(params) {
|
|
|
362
362
|
let result;
|
|
363
363
|
// URL発行
|
|
364
364
|
const authorizeObject = Object.assign(Object.assign({}, params.object), { accountId: '', paymentMethodId: transactionNumber, typeOf: factory.action.authorize.paymentMethod.any.ResultType.Payment });
|
|
365
|
-
const startParams = (0, factory_1.creatPublishPaymentUrlParams)(Object.assign({ object: authorizeObject, paymentServiceType, transaction: transaction, transactionNumber: transactionNumber, location: params.location }, (typeof params.identifier === 'string') ? { identifier: params.identifier } : undefined));
|
|
365
|
+
const startParams = (0, factory_1.creatPublishPaymentUrlParams)(Object.assign(Object.assign({ object: authorizeObject, paymentServiceType, transaction: transaction, transactionNumber: transactionNumber, location: params.location }, (typeof params.identifier === 'string') ? { identifier: params.identifier } : undefined), (typeof ticketToken === 'string') ? { ticketToken } : undefined));
|
|
366
366
|
const taskId = (_a = params.sameAs) === null || _a === void 0 ? void 0 : _a.id;
|
|
367
367
|
result = yield PayTransactionService.publishPaymentUrl(startParams, {
|
|
368
368
|
purposeAsTransaction: { id: transaction.id },
|
|
@@ -439,7 +439,7 @@ function authorize(params) {
|
|
|
439
439
|
if (typeof fixTransactionNumberResult.id === 'string') {
|
|
440
440
|
return { id: fixTransactionNumberResult.id };
|
|
441
441
|
}
|
|
442
|
-
const { transactionNumber, pendingPaymentAgencyTransaction, creditCard } = fixTransactionNumberResult;
|
|
442
|
+
const { transactionNumber, pendingPaymentAgencyTransaction, creditCard, invoiceByTicketToken } = fixTransactionNumberResult;
|
|
443
443
|
// let transactionNumber: string | undefined;
|
|
444
444
|
// let pendingPaymentAgencyTransaction: PayTransactionService.IPaymentAgencyTransaction | undefined;
|
|
445
445
|
// let creditCard: factory.action.authorize.paymentMethod.any.ICreditCard | undefined = params.object.creditCard;
|
|
@@ -570,8 +570,8 @@ function authorize(params) {
|
|
|
570
570
|
}
|
|
571
571
|
const result = (0, factory_1.createAuthorizeResult)({
|
|
572
572
|
payTransaction,
|
|
573
|
-
object: authorizeObjectIncludingPaymentMethodDetails
|
|
574
|
-
|
|
573
|
+
object: authorizeObjectIncludingPaymentMethodDetails,
|
|
574
|
+
invoiceByTicketToken
|
|
575
575
|
});
|
|
576
576
|
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
577
577
|
return { id: action.id };
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "5.3.0-alpha.
|
|
15
|
-
"@cinerino/sdk": "12.9.0-alpha.
|
|
14
|
+
"@chevre/factory": "5.3.0-alpha.2",
|
|
15
|
+
"@cinerino/sdk": "12.9.0-alpha.1",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.4.0-alpha.1",
|
|
18
18
|
"@sendgrid/client": "8.1.4",
|
|
@@ -115,5 +115,5 @@
|
|
|
115
115
|
"postversion": "git push origin --tags",
|
|
116
116
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
117
117
|
},
|
|
118
|
-
"version": "23.1.0-alpha.
|
|
118
|
+
"version": "23.1.0-alpha.16"
|
|
119
119
|
}
|