@chevre/domain 21.33.0-alpha.9 → 21.33.0

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.
Files changed (95) hide show
  1. package/example/src/chevre/findTransactionById.ts +8 -5
  2. package/example/src/chevre/migratePayCreditCardRecipes.ts +104 -0
  3. package/example/src/chevre/migratePayMovieTicketRecipes.ts +100 -0
  4. package/example/src/chevre/migrateTransactionObjectPaymentMethods.ts +147 -0
  5. package/example/src/chevre/reexportTasksByExportAction.ts +37 -0
  6. package/example/src/chevre/searchActionsBySameAs.ts +2 -1
  7. package/example/src/chevre/searchCheckMovieTicketResultYkknInfo.ts +26 -6
  8. package/example/src/chevre/searchTransactions.ts +1 -1
  9. package/example/src/chevre/unsetUnnecessaryFields.ts +3 -18
  10. package/lib/chevre/repo/action.d.ts +51 -0
  11. package/lib/chevre/repo/action.js +122 -2
  12. package/lib/chevre/repo/assetTransaction.d.ts +9 -2
  13. package/lib/chevre/repo/assetTransaction.js +48 -3
  14. package/lib/chevre/repo/mongoose/schemas/actionRecipe.d.ts +5 -0
  15. package/lib/chevre/repo/mongoose/schemas/actionRecipe.js +89 -0
  16. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +23 -25
  17. package/lib/chevre/repo/mongoose/schemas/transaction.js +5 -52
  18. package/lib/chevre/repo/transaction.d.ts +26 -11
  19. package/lib/chevre/repo/transaction.js +89 -17
  20. package/lib/chevre/service/assetTransaction/pay.d.ts +6 -2
  21. package/lib/chevre/service/assetTransaction/pay.js +49 -5
  22. package/lib/chevre/service/offer/event/voidTransaction.js +4 -6
  23. package/lib/chevre/service/offer/eventServiceByCOA/findAcceptAction.js +2 -1
  24. package/lib/chevre/service/offer/product.js +1 -1
  25. package/lib/chevre/service/payment/any/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +23 -0
  26. package/lib/chevre/service/payment/any/handlePrePublishedPaymentMethodIdOnAuthorizing.js +155 -0
  27. package/lib/chevre/service/payment/any.d.ts +10 -2
  28. package/lib/chevre/service/payment/any.js +83 -114
  29. package/lib/chevre/service/payment/creditCard/authorize.d.ts +41 -0
  30. package/lib/chevre/service/payment/creditCard/authorize.js +216 -0
  31. package/lib/chevre/service/payment/creditCard/factory.d.ts +35 -0
  32. package/lib/chevre/service/payment/creditCard/factory.js +57 -0
  33. package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.d.ts +20 -0
  34. package/lib/chevre/service/payment/creditCard/getGMOInfoFromSeller.js +47 -0
  35. package/lib/chevre/service/payment/creditCard/gmoError.d.ts +34 -0
  36. package/lib/chevre/service/payment/creditCard/gmoError.js +8 -0
  37. package/lib/chevre/service/payment/creditCard/payCreditCard.d.ts +20 -0
  38. package/lib/chevre/service/payment/creditCard/payCreditCard.js +151 -0
  39. package/lib/chevre/service/payment/creditCard/refundCreditCard.d.ts +26 -0
  40. package/lib/chevre/service/payment/creditCard/refundCreditCard.js +196 -0
  41. package/lib/chevre/service/payment/creditCard/searchGMOTrade.d.ts +13 -0
  42. package/lib/chevre/service/payment/creditCard/searchGMOTrade.js +62 -0
  43. package/lib/chevre/service/payment/creditCard/voidTransaction.d.ts +13 -0
  44. package/lib/chevre/service/payment/creditCard/voidTransaction.js +90 -0
  45. package/lib/chevre/service/payment/creditCard.d.ts +7 -106
  46. package/lib/chevre/service/payment/creditCard.js +12 -638
  47. package/lib/chevre/service/payment/faceToFace.d.ts +1 -1
  48. package/lib/chevre/service/payment/movieTicket/authorize.d.ts +38 -0
  49. package/lib/chevre/service/payment/movieTicket/authorize.js +71 -0
  50. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.d.ts +22 -0
  51. package/lib/chevre/service/payment/movieTicket/checkMovieTicket.js +109 -0
  52. package/lib/chevre/service/payment/movieTicket/factory.d.ts +52 -1
  53. package/lib/chevre/service/payment/movieTicket/factory.js +114 -1
  54. package/lib/chevre/service/payment/movieTicket/payMovieTicket.d.ts +24 -0
  55. package/lib/chevre/service/payment/movieTicket/payMovieTicket.js +157 -0
  56. package/lib/chevre/service/payment/movieTicket/{checkByIdentifier.d.ts → processPurchaseNumberAuth.d.ts} +5 -6
  57. package/lib/chevre/service/payment/movieTicket/{checkByIdentifier.js → processPurchaseNumberAuth.js} +4 -8
  58. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.d.ts +21 -0
  59. package/lib/chevre/service/payment/movieTicket/refundMovieTicket.js +248 -0
  60. package/lib/chevre/service/payment/movieTicket/validation.js +3 -3
  61. package/lib/chevre/service/payment/movieTicket/voidTransaction.d.ts +12 -0
  62. package/lib/chevre/service/payment/movieTicket/voidTransaction.js +74 -0
  63. package/lib/chevre/service/payment/movieTicket.d.ts +7 -75
  64. package/lib/chevre/service/payment/movieTicket.js +11 -567
  65. package/lib/chevre/service/payment/paymentCard.d.ts +1 -1
  66. package/lib/chevre/service/payment.d.ts +9 -1
  67. package/lib/chevre/service/payment.js +2 -1
  68. package/lib/chevre/service/task/acceptCOAOffer.js +2 -1
  69. package/lib/chevre/service/task/authorizePayment.js +2 -1
  70. package/lib/chevre/service/task/checkMovieTicket.js +1 -1
  71. package/lib/chevre/service/task/pay.d.ts +2 -2
  72. package/lib/chevre/service/task/pay.js +3 -2
  73. package/lib/chevre/service/task/publishPaymentUrl.js +2 -1
  74. package/lib/chevre/service/task/voidPayTransaction.d.ts +2 -2
  75. package/lib/chevre/service/task/voidPayTransaction.js +2 -4
  76. package/lib/chevre/service/task/voidPayment.js +0 -1
  77. package/lib/chevre/service/task.js +2 -0
  78. package/lib/chevre/service/transaction/moneyTransfer/exportTasks/factory.d.ts +1 -1
  79. package/lib/chevre/service/transaction/moneyTransfer/potentialActions.d.ts +1 -1
  80. package/lib/chevre/service/transaction/moneyTransfer.js +2 -2
  81. package/lib/chevre/service/transaction/placeOrder.js +2 -3
  82. package/lib/chevre/service/transaction/placeOrderInProgress/confirm.js +3 -2
  83. package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions.d.ts +0 -1
  84. package/lib/chevre/service/transaction/placeOrderInProgress/result.d.ts +1 -1
  85. package/lib/chevre/service/transaction/placeOrderInProgress/validation.d.ts +1 -1
  86. package/lib/chevre/service/transaction/placeOrderInProgress/validation.js +4 -3
  87. package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.d.ts +1 -1
  88. package/lib/chevre/service/transaction/returnOrder/potentialActions/returnPaymentMethod.d.ts +1 -1
  89. package/lib/chevre/service/transaction/returnOrder/potentialActions.d.ts +1 -1
  90. package/lib/chevre/service/transaction/returnOrder.js +2 -2
  91. package/lib/chevre/settings.d.ts +1 -0
  92. package/lib/chevre/settings.js +2 -1
  93. package/package.json +3 -3
  94. package/example/src/chevre/migrateOwnershipInfos2newUserPool.ts +0 -152
  95. package/example/src/chevre/migratePayTransactionReservedTicketIdentifier.ts +0 -95
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.voidTransaction = void 0;
13
+ const GMO = require("@motionpicture/gmo-service");
14
+ const credentials_1 = require("../../../credentials");
15
+ const factory = require("../../../factory");
16
+ const getGMOInfoFromSeller_1 = require("./getGMOInfoFromSeller");
17
+ const gmoError_1 = require("./gmoError");
18
+ /**
19
+ * クレジットカード決済中止
20
+ */
21
+ function voidTransaction(params) {
22
+ return (repos) => __awaiter(this, void 0, void 0, function* () {
23
+ var _a, _b, _c, _d, _e, _f;
24
+ const transaction = params.object;
25
+ // CreditCard系統の決済方法タイプは動的
26
+ const paymentMethodType = (_a = transaction.object.paymentMethod) === null || _a === void 0 ? void 0 : _a.identifier;
27
+ if (typeof paymentMethodType !== 'string') {
28
+ throw new factory.errors.ArgumentNull('object.paymentMethod.identifier');
29
+ }
30
+ const paymentMethodId = transaction.object.paymentMethodId;
31
+ if (typeof paymentMethodId !== 'string') {
32
+ throw new factory.errors.ArgumentNull('object.paymentMethodId');
33
+ }
34
+ const paymentServiceId = String(transaction.object.id);
35
+ const availableChannel = yield repos.paymentService.findAvailableChannel({
36
+ project: transaction.project,
37
+ typeOf: factory.service.paymentService.PaymentServiceType.CreditCard,
38
+ id: paymentServiceId
39
+ });
40
+ const sellerId = (_b = transaction.recipient) === null || _b === void 0 ? void 0 : _b.id;
41
+ if (typeof sellerId !== 'string') {
42
+ throw new factory.errors.ArgumentNull('object.recipient.id');
43
+ }
44
+ const { shopId, shopPass } = yield (0, getGMOInfoFromSeller_1.getGMOInfoFromSeller)({ paymentMethodType, seller: { id: sellerId }, paymentServiceId })(repos);
45
+ const creditCardService = new GMO.service.Credit({
46
+ endpoint: String(availableChannel.serviceUrl),
47
+ useFetch: credentials_1.credentials.gmo.useFetch
48
+ }, { timeout: credentials_1.credentials.gmo.timeout });
49
+ let searchTradeResult;
50
+ try {
51
+ searchTradeResult = yield creditCardService.searchTrade({
52
+ shopId: shopId,
53
+ shopPass: shopPass,
54
+ orderId: paymentMethodId,
55
+ siteId: (_c = availableChannel.credentials) === null || _c === void 0 ? void 0 : _c.siteId,
56
+ sitePass: (_d = availableChannel.credentials) === null || _d === void 0 ? void 0 : _d.sitePass
57
+ });
58
+ }
59
+ catch (error) {
60
+ // searchTradeでのエラーをハンドリング(2024-01-27~)
61
+ let throwsError = true;
62
+ if (error.name === 'GMOServiceBadRequestError') {
63
+ if (Array.isArray(error.errors) && error.errors.length > 0) {
64
+ const gmoErrors = error.errors;
65
+ // 指定されたIDとパスワードの取引が存在しません。
66
+ const notFoundErrorExists = gmoErrors.some(({ info }) => info === gmoError_1.GMOErrorInfo.TransactionNotFound);
67
+ if (notFoundErrorExists) {
68
+ throwsError = false;
69
+ }
70
+ }
71
+ }
72
+ if (throwsError) {
73
+ throw error;
74
+ }
75
+ }
76
+ // 仮売上であれば取消
77
+ if ((searchTradeResult === null || searchTradeResult === void 0 ? void 0 : searchTradeResult.status) === GMO.utils.util.JobCd.Auth) {
78
+ yield creditCardService.alterTran({
79
+ shopId: shopId,
80
+ shopPass: shopPass,
81
+ accessId: searchTradeResult.accessId,
82
+ accessPass: searchTradeResult.accessPass,
83
+ jobCd: GMO.utils.util.JobCd.Void,
84
+ siteId: (_e = availableChannel.credentials) === null || _e === void 0 ? void 0 : _e.siteId,
85
+ sitePass: (_f = availableChannel.credentials) === null || _f === void 0 ? void 0 : _f.sitePass
86
+ });
87
+ }
88
+ });
89
+ }
90
+ exports.voidTransaction = voidTransaction;
@@ -1,109 +1,10 @@
1
1
  /**
2
2
  * クレジットカード決済サービス
3
3
  */
4
- import * as GMO from '@motionpicture/gmo-service';
5
- import * as factory from '../../factory';
6
- import type { MongoRepository as AccountingReportRepo } from '../../repo/accountingReport';
7
- import type { MongoRepository as ActionRepo } from '../../repo/action';
8
- import type { MongoRepository as PaymentServiceRepo } from '../../repo/paymentService';
9
- import type { MongoRepository as PaymentServiceProviderRepo } from '../../repo/paymentServiceProvider';
10
- import type { MongoRepository as PaymentAcceptedRepo } from '../../repo/sellerPaymentAccepted';
11
- import type { MongoRepository as TaskRepo } from '../../repo/task';
12
- interface IPaymentAgencyTransaction {
13
- entryTranArgs: GMO.factory.credit.IEntryTranArgs;
14
- entryTranResult: GMO.factory.credit.IEntryTranResult;
15
- execTranArgs: GMO.factory.credit.IExecTranArgs;
16
- execTranResult: GMO.factory.credit.IExecTranResult | GMO.factory.credit.IExecTran3dsResult;
17
- secureTran2Result?: GMO.factory.credit.ISecureTran2Result;
18
- }
19
- type IAuthorizeResult = IPaymentAgencyTransaction & {
20
- accountId: string;
21
- paymentMethodId: string;
22
- };
23
- /**
24
- * クレジットカード決済承認
25
- */
26
- declare function authorize(params: factory.assetTransaction.pay.IStartParamsWithoutDetail, paymentServiceId: string, options: {
27
- pendingPaymentAgencyTransaction?: IPaymentAgencyTransaction;
28
- /**
29
- * 決済URL発行処理かどうか
30
- */
31
- processPublishPaymentUrl: boolean;
32
- /**
33
- * 実行者
34
- */
35
- executor?: {
36
- /**
37
- * task ID
38
- * taskによって実行されている場合値が存在する
39
- */
40
- id?: string;
41
- };
42
- }): (repos: {
43
- paymentAccepted: PaymentAcceptedRepo;
44
- paymentService: PaymentServiceRepo;
45
- paymentServiceProvider: PaymentServiceProviderRepo;
46
- }) => Promise<IAuthorizeResult>;
47
- /**
48
- * クレジットカード決済中止
49
- */
50
- declare function voidTransaction(params: factory.task.voidPayment.IData): (repos: {
51
- paymentAccepted: PaymentAcceptedRepo;
52
- paymentService: PaymentServiceRepo;
53
- paymentServiceProvider: PaymentServiceProviderRepo;
54
- }) => Promise<void>;
55
- /**
56
- * クレジットカード決済
57
- */
58
- declare function payCreditCard(params: factory.task.pay.IPayActionData): (repos: {
59
- action: ActionRepo;
60
- accountingReport: AccountingReportRepo;
61
- paymentAccepted: PaymentAcceptedRepo;
62
- paymentService: PaymentServiceRepo;
63
- paymentServiceProvider: PaymentServiceProviderRepo;
64
- task: TaskRepo;
65
- }) => Promise<import("@chevre/factory/lib/action/trade/pay").IAction>;
66
- /**
67
- * クレジットカード返金
68
- */
69
- declare function refundCreditCard(params: factory.task.refund.IData & {
70
- sameAs?: {
71
- id: string;
72
- };
73
- }, options: {
74
- requirePayAction: boolean;
75
- }): (repos: {
76
- action: ActionRepo;
77
- accountingReport: AccountingReportRepo;
78
- paymentAccepted: PaymentAcceptedRepo;
79
- paymentService: PaymentServiceRepo;
80
- paymentServiceProvider: PaymentServiceProviderRepo;
81
- task: TaskRepo;
82
- }) => Promise<import("@chevre/factory/lib/action/trade/refund").IAction>;
83
- interface IGMOInfo {
84
- shopId: string;
85
- shopPass: string;
86
- returnUrls3ds: string[];
87
- callbackType3ds?: factory.service.paymentService.ICallbackType3ds;
88
- }
89
- declare function getGMOInfoFromSeller(params: {
90
- paymentMethodType: string;
91
- seller: {
92
- id: string;
93
- };
94
- paymentServiceId: string;
95
- }): (repos: {
96
- paymentAccepted: PaymentAcceptedRepo;
97
- paymentServiceProvider: PaymentServiceProviderRepo;
98
- }) => Promise<IGMOInfo>;
99
- /**
100
- * 決済代行側の取引状態参照
101
- * 存在しない場合NotFoundエラー
102
- */
103
- declare function searchGMOTrade(params: {
104
- availableChannel: factory.product.IAvailableChannel;
105
- paymentMethodId: string;
106
- shopId: string;
107
- shopPass: string;
108
- }): Promise<GMO.factory.credit.ISearchTradeResult>;
109
- export { IAuthorizeResult, IPaymentAgencyTransaction, getGMOInfoFromSeller, authorize, payCreditCard, refundCreditCard, searchGMOTrade, voidTransaction };
4
+ import { authorize, IPaymentAgencyTransaction } from './creditCard/authorize';
5
+ import { getGMOInfoFromSeller } from './creditCard/getGMOInfoFromSeller';
6
+ import { payCreditCard } from './creditCard/payCreditCard';
7
+ import { refundCreditCard } from './creditCard/refundCreditCard';
8
+ import { searchGMOTrade } from './creditCard/searchGMOTrade';
9
+ import { voidTransaction } from './creditCard/voidTransaction';
10
+ export { IPaymentAgencyTransaction, getGMOInfoFromSeller, authorize, payCreditCard, refundCreditCard, searchGMOTrade, voidTransaction };