@chevre/domain 21.20.0-alpha.1 → 21.20.0-alpha.10
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/retryTasks.ts +39 -0
- package/example/src/chevre/transaction/processPlaceOrder.ts +105 -63
- package/lib/chevre/repo/action.d.ts +3 -3
- package/lib/chevre/repo/action.js +4 -6
- package/lib/chevre/service/assetTransaction/pay.d.ts +0 -10
- package/lib/chevre/service/assetTransaction/pay.js +19 -17
- package/lib/chevre/service/code.js +1 -1
- package/lib/chevre/service/delivery.js +2 -2
- package/lib/chevre/service/event/createEvent.js +1 -1
- package/lib/chevre/service/event.js +2 -2
- package/lib/chevre/service/moneyTransfer.js +1 -1
- package/lib/chevre/service/notification.js +2 -5
- package/lib/chevre/service/offer/event/cancel.js +2 -1
- package/lib/chevre/service/offer/event/voidTransaction.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA.js +2 -2
- package/lib/chevre/service/offer/moneyTransfer/authorize.d.ts +6 -1
- package/lib/chevre/service/offer/moneyTransfer/authorize.js +2 -1
- package/lib/chevre/service/offer/moneyTransfer/returnMoneyTransfer.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/settleTransaction.js +1 -1
- package/lib/chevre/service/offer/moneyTransfer/voidTransaction.js +1 -1
- package/lib/chevre/service/offer/product.js +1 -1
- package/lib/chevre/service/order/confirmPayTransaction.js +2 -2
- package/lib/chevre/service/order/placeOrder.js +2 -2
- package/lib/chevre/service/order/returnOrder.js +1 -1
- package/lib/chevre/service/order/sendOrder.js +1 -1
- package/lib/chevre/service/payment/any.d.ts +6 -8
- package/lib/chevre/service/payment/any.js +46 -10
- package/lib/chevre/service/payment/creditCard.d.ts +11 -20
- package/lib/chevre/service/payment/creditCard.js +191 -178
- package/lib/chevre/service/payment/faceToFace.d.ts +0 -4
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket/checkByIdentifier.js +1 -0
- package/lib/chevre/service/payment/movieTicket/validation.d.ts +0 -2
- package/lib/chevre/service/payment/movieTicket.d.ts +0 -6
- package/lib/chevre/service/payment/movieTicket.js +1 -1
- package/lib/chevre/service/payment/paymentCard.d.ts +0 -2
- package/lib/chevre/service/payment/paymentCard.js +6 -6
- package/lib/chevre/service/payment.js +1 -1
- package/lib/chevre/service/product.js +1 -1
- package/lib/chevre/service/reserve/cancelReservation.js +2 -2
- package/lib/chevre/service/reserve/confirmReservation.js +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.d.ts +1 -1
- package/lib/chevre/service/reserve/potentialActions/onReservationUsed.js +4 -4
- package/lib/chevre/service/reserve/useReservation.d.ts +1 -2
- package/lib/chevre/service/reserve/useReservation.js +4 -4
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +1 -1
- package/lib/chevre/service/task/confirmReserveTransaction.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +7 -7
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
- package/lib/chevre/service/task/voidPayTransaction.js +2 -2
- package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
- package/lib/chevre/service/transaction/moneyTransfer.js +1 -1
- package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +32 -0
- package/lib/chevre/service/transaction/returnOrder/preStart.js +631 -0
- package/lib/chevre/service/transaction/returnOrder.d.ts +8 -6
- package/lib/chevre/service/transaction/returnOrder.js +4 -616
- package/package.json +4 -4
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
+
import { chevre } from '../../../lib/index';
|
|
3
|
+
|
|
4
|
+
import * as moment from 'moment';
|
|
5
|
+
import * as mongoose from 'mongoose';
|
|
6
|
+
|
|
7
|
+
const project = { id: String(process.env.PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
|
|
13
|
+
const result = await taskRepo.taskModel.updateMany(
|
|
14
|
+
{
|
|
15
|
+
status: { $eq: chevre.factory.taskStatus.Aborted },
|
|
16
|
+
lastTriedAt: {
|
|
17
|
+
$gt: moment()
|
|
18
|
+
.add(-1, 'day')
|
|
19
|
+
.toDate()
|
|
20
|
+
},
|
|
21
|
+
name: { $eq: chevre.factory.taskName.TriggerWebhook },
|
|
22
|
+
'project.id': { $eq: project.id }
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
$set: {
|
|
26
|
+
status: chevre.factory.taskStatus.Ready,
|
|
27
|
+
remainingNumberOfTries: 20
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
)
|
|
31
|
+
.exec();
|
|
32
|
+
console.log('result:', result);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
main()
|
|
36
|
+
.then(() => {
|
|
37
|
+
console.log('success!');
|
|
38
|
+
})
|
|
39
|
+
.catch(console.error);
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
// tslint:disable:no-console
|
|
2
2
|
import * as mongoose from 'mongoose';
|
|
3
|
+
import * as readline from 'readline';
|
|
3
4
|
import * as redis from 'redis';
|
|
4
5
|
|
|
5
6
|
import { chevre } from '../../../../lib/index';
|
|
6
7
|
|
|
7
8
|
const project = { id: String(process.env.PROJECT_ID) };
|
|
8
9
|
const CLIENT_ID = '51qbjcfr72h62m06vtv5kkhgje';
|
|
10
|
+
const paymentMethodType = 'CreditCard';
|
|
11
|
+
const paymentServiceId = '5f9a4fed4f3709000abe6415';
|
|
12
|
+
// const paymentMethodType = 'PayPay';
|
|
13
|
+
// const paymentServiceId = '60e9560176a391000b23e20b';
|
|
14
|
+
const AMOUNT: number = 1;
|
|
15
|
+
const creditCard: chevre.factory.paymentMethod.paymentCard.creditCard.IUncheckedCardRaw = {
|
|
16
|
+
cardNo: '4100000000000100',
|
|
17
|
+
expire: '2812',
|
|
18
|
+
cardPass: '123',
|
|
19
|
+
holderName: 'AA AA'
|
|
20
|
+
};
|
|
9
21
|
|
|
10
22
|
// tslint:disable-next-line:max-func-body-length
|
|
11
23
|
async function main() {
|
|
@@ -37,21 +49,14 @@ async function main() {
|
|
|
37
49
|
project: { id: project.id },
|
|
38
50
|
agent: { id: CLIENT_ID },
|
|
39
51
|
object: {
|
|
40
|
-
// accountId?: string;
|
|
41
|
-
// additionalProperty?: IPropertyValue<string>[];
|
|
42
|
-
amount: 1,
|
|
43
|
-
// description?: string;
|
|
44
|
-
// name?: string;
|
|
45
|
-
paymentMethod: 'PayPay',
|
|
46
|
-
// paymentMethodId?: string;
|
|
47
52
|
typeOf: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment,
|
|
48
|
-
|
|
53
|
+
amount: AMOUNT,
|
|
54
|
+
paymentMethod: paymentMethodType,
|
|
55
|
+
issuedThrough: { id: paymentServiceId },
|
|
49
56
|
method: '1',
|
|
50
57
|
creditCard: {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
cardPass: '123',
|
|
54
|
-
holderName: 'AA AA'
|
|
58
|
+
...creditCard,
|
|
59
|
+
retUrl: String(process.env.SECURE_TRAN_RET_URL)
|
|
55
60
|
}
|
|
56
61
|
},
|
|
57
62
|
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
@@ -60,70 +65,107 @@ async function main() {
|
|
|
60
65
|
typeOf: chevre.factory.creativeWorkType.WebApplication,
|
|
61
66
|
id: CLIENT_ID
|
|
62
67
|
}
|
|
63
|
-
// options: {
|
|
64
|
-
// use3DS: true
|
|
65
|
-
// }
|
|
66
68
|
})({
|
|
67
69
|
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
68
70
|
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
69
71
|
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
70
72
|
paymentServiceProvider: await chevre.repository.PaymentServiceProvider.createInstance(mongoose.connection),
|
|
71
73
|
person: await chevre.repository.Person.createInstance({ userPoolId: '' }),
|
|
72
|
-
project: await chevre.repository.Project.createInstance(mongoose.connection),
|
|
73
74
|
transactionNumber: await chevre.repository.TransactionNumber.createInstance(client),
|
|
74
75
|
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
75
76
|
});
|
|
76
77
|
console.log(publishPaymentUrlResult);
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
79
|
+
// wait callback...
|
|
80
|
+
// tslint:disable-next-line:max-func-body-length
|
|
81
|
+
await new Promise<void>((resolve, reject) => {
|
|
82
|
+
const rl = readline.createInterface({
|
|
83
|
+
input: process.stdin,
|
|
84
|
+
output: process.stdout
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// tslint:disable-next-line:max-func-body-length
|
|
88
|
+
rl.question('callback received?:\n', async () => {
|
|
89
|
+
try {
|
|
90
|
+
await new Promise<void>(async (resolve2, reject2) => {
|
|
91
|
+
const rl2 = readline.createInterface({
|
|
92
|
+
input: process.stdin,
|
|
93
|
+
output: process.stdout
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
rl2.question('VOID or AUTH?:\n', async (jobCd) => {
|
|
97
|
+
if (jobCd === 'AUTH') {
|
|
98
|
+
const authorizeResult = await (await chevre.service.payment.any.createService()).authorize({
|
|
99
|
+
project: { id: project.id },
|
|
100
|
+
agent: { id: CLIENT_ID },
|
|
101
|
+
object: {
|
|
102
|
+
typeOf: chevre.factory.action.authorize.paymentMethod.any.ResultType.Payment,
|
|
103
|
+
amount: AMOUNT,
|
|
104
|
+
paymentMethodId: publishPaymentUrlResult.paymentMethodId,
|
|
105
|
+
paymentMethod: paymentMethodType,
|
|
106
|
+
issuedThrough: { id: paymentServiceId },
|
|
107
|
+
method: '1',
|
|
108
|
+
creditCard
|
|
109
|
+
},
|
|
110
|
+
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
111
|
+
paymentServiceType: chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
112
|
+
location: {
|
|
113
|
+
typeOf: chevre.factory.creativeWorkType.WebApplication,
|
|
114
|
+
id: CLIENT_ID
|
|
115
|
+
},
|
|
116
|
+
options: {
|
|
117
|
+
useCancelPayTransactionOnFailed: false,
|
|
118
|
+
useCheckMovieTicketBeforePay: false,
|
|
119
|
+
useCheckByIdentifierIfNotYet: false,
|
|
120
|
+
useSearchTrade4accountId: false
|
|
121
|
+
}
|
|
122
|
+
})({
|
|
123
|
+
accountingReport: await chevre.repository.AccountingReport.createInstance(mongoose.connection),
|
|
124
|
+
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
125
|
+
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
126
|
+
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
127
|
+
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
128
|
+
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
129
|
+
paymentServiceProvider: await chevre.repository.PaymentServiceProvider.createInstance(mongoose.connection),
|
|
130
|
+
person: await chevre.repository.Person.createInstance({ userPoolId: '' }),
|
|
131
|
+
product: await chevre.repository.Product.createInstance(mongoose.connection),
|
|
132
|
+
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
133
|
+
transactionNumber: await chevre.repository.TransactionNumber.createInstance(client),
|
|
134
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
135
|
+
});
|
|
136
|
+
console.log('payment authorized.', authorizeResult.result);
|
|
137
|
+
} else if (jobCd === 'VOID') {
|
|
138
|
+
await (await chevre.service.payment.any.createService()).invalidatePaymentUrl({
|
|
139
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
140
|
+
purpose: { id: transaction.id, typeOf: transaction.typeOf }
|
|
141
|
+
})({
|
|
142
|
+
accountingReport: await chevre.repository.AccountingReport.createInstance(mongoose.connection),
|
|
143
|
+
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
144
|
+
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
145
|
+
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
146
|
+
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
147
|
+
paymentServiceProvider: await chevre.repository.PaymentServiceProvider.createInstance(mongoose.connection),
|
|
148
|
+
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
149
|
+
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
150
|
+
});
|
|
151
|
+
console.log('payment voided.');
|
|
152
|
+
} else {
|
|
153
|
+
reject2(`jobCd ${jobCd} not implemented`);
|
|
154
|
+
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// rl.close();
|
|
159
|
+
resolve2();
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
resolve();
|
|
164
|
+
} catch (error) {
|
|
165
|
+
reject(error);
|
|
97
166
|
}
|
|
98
|
-
}
|
|
99
|
-
purpose: { id: transaction.id, typeOf: transaction.typeOf },
|
|
100
|
-
paymentServiceType: chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
|
|
101
|
-
location: {
|
|
102
|
-
typeOf: chevre.factory.creativeWorkType.WebApplication,
|
|
103
|
-
id: CLIENT_ID
|
|
104
|
-
},
|
|
105
|
-
options: {
|
|
106
|
-
useCancelPayTransactionOnFailed: false,
|
|
107
|
-
useCheckMovieTicketBeforePay: false,
|
|
108
|
-
useCheckByIdentifierIfNotYet: false,
|
|
109
|
-
useSearchTrade4accountId: false
|
|
110
|
-
}
|
|
111
|
-
})({
|
|
112
|
-
accountingReport: await chevre.repository.AccountingReport.createInstance(mongoose.connection),
|
|
113
|
-
action: await chevre.repository.Action.createInstance(mongoose.connection),
|
|
114
|
-
assetTransaction: await chevre.repository.AssetTransaction.createInstance(mongoose.connection),
|
|
115
|
-
event: await chevre.repository.Event.createInstance(mongoose.connection),
|
|
116
|
-
paymentAccepted: await chevre.repository.SellerPaymentAccepted.createInstance(mongoose.connection),
|
|
117
|
-
paymentService: await chevre.repository.PaymentService.createInstance(mongoose.connection),
|
|
118
|
-
paymentServiceProvider: await chevre.repository.PaymentServiceProvider.createInstance(mongoose.connection),
|
|
119
|
-
person: await chevre.repository.Person.createInstance({ userPoolId: '' }),
|
|
120
|
-
product: await chevre.repository.Product.createInstance(mongoose.connection),
|
|
121
|
-
project: await chevre.repository.Project.createInstance(mongoose.connection),
|
|
122
|
-
task: await chevre.repository.Task.createInstance(mongoose.connection),
|
|
123
|
-
transactionNumber: await chevre.repository.TransactionNumber.createInstance(client),
|
|
124
|
-
transaction: await chevre.repository.Transaction.createInstance(mongoose.connection)
|
|
167
|
+
});
|
|
125
168
|
});
|
|
126
|
-
console.log(authorizeResult);
|
|
127
169
|
}
|
|
128
170
|
|
|
129
171
|
main()
|
|
@@ -78,10 +78,10 @@ export declare class MongoRepository {
|
|
|
78
78
|
/**
|
|
79
79
|
* アクション取消
|
|
80
80
|
*/
|
|
81
|
-
|
|
82
|
-
typeOf:
|
|
81
|
+
cancelWithVoid(params: {
|
|
82
|
+
typeOf: factory.actionType;
|
|
83
83
|
id: string;
|
|
84
|
-
}): Promise<
|
|
84
|
+
}): Promise<void>;
|
|
85
85
|
/**
|
|
86
86
|
* アクション失敗
|
|
87
87
|
*/
|
|
@@ -511,18 +511,16 @@ class MongoRepository {
|
|
|
511
511
|
/**
|
|
512
512
|
* アクション取消
|
|
513
513
|
*/
|
|
514
|
-
|
|
514
|
+
cancelWithVoid(params) {
|
|
515
515
|
return __awaiter(this, void 0, void 0, function* () {
|
|
516
516
|
const doc = yield this.actionModel.findOneAndUpdate({
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
}, { actionStatus: factory.actionStatusType.CanceledActionStatus }, { new:
|
|
520
|
-
.select({ __v: 0, createdAt: 0, updatedAt: 0 })
|
|
517
|
+
_id: { $eq: params.id },
|
|
518
|
+
typeOf: { $eq: params.typeOf }
|
|
519
|
+
}, { actionStatus: factory.actionStatusType.CanceledActionStatus }, { new: false, projection: { _id: 1 } })
|
|
521
520
|
.exec();
|
|
522
521
|
if (doc === null) {
|
|
523
522
|
throw new factory.errors.NotFound(this.actionModel.modelName);
|
|
524
523
|
}
|
|
525
|
-
return doc.toObject();
|
|
526
524
|
});
|
|
527
525
|
}
|
|
528
526
|
/**
|
|
@@ -13,7 +13,6 @@ import type { MongoRepository as PaymentServiceRepo } from '../../repo/paymentSe
|
|
|
13
13
|
import type { MongoRepository as PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
|
|
14
14
|
import type { CognitoRepository as PersonRepo } from '../../repo/person';
|
|
15
15
|
import type { MongoRepository as ProductRepo } from '../../repo/product';
|
|
16
|
-
import type { MongoRepository as ProjectRepo } from '../../repo/project';
|
|
17
16
|
import type { MongoRepository as PaymentAcceptedRepo } from '../../repo/sellerPaymentAccepted';
|
|
18
17
|
import type { MongoRepository as TaskRepo } from '../../repo/task';
|
|
19
18
|
import * as CreditCardPayment from '../payment/creditCard';
|
|
@@ -27,17 +26,12 @@ export interface IStartOperationRepos {
|
|
|
27
26
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
28
27
|
person: PersonRepo;
|
|
29
28
|
product: ProductRepo;
|
|
30
|
-
project: ProjectRepo;
|
|
31
29
|
assetTransaction: AssetTransactionRepo;
|
|
32
30
|
task: TaskRepo;
|
|
33
31
|
}
|
|
34
32
|
export type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
|
|
35
33
|
export interface ICancelRepos {
|
|
36
|
-
action: ActionRepo;
|
|
37
|
-
accountingReport: AccountingReportRepo;
|
|
38
34
|
assetTransaction: AssetTransactionRepo;
|
|
39
|
-
project: ProjectRepo;
|
|
40
|
-
task: TaskRepo;
|
|
41
35
|
}
|
|
42
36
|
export type ICancelOperation<T> = (repos: ICancelRepos) => Promise<T>;
|
|
43
37
|
export interface IConfirmRepos {
|
|
@@ -47,7 +41,6 @@ export interface IConfirmRepos {
|
|
|
47
41
|
assetTransaction: AssetTransactionRepo;
|
|
48
42
|
event: EventRepo;
|
|
49
43
|
order: OrderRepo;
|
|
50
|
-
project: ProjectRepo;
|
|
51
44
|
task: TaskRepo;
|
|
52
45
|
}
|
|
53
46
|
export type IConfirmOperation<T> = (repos: IConfirmRepos) => Promise<T>;
|
|
@@ -61,14 +54,12 @@ export type ICheckOperation<T> = (repos: {
|
|
|
61
54
|
paymentAccepted: PaymentAcceptedRepo;
|
|
62
55
|
paymentService: PaymentServiceRepo;
|
|
63
56
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
64
|
-
project: ProjectRepo;
|
|
65
57
|
}) => Promise<T>;
|
|
66
58
|
export type IPublishPaymentUrlOperation<T> = (repos: {
|
|
67
59
|
paymentAccepted: PaymentAcceptedRepo;
|
|
68
60
|
paymentService: PaymentServiceRepo;
|
|
69
61
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
70
62
|
person: PersonRepo;
|
|
71
|
-
project: ProjectRepo;
|
|
72
63
|
}) => Promise<T>;
|
|
73
64
|
export type IInvalidatePaymentUrlOperation<T> = (repos: {
|
|
74
65
|
accountingReport: AccountingReportRepo;
|
|
@@ -76,7 +67,6 @@ export type IInvalidatePaymentUrlOperation<T> = (repos: {
|
|
|
76
67
|
paymentAccepted: PaymentAcceptedRepo;
|
|
77
68
|
paymentService: PaymentServiceRepo;
|
|
78
69
|
paymentServiceProvider: PaymentServiceProviderRepo;
|
|
79
|
-
project: ProjectRepo;
|
|
80
70
|
task: TaskRepo;
|
|
81
71
|
assetTransaction: AssetTransactionRepo;
|
|
82
72
|
}) => Promise<T>;
|
|
@@ -23,7 +23,7 @@ const potentialActions_1 = require("./pay/potentialActions");
|
|
|
23
23
|
*/
|
|
24
24
|
function publishPaymentUrl(params) {
|
|
25
25
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
var _a, _b;
|
|
26
|
+
var _a, _b, _c;
|
|
27
27
|
const paymentServiceType = (_a = params.object) === null || _a === void 0 ? void 0 : _a.typeOf;
|
|
28
28
|
// 金額をfix
|
|
29
29
|
const amount = (_b = params.object.paymentMethod) === null || _b === void 0 ? void 0 : _b.amount;
|
|
@@ -40,14 +40,22 @@ function publishPaymentUrl(params) {
|
|
|
40
40
|
let result;
|
|
41
41
|
switch (paymentServiceType) {
|
|
42
42
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
43
|
-
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, { searchTrade4accountId: false })(repos);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, { searchTrade4accountId: false, processPublishPaymentUrl: true })(repos);
|
|
44
|
+
let paymentUrl;
|
|
45
|
+
// 3DS拡張(2024-01-02~)
|
|
46
|
+
const retUrl = (_c = params.object.paymentMethod.creditCard) === null || _c === void 0 ? void 0 : _c.retUrl;
|
|
47
|
+
if (typeof retUrl === 'string' && retUrl.length > 0) {
|
|
48
|
+
paymentUrl = authorizeResult.execTranResult.redirectUrl;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
paymentUrl = authorizeResult.execTranResult.acsUrl;
|
|
52
|
+
}
|
|
53
|
+
if (typeof paymentUrl !== 'string' || paymentUrl.length === 0) {
|
|
54
|
+
throw new factory.errors.ServiceUnavailable(`Payment URL unable to publish. [retUrl: ${retUrl}]`);
|
|
47
55
|
}
|
|
48
56
|
result = {
|
|
49
57
|
paymentMethodId: transactionNumber,
|
|
50
|
-
paymentUrl
|
|
58
|
+
paymentUrl,
|
|
51
59
|
entryTranArgs: authorizeResult.entryTranArgs,
|
|
52
60
|
entryTranResult: authorizeResult.entryTranResult,
|
|
53
61
|
execTranArgs: authorizeResult.execTranArgs,
|
|
@@ -71,7 +79,7 @@ function invalidatePaymentUrl(params) {
|
|
|
71
79
|
const paymentServiceType = (_a = params.object[0]) === null || _a === void 0 ? void 0 : _a.typeOf;
|
|
72
80
|
switch (paymentServiceType) {
|
|
73
81
|
case factory.service.paymentService.PaymentServiceType.CreditCard:
|
|
74
|
-
yield CreditCardPayment.refundCreditCard(params, false)(repos);
|
|
82
|
+
yield CreditCardPayment.refundCreditCard(params, { requirePayAction: false })(repos);
|
|
75
83
|
break;
|
|
76
84
|
default:
|
|
77
85
|
throw new factory.errors.NotImplemented(`Payment service '${paymentServiceType}' not implemented`);
|
|
@@ -296,20 +304,14 @@ function processAuthorizeAccount(params, transaction, paymentServiceId) {
|
|
|
296
304
|
}
|
|
297
305
|
function processAuthorizeCreditCard(params, transaction, paymentServiceId, options) {
|
|
298
306
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
299
|
-
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, Object.assign({ searchTrade4accountId: options.searchTrade4accountId }, (options.pendingPaymentAgencyTransaction !== undefined)
|
|
307
|
+
const authorizeResult = yield CreditCardPayment.authorize(params, paymentServiceId, Object.assign({ processPublishPaymentUrl: false, searchTrade4accountId: options.searchTrade4accountId }, (options.pendingPaymentAgencyTransaction !== undefined)
|
|
300
308
|
? { pendingPaymentAgencyTransaction: options.pendingPaymentAgencyTransaction }
|
|
301
309
|
: undefined))(repos);
|
|
302
310
|
return saveAuthorizeResult({
|
|
303
311
|
id: transaction.id,
|
|
304
|
-
update: {
|
|
305
|
-
'object.
|
|
306
|
-
|
|
307
|
-
'object.paymentMethod.paymentMethodId': authorizeResult.paymentMethodId,
|
|
308
|
-
'object.entryTranArgs': authorizeResult.entryTranArgs,
|
|
309
|
-
'object.entryTranResult': authorizeResult.entryTranResult,
|
|
310
|
-
'object.execTranArgs': authorizeResult.execTranArgs,
|
|
311
|
-
'object.execTranResult': authorizeResult.execTranResult
|
|
312
|
-
}
|
|
312
|
+
update: Object.assign({ 'object.accountId': authorizeResult.accountId, 'object.paymentMethod.accountId': authorizeResult.accountId, 'object.paymentMethod.paymentMethodId': authorizeResult.paymentMethodId, 'object.entryTranArgs': authorizeResult.entryTranArgs, 'object.entryTranResult': authorizeResult.entryTranResult, 'object.execTranArgs': authorizeResult.execTranArgs, 'object.execTranResult': authorizeResult.execTranResult }, (authorizeResult.secureTran2Result !== undefined)
|
|
313
|
+
? { 'object.secureTran2Result': authorizeResult.secureTran2Result }
|
|
314
|
+
: undefined)
|
|
313
315
|
})(repos);
|
|
314
316
|
});
|
|
315
317
|
}
|
|
@@ -103,7 +103,7 @@ function verifyToken(params) {
|
|
|
103
103
|
throw error;
|
|
104
104
|
}
|
|
105
105
|
if (repos.action !== undefined && action !== undefined) {
|
|
106
|
-
yield repos.action.
|
|
106
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
107
107
|
}
|
|
108
108
|
return result;
|
|
109
109
|
});
|
|
@@ -63,7 +63,7 @@ function givePointAward(params) {
|
|
|
63
63
|
}
|
|
64
64
|
// アクション完了
|
|
65
65
|
const actionResult = {};
|
|
66
|
-
yield repos.action.
|
|
66
|
+
yield repos.action.completeWithVoid({ typeOf: params.typeOf, id: action.id, result: actionResult });
|
|
67
67
|
});
|
|
68
68
|
}
|
|
69
69
|
exports.givePointAward = givePointAward;
|
|
@@ -140,7 +140,7 @@ function returnPointAward(params) {
|
|
|
140
140
|
const actionResult = {
|
|
141
141
|
moneyTransferTransaction: moneyTransferTransactions
|
|
142
142
|
};
|
|
143
|
-
yield repos.action.
|
|
143
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
144
144
|
});
|
|
145
145
|
}
|
|
146
146
|
exports.returnPointAward = returnPointAward;
|
|
@@ -193,7 +193,7 @@ function importFromCOA(params) {
|
|
|
193
193
|
}
|
|
194
194
|
// アクション完了
|
|
195
195
|
const actionResult = { savedScreeningEventsCount, savedScreeningEventSeriesCount };
|
|
196
|
-
yield repos.action.
|
|
196
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
197
197
|
});
|
|
198
198
|
}
|
|
199
199
|
exports.importFromCOA = importFromCOA;
|
|
@@ -807,7 +807,7 @@ function updateEvent4ttts(params) {
|
|
|
807
807
|
throw error;
|
|
808
808
|
}
|
|
809
809
|
// アクション完了
|
|
810
|
-
yield repos.action.
|
|
810
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: { id: event.id } });
|
|
811
811
|
yield (0, offer_1.onEventChanged)({
|
|
812
812
|
id: [event.id],
|
|
813
813
|
project: { id: event.project.id },
|
|
@@ -439,7 +439,7 @@ function moneyTransfer(params) {
|
|
|
439
439
|
throw error;
|
|
440
440
|
}
|
|
441
441
|
const actionResult = {};
|
|
442
|
-
yield repos.action.
|
|
442
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
443
443
|
});
|
|
444
444
|
}
|
|
445
445
|
exports.moneyTransfer = moneyTransfer;
|
|
@@ -11,14 +11,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.triggerWebhook = exports.report2developers = exports.sendEmailMessage = void 0;
|
|
13
13
|
const sgMail = require("@sendgrid/mail");
|
|
14
|
-
const createDebug = require("debug");
|
|
15
14
|
const http_status_1 = require("http-status");
|
|
16
15
|
const request = require("request");
|
|
17
16
|
const util = require("util");
|
|
18
17
|
const credentials_1 = require("../credentials");
|
|
19
18
|
const settings_1 = require("../settings");
|
|
20
19
|
const factory = require("../factory");
|
|
21
|
-
const debug = createDebug('chevre-domain:service');
|
|
22
20
|
/**
|
|
23
21
|
* Eメールメッセージを送信する
|
|
24
22
|
* https://sendgrid.com/docs/API_Reference/Web_API_v3/Mail/errors.html
|
|
@@ -110,8 +108,7 @@ function sendEmailMessage(params) {
|
|
|
110
108
|
throw error;
|
|
111
109
|
}
|
|
112
110
|
// アクション完了
|
|
113
|
-
|
|
114
|
-
yield repos.action.complete({ typeOf: action.typeOf, id: action.id, result: result });
|
|
111
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
115
112
|
});
|
|
116
113
|
}
|
|
117
114
|
exports.sendEmailMessage = sendEmailMessage;
|
|
@@ -365,6 +362,6 @@ function processInformAction(params) {
|
|
|
365
362
|
throw error;
|
|
366
363
|
}
|
|
367
364
|
}
|
|
368
|
-
yield repos.action.
|
|
365
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
369
366
|
});
|
|
370
367
|
}
|
|
@@ -28,7 +28,8 @@ function cancel(params) {
|
|
|
28
28
|
}
|
|
29
29
|
// MongoDBでcompleteステータスであるにも関わらず、Chevreでは削除されている、というのが最悪の状況
|
|
30
30
|
// それだけは回避するためにMongoDBを先に変更
|
|
31
|
-
|
|
31
|
+
yield repos.action.cancelWithVoid({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
|
|
32
|
+
const action = yield repos.action.findById({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
|
|
32
33
|
switch (action.instrument.identifier) {
|
|
33
34
|
case factory.service.webAPI.Identifier.COA:
|
|
34
35
|
// 実質使用する予定なしなので廃止(2022-05-12~)
|
|
@@ -60,7 +60,7 @@ function voidTransaction(params) {
|
|
|
60
60
|
// no op
|
|
61
61
|
}
|
|
62
62
|
yield Promise.all(authorizeActions.map((action) => __awaiter(this, void 0, void 0, function* () {
|
|
63
|
-
yield repos.action.
|
|
63
|
+
yield repos.action.cancelWithVoid({ typeOf: action.typeOf, id: action.id });
|
|
64
64
|
switch (action.instrument.identifier) {
|
|
65
65
|
case exports.WebAPIIdentifier.COA:
|
|
66
66
|
yield processVoidTransaction4coa({
|
|
@@ -143,13 +143,13 @@ function cancel(params) {
|
|
|
143
143
|
throw new factory.errors.Forbidden('Transaction not yours');
|
|
144
144
|
}
|
|
145
145
|
// 取引内のアクションかどうか確認
|
|
146
|
-
|
|
146
|
+
const action = yield repos.action.findById({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
|
|
147
147
|
if (action.purpose.typeOf !== transaction.typeOf || action.purpose.id !== transaction.id) {
|
|
148
148
|
throw new factory.errors.Argument('Transaction', 'Action not found in the transaction');
|
|
149
149
|
}
|
|
150
150
|
// MongoDBでcompleteステータスであるにも関わらず、COAでは削除されている、というのが最悪の状況
|
|
151
151
|
// それだけは回避するためにMongoDBを先に変更
|
|
152
|
-
|
|
152
|
+
yield repos.action.cancelWithVoid({ typeOf: factory.actionType.AuthorizeAction, id: params.id });
|
|
153
153
|
let cancelResult;
|
|
154
154
|
const actionResult = action.result;
|
|
155
155
|
if ((actionResult === null || actionResult === void 0 ? void 0 : actionResult.requestBody) !== undefined && actionResult.responseBody !== undefined) {
|
|
@@ -24,5 +24,10 @@ export declare function authorize(params: {
|
|
|
24
24
|
};
|
|
25
25
|
object: factory.action.authorize.offer.moneyTransfer.IObject;
|
|
26
26
|
purpose: factory.action.authorize.offer.moneyTransfer.IPurpose;
|
|
27
|
-
}): IAuthorizeOperation<
|
|
27
|
+
}): IAuthorizeOperation<{
|
|
28
|
+
/**
|
|
29
|
+
* 承認アクションID
|
|
30
|
+
*/
|
|
31
|
+
id: string;
|
|
32
|
+
}>;
|
|
28
33
|
export {};
|
|
@@ -64,7 +64,8 @@ function authorize(params) {
|
|
|
64
64
|
requestBody: requestBody,
|
|
65
65
|
responseBody: responseBody
|
|
66
66
|
};
|
|
67
|
-
|
|
67
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
|
|
68
|
+
return { id: action.id };
|
|
68
69
|
});
|
|
69
70
|
}
|
|
70
71
|
exports.authorize = authorize;
|
|
@@ -74,7 +74,7 @@ function returnMoneyTransfer(params) {
|
|
|
74
74
|
throw error;
|
|
75
75
|
}
|
|
76
76
|
const actionResult = {};
|
|
77
|
-
yield repos.action.
|
|
77
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
exports.returnMoneyTransfer = returnMoneyTransfer;
|
|
@@ -27,7 +27,7 @@ function settleTransaction(params) {
|
|
|
27
27
|
throw error;
|
|
28
28
|
}
|
|
29
29
|
const actionResult = {};
|
|
30
|
-
yield repos.action.
|
|
30
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
exports.settleTransaction = settleTransaction;
|
|
@@ -45,7 +45,7 @@ function voidTransaction(params) {
|
|
|
45
45
|
}
|
|
46
46
|
yield Promise.all(authorizeActions.map((action) => __awaiter(this, void 0, void 0, function* () {
|
|
47
47
|
var _a, _b;
|
|
48
|
-
yield repos.action.
|
|
48
|
+
yield repos.action.cancelWithVoid({ typeOf: action.typeOf, id: action.id });
|
|
49
49
|
const pendingTransactionTransactionNumber = (_b = (_a = action.object.itemOffered.object) === null || _a === void 0 ? void 0 : _a.pendingTransaction) === null || _b === void 0 ? void 0 : _b.transactionNumber;
|
|
50
50
|
if (typeof pendingTransactionTransactionNumber === 'string') {
|
|
51
51
|
// 取引が存在すれば中止
|
|
@@ -247,7 +247,7 @@ function voidTransaction(params) {
|
|
|
247
247
|
// purpose: params.purpose
|
|
248
248
|
// })(repos);
|
|
249
249
|
}
|
|
250
|
-
yield repos.action.
|
|
250
|
+
yield repos.action.cancelWithVoid({ typeOf: action.typeOf, id: action.id });
|
|
251
251
|
yield processVoidRegisterServiceTransaction({
|
|
252
252
|
action,
|
|
253
253
|
project: params.project
|
|
@@ -36,7 +36,7 @@ function confirmPayTransaction(data) {
|
|
|
36
36
|
assetTransaction: repos.assetTransaction,
|
|
37
37
|
event: repos.event,
|
|
38
38
|
order: repos.order,
|
|
39
|
-
project: repos.project,
|
|
39
|
+
// project: repos.project,
|
|
40
40
|
task: repos.task
|
|
41
41
|
});
|
|
42
42
|
}
|
|
@@ -52,7 +52,7 @@ function confirmPayTransaction(data) {
|
|
|
52
52
|
}
|
|
53
53
|
// アクション完了
|
|
54
54
|
const actionResult = {};
|
|
55
|
-
yield repos.action.
|
|
55
|
+
yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
56
56
|
// processOrder連携(2023-08-23~)
|
|
57
57
|
yield onConfirmed(data)({
|
|
58
58
|
task: repos.task
|