@smartsoft001/trans-shell-app-services 1.1.90 → 1.2.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.
package/.eslintrc.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../../../.eslintrc",
3
+ "rules": {
4
+ "import/order": "off"
5
+ },
6
+ "ignorePatterns": ["!**/*"],
7
+ "overrides": [
8
+ {
9
+ "files": ["*.json"],
10
+ "parser": "jsonc-eslint-parser"
11
+ }
12
+ ]
13
+ }
package/README.md CHANGED
@@ -1,7 +1,32 @@
1
- # trans-shell-app-services
1
+ # 📦 @smartsoft001/trans-shell-app-services
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ ![npm](https://img.shields.io/npm/v/@smartsoft001/trans-shell-app-services) ![downloads](https://img.shields.io/npm/dm/@smartsoft001/trans-shell-app-services)
4
4
 
5
- ## Running unit tests
5
+ ## 🚀 Usage
6
6
 
7
- Run `ng test trans-shell-app-services` to execute the unit tests via [Jest](https://jestjs.io).
7
+ `npm i @smartsoft001/trans-shell-app-services`
8
+
9
+ ## 🛠️ Services & Methods
10
+
11
+ ### TransService
12
+
13
+ Methods:
14
+
15
+ <table>
16
+ <tr>
17
+ <td>create</td>
18
+ <td>Creates a new transaction using the CreatorService, internal service, and payment services. Returns orderId, redirectUrl, and responseData.</td>
19
+ </tr>
20
+ <tr>
21
+ <td>refresh</td>
22
+ <td>Refreshes the status of a transaction using the RefresherService, internal service, and payment services.</td>
23
+ </tr>
24
+ <tr>
25
+ <td>refund</td>
26
+ <td>Processes a refund for a completed transaction using the RefundService, internal service, and payment services.</td>
27
+ </tr>
28
+ <tr>
29
+ <td>getById</td>
30
+ <td>Retrieves a transaction by its ID from the repository.</td>
31
+ </tr>
32
+ </table>
package/jest.config.ts ADDED
@@ -0,0 +1,27 @@
1
+ /* eslint-disable */
2
+ export default {
3
+ globals: {},
4
+ transform: {
5
+ '^.+\\.[tj]sx?$': [
6
+ 'ts-jest',
7
+ {
8
+ tsConfig: '<rootDir>/tsconfig.spec.json',
9
+ },
10
+ ],
11
+ },
12
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
13
+ coverageDirectory: '../../../../coverage/packages/trans/shell/app-services',
14
+ displayName: 'trans-shell-app-services',
15
+ testEnvironment: 'node',
16
+ preset: '../../../../jest.preset.js',
17
+ /* TODO: Update to latest Jest snapshotFormat
18
+ * By default Nx has kept the older style of Jest Snapshot formats
19
+ * to prevent breaking of any existing tests with snapshots.
20
+ * It's recommend you update to the latest format.
21
+ * You can do this by removing snapshotFormat property
22
+ * and running tests with --update-snapshot flag.
23
+ * Example: From within the project directory, run "nx test --update-snapshot"
24
+ * More info: https://jestjs.io/docs/upgrading-to-jest29#snapshot-format
25
+ */
26
+ snapshotFormat: { escapeString: true, printBasicPrototype: true },
27
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smartsoft001/trans-shell-app-services",
3
- "version": "1.1.90",
3
+ "version": "1.2.0",
4
4
  "description": "This library was generated with [Nx](https://nx.dev).",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,37 +11,5 @@
11
11
  "bugs": {
12
12
  "url": "https://github.com/emiljuchnikowski/smartsoft/issues"
13
13
  },
14
- "homepage": "https://github.com/emiljuchnikowski/smartsoft#readme",
15
- "dependencies": {
16
- "@angular/common": "16.1.3",
17
- "@angular/core": "16.1.3",
18
- "@angular/platform-browser-dynamic": "16.1.3",
19
- "@nestjs/axios": "3.0.0",
20
- "@nestjs/common": "^10.0.5",
21
- "@nestjs/core": "^10.0.5",
22
- "crypto-js": "^4.1.1",
23
- "flatted": "^3.2.4",
24
- "guid-typescript": "1.0.9",
25
- "lodash": "^4.17.20",
26
- "md5": "2.3.0",
27
- "paypal-rest-sdk": "^1.8.1",
28
- "reflect-metadata": "0.1.13",
29
- "rxjs": "7.8.1",
30
- "typeorm": "0.3.17"
31
- },
32
- "peerDependencies": {
33
- "@smartsoft001/domain-core": "1.1.90",
34
- "@smartsoft001/models": "1.1.90",
35
- "@smartsoft001/paynow": "1.1.90",
36
- "@smartsoft001/paypal": "1.1.90",
37
- "@smartsoft001/payu": "1.1.90",
38
- "@smartsoft001/revolut": "1.1.90",
39
- "@smartsoft001/trans-domain": "1.1.90",
40
- "@smartsoft001/users": "1.1.90",
41
- "@smartsoft001/utils": "1.1.90",
42
- "util": "0.12.5",
43
- "tslib": "2.5.3"
44
- },
45
- "main": "./src/index.js",
46
- "types": "./src/index.d.ts"
14
+ "homepage": "https://github.com/emiljuchnikowski/smartsoft#readme"
47
15
  }
package/project.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "trans-shell-app-services",
3
+ "$schema": "../../../../node_modules/nx/schemas/project-schema.json",
4
+ "sourceRoot": "packages/trans/shell/app-services/src",
5
+ "projectType": "library",
6
+ "generators": {},
7
+ "targets": {
8
+ "lint": {
9
+ "executor": "@nx/eslint:lint",
10
+ "outputs": ["{options.outputFile}"],
11
+ "options": {
12
+ "lintFilePatterns": [
13
+ "packages/trans/shell/app-services/**/*.{ts,tsx,js,jsx}",
14
+ "packages/trans/shell/app-services/package.json"
15
+ ]
16
+ }
17
+ },
18
+ "test": {
19
+ "executor": "@nx/jest:jest",
20
+ "options": {
21
+ "jestConfig": "packages/trans/shell/app-services/jest.config.ts",
22
+ "passWithNoTests": true
23
+ },
24
+ "outputs": ["{workspaceRoot}/coverage/packages/trans/shell/app-services"]
25
+ },
26
+ "build": {
27
+ "executor": "@nx/esbuild:esbuild",
28
+ "outputs": ["{options.outputPath}"],
29
+ "options": {
30
+ "outputPath": "dist/packages/trans/shell/app-services",
31
+ "tsConfig": "packages/trans/shell/app-services/tsconfig.lib.json",
32
+ "packageJson": "packages/trans/shell/app-services/package.json",
33
+ "main": "packages/trans/shell/app-services/src/index.ts",
34
+ "assets": ["packages/trans/shell/app-services/*.md"]
35
+ }
36
+ }
37
+ },
38
+ "tags": ["scope:trans", "type:shell"]
39
+ }
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './lib/services';
@@ -0,0 +1,6 @@
1
+ import { TransService } from './trans/trans.service';
2
+
3
+ export * from './trans/trans.service';
4
+ export * from './internal/internal.service';
5
+
6
+ export const SERVICES = [TransService];
@@ -0,0 +1 @@
1
+ export const TRANS_TOKEN_INTERNAL_SERVICE = 'TRANS_TOKEN_INTERNAL_SERVICE';
@@ -0,0 +1,266 @@
1
+ import { Test, TestingModule } from '@nestjs/testing';
2
+ import { HttpService } from '@nestjs/axios';
3
+ import { ModuleRef } from '@nestjs/core';
4
+
5
+ import { PaypalService } from '@smartsoft001/paypal';
6
+ import {
7
+ CreatorService,
8
+ RefresherService,
9
+ RefundService,
10
+ Trans,
11
+ TransConfig,
12
+ TransSystem,
13
+ } from '@smartsoft001/trans-domain';
14
+ import { PayuService } from '@smartsoft001/payu';
15
+ import { RevolutService } from '@smartsoft001/revolut';
16
+ import { PaynowService } from '@smartsoft001/paynow';
17
+ import { IItemRepository } from '@smartsoft001/domain-core';
18
+
19
+ import { TransService } from './trans.service';
20
+
21
+ // Mock PayPal SDK before importing it
22
+ jest.mock('paypal-rest-sdk', () => ({
23
+ payment: {
24
+ create: jest.fn(),
25
+ execute: jest.fn(),
26
+ get: jest.fn(),
27
+ },
28
+ sale: {
29
+ refund: jest.fn(),
30
+ },
31
+ configure: jest.fn(),
32
+ }));
33
+
34
+ describe('trans: TransService', () => {
35
+ let service: TransService;
36
+ let mockModuleRef: jest.Mocked<ModuleRef>;
37
+ let mockCreatorService: jest.Mocked<CreatorService<any>>;
38
+ let mockRefresherService: jest.Mocked<RefresherService<any>>;
39
+ let mockRefundService: jest.Mocked<RefundService<any>>;
40
+ let mockHttpService: jest.Mocked<HttpService>;
41
+ let mockConfig: TransConfig;
42
+ let mockRepository: jest.Mocked<IItemRepository<Trans<any>>>;
43
+ let mockPayuService: jest.Mocked<PayuService>;
44
+ let mockPaynowService: jest.Mocked<PaynowService>;
45
+ let mockPaypalService: jest.Mocked<PaypalService>;
46
+ let mockRevolutService: jest.Mocked<RevolutService>;
47
+ let mockInternalService: any;
48
+
49
+ beforeEach(async () => {
50
+ mockModuleRef = {
51
+ get: jest.fn(),
52
+ } as any;
53
+
54
+ mockCreatorService = {
55
+ create: jest.fn(),
56
+ } as any;
57
+
58
+ mockRefresherService = {
59
+ refresh: jest.fn(),
60
+ } as any;
61
+
62
+ mockRefundService = {
63
+ refund: jest.fn(),
64
+ } as any;
65
+
66
+ mockHttpService = {
67
+ post: jest.fn(),
68
+ put: jest.fn(),
69
+ } as any;
70
+
71
+ mockConfig = {
72
+ internalApiUrl: 'http://test-api.com',
73
+ } as any;
74
+
75
+ mockRepository = {
76
+ getById: jest.fn(),
77
+ } as any;
78
+
79
+ mockPayuService = {
80
+ create: jest.fn(),
81
+ getStatus: jest.fn(),
82
+ refund: jest.fn(),
83
+ } as any;
84
+
85
+ mockPaynowService = {
86
+ create: jest.fn(),
87
+ getStatus: jest.fn(),
88
+ refund: jest.fn(),
89
+ } as any;
90
+
91
+ mockPaypalService = {
92
+ create: jest.fn(),
93
+ getStatus: jest.fn(),
94
+ refund: jest.fn(),
95
+ } as any;
96
+
97
+ mockRevolutService = {
98
+ create: jest.fn(),
99
+ getStatus: jest.fn(),
100
+ refund: jest.fn(),
101
+ } as any;
102
+
103
+ mockInternalService = {
104
+ create: jest.fn(),
105
+ refresh: jest.fn(),
106
+ };
107
+
108
+ const module: TestingModule = await Test.createTestingModule({
109
+ providers: [
110
+ TransService,
111
+ {
112
+ provide: ModuleRef,
113
+ useValue: mockModuleRef,
114
+ },
115
+ {
116
+ provide: CreatorService,
117
+ useValue: mockCreatorService,
118
+ },
119
+ {
120
+ provide: RefresherService,
121
+ useValue: mockRefresherService,
122
+ },
123
+ {
124
+ provide: RefundService,
125
+ useValue: mockRefundService,
126
+ },
127
+ {
128
+ provide: HttpService,
129
+ useValue: mockHttpService,
130
+ },
131
+ {
132
+ provide: TransConfig,
133
+ useValue: mockConfig,
134
+ },
135
+ {
136
+ provide: IItemRepository,
137
+ useValue: mockRepository,
138
+ },
139
+ {
140
+ provide: PayuService,
141
+ useValue: mockPayuService,
142
+ },
143
+ {
144
+ provide: PaynowService,
145
+ useValue: mockPaynowService,
146
+ },
147
+ {
148
+ provide: PaypalService,
149
+ useValue: mockPaypalService,
150
+ },
151
+ {
152
+ provide: RevolutService,
153
+ useValue: mockRevolutService,
154
+ },
155
+ ],
156
+ }).compile();
157
+
158
+ service = module.get<TransService>(TransService);
159
+ });
160
+
161
+ it('should be defined', () => {
162
+ expect(service).toBeDefined();
163
+ });
164
+
165
+ describe('create', () => {
166
+ it('should call creator service with correct parameters', async () => {
167
+ const mockOps = {
168
+ amount: 100,
169
+ system: 'payu' as TransSystem,
170
+ name: 'Test Transaction',
171
+ firstName: 'John',
172
+ lastName: 'Doe',
173
+ email: 'john@example.com',
174
+ contactPhone: '123456789',
175
+ data: {},
176
+ options: {},
177
+ clientIp: '127.0.0.1',
178
+ };
179
+ const mockResult = {
180
+ orderId: 'test-order',
181
+ redirectUrl: 'http://test.com',
182
+ };
183
+ mockCreatorService.create.mockResolvedValue(mockResult);
184
+ mockModuleRef.get.mockReturnValue(mockInternalService);
185
+
186
+ const result = await service.create(mockOps);
187
+
188
+ expect(result).toEqual(mockResult);
189
+ });
190
+ });
191
+
192
+ describe('refresh', () => {
193
+ it('should call refresher service with correct parameters', async () => {
194
+ const transId = 'test-trans-id';
195
+ const mockData = { status: 'completed' };
196
+ mockModuleRef.get.mockReturnValue(mockInternalService);
197
+
198
+ await service.refresh(transId, mockData);
199
+
200
+ expect(mockRefresherService.refresh).toHaveBeenCalledWith(
201
+ transId,
202
+ mockInternalService,
203
+ expect.any(Object),
204
+ mockData,
205
+ );
206
+ });
207
+ });
208
+
209
+ describe('refund', () => {
210
+ it('should call refund service with correct parameters', async () => {
211
+ const transId = 'test-trans-id';
212
+ const comment = 'Test refund';
213
+ mockModuleRef.get.mockReturnValue(mockInternalService);
214
+
215
+ await service.refund(transId, comment);
216
+
217
+ expect(mockRefundService.refund).toHaveBeenCalledWith(
218
+ transId,
219
+ mockInternalService,
220
+ expect.any(Object),
221
+ comment,
222
+ );
223
+ });
224
+ });
225
+
226
+ describe('getById', () => {
227
+ it('should return transaction by id', async () => {
228
+ const mockTrans = { id: 'test-id', status: 'completed' } as Trans<any>;
229
+ mockRepository.getById.mockResolvedValue(mockTrans);
230
+
231
+ const result = await service.getById('test-id');
232
+
233
+ expect(result).toEqual(mockTrans);
234
+ });
235
+ });
236
+
237
+ describe('getInternalService', () => {
238
+ it('should return internal service from module ref when available', () => {
239
+ mockModuleRef.get.mockReturnValue(mockInternalService);
240
+
241
+ const result = (service as any).getInternalService();
242
+
243
+ expect(result).toBe(mockInternalService);
244
+ });
245
+
246
+ it('should return fallback internal service with create method when module ref fails', () => {
247
+ mockModuleRef.get.mockImplementation(() => {
248
+ throw new Error('Service not found');
249
+ });
250
+
251
+ const result = (service as any).getInternalService();
252
+
253
+ expect(result).toHaveProperty('create');
254
+ });
255
+
256
+ it('should return fallback internal service with refresh method when module ref fails', () => {
257
+ mockModuleRef.get.mockImplementation(() => {
258
+ throw new Error('Service not found');
259
+ });
260
+
261
+ const result = (service as any).getInternalService();
262
+
263
+ expect(result).toHaveProperty('refresh');
264
+ });
265
+ });
266
+ });
@@ -0,0 +1,118 @@
1
+ import { Injectable, Optional } from '@nestjs/common';
2
+ import { ModuleRef } from '@nestjs/core';
3
+ import { HttpService } from '@nestjs/axios';
4
+
5
+ import {
6
+ ITransCreate,
7
+ Trans,
8
+ TransConfig,
9
+ CreatorService,
10
+ RefresherService,
11
+ ITransPaymentSingleService,
12
+ ITransInternalService,
13
+ RefundService,
14
+ } from '@smartsoft001/trans-domain';
15
+ import { PayuService } from '@smartsoft001/payu';
16
+ import { PaypalService } from '@smartsoft001/paypal';
17
+ import { RevolutService } from '@smartsoft001/revolut';
18
+ import { IItemRepository } from '@smartsoft001/domain-core';
19
+ import { PaynowService } from '@smartsoft001/paynow';
20
+
21
+ import { TRANS_TOKEN_INTERNAL_SERVICE } from '../internal/internal.service';
22
+
23
+ @Injectable()
24
+ export class TransService {
25
+ private _paymentService: {
26
+ [key: string]: ITransPaymentSingleService;
27
+ } = {
28
+ payu: this.payuService,
29
+ paypal: this.paypalService,
30
+ paynow: this.paynowService,
31
+ revolut: this.revolutService,
32
+ };
33
+
34
+ private _internalService = {
35
+ create: (trans: Trans<any>) => {
36
+ if (!this.config.internalApiUrl)
37
+ return Promise.resolve({
38
+ date: new Date(),
39
+ req: trans,
40
+ });
41
+
42
+ return this.httpService
43
+ .post(this.config.internalApiUrl, trans)
44
+ .toPromise()
45
+ .then((res) => res.data);
46
+ },
47
+
48
+ refresh: (trans: Trans<any>) => {
49
+ if (!this.config.internalApiUrl)
50
+ return Promise.resolve({
51
+ date: new Date(),
52
+ req: trans,
53
+ id: trans.id,
54
+ });
55
+
56
+ return this.httpService
57
+ .put(this.config.internalApiUrl + '/' + trans.id, trans)
58
+ .toPromise()
59
+ .then((res) => res.data);
60
+ },
61
+ };
62
+
63
+ constructor(
64
+ private moduleRef: ModuleRef,
65
+ private creatorService: CreatorService<any>,
66
+ private refresherService: RefresherService<any>,
67
+ private refundService: RefundService<any>,
68
+ private httpService: HttpService,
69
+ private config: TransConfig,
70
+ private repository: IItemRepository<Trans<any>>,
71
+ @Optional() private payuService: PayuService,
72
+ @Optional() private paynowService: PaynowService,
73
+ @Optional() private paypalService: PaypalService,
74
+ @Optional() private revolutService: RevolutService,
75
+ ) {}
76
+
77
+ create<T>(
78
+ ops: ITransCreate<T>,
79
+ ): Promise<{ orderId: string; redirectUrl?: string; responseData?: any }> {
80
+ return this.creatorService.create(
81
+ ops,
82
+ this.getInternalService(),
83
+ this._paymentService,
84
+ );
85
+ }
86
+
87
+ async refresh(transId: string, data = {}): Promise<void> {
88
+ await this.refresherService.refresh(
89
+ transId,
90
+ this.getInternalService(),
91
+ this._paymentService,
92
+ data,
93
+ );
94
+ }
95
+
96
+ async refund(transId: string, comment = 'Refund'): Promise<void> {
97
+ await this.refundService.refund(
98
+ transId,
99
+ this.getInternalService(),
100
+ this._paymentService,
101
+ comment,
102
+ );
103
+ }
104
+
105
+ async getById(id: any): Promise<Trans<any>> {
106
+ return await this.repository.getById(id);
107
+ }
108
+
109
+ private getInternalService(): ITransInternalService<any> {
110
+ try {
111
+ return this.moduleRef.get(TRANS_TOKEN_INTERNAL_SERVICE, {
112
+ strict: false,
113
+ });
114
+ } catch (e) {
115
+ return this._internalService;
116
+ }
117
+ }
118
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../../../tsconfig.base.json",
3
+ "files": [],
4
+ "include": [],
5
+ "references": [
6
+ {
7
+ "path": "./tsconfig.lib.json"
8
+ },
9
+ {
10
+ "path": "./tsconfig.spec.json"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "outDir": "../../../../dist/out-tsc",
6
+ "declaration": true,
7
+ "types": ["node"]
8
+ },
9
+ "exclude": ["**/*.spec.ts", "**/*.test.ts", "jest.config.ts"],
10
+ "include": ["**/*.ts"]
11
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../../../dist/out-tsc",
5
+ "module": "commonjs",
6
+ "types": ["jest", "node"]
7
+ },
8
+ "include": [
9
+ "**/*.spec.ts",
10
+ "**/*.test.ts",
11
+ "**/*.spec.tsx",
12
+ "**/*.test.tsx",
13
+ "**/*.spec.js",
14
+ "**/*.test.js",
15
+ "**/*.spec.jsx",
16
+ "**/*.test.jsx",
17
+ "**/*.d.ts",
18
+ "jest.config.ts"
19
+ ]
20
+ }
package/src/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./lib/services";
package/src/index.js DELETED
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./lib/services"), exports);
5
- //# sourceMappingURL=index.js.map
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../libs/trans/shell/app-services/src/index.ts"],"names":[],"mappings":";;;AAAA,yDAA+B"}
@@ -1,4 +0,0 @@
1
- import { TransService } from "./trans/trans.service";
2
- export * from './trans/trans.service';
3
- export * from './internal/internal.service';
4
- export declare const SERVICES: (typeof TransService)[];
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SERVICES = void 0;
4
- const tslib_1 = require("tslib");
5
- const trans_service_1 = require("./trans/trans.service");
6
- tslib_1.__exportStar(require("./trans/trans.service"), exports);
7
- tslib_1.__exportStar(require("./internal/internal.service"), exports);
8
- exports.SERVICES = [
9
- trans_service_1.TransService
10
- ];
11
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../libs/trans/shell/app-services/src/lib/services/index.ts"],"names":[],"mappings":";;;;AAAA,yDAAmD;AAEnD,gEAAsC;AACtC,sEAA4C;AAE/B,QAAA,QAAQ,GAAG;IACpB,4BAAY;CACf,CAAC"}
@@ -1 +0,0 @@
1
- export declare const TRANS_TOKEN_INTERNAL_SERVICE = "TRANS_TOKEN_INTERNAL_SERVICE";
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TRANS_TOKEN_INTERNAL_SERVICE = void 0;
4
- exports.TRANS_TOKEN_INTERNAL_SERVICE = "TRANS_TOKEN_INTERNAL_SERVICE";
5
- //# sourceMappingURL=internal.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"internal.service.js","sourceRoot":"","sources":["../../../../../../../../../libs/trans/shell/app-services/src/lib/services/internal/internal.service.ts"],"names":[],"mappings":";;;AAAa,QAAA,4BAA4B,GAAG,8BAA8B,CAAC"}
@@ -1,33 +0,0 @@
1
- import { ModuleRef } from "@nestjs/core";
2
- import { HttpService } from "@nestjs/axios";
3
- import { ITransCreate, Trans, TransConfig, CreatorService, RefresherService, RefundService } from "@smartsoft001/trans-domain";
4
- import { PayuService } from "@smartsoft001/payu";
5
- import { PaypalService } from "@smartsoft001/paypal";
6
- import { RevolutService } from "@smartsoft001/revolut";
7
- import { IItemRepository } from "@smartsoft001/domain-core";
8
- import { PaynowService } from "@smartsoft001/paynow";
9
- export declare class TransService {
10
- private moduleRef;
11
- private creatorService;
12
- private refresherService;
13
- private refundService;
14
- private httpService;
15
- private config;
16
- private repository;
17
- private payuService;
18
- private paynowService;
19
- private paypalService;
20
- private revolutService;
21
- private _paymentService;
22
- private _internalService;
23
- constructor(moduleRef: ModuleRef, creatorService: CreatorService<any>, refresherService: RefresherService<any>, refundService: RefundService<any>, httpService: HttpService, config: TransConfig, repository: IItemRepository<Trans<any>>, payuService: PayuService, paynowService: PaynowService, paypalService: PaypalService, revolutService: RevolutService);
24
- create<T>(ops: ITransCreate<T>): Promise<{
25
- orderId: string;
26
- redirectUrl?: string;
27
- responseData?: any;
28
- }>;
29
- refresh(transId: string, data?: {}): Promise<void>;
30
- refund(transId: string, comment?: string): Promise<void>;
31
- getById(id: any): Promise<Trans<any>>;
32
- private getInternalService;
33
- }
@@ -1,101 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TransService = void 0;
4
- const tslib_1 = require("tslib");
5
- const common_1 = require("@nestjs/common");
6
- const core_1 = require("@nestjs/core");
7
- const axios_1 = require("@nestjs/axios");
8
- const trans_domain_1 = require("@smartsoft001/trans-domain");
9
- const payu_1 = require("@smartsoft001/payu");
10
- const paypal_1 = require("@smartsoft001/paypal");
11
- const revolut_1 = require("@smartsoft001/revolut");
12
- const domain_core_1 = require("@smartsoft001/domain-core");
13
- const paynow_1 = require("@smartsoft001/paynow");
14
- const internal_service_1 = require("../internal/internal.service");
15
- let TransService = exports.TransService = class TransService {
16
- constructor(moduleRef, creatorService, refresherService, refundService, httpService, config, repository, payuService, paynowService, paypalService, revolutService) {
17
- this.moduleRef = moduleRef;
18
- this.creatorService = creatorService;
19
- this.refresherService = refresherService;
20
- this.refundService = refundService;
21
- this.httpService = httpService;
22
- this.config = config;
23
- this.repository = repository;
24
- this.payuService = payuService;
25
- this.paynowService = paynowService;
26
- this.paypalService = paypalService;
27
- this.revolutService = revolutService;
28
- this._paymentService = {
29
- payu: this.payuService,
30
- paypal: this.paypalService,
31
- paynow: this.paynowService,
32
- revolut: this.revolutService,
33
- };
34
- this._internalService = {
35
- create: (trans) => {
36
- if (!this.config.internalApiUrl)
37
- return Promise.resolve({
38
- date: new Date(),
39
- req: trans
40
- });
41
- return this.httpService
42
- .post(this.config.internalApiUrl, trans)
43
- .toPromise()
44
- .then((res) => res.data);
45
- },
46
- refresh: (trans) => {
47
- if (!this.config.internalApiUrl)
48
- return Promise.resolve({
49
- date: new Date(),
50
- req: trans,
51
- id: trans.id
52
- });
53
- return this.httpService
54
- .put(this.config.internalApiUrl + "/" + trans.id, trans)
55
- .toPromise()
56
- .then((res) => res.data);
57
- },
58
- };
59
- }
60
- create(ops) {
61
- return this.creatorService.create(ops, this.getInternalService(), this._paymentService);
62
- }
63
- async refresh(transId, data = {}) {
64
- await this.refresherService.refresh(transId, this.getInternalService(), this._paymentService, data);
65
- }
66
- async refund(transId, comment = "Refund") {
67
- await this.refundService.refund(transId, this.getInternalService(), this._paymentService, comment);
68
- }
69
- async getById(id) {
70
- return await this.repository.getById(id);
71
- }
72
- getInternalService() {
73
- try {
74
- return this.moduleRef.get(internal_service_1.TRANS_TOKEN_INTERNAL_SERVICE, {
75
- strict: false,
76
- });
77
- }
78
- catch (e) {
79
- return this._internalService;
80
- }
81
- }
82
- };
83
- exports.TransService = TransService = tslib_1.__decorate([
84
- (0, common_1.Injectable)(),
85
- tslib_1.__param(7, (0, common_1.Optional)()),
86
- tslib_1.__param(8, (0, common_1.Optional)()),
87
- tslib_1.__param(9, (0, common_1.Optional)()),
88
- tslib_1.__param(10, (0, common_1.Optional)()),
89
- tslib_1.__metadata("design:paramtypes", [core_1.ModuleRef,
90
- trans_domain_1.CreatorService,
91
- trans_domain_1.RefresherService,
92
- trans_domain_1.RefundService,
93
- axios_1.HttpService,
94
- trans_domain_1.TransConfig,
95
- domain_core_1.IItemRepository,
96
- payu_1.PayuService,
97
- paynow_1.PaynowService,
98
- paypal_1.PaypalService,
99
- revolut_1.RevolutService])
100
- ], TransService);
101
- //# sourceMappingURL=trans.service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"trans.service.js","sourceRoot":"","sources":["../../../../../../../../../libs/trans/shell/app-services/src/lib/services/trans/trans.service.ts"],"names":[],"mappings":";;;;AAAA,2CAAsD;AACtD,uCAAyC;AACzC,yCAA0C;AAE1C,6DAQoC;AACpC,6CAAiD;AACjD,iDAAqD;AACrD,mDAAuD;AACvD,2DAA0D;AAC1D,iDAAmD;AAEnD,mEAA4E;AAGrE,IAAM,YAAY,0BAAlB,MAAM,YAAY;IAqCvB,YACU,SAAoB,EACpB,cAAmC,EACnC,gBAAuC,EACvC,aAAiC,EACjC,WAAwB,EACxB,MAAmB,EACnB,UAAuC,EACnC,WAAgC,EAChC,aAAoC,EACpC,aAAoC,EACpC,cAAsC;QAV1C,cAAS,GAAT,SAAS,CAAW;QACpB,mBAAc,GAAd,cAAc,CAAqB;QACnC,qBAAgB,GAAhB,gBAAgB,CAAuB;QACvC,kBAAa,GAAb,aAAa,CAAoB;QACjC,gBAAW,GAAX,WAAW,CAAa;QACxB,WAAM,GAAN,MAAM,CAAa;QACnB,eAAU,GAAV,UAAU,CAA6B;QAC3B,gBAAW,GAAX,WAAW,CAAa;QACxB,kBAAa,GAAb,aAAa,CAAe;QAC5B,kBAAa,GAAb,aAAa,CAAe;QAC5B,mBAAc,GAAd,cAAc,CAAgB;QA/C5C,oBAAe,GAEnB;YACF,IAAI,EAAE,I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 -1 +0,0 @@
1
- {"version":3,"file":"test-setup.js","sourceRoot":"","sources":["../../../../../libs/trans/shell/app-services/test-setup.ts"],"names":[],"mappings":""}
File without changes