@xsolla/payment-client-core 0.0.4 → 0.0.6
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/esm2020/lib/core/device-finger-print/device-finger-print-components.interface.mjs +2 -0
- package/esm2020/lib/core/device-finger-print/device-finger-print.service.mjs +167 -0
- package/esm2020/lib/core/device-finger-print/fingerprint-js.interface.mjs +2 -0
- package/esm2020/lib/core/device-finger-print/hash.type.mjs +2 -0
- package/esm2020/lib/core/exceptions-handling/elk/additional-info.interface.mjs +2 -0
- package/esm2020/lib/core/exceptions-handling/elk/elk-logger.service.mjs +120 -0
- package/esm2020/lib/core/exceptions-handling/elk/error-without-meta-fields.interface.mjs +2 -0
- package/esm2020/lib/core/exceptions-handling/elk/log-message.interface.mjs +2 -0
- package/esm2020/lib/core/exceptions-handling/errors/default-terminal-error.class.mjs +8 -0
- package/esm2020/lib/core/exceptions-handling/errors/elk-error-types.enum.mjs +13 -0
- package/esm2020/lib/core/exceptions-handling/errors/tagged-error.class.mjs +16 -0
- package/esm2020/lib/core/exceptions-handling/errors/terminal-error.class.mjs +8 -0
- package/esm2020/lib/core/exceptions-handling/errors/token-error.class.mjs +7 -0
- package/esm2020/lib/core/exceptions-handling/errors/ws-error.class.mjs +10 -0
- package/esm2020/lib/core/payment/actions/action-factory-value.interface.mjs +2 -0
- package/esm2020/lib/core/payment/actions/action-type-command.map.mjs +6 -0
- package/esm2020/lib/core/payment/actions/action.interface.mjs +2 -0
- package/esm2020/lib/core/payment/actions/check-status/check-status.action.class.mjs +16 -0
- package/esm2020/lib/core/payment/actions/check-status/check-status.action.token.mjs +11 -0
- package/esm2020/lib/core/payment/actions/check-status/check-status.action.type.mjs +2 -0
- package/esm2020/lib/core/payment/actions/next-action.interface.mjs +2 -0
- package/esm2020/lib/core/payment/actions/next-action.service.mjs +55 -0
- package/esm2020/lib/core/payment/actions/next-actions.mjs +11 -0
- package/esm2020/lib/core/payment/actions/show-fields/show-fields.action.class.mjs +16 -0
- package/esm2020/lib/core/payment/actions/show-fields/show-fields.action.token.mjs +11 -0
- package/esm2020/lib/core/payment/actions/show-fields/show-fields.action.type.mjs +2 -0
- package/esm2020/lib/core/payment/actions/status-updated/status-updated.action.class.mjs +13 -0
- package/esm2020/lib/core/payment/actions/status-updated/status-updated.action.token.mjs +11 -0
- package/esm2020/lib/core/payment/actions/status-updated/status-updated.action.type.mjs +2 -0
- package/esm2020/lib/core/payment/field-names.enum.mjs +64 -0
- package/esm2020/lib/core/payment/field.interface.mjs +1 -1
- package/esm2020/lib/core/payment/form/common-control-config.interface.mjs +2 -0
- package/esm2020/lib/core/payment/form/controls/control-config.mjs +6 -0
- package/esm2020/lib/core/payment/form/controls/control-config.service.mjs +39 -0
- package/esm2020/lib/core/payment/form/controls/control-type.type.mjs +2 -0
- package/esm2020/lib/core/payment/form/controls/text-control.config.mjs +8 -0
- package/esm2020/lib/core/payment/form/converters/converter.abstract.mjs +75 -0
- package/esm2020/lib/core/payment/form/converters/converters-map.interface.mjs +2 -0
- package/esm2020/lib/core/payment/form/converters/converters-map.mjs +9 -0
- package/esm2020/lib/core/payment/form/converters/email.converter.mjs +29 -0
- package/esm2020/lib/core/payment/form/converters/zip.converter.mjs +64 -0
- package/esm2020/lib/core/payment/form/form-state.interface.mjs +2 -0
- package/esm2020/lib/core/payment/form/form.module.mjs +33 -0
- package/esm2020/lib/core/payment/form/form.service.mjs +28 -0
- package/esm2020/lib/core/payment/form/validators/convert.function.mjs +22 -0
- package/esm2020/lib/core/payment/form/validators/email-validator.mjs +7 -0
- package/esm2020/lib/core/payment/form/validators/required-validator.mjs +6 -0
- package/esm2020/lib/core/payment/form/validators/restricted-value.validator.mjs +6 -0
- package/esm2020/lib/core/payment/form/validators/validation-error.interface.mjs +2 -0
- package/esm2020/lib/core/payment/form/validators/validation-errors.interface.mjs +2 -0
- package/esm2020/lib/core/payment/form/validators/validator-fn.type.mjs +2 -0
- package/esm2020/lib/core/payment/initialize/initialize-request-params.interface.mjs +2 -0
- package/esm2020/lib/core/payment/initialize/initialize-response.class.mjs +43 -0
- package/esm2020/lib/core/payment/initialize/initialize-response.token.mjs +8 -0
- package/esm2020/lib/core/payment/initialize/initialize.service.mjs +46 -0
- package/esm2020/lib/core/payment/payment-form.interface.mjs +2 -0
- package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
- package/esm2020/lib/core/payment/payment.service.mjs +37 -14
- package/esm2020/lib/core/payment/status/check-status/check-status.service.mjs +56 -0
- package/esm2020/lib/core/payment/status/check-status/request/check-status-request.class.mjs +16 -0
- package/esm2020/lib/core/payment/status/check-status/request/check-status-request.token.mjs +8 -0
- package/esm2020/lib/core/payment/status/check-status/response/check-status-response.class.mjs +9 -0
- package/esm2020/lib/core/payment/status/check-status/response/check-status-response.token.mjs +8 -0
- package/esm2020/lib/core/payment/status/listen-status/listen-status.service.mjs +112 -0
- package/esm2020/lib/core/payment/status/status-groups.mjs +7 -0
- package/esm2020/lib/core/payment/status/status-params.interface.mjs +2 -0
- package/esm2020/lib/core/payment/status/status-request/request/status-request.class.mjs +22 -0
- package/esm2020/lib/core/payment/status/status-request/request/status-request.token.mjs +8 -0
- package/esm2020/lib/core/payment/status/status-request/response/status-response.class.mjs +96 -0
- package/esm2020/lib/core/payment/status/status-request/response/status-response.token.mjs +8 -0
- package/esm2020/lib/core/payment/status/status-request/status-request-params.interface.mjs +2 -0
- package/esm2020/lib/core/payment/status/status-request/status-request.service.mjs +68 -0
- package/esm2020/lib/core/payment/status/status-settings.interface.mjs +2 -0
- package/esm2020/lib/core/payment/status/status-updated.interface.mjs +2 -0
- package/esm2020/lib/core/payment/status/status.interface.mjs +1 -1
- package/esm2020/lib/core/payment/status/status.service.mjs +38 -0
- package/esm2020/lib/core/payment/status/websocket-status/websocket-status.enum.mjs +6 -0
- package/esm2020/lib/core/payment/status/websocket-status/websocket-status.service.mjs +76 -0
- package/esm2020/lib/core/payment/submit/request/submit-request.class.mjs +16 -0
- package/esm2020/lib/core/payment/submit/request/submit-request.token.mjs +8 -0
- package/esm2020/lib/core/payment/submit/response/submit-response.class.mjs +31 -0
- package/esm2020/lib/core/payment/submit/response/submit-response.token.mjs +8 -0
- package/esm2020/lib/core/payment/submit/submit.service.mjs +59 -0
- package/esm2020/lib/core/payment/sync/field-sync-state.interface.mjs +2 -0
- package/esm2020/lib/core/payment/sync/sync-request.class.mjs +31 -0
- package/esm2020/lib/core/payment/sync/sync-request.token.mjs +8 -0
- package/esm2020/lib/core/payment/sync/sync-response.class.mjs +14 -0
- package/esm2020/lib/core/payment/sync/sync-response.token.mjs +8 -0
- package/esm2020/lib/core/payment/sync/sync.service.mjs +91 -0
- package/esm2020/lib/core/payment/xps-api-part-request.abstract.mjs +8 -0
- package/esm2020/lib/core/payment/xps-api-part.abstract.mjs +19 -0
- package/esm2020/lib/core/payment/xps-error.interface.mjs +1 -1
- package/esm2020/lib/core/payment/xps-request.abstract.mjs +8 -0
- package/esm2020/lib/core/payment/xps-response.interface.mjs +1 -1
- package/esm2020/lib/core/properties.type.mjs +2 -0
- package/esm2020/lib/core/web-socket/centrifugo-web-socket.service.mjs +200 -0
- package/esm2020/lib/core/web-socket/nchan-web-socket.service.mjs +116 -0
- package/esm2020/lib/core/web-socket/web-socket-client-type.enum.mjs +6 -0
- package/esm2020/lib/core/web-socket/web-socket.factory.mjs +28 -0
- package/esm2020/lib/core/web-socket/web-socket.interface.mjs +2 -0
- package/esm2020/lib/core/xps-boolean.enum.mjs +2 -0
- package/esm2020/lib/core-library.module.mjs +43 -4
- package/esm2020/lib/core-library.service.mjs +18 -11
- package/fesm2015/xsolla-payment-client-core.mjs +2201 -87
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +2117 -83
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/device-finger-print/device-finger-print-components.interface.d.ts +4 -0
- package/lib/core/device-finger-print/device-finger-print.service.d.ts +44 -0
- package/lib/core/device-finger-print/fingerprint-js.interface.d.ts +6 -0
- package/lib/core/device-finger-print/hash.type.d.ts +3 -0
- package/lib/core/exceptions-handling/elk/additional-info.interface.d.ts +19 -0
- package/lib/core/exceptions-handling/elk/elk-logger.service.d.ts +27 -0
- package/lib/core/exceptions-handling/elk/error-without-meta-fields.interface.d.ts +8 -0
- package/lib/core/exceptions-handling/elk/log-message.interface.d.ts +8 -0
- package/lib/core/exceptions-handling/errors/default-terminal-error.class.d.ts +4 -0
- package/lib/core/exceptions-handling/errors/elk-error-types.enum.d.ts +11 -0
- package/lib/core/exceptions-handling/errors/tagged-error.class.d.ts +10 -0
- package/lib/core/exceptions-handling/errors/terminal-error.class.d.ts +5 -0
- package/lib/core/exceptions-handling/errors/token-error.class.d.ts +4 -0
- package/lib/core/exceptions-handling/errors/ws-error.class.d.ts +5 -0
- package/lib/core/payment/actions/action-factory-value.interface.d.ts +5 -0
- package/lib/core/payment/actions/action-type-command.map.d.ts +4 -0
- package/lib/core/payment/actions/check-status/check-status.action.class.d.ts +8 -0
- package/lib/core/payment/actions/check-status/check-status.action.token.d.ts +4 -0
- package/lib/core/payment/actions/check-status/check-status.action.type.d.ts +12 -0
- package/lib/core/payment/actions/next-action.interface.d.ts +4 -0
- package/lib/core/payment/actions/next-action.service.d.ts +20 -0
- package/lib/core/payment/actions/next-actions.d.ts +5 -0
- package/lib/core/payment/actions/show-fields/show-fields.action.class.d.ts +8 -0
- package/lib/core/payment/actions/show-fields/show-fields.action.token.d.ts +4 -0
- package/lib/core/payment/actions/show-fields/show-fields.action.type.d.ts +12 -0
- package/lib/core/payment/actions/status-updated/status-updated.action.class.d.ts +8 -0
- package/lib/core/payment/actions/status-updated/status-updated.action.token.d.ts +4 -0
- package/lib/core/payment/actions/status-updated/status-updated.action.type.d.ts +11 -0
- package/lib/core/payment/field-names.enum.d.ts +62 -0
- package/lib/core/payment/field.interface.d.ts +5 -5
- package/lib/core/payment/form/common-control-config.interface.d.ts +9 -0
- package/lib/core/payment/form/controls/control-config.d.ts +9 -0
- package/lib/core/payment/form/controls/control-config.service.d.ts +15 -0
- package/lib/core/payment/form/controls/control-type.type.d.ts +1 -0
- package/lib/core/payment/form/controls/text-control.config.d.ts +11 -0
- package/lib/core/payment/form/converters/converter.abstract.d.ts +23 -0
- package/lib/core/payment/form/converters/converters-map.d.ts +4 -0
- package/lib/core/payment/form/converters/converters-map.interface.d.ts +5 -0
- package/lib/core/payment/form/converters/email.converter.d.ts +14 -0
- package/lib/core/payment/form/converters/zip.converter.d.ts +21 -0
- package/lib/core/payment/form/form-state.interface.d.ts +3 -0
- package/lib/core/payment/form/form.module.d.ts +7 -0
- package/lib/core/payment/form/form.service.d.ts +12 -0
- package/lib/core/payment/form/validators/convert.function.d.ts +3 -0
- package/lib/core/payment/form/validators/email-validator.d.ts +2 -0
- package/lib/core/payment/form/validators/required-validator.d.ts +2 -0
- package/lib/core/payment/form/validators/restricted-value.validator.d.ts +2 -0
- package/lib/core/payment/form/validators/validation-error.interface.d.ts +4 -0
- package/lib/core/payment/form/validators/validation-errors.interface.d.ts +4 -0
- package/lib/core/payment/form/validators/validator-fn.type.d.ts +3 -0
- package/lib/core/payment/initialize/initialize-response.class.d.ts +7 -0
- package/lib/core/payment/initialize/initialize-response.token.d.ts +6 -0
- package/lib/core/payment/initialize/initialize.service.d.ts +18 -0
- package/lib/core/payment/payment-form.interface.d.ts +39 -0
- package/lib/core/payment/payment.interface.d.ts +12 -8
- package/lib/core/payment/payment.service.d.ts +23 -8
- package/lib/core/payment/status/check-status/check-status.service.d.ts +20 -0
- package/lib/core/payment/status/check-status/request/check-status-request.class.d.ts +8 -0
- package/lib/core/payment/status/check-status/request/check-status-request.token.d.ts +6 -0
- package/lib/core/payment/status/check-status/response/check-status-response.class.d.ts +8 -0
- package/lib/core/payment/status/check-status/response/check-status-response.token.d.ts +7 -0
- package/lib/core/payment/status/listen-status/listen-status.service.d.ts +28 -0
- package/lib/core/payment/status/status-groups.d.ts +5 -0
- package/lib/core/payment/status/status-params.interface.d.ts +9 -0
- package/lib/core/payment/status/status-request/request/status-request.class.d.ts +17 -0
- package/lib/core/payment/status/status-request/request/status-request.token.d.ts +6 -0
- package/lib/core/payment/status/status-request/response/status-response.class.d.ts +14 -0
- package/lib/core/payment/status/status-request/response/status-response.token.d.ts +7 -0
- package/lib/core/payment/status/status-request/status-request-params.interface.d.ts +10 -0
- package/lib/core/payment/status/status-request/status-request.service.d.ts +21 -0
- package/lib/core/payment/status/status-settings.interface.d.ts +13 -0
- package/lib/core/payment/status/status-updated.interface.d.ts +6 -0
- package/lib/core/payment/status/status.interface.d.ts +0 -1
- package/lib/core/payment/status/status.service.d.ts +16 -0
- package/lib/core/payment/status/websocket-status/websocket-status.enum.d.ts +4 -0
- package/lib/core/payment/status/websocket-status/websocket-status.service.d.ts +24 -0
- package/lib/core/payment/submit/request/submit-request.class.d.ts +13 -0
- package/lib/core/payment/submit/request/submit-request.token.d.ts +6 -0
- package/lib/core/payment/submit/response/submit-response.class.d.ts +26 -0
- package/lib/core/payment/submit/response/submit-response.token.d.ts +6 -0
- package/lib/core/payment/submit/submit.service.d.ts +21 -0
- package/lib/core/payment/sync/field-sync-state.interface.d.ts +5 -0
- package/lib/core/payment/sync/sync-request.class.d.ts +15 -0
- package/lib/core/payment/sync/sync-request.token.d.ts +6 -0
- package/lib/core/payment/sync/sync-response.class.d.ts +11 -0
- package/lib/core/payment/sync/sync-response.token.d.ts +6 -0
- package/lib/core/payment/sync/sync.service.d.ts +27 -0
- package/lib/core/payment/xps-api-part-request.abstract.d.ts +6 -0
- package/lib/core/payment/xps-api-part.abstract.d.ts +8 -0
- package/lib/core/payment/xps-error.interface.d.ts +1 -0
- package/lib/core/payment/xps-request.abstract.d.ts +6 -0
- package/lib/core/payment/xps-response.interface.d.ts +3 -6
- package/lib/core/properties.type.d.ts +3 -0
- package/lib/core/web-socket/centrifugo-web-socket.service.d.ts +41 -0
- package/lib/core/web-socket/nchan-web-socket.service.d.ts +30 -0
- package/lib/core/web-socket/web-socket-client-type.enum.d.ts +4 -0
- package/lib/core/web-socket/web-socket.factory.d.ts +13 -0
- package/lib/core/web-socket/web-socket.interface.d.ts +9 -0
- package/lib/core/xps-boolean.enum.d.ts +4 -0
- package/lib/core-library.module.d.ts +2 -1
- package/lib/core-library.service.d.ts +6 -2
- package/package.json +19 -4
- package/xsolla-payment-client-core-0.0.6.tgz +0 -0
- package/esm2020/lib/core/boolean-string.enum.mjs +0 -6
- package/esm2020/lib/core/payment/actions/action.type.mjs +0 -2
- package/esm2020/lib/core/payment/actions/check-status.action.type.mjs +0 -2
- package/esm2020/lib/core/payment/actions/next-action.type.mjs +0 -2
- package/esm2020/lib/core/payment/initialize-request-params.interface.mjs +0 -2
- package/esm2020/lib/core/payment/initialize.service.mjs +0 -39
- package/lib/core/boolean-string.enum.d.ts +0 -4
- package/lib/core/payment/actions/check-status.action.type.d.ts +0 -12
- package/lib/core/payment/actions/next-action.type.d.ts +0 -2
- package/lib/core/payment/initialize.service.d.ts +0 -16
- package/xsolla-payment-client-core-0.0.4.tgz +0 -0
- /package/lib/core/payment/actions/{action.type.d.ts → action.interface.d.ts} +0 -0
- /package/lib/core/payment/{initialize-request-params.interface.d.ts → initialize/initialize-request-params.interface.d.ts} +0 -0
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { InjectionToken, Injectable, Inject, NgModule } from '@angular/core';
|
|
4
|
-
import { firstValueFrom, lastValueFrom, map, throwError } from 'rxjs';
|
|
3
|
+
import { InjectionToken, Injectable, Inject, isDevMode, NgModule } from '@angular/core';
|
|
4
|
+
import { firstValueFrom, lastValueFrom, map, BehaviorSubject, Subject, filter as filter$1, takeUntil, skip, throwError } from 'rxjs';
|
|
5
5
|
import * as i1 from '@angular/common/http';
|
|
6
6
|
import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
7
|
-
import {
|
|
7
|
+
import { UntypedFormGroup, Validators, UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
|
|
8
|
+
import { filter, map as map$1, catchError } from 'rxjs/operators';
|
|
8
9
|
import * as i1$1 from '@angular/router';
|
|
9
10
|
|
|
10
11
|
class AppError extends Error {
|
|
@@ -424,6 +425,2134 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
424
425
|
}] }, { type: SettingsService }, { type: SecureApiClient }];
|
|
425
426
|
} });
|
|
426
427
|
|
|
428
|
+
class InitializeResponse {
|
|
429
|
+
constructor(response) {
|
|
430
|
+
this.paymentForm = null;
|
|
431
|
+
this.paymentForm = this.extractPaymentForm(response);
|
|
432
|
+
}
|
|
433
|
+
extractPaymentForm(response) {
|
|
434
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
435
|
+
if (!response) {
|
|
436
|
+
return null;
|
|
437
|
+
}
|
|
438
|
+
return {
|
|
439
|
+
totalAmount: response.buyData.sum,
|
|
440
|
+
currency: response.buyData.currency,
|
|
441
|
+
fields: Object.keys(response.form).map((key) => response.form[key]),
|
|
442
|
+
taxDisclaimer: response.taxDisclaimer,
|
|
443
|
+
number: response.number,
|
|
444
|
+
barcode: response.barcode,
|
|
445
|
+
instruction: response.instruction,
|
|
446
|
+
offers: response.offers,
|
|
447
|
+
error: response.error,
|
|
448
|
+
errors: response.errors,
|
|
449
|
+
restrictions: response.restrictions,
|
|
450
|
+
info: response.info,
|
|
451
|
+
buyData: response.buyData,
|
|
452
|
+
pid: response.pid,
|
|
453
|
+
messages: (_a = response.messages) !== null && _a !== void 0 ? _a : [],
|
|
454
|
+
title: response.title,
|
|
455
|
+
summary: response.summary,
|
|
456
|
+
skipForm: response.skipForm,
|
|
457
|
+
isSavedMethodPayment: !!((_b = response.form) === null || _b === void 0 ? void 0 : _b.saved_method_id),
|
|
458
|
+
couponCode: ((_d = (_c = response.form) === null || _c === void 0 ? void 0 : _c.couponCode) === null || _d === void 0 ? void 0 : _d.value) || '',
|
|
459
|
+
publicId: response.public_id,
|
|
460
|
+
skipCheckout: response.skipCheckout,
|
|
461
|
+
koreaNotification: response.form.korea_limits_instruction,
|
|
462
|
+
isCheckout: response.isCheckout,
|
|
463
|
+
categories: response.categories,
|
|
464
|
+
hasFatalErrors: (_e = response.textAll) === null || _e === void 0 ? void 0 : _e.fatal,
|
|
465
|
+
userSession: response.userSession,
|
|
466
|
+
statusText: (_h = (_g = (_f = response.status) === null || _f === void 0 ? void 0 : _f.statusData) === null || _g === void 0 ? void 0 : _g.stateText) !== null && _h !== void 0 ? _h : null,
|
|
467
|
+
country: response.country ? response.country.iso : null,
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
const initializeResponseFactoryToken = new InjectionToken('InitializeResponse');
|
|
473
|
+
const initializeResponseFactoryProvider = {
|
|
474
|
+
provide: initializeResponseFactoryToken,
|
|
475
|
+
useValue: (...args) => new InitializeResponse(...args),
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
class InitializeService {
|
|
479
|
+
constructor(responseFactory, secureApi, settingsService, countryService) {
|
|
480
|
+
this.responseFactory = responseFactory;
|
|
481
|
+
this.secureApi = secureApi;
|
|
482
|
+
this.settingsService = settingsService;
|
|
483
|
+
this.countryService = countryService;
|
|
484
|
+
this.apiRoute = 'directpayment';
|
|
485
|
+
}
|
|
486
|
+
request(config) {
|
|
487
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
488
|
+
const requestParams = {
|
|
489
|
+
access_token: this.settingsService.token,
|
|
490
|
+
pid: String(config.paymentMethodId),
|
|
491
|
+
country: this.countryService.getCountry(),
|
|
492
|
+
returnUrl: config.returnUrl,
|
|
493
|
+
};
|
|
494
|
+
return lastValueFrom(this.secureApi
|
|
495
|
+
.post(this.apiRoute, new URLSearchParams(Object.assign({}, requestParams)), {
|
|
496
|
+
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
497
|
+
responseType: 'json',
|
|
498
|
+
})
|
|
499
|
+
.pipe(map((response) => this.responseFactory(response)))).catch((error) => {
|
|
500
|
+
throw new ResponseError(error.message);
|
|
501
|
+
});
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
InitializeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, deps: [{ token: initializeResponseFactoryToken }, { token: SecureApiClient }, { token: SettingsService }, { token: CountryService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
506
|
+
InitializeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, providedIn: 'root' });
|
|
507
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, decorators: [{
|
|
508
|
+
type: Injectable,
|
|
509
|
+
args: [{
|
|
510
|
+
providedIn: 'root',
|
|
511
|
+
}]
|
|
512
|
+
}], ctorParameters: function () {
|
|
513
|
+
return [{ type: undefined, decorators: [{
|
|
514
|
+
type: Inject,
|
|
515
|
+
args: [initializeResponseFactoryToken]
|
|
516
|
+
}] }, { type: SecureApiClient }, { type: SettingsService }, { type: CountryService }];
|
|
517
|
+
} });
|
|
518
|
+
|
|
519
|
+
class XpsApiPartRequest {
|
|
520
|
+
addXpsParameters(parameters) {
|
|
521
|
+
for (const key in parameters) {
|
|
522
|
+
this[`xps_${key}`] = parameters[key];
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
class TokenError extends AppError {
|
|
528
|
+
constructor() {
|
|
529
|
+
super('XPS API needs token.');
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
class SubmitRequest extends XpsApiPartRequest {
|
|
534
|
+
constructor(parameters) {
|
|
535
|
+
super();
|
|
536
|
+
const { token, dfpHash } = parameters;
|
|
537
|
+
if (token === null) {
|
|
538
|
+
throw new TokenError();
|
|
539
|
+
}
|
|
540
|
+
this.access_token = token;
|
|
541
|
+
if (dfpHash) {
|
|
542
|
+
this.xps_dfp_hash = dfpHash;
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
const submitRequestFactoryToken = new InjectionToken('SubmitRequest');
|
|
548
|
+
const submitRequestFactoryProvider = {
|
|
549
|
+
provide: submitRequestFactoryToken,
|
|
550
|
+
useValue: (...args) => new SubmitRequest(...args),
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
var XpsCommand;
|
|
554
|
+
(function (XpsCommand) {
|
|
555
|
+
XpsCommand["form"] = "form";
|
|
556
|
+
XpsCommand["check"] = "check";
|
|
557
|
+
XpsCommand["status"] = "status";
|
|
558
|
+
XpsCommand["checkout"] = "checkout";
|
|
559
|
+
XpsCommand["account"] = "account";
|
|
560
|
+
XpsCommand["create"] = "create";
|
|
561
|
+
})(XpsCommand || (XpsCommand = {}));
|
|
562
|
+
|
|
563
|
+
var FieldNames;
|
|
564
|
+
(function (FieldNames) {
|
|
565
|
+
FieldNames["address1"] = "address1";
|
|
566
|
+
FieldNames["address2"] = "address2";
|
|
567
|
+
FieldNames["address"] = "address";
|
|
568
|
+
FieldNames["allowRecurrentSubscription"] = "allowRecurrentSubscription";
|
|
569
|
+
FieldNames["allowSubscription"] = "allowSubscription";
|
|
570
|
+
FieldNames["apt"] = "apt";
|
|
571
|
+
FieldNames["availableCardTypes"] = "available_card_types";
|
|
572
|
+
FieldNames["bank"] = "bank";
|
|
573
|
+
FieldNames["birthDate"] = "birth_date";
|
|
574
|
+
FieldNames["cardMonth"] = "card_month";
|
|
575
|
+
FieldNames["cardYear"] = "card_year";
|
|
576
|
+
FieldNames["cardNumber"] = "card_number";
|
|
577
|
+
FieldNames["cardholdername"] = "cardholdername";
|
|
578
|
+
FieldNames["city"] = "city";
|
|
579
|
+
FieldNames["couponCode"] = "couponCode";
|
|
580
|
+
FieldNames["cpfName"] = "cpf_name";
|
|
581
|
+
FieldNames["cpfNumber"] = "cpf_number";
|
|
582
|
+
FieldNames["cvv"] = "cvv";
|
|
583
|
+
FieldNames["description"] = "description";
|
|
584
|
+
FieldNames["email"] = "email";
|
|
585
|
+
FieldNames["psEmail"] = "psEmail";
|
|
586
|
+
FieldNames["euCheck"] = "eu_check";
|
|
587
|
+
FieldNames["extraCvv"] = "extra_cvv";
|
|
588
|
+
FieldNames["extraCardNumber"] = "extra_card_number";
|
|
589
|
+
FieldNames["extraCardType"] = "extra_card_type";
|
|
590
|
+
FieldNames["fName"] = "f_name";
|
|
591
|
+
FieldNames["installments"] = "installments";
|
|
592
|
+
FieldNames["lName"] = "l_name";
|
|
593
|
+
FieldNames["needInstallments"] = "needInstallments";
|
|
594
|
+
FieldNames["personId"] = "person_id";
|
|
595
|
+
FieldNames["personIdAr"] = "person_id_ar";
|
|
596
|
+
FieldNames["personIdCo"] = "person_id_co";
|
|
597
|
+
FieldNames["phone"] = "phone";
|
|
598
|
+
FieldNames["purchaseDescription"] = "purchaseDescription";
|
|
599
|
+
FieldNames["recurrentType"] = "recurrent_type";
|
|
600
|
+
FieldNames["rockstarTaxes"] = "rockstar_taxes";
|
|
601
|
+
FieldNames["state"] = "state";
|
|
602
|
+
FieldNames["street"] = "street";
|
|
603
|
+
FieldNames["streetNumber"] = "street_number";
|
|
604
|
+
FieldNames["take2Taxes"] = "take2_taxes";
|
|
605
|
+
FieldNames["termsAndConditions"] = "termsAndConditions";
|
|
606
|
+
FieldNames["termsAndConditionsAtariPp"] = "termsAndConditionsAtariPP";
|
|
607
|
+
FieldNames["termsAndConditionsAtariTc"] = "termsAndConditionsAtariTC";
|
|
608
|
+
FieldNames["termsAndConditionsHtcEula"] = "termsAndConditionsHtcEula";
|
|
609
|
+
FieldNames["termsAndConditionsRobloxEula"] = "termsAndConditionsRobloxEula";
|
|
610
|
+
FieldNames["termsAndConditionsRolandEula"] = "termsAndConditionsRolandEula";
|
|
611
|
+
FieldNames["termsAndConditionsDeusLoVultEula"] = "termsAndConditionsDeusLoVultEula";
|
|
612
|
+
FieldNames["termsAndConditionsOnzenga"] = "termsAndConditionsOnzenga";
|
|
613
|
+
FieldNames["xsollaTipsAmount"] = "xsollaTipsAmount";
|
|
614
|
+
FieldNames["zip"] = "zip";
|
|
615
|
+
FieldNames["allowSave"] = "allowSave";
|
|
616
|
+
FieldNames["koreaLimitsInstruction"] = "korea_limits_instruction";
|
|
617
|
+
FieldNames["tokenApplePay"] = "token_applepay";
|
|
618
|
+
FieldNames["fixInvoice"] = "fix_invoice";
|
|
619
|
+
FieldNames["fixPid"] = "fix_pid";
|
|
620
|
+
FieldNames["signature"] = "signature";
|
|
621
|
+
FieldNames["qr"] = "qr";
|
|
622
|
+
FieldNames["sum"] = "sum";
|
|
623
|
+
FieldNames["out"] = "out";
|
|
624
|
+
FieldNames["tinkoffDisclaimer"] = "ps.tinkoff.disclaimer";
|
|
625
|
+
})(FieldNames || (FieldNames = {}));
|
|
626
|
+
|
|
627
|
+
class SubmitResponse {
|
|
628
|
+
constructor(parameters, responseNumber = 0) {
|
|
629
|
+
var _a, _b, _c;
|
|
630
|
+
this.responseNumber = responseNumber;
|
|
631
|
+
/* Todo split into properties */
|
|
632
|
+
this.parameters = parameters;
|
|
633
|
+
this.fields = Object.keys(parameters.form).map((key) => parameters.form[key]);
|
|
634
|
+
if (parameters.onlineBanking) {
|
|
635
|
+
this.onlineBanking = {
|
|
636
|
+
url: parameters.onlineBanking.value,
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
this.isNeedRedirect =
|
|
640
|
+
parameters.currentCommand === XpsCommand.account ||
|
|
641
|
+
(parameters.currentCommand === XpsCommand.checkout &&
|
|
642
|
+
Boolean(parameters.checkout));
|
|
643
|
+
this.buyData = parameters.buyData;
|
|
644
|
+
this.fixInvoice = (_a = this.fields.find((field) => field.name === FieldNames.fixInvoice)) === null || _a === void 0 ? void 0 : _a.value;
|
|
645
|
+
this.signature = (_b = this.fields.find((field) => field.name === FieldNames.signature)) === null || _b === void 0 ? void 0 : _b.value;
|
|
646
|
+
this.hasFatalErrors = (_c = parameters.textAll) === null || _c === void 0 ? void 0 : _c.fatal;
|
|
647
|
+
this.userSession = parameters.userSession;
|
|
648
|
+
this.pid = parameters.pid;
|
|
649
|
+
this.errors = parameters.errors;
|
|
650
|
+
this.summary = parameters.summary;
|
|
651
|
+
this.title = parameters.title;
|
|
652
|
+
this.currentCommand = parameters.currentCommand;
|
|
653
|
+
this.messages = parameters.messages;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
const submitResponseFactoryToken = new InjectionToken('SubmitResponse');
|
|
658
|
+
const submitResponseFactoryProvider = {
|
|
659
|
+
provide: submitResponseFactoryToken,
|
|
660
|
+
useValue: (...args) => new SubmitResponse(...args),
|
|
661
|
+
};
|
|
662
|
+
|
|
663
|
+
class TerminalError extends AppError {
|
|
664
|
+
constructor(message, code) {
|
|
665
|
+
super(message);
|
|
666
|
+
this.code = code;
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
class DefaultTerminalError extends TerminalError {
|
|
671
|
+
constructor() {
|
|
672
|
+
const message = `It's not you, it's us, but we can help. Please contact our customer support.`;
|
|
673
|
+
super(message, '1000-0002');
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
class DeviceFingerPrintService {
|
|
678
|
+
constructor(secureApi, settingsService, window) {
|
|
679
|
+
this.secureApi = secureApi;
|
|
680
|
+
this.settingsService = settingsService;
|
|
681
|
+
this.window = window;
|
|
682
|
+
this.apiRoute = 'dfp';
|
|
683
|
+
this.fingerprintApiUrl = 'https://afs.xsolla.com/dfp/api/v1/';
|
|
684
|
+
}
|
|
685
|
+
init() {
|
|
686
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
687
|
+
if (!this.settingsService.isInitialized) {
|
|
688
|
+
return;
|
|
689
|
+
}
|
|
690
|
+
this.fingerprintJs = yield this.loadFingerprintJs();
|
|
691
|
+
this.hash = yield this.buildHash();
|
|
692
|
+
this.antifraudFingerprintLibrary =
|
|
693
|
+
yield this.loadAntifraudFingerprintLibrary();
|
|
694
|
+
});
|
|
695
|
+
}
|
|
696
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
697
|
+
getHash() {
|
|
698
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
699
|
+
return this.hash;
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
loadFingerprintJs() {
|
|
703
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
704
|
+
const { default: library, murmurX64Hash128: getHash } = yield import('@fingerprintjs/fingerprintjs');
|
|
705
|
+
return { library, getHash };
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
loadAntifraudFingerprintLibrary() {
|
|
709
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
710
|
+
const library = yield import('@xsolla/antifraud-fingerprint');
|
|
711
|
+
return library.default;
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
715
|
+
makeAntifraudFingerprint() {
|
|
716
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
717
|
+
if (!this.settingsService.token) {
|
|
718
|
+
return null;
|
|
719
|
+
}
|
|
720
|
+
const antifraudFingerprint = this.antifraudFingerprintLibrary;
|
|
721
|
+
try {
|
|
722
|
+
return new antifraudFingerprint({
|
|
723
|
+
api: {
|
|
724
|
+
url: this.fingerprintApiUrl,
|
|
725
|
+
token: this.settingsService.token,
|
|
726
|
+
timeout: 3000,
|
|
727
|
+
},
|
|
728
|
+
retry: {
|
|
729
|
+
num: 1,
|
|
730
|
+
timeout: 500,
|
|
731
|
+
},
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
catch (error) {
|
|
735
|
+
return null;
|
|
736
|
+
}
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
/**
|
|
740
|
+
*Загружаем библиотеку, генерируем данные,
|
|
741
|
+
*хешируем с помощью BASE64 и отправляем на бэкенд,
|
|
742
|
+
*в ответ получаем dfp_hash.
|
|
743
|
+
**/
|
|
744
|
+
buildHash() {
|
|
745
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
746
|
+
const fingerPrintData = yield this.generate();
|
|
747
|
+
const hash = yield this.send(fingerPrintData).catch(() => {
|
|
748
|
+
return null;
|
|
749
|
+
});
|
|
750
|
+
return JSON.stringify(hash);
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
*Новая версия библиотеки содержит не все компоненты, некоторые приходится имплементировать самостоятельно
|
|
755
|
+
**/
|
|
756
|
+
getHasLiedResolution() {
|
|
757
|
+
const { screen } = this.window;
|
|
758
|
+
return (screen.width < screen.availWidth || screen.height < screen.availHeight);
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
*Бэкенд заточен под конкретные поля, которые необходимо смапить.
|
|
762
|
+
**/
|
|
763
|
+
getComponents(components) {
|
|
764
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
765
|
+
return {
|
|
766
|
+
user_agent: navigator.userAgent,
|
|
767
|
+
language: (_c = (_b = (_a = components.languages.value) === null || _a === void 0 ? void 0 : _a.shift()) === null || _b === void 0 ? void 0 : _b.shift()) !== null && _c !== void 0 ? _c : '',
|
|
768
|
+
color_depth: components.colorDepth.value,
|
|
769
|
+
device_memory: components.deviceMemory.value,
|
|
770
|
+
hardware_concurrency: components.hardwareConcurrency.value,
|
|
771
|
+
resolution: components.screenResolution.value,
|
|
772
|
+
available_resolution: components.screenResolution.value,
|
|
773
|
+
timezone_offset: new Date().getTimezoneOffset(),
|
|
774
|
+
session_storage: components.sessionStorage.value ? 1 : 0,
|
|
775
|
+
local_storage: components.localStorage.value ? 1 : 0,
|
|
776
|
+
indexed_db: components.indexedDB.value ? 1 : 0,
|
|
777
|
+
open_database: components.openDatabase.value ? 1 : 0,
|
|
778
|
+
navigator_platform: components.platform.value,
|
|
779
|
+
regular_plugins: (_e = (_d = components.plugins.value) === null || _d === void 0 ? void 0 : _d.map((plugin) => plugin.name)) !== null && _e !== void 0 ? _e : [],
|
|
780
|
+
canvas: (_f = components.canvas.value) === null || _f === void 0 ? void 0 : _f.text,
|
|
781
|
+
webgl: (_g = components.canvas.value) === null || _g === void 0 ? void 0 : _g.text,
|
|
782
|
+
webgl_vendor: components.vendor.value,
|
|
783
|
+
has_lied_resolution: this.getHasLiedResolution(),
|
|
784
|
+
touch_support: Object.values((_h = components.touchSupport.value) !== null && _h !== void 0 ? _h : {}),
|
|
785
|
+
js_fonts: components.fonts.value,
|
|
786
|
+
};
|
|
787
|
+
}
|
|
788
|
+
/**
|
|
789
|
+
* Получаем данные dfp с помощью FingerprintJS, мапим необходимые поля, добавляем хэш
|
|
790
|
+
**/
|
|
791
|
+
generate() {
|
|
792
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
793
|
+
const { library, getHash } = this.fingerprintJs;
|
|
794
|
+
const fingerprint = yield library.load();
|
|
795
|
+
const commonFingerPrintData = yield fingerprint.get();
|
|
796
|
+
const fingerPrintData = this.getComponents(commonFingerPrintData.components);
|
|
797
|
+
fingerPrintData.hash = getHash(JSON.stringify(fingerPrintData));
|
|
798
|
+
return fingerPrintData;
|
|
799
|
+
});
|
|
800
|
+
}
|
|
801
|
+
/**
|
|
802
|
+
* Отправка dfp на сервер, в ответ получаем dfp_hash
|
|
803
|
+
**/
|
|
804
|
+
send(fingerPrintData) {
|
|
805
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
806
|
+
const token = this.settingsService.token;
|
|
807
|
+
if (token === null) {
|
|
808
|
+
throw new DefaultTerminalError();
|
|
809
|
+
}
|
|
810
|
+
const requestBody = {
|
|
811
|
+
access_token: token,
|
|
812
|
+
'dfp[200]': '',
|
|
813
|
+
};
|
|
814
|
+
requestBody['dfp[200]'] = btoa(encodeURIComponent(JSON.stringify(fingerPrintData)));
|
|
815
|
+
return lastValueFrom(this.secureApi.post(this.apiRoute, new URLSearchParams(requestBody), {
|
|
816
|
+
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
817
|
+
responseType: 'json',
|
|
818
|
+
}))
|
|
819
|
+
.then((response) => {
|
|
820
|
+
return response.dfp_hash;
|
|
821
|
+
})
|
|
822
|
+
.then((hash) => __awaiter(this, void 0, void 0, function* () {
|
|
823
|
+
const fingerprint = yield this.makeAntifraudFingerprint();
|
|
824
|
+
if (!fingerprint) {
|
|
825
|
+
return null;
|
|
826
|
+
}
|
|
827
|
+
yield (fingerprint === null || fingerprint === void 0 ? void 0 : fingerprint.dispatch(hash['200']).catch((err) => console.log(err)));
|
|
828
|
+
const afsHash = yield fingerprint.hash();
|
|
829
|
+
return Object.assign({ '301': afsHash }, hash);
|
|
830
|
+
}))
|
|
831
|
+
.catch((error) => {
|
|
832
|
+
var _a, _b, _c, _d, _e, _f;
|
|
833
|
+
const response = error.getHttpErrorData().response;
|
|
834
|
+
throw new TerminalError((_c = (_b = (_a = response.data) === null || _a === void 0 ? void 0 : _a.errors[0]) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : '', (_f = (_e = (_d = response.data) === null || _d === void 0 ? void 0 : _d.errors[0]) === null || _e === void 0 ? void 0 : _e.support_code) !== null && _f !== void 0 ? _f : '');
|
|
835
|
+
});
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
DeviceFingerPrintService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DeviceFingerPrintService, deps: [{ token: SecureApiClient }, { token: SettingsService }, { token: windowToken }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
840
|
+
DeviceFingerPrintService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DeviceFingerPrintService, providedIn: 'root' });
|
|
841
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DeviceFingerPrintService, decorators: [{
|
|
842
|
+
type: Injectable,
|
|
843
|
+
args: [{
|
|
844
|
+
providedIn: 'root',
|
|
845
|
+
}]
|
|
846
|
+
}], ctorParameters: function () {
|
|
847
|
+
return [{ type: SecureApiClient }, { type: SettingsService }, { type: undefined, decorators: [{
|
|
848
|
+
type: Inject,
|
|
849
|
+
args: [windowToken]
|
|
850
|
+
}] }];
|
|
851
|
+
} });
|
|
852
|
+
|
|
853
|
+
class SubmitService {
|
|
854
|
+
constructor(requestFactory, responseFactory, settingsService, deviceFingerPrintService, secureApi) {
|
|
855
|
+
this.requestFactory = requestFactory;
|
|
856
|
+
this.responseFactory = responseFactory;
|
|
857
|
+
this.settingsService = settingsService;
|
|
858
|
+
this.deviceFingerPrintService = deviceFingerPrintService;
|
|
859
|
+
this.secureApi = secureApi;
|
|
860
|
+
this.directPaymentApiRoute = 'directpayment';
|
|
861
|
+
}
|
|
862
|
+
// NB: Never add 'async' statement for this method!
|
|
863
|
+
// 'Async' statement wraps current promise into another.
|
|
864
|
+
// In this way two promises become unequal, that can broke XPS API requests logic.
|
|
865
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
866
|
+
request(fields, form) {
|
|
867
|
+
const responsePromise = this.deviceFingerPrintService
|
|
868
|
+
.getHash()
|
|
869
|
+
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
870
|
+
.then((dfpHash) => {
|
|
871
|
+
const request = this.requestFactory({
|
|
872
|
+
token: this.settingsService.token,
|
|
873
|
+
fields,
|
|
874
|
+
form,
|
|
875
|
+
dfpHash,
|
|
876
|
+
});
|
|
877
|
+
return lastValueFrom(this.secureApi.post(this.directPaymentApiRoute, request, {
|
|
878
|
+
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
879
|
+
responseType: 'json',
|
|
880
|
+
}))
|
|
881
|
+
.then((response) => this.responseFactory(response))
|
|
882
|
+
.catch((error) => {
|
|
883
|
+
throw new ResponseError(error.message);
|
|
884
|
+
});
|
|
885
|
+
});
|
|
886
|
+
return responsePromise;
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
SubmitService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SubmitService, deps: [{ token: submitRequestFactoryToken }, { token: submitResponseFactoryToken }, { token: SettingsService }, { token: DeviceFingerPrintService }, { token: SecureApiClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
890
|
+
SubmitService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SubmitService, providedIn: 'root' });
|
|
891
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SubmitService, decorators: [{
|
|
892
|
+
type: Injectable,
|
|
893
|
+
args: [{ providedIn: 'root' }]
|
|
894
|
+
}], ctorParameters: function () {
|
|
895
|
+
return [{ type: undefined, decorators: [{
|
|
896
|
+
type: Inject,
|
|
897
|
+
args: [submitRequestFactoryToken]
|
|
898
|
+
}] }, { type: undefined, decorators: [{
|
|
899
|
+
type: Inject,
|
|
900
|
+
args: [submitResponseFactoryToken]
|
|
901
|
+
}] }, { type: SettingsService }, { type: DeviceFingerPrintService }, { type: SecureApiClient }];
|
|
902
|
+
} });
|
|
903
|
+
|
|
904
|
+
class XpsRequest {
|
|
905
|
+
addXpsParameters(parameters) {
|
|
906
|
+
for (const key in parameters) {
|
|
907
|
+
this[`xps_${key}`] = parameters[key];
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
913
|
+
class SyncRequest extends XpsRequest {
|
|
914
|
+
constructor(parameters) {
|
|
915
|
+
super();
|
|
916
|
+
this.xps_fix_command = 'calculate';
|
|
917
|
+
this.access_token = parameters.token;
|
|
918
|
+
const fieldsValues = this.getFieldsValues(parameters.changedField, parameters.fields, parameters.form);
|
|
919
|
+
this.addXpsParameters(Object.assign(Object.assign({}, fieldsValues), { change_element: parameters.changedField.name }));
|
|
920
|
+
}
|
|
921
|
+
getFieldsValues(changedField, fields, form) {
|
|
922
|
+
var _a;
|
|
923
|
+
const fieldsMap = this.getFieldsMap(fields);
|
|
924
|
+
return (_a = changedField === null || changedField === void 0 ? void 0 : changedField.javascript) === null || _a === void 0 ? void 0 : _a.change.params.reduce((xpsParams, fieldName) => {
|
|
925
|
+
var _a;
|
|
926
|
+
const formControl = form.get(fieldName);
|
|
927
|
+
const field = fieldsMap.get(fieldName);
|
|
928
|
+
if (formControl || field) {
|
|
929
|
+
xpsParams[fieldName] = (_a = formControl === null || formControl === void 0 ? void 0 : formControl.value) !== null && _a !== void 0 ? _a : field === null || field === void 0 ? void 0 : field.value;
|
|
930
|
+
}
|
|
931
|
+
return xpsParams;
|
|
932
|
+
}, {});
|
|
933
|
+
}
|
|
934
|
+
getFieldsMap(fields) {
|
|
935
|
+
const map = new Map();
|
|
936
|
+
fields.forEach((field) => map.set(field.name, field));
|
|
937
|
+
return map;
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
const syncRequestFactoryToken = new InjectionToken('SyncRequest');
|
|
942
|
+
const syncRequestFactoryProvider = {
|
|
943
|
+
provide: syncRequestFactoryToken,
|
|
944
|
+
useValue: (...args) => new SyncRequest(...args),
|
|
945
|
+
};
|
|
946
|
+
|
|
947
|
+
class SyncResponse {
|
|
948
|
+
constructor(changedField, response) {
|
|
949
|
+
var _a;
|
|
950
|
+
const fieldError = (_a = response === null || response === void 0 ? void 0 : response.errors) === null || _a === void 0 ? void 0 : _a.find((error) => error.element_name === changedField.name);
|
|
951
|
+
if (fieldError) {
|
|
952
|
+
this.rewritableError = {
|
|
953
|
+
code: fieldError.code,
|
|
954
|
+
message: fieldError.message,
|
|
955
|
+
};
|
|
956
|
+
}
|
|
957
|
+
this.fields = Object.keys(response.form).map((key) => response.form[key]);
|
|
958
|
+
this.parameters = response;
|
|
959
|
+
}
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
const syncResponseFactoryToken = new InjectionToken('SyncResponse');
|
|
963
|
+
const syncResponseFactoryProvider = {
|
|
964
|
+
provide: syncResponseFactoryToken,
|
|
965
|
+
useValue: (...args) => new SyncResponse(...args),
|
|
966
|
+
};
|
|
967
|
+
|
|
968
|
+
class SyncService {
|
|
969
|
+
constructor(requestFactory, responseFactory, secureApi, settingsService) {
|
|
970
|
+
this.requestFactory = requestFactory;
|
|
971
|
+
this.responseFactory = responseFactory;
|
|
972
|
+
this.secureApi = secureApi;
|
|
973
|
+
this.settingsService = settingsService;
|
|
974
|
+
this.apiRoute = 'directpayment';
|
|
975
|
+
this.prevFieldSyncStates = {};
|
|
976
|
+
this.form = new UntypedFormGroup({});
|
|
977
|
+
this.fields = [];
|
|
978
|
+
}
|
|
979
|
+
setup(form, fields) {
|
|
980
|
+
this.reset();
|
|
981
|
+
this.form = form;
|
|
982
|
+
this.fields = fields;
|
|
983
|
+
}
|
|
984
|
+
reset() {
|
|
985
|
+
this.prevFieldSyncStates = {};
|
|
986
|
+
this.form = new UntypedFormGroup({});
|
|
987
|
+
this.fields = [];
|
|
988
|
+
}
|
|
989
|
+
validate(field) {
|
|
990
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
991
|
+
if (!this.isReadyField(field)) {
|
|
992
|
+
return Promise.resolve(null);
|
|
993
|
+
}
|
|
994
|
+
const control = this.form.get(field.name);
|
|
995
|
+
const value = control === null || control === void 0 ? void 0 : control.value;
|
|
996
|
+
const prevFieldState = this.getPrevFieldSyncState(field);
|
|
997
|
+
const isInitialValue = value === field.value && !prevFieldState;
|
|
998
|
+
if (isInitialValue) {
|
|
999
|
+
return Promise.resolve(null);
|
|
1000
|
+
}
|
|
1001
|
+
if (prevFieldState && value === prevFieldState.value) {
|
|
1002
|
+
return Promise.resolve(prevFieldState.result);
|
|
1003
|
+
}
|
|
1004
|
+
const requestPromise = this.request(field);
|
|
1005
|
+
this.setPrevFieldSyncState(field, value, requestPromise);
|
|
1006
|
+
return requestPromise.then((response) => {
|
|
1007
|
+
var _a;
|
|
1008
|
+
return (_a = response.rewritableError) !== null && _a !== void 0 ? _a : null;
|
|
1009
|
+
});
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
request(field) {
|
|
1013
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1014
|
+
const requestParams = this.requestFactory({
|
|
1015
|
+
token: this.settingsService.token,
|
|
1016
|
+
changedField: field,
|
|
1017
|
+
fields: this.fields,
|
|
1018
|
+
form: this.form,
|
|
1019
|
+
});
|
|
1020
|
+
return lastValueFrom(this.secureApi.post(this.apiRoute, new URLSearchParams(requestParams), {
|
|
1021
|
+
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
1022
|
+
responseType: 'json',
|
|
1023
|
+
})).then((response) => {
|
|
1024
|
+
return this.responseFactory(field, response);
|
|
1025
|
+
});
|
|
1026
|
+
});
|
|
1027
|
+
}
|
|
1028
|
+
isReadyField(field) {
|
|
1029
|
+
var _a, _b;
|
|
1030
|
+
const isSyncEnabled = !!((_a = field.javascript) === null || _a === void 0 ? void 0 : _a.change);
|
|
1031
|
+
const isExistsInForm = !!((_b = this.form) === null || _b === void 0 ? void 0 : _b.get(field.name));
|
|
1032
|
+
return isSyncEnabled && isExistsInForm;
|
|
1033
|
+
}
|
|
1034
|
+
getPrevFieldSyncState(field) {
|
|
1035
|
+
return this.prevFieldSyncStates[field.name];
|
|
1036
|
+
}
|
|
1037
|
+
setPrevFieldSyncState(field, value, result) {
|
|
1038
|
+
this.prevFieldSyncStates[field.name] = { value, result };
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
SyncService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, deps: [{ token: syncRequestFactoryToken }, { token: syncResponseFactoryToken }, { token: SecureApiClient }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1042
|
+
SyncService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, providedIn: 'root' });
|
|
1043
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, decorators: [{
|
|
1044
|
+
type: Injectable,
|
|
1045
|
+
args: [{
|
|
1046
|
+
providedIn: 'root',
|
|
1047
|
+
}]
|
|
1048
|
+
}], ctorParameters: function () {
|
|
1049
|
+
return [{ type: undefined, decorators: [{
|
|
1050
|
+
type: Inject,
|
|
1051
|
+
args: [syncRequestFactoryToken]
|
|
1052
|
+
}] }, { type: undefined, decorators: [{
|
|
1053
|
+
type: Inject,
|
|
1054
|
+
args: [syncResponseFactoryToken]
|
|
1055
|
+
}] }, { type: SecureApiClient }, { type: SettingsService }];
|
|
1056
|
+
} });
|
|
1057
|
+
|
|
1058
|
+
class ControlConfig {
|
|
1059
|
+
constructor() {
|
|
1060
|
+
this.shouldHideUserInput = false;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
class TextControlConfig extends ControlConfig {
|
|
1065
|
+
constructor() {
|
|
1066
|
+
super(...arguments);
|
|
1067
|
+
this.controlType = 'text';
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
function convert(validator, message) {
|
|
1072
|
+
return (control) => {
|
|
1073
|
+
const errors = validator(control);
|
|
1074
|
+
if (!errors) {
|
|
1075
|
+
return errors;
|
|
1076
|
+
}
|
|
1077
|
+
const firstErrorKey = Object.keys(errors)[0];
|
|
1078
|
+
let error = errors[firstErrorKey];
|
|
1079
|
+
error = typeof error === 'object' && error !== null ? error : {};
|
|
1080
|
+
const rewritableError = Object.assign({}, error);
|
|
1081
|
+
rewritableError.message = message;
|
|
1082
|
+
if (error[firstErrorKey] != null) {
|
|
1083
|
+
rewritableError.value = error[firstErrorKey];
|
|
1084
|
+
}
|
|
1085
|
+
if (rewritableError.requiredLength) {
|
|
1086
|
+
rewritableError.number = rewritableError.requiredLength;
|
|
1087
|
+
}
|
|
1088
|
+
errors.rewritableError = rewritableError;
|
|
1089
|
+
return errors;
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
|
|
1093
|
+
const emailRegexp = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i; // eslint-disable-line
|
|
1094
|
+
function emailValidator() {
|
|
1095
|
+
return convert(Validators.pattern(emailRegexp), 'Enter a valid email');
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
function requiredValidator() {
|
|
1099
|
+
return convert(Validators.required, 'Required');
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
class Converter {
|
|
1103
|
+
constructor(syncService) {
|
|
1104
|
+
this.syncService = syncService;
|
|
1105
|
+
}
|
|
1106
|
+
convertToConfig(field, formState) {
|
|
1107
|
+
const config = this.createControlConfig(field, formState);
|
|
1108
|
+
if (formState === null || formState === void 0 ? void 0 : formState.disabled) {
|
|
1109
|
+
config.disabled = true;
|
|
1110
|
+
}
|
|
1111
|
+
return config;
|
|
1112
|
+
}
|
|
1113
|
+
convertToFormControl(field) {
|
|
1114
|
+
return new UntypedFormControl(this.getValue(field), this.getValidators(field), this.getAsyncValidators(field));
|
|
1115
|
+
}
|
|
1116
|
+
getValidators(field) {
|
|
1117
|
+
const validators = [];
|
|
1118
|
+
if (field.isMandatory === "1" /* XpsBoolean.true */) {
|
|
1119
|
+
validators.push(requiredValidator());
|
|
1120
|
+
}
|
|
1121
|
+
if (field.regex) {
|
|
1122
|
+
const match = /^\/(.*)\/([gim]*)$/.exec(field.regex);
|
|
1123
|
+
if (match) {
|
|
1124
|
+
const pattern = new RegExp(match[1], match[2]);
|
|
1125
|
+
const errorMessage = field.validation_error_msg
|
|
1126
|
+
? field.validation_error_msg
|
|
1127
|
+
: 'Enter valid data';
|
|
1128
|
+
validators.push(convert(Validators.pattern(pattern), errorMessage));
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
return validators;
|
|
1132
|
+
}
|
|
1133
|
+
getAsyncValidators(field) {
|
|
1134
|
+
return () => __awaiter(this, void 0, void 0, function* () { return this.syncService.validate(field); });
|
|
1135
|
+
}
|
|
1136
|
+
createDefaultControlConfig(controlConfigClass, field) {
|
|
1137
|
+
const config = new controlConfigClass();
|
|
1138
|
+
this.copyCommonOptions(config, field);
|
|
1139
|
+
return config;
|
|
1140
|
+
}
|
|
1141
|
+
getValue(field) {
|
|
1142
|
+
return field.value;
|
|
1143
|
+
}
|
|
1144
|
+
getDataType() {
|
|
1145
|
+
return 'text';
|
|
1146
|
+
}
|
|
1147
|
+
getAutocomplete() {
|
|
1148
|
+
return 'off';
|
|
1149
|
+
}
|
|
1150
|
+
shouldHideUserInput() {
|
|
1151
|
+
return false;
|
|
1152
|
+
}
|
|
1153
|
+
getCommonControlConfig(field) {
|
|
1154
|
+
return {
|
|
1155
|
+
name: field.name,
|
|
1156
|
+
title: field.title,
|
|
1157
|
+
labelHint: field.label_hint,
|
|
1158
|
+
dataType: this.getDataType(),
|
|
1159
|
+
readonly: field.isReadonly === "1" /* XpsBoolean.true */,
|
|
1160
|
+
placeholder: field.example,
|
|
1161
|
+
autocomplete: this.getAutocomplete(),
|
|
1162
|
+
};
|
|
1163
|
+
}
|
|
1164
|
+
copyCommonOptions(target, field) {
|
|
1165
|
+
const commonControlConfig = this.getCommonControlConfig(field);
|
|
1166
|
+
Object.keys(commonControlConfig).forEach((sourceKey) => {
|
|
1167
|
+
if (!(sourceKey in target)) {
|
|
1168
|
+
target[sourceKey] = commonControlConfig[sourceKey];
|
|
1169
|
+
}
|
|
1170
|
+
});
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
class EmailConverter extends Converter {
|
|
1175
|
+
constructor(syncService) {
|
|
1176
|
+
super(syncService);
|
|
1177
|
+
}
|
|
1178
|
+
getValidators(field) {
|
|
1179
|
+
return super.getValidators(field).concat([emailValidator()]);
|
|
1180
|
+
}
|
|
1181
|
+
createControlConfig(field) {
|
|
1182
|
+
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
1183
|
+
config.autocomplete = 'email';
|
|
1184
|
+
config.icon = 'mail';
|
|
1185
|
+
return config;
|
|
1186
|
+
}
|
|
1187
|
+
getDataType() {
|
|
1188
|
+
return 'email';
|
|
1189
|
+
}
|
|
1190
|
+
}
|
|
1191
|
+
EmailConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: EmailConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1192
|
+
EmailConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: EmailConverter });
|
|
1193
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: EmailConverter, decorators: [{
|
|
1194
|
+
type: Injectable
|
|
1195
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
1196
|
+
|
|
1197
|
+
const restrictedValueValidator = (restrictedValue) => {
|
|
1198
|
+
return ({ value }) => {
|
|
1199
|
+
return value !== restrictedValue ? null : { valueAllowed: false };
|
|
1200
|
+
};
|
|
1201
|
+
};
|
|
1202
|
+
|
|
1203
|
+
class ZipConverter extends Converter {
|
|
1204
|
+
constructor(syncService, countryService) {
|
|
1205
|
+
super(syncService);
|
|
1206
|
+
this.countryService = countryService;
|
|
1207
|
+
this.minLength = 3;
|
|
1208
|
+
this.maxLength = 10;
|
|
1209
|
+
this.usCountryLength = 5;
|
|
1210
|
+
}
|
|
1211
|
+
get isUsCountry() {
|
|
1212
|
+
return this.countryService.getCountry() === 'US';
|
|
1213
|
+
}
|
|
1214
|
+
getValidators(field) {
|
|
1215
|
+
const minLength = this.isUsCountry ? this.usCountryLength : this.minLength;
|
|
1216
|
+
const maxLength = this.isUsCountry ? this.usCountryLength : this.maxLength;
|
|
1217
|
+
const validators = super
|
|
1218
|
+
.getValidators(field)
|
|
1219
|
+
.concat([
|
|
1220
|
+
convert(Validators.minLength(minLength), 'Enter at least ${minLength} characters'),
|
|
1221
|
+
convert(Validators.maxLength(maxLength), 'Enter no more than ${maxLength} characters'),
|
|
1222
|
+
]);
|
|
1223
|
+
if (this.isUsCountry) {
|
|
1224
|
+
validators.push(convert(restrictedValueValidator('00000'), 'Enter a valid ZIP code'));
|
|
1225
|
+
}
|
|
1226
|
+
return validators;
|
|
1227
|
+
}
|
|
1228
|
+
createControlConfig(field) {
|
|
1229
|
+
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
1230
|
+
config.icon = 'location';
|
|
1231
|
+
if (this.isUsCountry) {
|
|
1232
|
+
config.maskConfig = {
|
|
1233
|
+
mask: () => new Array(this.usCountryLength).fill('9').join(''),
|
|
1234
|
+
guide: false,
|
|
1235
|
+
unmaskModelValue: true,
|
|
1236
|
+
showMask: true,
|
|
1237
|
+
};
|
|
1238
|
+
config.inputMode = 'numeric';
|
|
1239
|
+
}
|
|
1240
|
+
else {
|
|
1241
|
+
config.maxLength = this.maxLength;
|
|
1242
|
+
}
|
|
1243
|
+
return config;
|
|
1244
|
+
}
|
|
1245
|
+
getAutocomplete() {
|
|
1246
|
+
return 'postal-code';
|
|
1247
|
+
}
|
|
1248
|
+
getDataType() {
|
|
1249
|
+
return 'text';
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
ZipConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ZipConverter, deps: [{ token: SyncService }, { token: CountryService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1253
|
+
ZipConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ZipConverter });
|
|
1254
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ZipConverter, decorators: [{
|
|
1255
|
+
type: Injectable
|
|
1256
|
+
}], ctorParameters: function () { return [{ type: SyncService }, { type: CountryService }]; } });
|
|
1257
|
+
|
|
1258
|
+
const convertersMapToken = new InjectionToken('ConvertersTokensMap');
|
|
1259
|
+
const convertersMap = {
|
|
1260
|
+
zip: ZipConverter,
|
|
1261
|
+
email: EmailConverter,
|
|
1262
|
+
};
|
|
1263
|
+
|
|
1264
|
+
class ControlConfigService {
|
|
1265
|
+
constructor(convertersMap, injector) {
|
|
1266
|
+
this.convertersMap = convertersMap;
|
|
1267
|
+
this.injector = injector;
|
|
1268
|
+
}
|
|
1269
|
+
getFormControl(field) {
|
|
1270
|
+
const converter = this.getConverter(field);
|
|
1271
|
+
if (!converter) {
|
|
1272
|
+
return null;
|
|
1273
|
+
}
|
|
1274
|
+
return converter.convertToFormControl(field);
|
|
1275
|
+
}
|
|
1276
|
+
getConverter(field) {
|
|
1277
|
+
if (!field) {
|
|
1278
|
+
return null;
|
|
1279
|
+
}
|
|
1280
|
+
const sanitizedName = field.name.replace(/^fix_/i, '');
|
|
1281
|
+
let converter = this.convertersMap[sanitizedName];
|
|
1282
|
+
if (!converter) {
|
|
1283
|
+
converter = this.convertersMap[field.type];
|
|
1284
|
+
}
|
|
1285
|
+
if (!converter) {
|
|
1286
|
+
return null;
|
|
1287
|
+
}
|
|
1288
|
+
return this.injector.get(converter);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
ControlConfigService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ControlConfigService, deps: [{ token: convertersMapToken }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1292
|
+
ControlConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ControlConfigService });
|
|
1293
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ControlConfigService, decorators: [{
|
|
1294
|
+
type: Injectable
|
|
1295
|
+
}], ctorParameters: function () {
|
|
1296
|
+
return [{ type: undefined, decorators: [{
|
|
1297
|
+
type: Inject,
|
|
1298
|
+
args: [convertersMapToken]
|
|
1299
|
+
}] }, { type: i0.Injector }];
|
|
1300
|
+
} });
|
|
1301
|
+
|
|
1302
|
+
class FormService {
|
|
1303
|
+
constructor(controlConfigService) {
|
|
1304
|
+
this.controlConfigService = controlConfigService;
|
|
1305
|
+
}
|
|
1306
|
+
createForm(fields) {
|
|
1307
|
+
const controls = this.getVisibleFields(fields).reduce((result, field) => {
|
|
1308
|
+
const formControl = this.controlConfigService.getFormControl(field);
|
|
1309
|
+
if (formControl) {
|
|
1310
|
+
result[field.name] = formControl;
|
|
1311
|
+
}
|
|
1312
|
+
return result;
|
|
1313
|
+
}, {});
|
|
1314
|
+
return new UntypedFormGroup(controls);
|
|
1315
|
+
}
|
|
1316
|
+
getVisibleFields(fields) {
|
|
1317
|
+
return fields.filter(({ isVisible }) => isVisible === "1" /* XpsBoolean.true */);
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
FormService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormService, deps: [{ token: ControlConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1321
|
+
FormService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormService });
|
|
1322
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormService, decorators: [{
|
|
1323
|
+
type: Injectable
|
|
1324
|
+
}], ctorParameters: function () { return [{ type: ControlConfigService }]; } });
|
|
1325
|
+
|
|
1326
|
+
class StatusUpdatedAction {
|
|
1327
|
+
constructor(statusResponse) {
|
|
1328
|
+
this.type = 'status_updated';
|
|
1329
|
+
this.data = {
|
|
1330
|
+
statusState: statusResponse.status.statusState,
|
|
1331
|
+
invoice: statusResponse.status.invoice,
|
|
1332
|
+
isSuccess: statusResponse.status.isSuccess,
|
|
1333
|
+
isCanceled: statusResponse.status.isCanceled,
|
|
1334
|
+
group: statusResponse.status.group,
|
|
1335
|
+
};
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
class XpsApiPart {
|
|
1340
|
+
constructor() {
|
|
1341
|
+
this.response = new BehaviorSubject(null);
|
|
1342
|
+
}
|
|
1343
|
+
get response$() {
|
|
1344
|
+
return this.response
|
|
1345
|
+
.asObservable()
|
|
1346
|
+
.pipe(filter((response) => response !== null));
|
|
1347
|
+
}
|
|
1348
|
+
emitResponse(response) {
|
|
1349
|
+
this.response.next(response);
|
|
1350
|
+
}
|
|
1351
|
+
get currentValue() {
|
|
1352
|
+
return this.response.getValue();
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
1357
|
+
class StatusRequest extends XpsApiPartRequest {
|
|
1358
|
+
constructor(parameters) {
|
|
1359
|
+
super();
|
|
1360
|
+
this.xps_fix_command = 'status';
|
|
1361
|
+
if (parameters.token === null) {
|
|
1362
|
+
throw new TokenError();
|
|
1363
|
+
}
|
|
1364
|
+
this.access_token = parameters.token;
|
|
1365
|
+
this.xps_fix_invoice = parameters.invoice;
|
|
1366
|
+
this.xps_fix_pid = parameters.pid;
|
|
1367
|
+
this.xps_signature = parameters.signature;
|
|
1368
|
+
this.xps_fix_testProject = parameters.testProject;
|
|
1369
|
+
this.xps_fix_testPs = parameters.testPs;
|
|
1370
|
+
this.xps_fix_testXsolla = parameters.testXsolla;
|
|
1371
|
+
this.xps_fix_userReturnStatus = parameters.userReturnStatus;
|
|
1372
|
+
this.xps_locale = parameters.locale;
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
|
|
1376
|
+
const statusRequestFactoryToken = new InjectionToken('StatusRequest');
|
|
1377
|
+
const statusRequestFactoryProvider = {
|
|
1378
|
+
provide: statusRequestFactoryToken,
|
|
1379
|
+
useValue: (...args) => new StatusRequest(...args),
|
|
1380
|
+
};
|
|
1381
|
+
|
|
1382
|
+
var StatusGroups;
|
|
1383
|
+
(function (StatusGroups) {
|
|
1384
|
+
StatusGroups["troubled"] = "troubled";
|
|
1385
|
+
StatusGroups["done"] = "done";
|
|
1386
|
+
StatusGroups["invoice"] = "invoice";
|
|
1387
|
+
})(StatusGroups || (StatusGroups = {}));
|
|
1388
|
+
|
|
1389
|
+
var StatusEnum;
|
|
1390
|
+
(function (StatusEnum) {
|
|
1391
|
+
StatusEnum["created"] = "created";
|
|
1392
|
+
StatusEnum["awaiting"] = "awaiting";
|
|
1393
|
+
StatusEnum["processing"] = "processing";
|
|
1394
|
+
StatusEnum["authorized"] = "authorized";
|
|
1395
|
+
StatusEnum["held"] = "held";
|
|
1396
|
+
StatusEnum["done"] = "done";
|
|
1397
|
+
StatusEnum["error"] = "error";
|
|
1398
|
+
StatusEnum["canceled"] = "canceled";
|
|
1399
|
+
})(StatusEnum || (StatusEnum = {}));
|
|
1400
|
+
|
|
1401
|
+
class StatusResponse {
|
|
1402
|
+
constructor(parameters) {
|
|
1403
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1404
|
+
if ((_a = parameters.errors) === null || _a === void 0 ? void 0 : _a[0]) {
|
|
1405
|
+
this.error = {
|
|
1406
|
+
code: parameters.errors[0].code.toString(),
|
|
1407
|
+
message: parameters.errors[0].message,
|
|
1408
|
+
};
|
|
1409
|
+
}
|
|
1410
|
+
if (!parameters.status) {
|
|
1411
|
+
throw new TerminalError((_c = (_b = this.error) === null || _b === void 0 ? void 0 : _b.message) !== null && _c !== void 0 ? _c : '', (_e = (_d = this.error) === null || _d === void 0 ? void 0 : _d.code.toString()) !== null && _e !== void 0 ? _e : '');
|
|
1412
|
+
}
|
|
1413
|
+
this.status = {
|
|
1414
|
+
statusState: parameters.status.statusData.stateText,
|
|
1415
|
+
email: parameters.status.statusData.email,
|
|
1416
|
+
webSocketUrl: parameters.status.statusData.webSocketChannelUrl,
|
|
1417
|
+
webSocketChannelName: parameters.status.statusData.webSocketChannelName,
|
|
1418
|
+
webSocketClientType: parameters.status.statusData.webSocketClientType,
|
|
1419
|
+
financeInfo: parameters.status.text.info,
|
|
1420
|
+
discount: parameters.status.text.info.discount
|
|
1421
|
+
? Math.abs(Number.parseFloat((_g = (_f = parameters.status.text.info.discount) === null || _f === void 0 ? void 0 : _f.value) !== null && _g !== void 0 ? _g : ''))
|
|
1422
|
+
: null,
|
|
1423
|
+
isCancelUser: parameters.status.isCancelUser,
|
|
1424
|
+
postMessageStatus: parameters.status.isCancelUser
|
|
1425
|
+
? StatusGroups.troubled
|
|
1426
|
+
: parameters.status.group,
|
|
1427
|
+
virtualCurrencyAmount: parameters.status.statusData.out,
|
|
1428
|
+
backUrlSettings: {
|
|
1429
|
+
backUrl: parameters.status.text.backurl,
|
|
1430
|
+
backUrlAction: parameters.status.text.backurl_action,
|
|
1431
|
+
backUrlCaption: parameters.status.text.backurl_caption,
|
|
1432
|
+
returnRegion: parameters.status.return_region,
|
|
1433
|
+
},
|
|
1434
|
+
additionalBackButton: this.getAdditionalBackButton(parameters.status),
|
|
1435
|
+
group: parameters.status.group,
|
|
1436
|
+
needToCheck: parameters.status.needToCheck,
|
|
1437
|
+
autoRedirect: parameters.status.autoredirect,
|
|
1438
|
+
statusMessage: parameters.status.text.state,
|
|
1439
|
+
userId: parameters.status.statusData.v1,
|
|
1440
|
+
invoice: parameters.status.statusData.invoice,
|
|
1441
|
+
pid: parameters.status.statusData.pid,
|
|
1442
|
+
projectAmount: this.getProjectAmount(parameters.status),
|
|
1443
|
+
titleClass: parameters.status.title_class,
|
|
1444
|
+
paymentCountryIso: parameters.status.statusData.payment_country_iso,
|
|
1445
|
+
order: parameters.status.text.order,
|
|
1446
|
+
};
|
|
1447
|
+
if (parameters.form) {
|
|
1448
|
+
this.status.userReturnStatus = this.getUserReturnStatus(parameters.form);
|
|
1449
|
+
}
|
|
1450
|
+
if (this.status.statusState === StatusEnum.done ||
|
|
1451
|
+
this.status.statusState === StatusEnum.authorized) {
|
|
1452
|
+
this.status.isSuccess = true;
|
|
1453
|
+
}
|
|
1454
|
+
if (this.status.statusState === StatusEnum.canceled ||
|
|
1455
|
+
this.status.isCancelUser) {
|
|
1456
|
+
this.status.isCanceled = true;
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
getUserReturnStatus(form) {
|
|
1460
|
+
var _a;
|
|
1461
|
+
const value = (_a = form['fix_userReturnStatus']) === null || _a === void 0 ? void 0 : _a.value;
|
|
1462
|
+
if (value === 'undefined')
|
|
1463
|
+
return undefined;
|
|
1464
|
+
return value;
|
|
1465
|
+
}
|
|
1466
|
+
getProjectAmount(status) {
|
|
1467
|
+
if (!status.statusData.projectAmount) {
|
|
1468
|
+
return;
|
|
1469
|
+
}
|
|
1470
|
+
const [amount, currency] = status.statusData.projectAmount.split(' ');
|
|
1471
|
+
return {
|
|
1472
|
+
amount,
|
|
1473
|
+
currency,
|
|
1474
|
+
};
|
|
1475
|
+
}
|
|
1476
|
+
getAdditionalBackButton(status) {
|
|
1477
|
+
var _a, _b, _c, _d;
|
|
1478
|
+
if (!status.text.is_additional_back_url_enabled) {
|
|
1479
|
+
return {
|
|
1480
|
+
link: '',
|
|
1481
|
+
action: '',
|
|
1482
|
+
label: '',
|
|
1483
|
+
region: '',
|
|
1484
|
+
isEnabled: false,
|
|
1485
|
+
};
|
|
1486
|
+
}
|
|
1487
|
+
return {
|
|
1488
|
+
link: (_a = status.text.additional_back_url_link) !== null && _a !== void 0 ? _a : '',
|
|
1489
|
+
action: (_b = status.text.additional_back_url_action) !== null && _b !== void 0 ? _b : '',
|
|
1490
|
+
label: (_c = status.text.additional_back_url_label) !== null && _c !== void 0 ? _c : '',
|
|
1491
|
+
region: (_d = status.additional_button_return_region) !== null && _d !== void 0 ? _d : '',
|
|
1492
|
+
isEnabled: status.text.is_additional_back_url_enabled,
|
|
1493
|
+
};
|
|
1494
|
+
}
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
const statusResponseFactoryToken = new InjectionToken('StatusResponse');
|
|
1498
|
+
const statusResponseFactoryProvider = {
|
|
1499
|
+
provide: statusResponseFactoryToken,
|
|
1500
|
+
useValue: (...args) => new StatusResponse(...args),
|
|
1501
|
+
};
|
|
1502
|
+
|
|
1503
|
+
class StatusRequestService extends XpsApiPart {
|
|
1504
|
+
constructor(secureApiClient, settingsService, requestFactory, responseFactory) {
|
|
1505
|
+
super();
|
|
1506
|
+
this.secureApiClient = secureApiClient;
|
|
1507
|
+
this.settingsService = settingsService;
|
|
1508
|
+
this.requestFactory = requestFactory;
|
|
1509
|
+
this.responseFactory = responseFactory;
|
|
1510
|
+
this.apiRoute = 'directpayment';
|
|
1511
|
+
}
|
|
1512
|
+
setRequestParams(params) {
|
|
1513
|
+
this.requestParams = {
|
|
1514
|
+
locale: params.locale,
|
|
1515
|
+
testProject: params.testProject,
|
|
1516
|
+
testPs: params.testPs,
|
|
1517
|
+
testXsolla: params.testXsolla,
|
|
1518
|
+
userReturnStatus: params.userReturnStatus,
|
|
1519
|
+
invoice: params.invoice,
|
|
1520
|
+
pid: params.pid,
|
|
1521
|
+
signature: params.signature,
|
|
1522
|
+
};
|
|
1523
|
+
}
|
|
1524
|
+
request() {
|
|
1525
|
+
const requestParams = this.requestFactory(Object.assign({ token: this.settingsService.token }, this.requestParams));
|
|
1526
|
+
lastValueFrom(this.secureApiClient.post(this.apiRoute, new URLSearchParams(requestParams), {
|
|
1527
|
+
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
1528
|
+
responseType: 'json',
|
|
1529
|
+
}))
|
|
1530
|
+
.then((response) => {
|
|
1531
|
+
const statusResponse = this.responseFactory({
|
|
1532
|
+
status: response.status,
|
|
1533
|
+
errors: response.errors,
|
|
1534
|
+
form: response.form,
|
|
1535
|
+
});
|
|
1536
|
+
this.emitResponse(statusResponse);
|
|
1537
|
+
})
|
|
1538
|
+
.catch((e) => {
|
|
1539
|
+
throw new TerminalError(e.message, e.code);
|
|
1540
|
+
});
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
StatusRequestService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusRequestService, deps: [{ token: SecureApiClient }, { token: SettingsService }, { token: statusRequestFactoryToken }, { token: statusResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1544
|
+
StatusRequestService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusRequestService, providedIn: 'root' });
|
|
1545
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusRequestService, decorators: [{
|
|
1546
|
+
type: Injectable,
|
|
1547
|
+
args: [{
|
|
1548
|
+
providedIn: 'root',
|
|
1549
|
+
}]
|
|
1550
|
+
}], ctorParameters: function () {
|
|
1551
|
+
return [{ type: SecureApiClient }, { type: SettingsService }, { type: undefined, decorators: [{
|
|
1552
|
+
type: Inject,
|
|
1553
|
+
args: [statusRequestFactoryToken]
|
|
1554
|
+
}] }, { type: undefined, decorators: [{
|
|
1555
|
+
type: Inject,
|
|
1556
|
+
args: [statusResponseFactoryToken]
|
|
1557
|
+
}] }];
|
|
1558
|
+
} });
|
|
1559
|
+
|
|
1560
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
1561
|
+
class CheckStatusRequest extends XpsApiPartRequest {
|
|
1562
|
+
constructor(token, invoice) {
|
|
1563
|
+
super();
|
|
1564
|
+
this.xps_fix_command = 'status';
|
|
1565
|
+
this.section = 'getstatus';
|
|
1566
|
+
if (token === null) {
|
|
1567
|
+
throw new TokenError();
|
|
1568
|
+
}
|
|
1569
|
+
this.access_token = token;
|
|
1570
|
+
this.invoice = invoice;
|
|
1571
|
+
}
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
const checkStatusRequestFactoryToken = new InjectionToken('CheckStatusRequest');
|
|
1575
|
+
const checkStatusRequestFactoryProvider = {
|
|
1576
|
+
provide: checkStatusRequestFactoryToken,
|
|
1577
|
+
useValue: (...args) => new CheckStatusRequest(...args),
|
|
1578
|
+
};
|
|
1579
|
+
|
|
1580
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
1581
|
+
class CheckStatusResponse {
|
|
1582
|
+
constructor(parameters) {
|
|
1583
|
+
this.status = parameters.status;
|
|
1584
|
+
this.final = parameters.final;
|
|
1585
|
+
this.isPaymentAccountAttached = parameters.isPaymentAccountAttached;
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
const checkStatusResponseFactoryToken = new InjectionToken('CheckStatusResponse');
|
|
1590
|
+
const checkStatusResponseFactoryProvider = {
|
|
1591
|
+
provide: checkStatusResponseFactoryToken,
|
|
1592
|
+
useValue: (...args) => new CheckStatusResponse(...args),
|
|
1593
|
+
};
|
|
1594
|
+
|
|
1595
|
+
class CheckStatusService extends XpsApiPart {
|
|
1596
|
+
constructor(secureApiClient, settingsService, requestFactory, responseFactory) {
|
|
1597
|
+
super();
|
|
1598
|
+
this.secureApiClient = secureApiClient;
|
|
1599
|
+
this.settingsService = settingsService;
|
|
1600
|
+
this.requestFactory = requestFactory;
|
|
1601
|
+
this.responseFactory = responseFactory;
|
|
1602
|
+
this.apiRoute = 'directpayment';
|
|
1603
|
+
}
|
|
1604
|
+
setRequestParams(invoice) {
|
|
1605
|
+
this.invoice = invoice;
|
|
1606
|
+
}
|
|
1607
|
+
request() {
|
|
1608
|
+
const requestParams = this.requestFactory(this.settingsService.token, this.invoice);
|
|
1609
|
+
lastValueFrom(this.secureApiClient.post(this.apiRoute, new URLSearchParams(Object.assign({}, requestParams)), {
|
|
1610
|
+
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
1611
|
+
responseType: 'json',
|
|
1612
|
+
}))
|
|
1613
|
+
.then((response) => {
|
|
1614
|
+
const checkStatusResponse = this.responseFactory({
|
|
1615
|
+
status: response.status,
|
|
1616
|
+
final: response.final,
|
|
1617
|
+
isPaymentAccountAttached: response.is_payment_account_attached,
|
|
1618
|
+
});
|
|
1619
|
+
this.emitResponse(checkStatusResponse);
|
|
1620
|
+
})
|
|
1621
|
+
.catch((error) => {
|
|
1622
|
+
throw new ResponseError(error.message);
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
CheckStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, deps: [{ token: SecureApiClient }, { token: SettingsService }, { token: checkStatusRequestFactoryToken }, { token: checkStatusResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1627
|
+
CheckStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, providedIn: 'root' });
|
|
1628
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, decorators: [{
|
|
1629
|
+
type: Injectable,
|
|
1630
|
+
args: [{
|
|
1631
|
+
providedIn: 'root',
|
|
1632
|
+
}]
|
|
1633
|
+
}], ctorParameters: function () {
|
|
1634
|
+
return [{ type: SecureApiClient }, { type: SettingsService }, { type: undefined, decorators: [{
|
|
1635
|
+
type: Inject,
|
|
1636
|
+
args: [checkStatusRequestFactoryToken]
|
|
1637
|
+
}] }, { type: undefined, decorators: [{
|
|
1638
|
+
type: Inject,
|
|
1639
|
+
args: [checkStatusResponseFactoryToken]
|
|
1640
|
+
}] }];
|
|
1641
|
+
} });
|
|
1642
|
+
|
|
1643
|
+
var WebSocketStatus;
|
|
1644
|
+
(function (WebSocketStatus) {
|
|
1645
|
+
WebSocketStatus["statusChanged"] = "status_changed";
|
|
1646
|
+
WebSocketStatus["troubledStatus"] = "troubled_status";
|
|
1647
|
+
})(WebSocketStatus || (WebSocketStatus = {}));
|
|
1648
|
+
|
|
1649
|
+
var WebSocketClientType;
|
|
1650
|
+
(function (WebSocketClientType) {
|
|
1651
|
+
WebSocketClientType["nchan"] = "nchan";
|
|
1652
|
+
WebSocketClientType["centrifugo"] = "centrifugo";
|
|
1653
|
+
})(WebSocketClientType || (WebSocketClientType = {}));
|
|
1654
|
+
|
|
1655
|
+
class NchanWebSocketService {
|
|
1656
|
+
constructor() {
|
|
1657
|
+
this.type = WebSocketClientType.nchan;
|
|
1658
|
+
this.reconnectionTimerId = null;
|
|
1659
|
+
this.incomingMessages$ = new Subject();
|
|
1660
|
+
this.successfulReconnectionEventsProxy$ = new Subject();
|
|
1661
|
+
}
|
|
1662
|
+
open() {
|
|
1663
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1664
|
+
if (this.openPromise && !this.isClosed()) {
|
|
1665
|
+
return this.openPromise;
|
|
1666
|
+
}
|
|
1667
|
+
this.openPromise = this.createConnection()
|
|
1668
|
+
.catch(() => __awaiter(this, void 0, void 0, function* () {
|
|
1669
|
+
return this.waitWhileNotReconnect();
|
|
1670
|
+
}))
|
|
1671
|
+
.then(() => {
|
|
1672
|
+
this.connection.onclose = () => __awaiter(this, void 0, void 0, function* () { return this.open(); });
|
|
1673
|
+
});
|
|
1674
|
+
return this.openPromise;
|
|
1675
|
+
});
|
|
1676
|
+
}
|
|
1677
|
+
close() {
|
|
1678
|
+
this.clearReconnectionTimer();
|
|
1679
|
+
if (this.isClosed()) {
|
|
1680
|
+
return;
|
|
1681
|
+
}
|
|
1682
|
+
this.connection.onclose = null;
|
|
1683
|
+
this.connection.close();
|
|
1684
|
+
}
|
|
1685
|
+
get messages$() {
|
|
1686
|
+
return this.incomingMessages$
|
|
1687
|
+
.asObservable()
|
|
1688
|
+
.pipe(map$1((event) => event.data));
|
|
1689
|
+
}
|
|
1690
|
+
subscribeOnSuccessfulReconnection(next) {
|
|
1691
|
+
return this.successfulReconnectionEventsProxy$
|
|
1692
|
+
.asObservable()
|
|
1693
|
+
.subscribe(next);
|
|
1694
|
+
}
|
|
1695
|
+
isClosed() {
|
|
1696
|
+
if (!this.connection) {
|
|
1697
|
+
return true;
|
|
1698
|
+
}
|
|
1699
|
+
return [this.connection.CLOSED, this.connection.CLOSING].includes(this.connection.readyState);
|
|
1700
|
+
}
|
|
1701
|
+
clearReconnectionTimer() {
|
|
1702
|
+
if (this.reconnectionTimerId) {
|
|
1703
|
+
clearTimeout(this.reconnectionTimerId);
|
|
1704
|
+
this.reconnectionTimerId = null;
|
|
1705
|
+
}
|
|
1706
|
+
}
|
|
1707
|
+
setFirstReconnectionTimeout() {
|
|
1708
|
+
const min = NchanWebSocketService.timeoutsMs.reconnection -
|
|
1709
|
+
NchanWebSocketService.timeoutsMs.reconnectionMaxDeviation;
|
|
1710
|
+
const max = NchanWebSocketService.timeoutsMs.reconnection +
|
|
1711
|
+
NchanWebSocketService.timeoutsMs.reconnectionMaxDeviation;
|
|
1712
|
+
this.reconnectionTimeoutMs =
|
|
1713
|
+
Math.floor(Math.random() * (max - min + 1)) + min;
|
|
1714
|
+
}
|
|
1715
|
+
incrementReconnectionTimeout() {
|
|
1716
|
+
this.reconnectionTimeoutMs =
|
|
1717
|
+
this.reconnectionTimeoutMs *
|
|
1718
|
+
NchanWebSocketService.reconnectionTimeoutIncrementFactor;
|
|
1719
|
+
}
|
|
1720
|
+
createConnection() {
|
|
1721
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1722
|
+
this.connection = new WebSocket(this.url);
|
|
1723
|
+
this.connection.onmessage = this.incomingMessages$.next.bind(this.incomingMessages$);
|
|
1724
|
+
return new Promise((resolve, reject) => {
|
|
1725
|
+
this.connection.onopen = () => {
|
|
1726
|
+
clearTimeout(this.openConnectionTimerId);
|
|
1727
|
+
resolve();
|
|
1728
|
+
};
|
|
1729
|
+
this.connection.onclose = () => {
|
|
1730
|
+
reject();
|
|
1731
|
+
};
|
|
1732
|
+
});
|
|
1733
|
+
});
|
|
1734
|
+
}
|
|
1735
|
+
reconnect() {
|
|
1736
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1737
|
+
this.clearReconnectionTimer();
|
|
1738
|
+
return new Promise((resolve) => {
|
|
1739
|
+
this.reconnectionTimerId = setTimeout(() => {
|
|
1740
|
+
this.createConnection()
|
|
1741
|
+
.then(() => resolve(true))
|
|
1742
|
+
.catch(() => resolve(false));
|
|
1743
|
+
this.incrementReconnectionTimeout();
|
|
1744
|
+
}, this.reconnectionTimeoutMs);
|
|
1745
|
+
});
|
|
1746
|
+
});
|
|
1747
|
+
}
|
|
1748
|
+
waitWhileNotReconnect() {
|
|
1749
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1750
|
+
this.clearReconnectionTimer();
|
|
1751
|
+
this.setFirstReconnectionTimeout();
|
|
1752
|
+
let isConnected = false;
|
|
1753
|
+
while (!isConnected) {
|
|
1754
|
+
isConnected = yield this.reconnect();
|
|
1755
|
+
}
|
|
1756
|
+
this.successfulReconnectionEventsProxy$.next();
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
}
|
|
1760
|
+
NchanWebSocketService.reconnectionTimeoutIncrementFactor = 2;
|
|
1761
|
+
NchanWebSocketService.timeoutsMs = {
|
|
1762
|
+
reconnection: 1500,
|
|
1763
|
+
reconnectionMaxDeviation: 1500,
|
|
1764
|
+
};
|
|
1765
|
+
NchanWebSocketService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NchanWebSocketService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1766
|
+
NchanWebSocketService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NchanWebSocketService, providedIn: 'root' });
|
|
1767
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NchanWebSocketService, decorators: [{
|
|
1768
|
+
type: Injectable,
|
|
1769
|
+
args: [{
|
|
1770
|
+
providedIn: 'root',
|
|
1771
|
+
}]
|
|
1772
|
+
}] });
|
|
1773
|
+
|
|
1774
|
+
var ErrorTags;
|
|
1775
|
+
(function (ErrorTags) {
|
|
1776
|
+
ErrorTags["APP"] = "appError";
|
|
1777
|
+
ErrorTags["HTTP"] = "httpError";
|
|
1778
|
+
ErrorTags["JS"] = "jsError";
|
|
1779
|
+
ErrorTags["WS"] = "webSocket";
|
|
1780
|
+
ErrorTags["ENCRYPT"] = "encrypt";
|
|
1781
|
+
ErrorTags["APPLEPAY"] = "applepay";
|
|
1782
|
+
ErrorTags["HEADLESS_UI"] = "headlessUi";
|
|
1783
|
+
ErrorTags["GOOGLEPAY"] = "googlepay";
|
|
1784
|
+
ErrorTags["PAYTM"] = "paytm";
|
|
1785
|
+
})(ErrorTags || (ErrorTags = {}));
|
|
1786
|
+
|
|
1787
|
+
class TaggedError extends Error {
|
|
1788
|
+
constructor(message, tags) {
|
|
1789
|
+
super(message);
|
|
1790
|
+
this.tags = [];
|
|
1791
|
+
this.parentTag = ErrorTags.HEADLESS_UI;
|
|
1792
|
+
this.tags = this.childTag
|
|
1793
|
+
? [this.parentTag, this.childTag]
|
|
1794
|
+
: [this.parentTag];
|
|
1795
|
+
if (tags) {
|
|
1796
|
+
const newTags = tags.filter((t, i, arr) => !this.tags.includes(t) && arr.indexOf(t) == i);
|
|
1797
|
+
this.tags = [...this.tags, ...newTags];
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
|
|
1802
|
+
class WsError extends TaggedError {
|
|
1803
|
+
constructor(message, channelName, tags) {
|
|
1804
|
+
tags = tags ? [...tags, ErrorTags.WS] : [ErrorTags.WS];
|
|
1805
|
+
const messageWithChannel = `${message}. ChannelName - ${channelName}`;
|
|
1806
|
+
super(messageWithChannel, tags);
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
|
|
1810
|
+
class ElkLoggerService {
|
|
1811
|
+
constructor(window, settingsService, http, ngZone) {
|
|
1812
|
+
this.window = window;
|
|
1813
|
+
this.settingsService = settingsService;
|
|
1814
|
+
this.http = http;
|
|
1815
|
+
this.ngZone = ngZone;
|
|
1816
|
+
this.vendors = new RegExp('node_modules\\/(@angular|zone).*.js$');
|
|
1817
|
+
this.stackTrace = this.loadStackTrace();
|
|
1818
|
+
}
|
|
1819
|
+
handleError(error) {
|
|
1820
|
+
this.ngZone.runOutsideAngular(() => {
|
|
1821
|
+
if (isDevMode()) {
|
|
1822
|
+
console.error(error);
|
|
1823
|
+
return;
|
|
1824
|
+
}
|
|
1825
|
+
this.parseError(error).catch(console.log);
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
log(message, tags, extra) {
|
|
1829
|
+
const logTags = [ErrorTags.HEADLESS_UI, ...tags];
|
|
1830
|
+
if (isDevMode()) {
|
|
1831
|
+
console.log(message, tags);
|
|
1832
|
+
return;
|
|
1833
|
+
}
|
|
1834
|
+
const logMessage = {
|
|
1835
|
+
additionalInfo: this.getAdditionalInfo(),
|
|
1836
|
+
extra,
|
|
1837
|
+
message,
|
|
1838
|
+
};
|
|
1839
|
+
this.sendLog(logMessage, logTags);
|
|
1840
|
+
}
|
|
1841
|
+
parseError(error) {
|
|
1842
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1843
|
+
const errorObj = error instanceof TaggedError
|
|
1844
|
+
? error
|
|
1845
|
+
: new TaggedError(error.message || error.toString());
|
|
1846
|
+
errorObj.trace = yield this.getErrorTrace(errorObj);
|
|
1847
|
+
errorObj.additionalInfo = this.getAdditionalInfo();
|
|
1848
|
+
const { tags } = errorObj;
|
|
1849
|
+
const cleanError = this.removeErrorMetaFields(errorObj);
|
|
1850
|
+
this.sendLog(cleanError, tags);
|
|
1851
|
+
return errorObj;
|
|
1852
|
+
});
|
|
1853
|
+
}
|
|
1854
|
+
loadStackTrace() {
|
|
1855
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1856
|
+
const library = yield import('stacktrace-js');
|
|
1857
|
+
return library.default;
|
|
1858
|
+
});
|
|
1859
|
+
}
|
|
1860
|
+
getErrorTrace(error) {
|
|
1861
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1862
|
+
const stackTrace = yield this.stackTrace;
|
|
1863
|
+
const stackFramesArr = yield stackTrace.fromError(error);
|
|
1864
|
+
const filteredFramesArr = stackFramesArr.filter(({ fileName }) => fileName && !this.vendors.test(fileName));
|
|
1865
|
+
return filteredFramesArr
|
|
1866
|
+
.map((stackFrame) => stackFrame.toString())
|
|
1867
|
+
.join('\n');
|
|
1868
|
+
});
|
|
1869
|
+
}
|
|
1870
|
+
getAdditionalInfo() {
|
|
1871
|
+
const extractUrlHost = (url) => url.replace(/^https?:\/\/([^/?#]+).*$/i, '$1');
|
|
1872
|
+
return {
|
|
1873
|
+
location: {
|
|
1874
|
+
url: this.window.location.href,
|
|
1875
|
+
},
|
|
1876
|
+
project: {
|
|
1877
|
+
id: this.settingsService.project.id,
|
|
1878
|
+
},
|
|
1879
|
+
referrer: {
|
|
1880
|
+
url: this.window.document.referrer,
|
|
1881
|
+
},
|
|
1882
|
+
viewport: {
|
|
1883
|
+
width: this.window.document.documentElement.clientWidth,
|
|
1884
|
+
height: this.window.document.documentElement.clientHeight,
|
|
1885
|
+
},
|
|
1886
|
+
cdn_address: this.settingsService.settings.cdnUrl
|
|
1887
|
+
? extractUrlHost(this.settingsService.settings.cdnUrl)
|
|
1888
|
+
: 'none',
|
|
1889
|
+
country: this.settingsService.user.country.value,
|
|
1890
|
+
local: this.settingsService.user.country.localized_name,
|
|
1891
|
+
};
|
|
1892
|
+
}
|
|
1893
|
+
removeErrorMetaFields(error) {
|
|
1894
|
+
const metaPropList = [
|
|
1895
|
+
'parentTag',
|
|
1896
|
+
'childTag',
|
|
1897
|
+
'RESTRICTED_KEYS_REGEXP',
|
|
1898
|
+
'tags',
|
|
1899
|
+
];
|
|
1900
|
+
Object.keys(error).forEach((key) => {
|
|
1901
|
+
if (metaPropList.includes(key))
|
|
1902
|
+
delete error[key];
|
|
1903
|
+
});
|
|
1904
|
+
// implementing own 'message' property from prototype
|
|
1905
|
+
return Object.assign(Object.assign({}, error), { message: error.message });
|
|
1906
|
+
}
|
|
1907
|
+
sendLog(message, tags) {
|
|
1908
|
+
const url = `https://logs-01.xsolla.com/tag/${tags.join(',')}`;
|
|
1909
|
+
firstValueFrom(this.http.post(url, message, {
|
|
1910
|
+
headers: new HttpHeaders().set('Content-Type', 'text/plain'),
|
|
1911
|
+
responseType: 'text',
|
|
1912
|
+
})).catch((err) => console.error('Elk Logger: request error', err));
|
|
1913
|
+
}
|
|
1914
|
+
}
|
|
1915
|
+
ElkLoggerService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ElkLoggerService, deps: [{ token: windowToken }, { token: SettingsService }, { token: i1.HttpClient }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1916
|
+
ElkLoggerService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ElkLoggerService, providedIn: 'root' });
|
|
1917
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ElkLoggerService, decorators: [{
|
|
1918
|
+
type: Injectable,
|
|
1919
|
+
args: [{
|
|
1920
|
+
providedIn: 'root',
|
|
1921
|
+
}]
|
|
1922
|
+
}], ctorParameters: function () {
|
|
1923
|
+
return [{ type: undefined, decorators: [{
|
|
1924
|
+
type: Inject,
|
|
1925
|
+
args: [windowToken]
|
|
1926
|
+
}] }, { type: SettingsService }, { type: i1.HttpClient }, { type: i0.NgZone }];
|
|
1927
|
+
} });
|
|
1928
|
+
|
|
1929
|
+
class CentrifugoWebSocketService {
|
|
1930
|
+
constructor(elkLoggerService) {
|
|
1931
|
+
this.elkLoggerService = elkLoggerService;
|
|
1932
|
+
this.type = WebSocketClientType.centrifugo;
|
|
1933
|
+
this.reconnectionTimerId = null;
|
|
1934
|
+
this.isConnectionOpen = false;
|
|
1935
|
+
this.isConnecting = false;
|
|
1936
|
+
this.incomingMessages$ = new Subject();
|
|
1937
|
+
this.successfulReconnectionEventsProxy$ = new Subject();
|
|
1938
|
+
}
|
|
1939
|
+
open(url, channel) {
|
|
1940
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1941
|
+
if (url === this.url && channel === this.channel) {
|
|
1942
|
+
return;
|
|
1943
|
+
}
|
|
1944
|
+
try {
|
|
1945
|
+
this.url = url;
|
|
1946
|
+
this.channel = channel;
|
|
1947
|
+
yield this.createConnection(url, channel);
|
|
1948
|
+
}
|
|
1949
|
+
catch (error) {
|
|
1950
|
+
// @ts-expect-error error is unknown
|
|
1951
|
+
const message = ((error === null || error === void 0 ? void 0 : error.message) || error);
|
|
1952
|
+
const unknownError = new WsError(`unknown websocket error: ${message}`, channel);
|
|
1953
|
+
this.elkLoggerService.handleError(unknownError);
|
|
1954
|
+
}
|
|
1955
|
+
});
|
|
1956
|
+
}
|
|
1957
|
+
close() {
|
|
1958
|
+
this.clearReconnectionTimer();
|
|
1959
|
+
if (!this.isConnectionOpen) {
|
|
1960
|
+
return;
|
|
1961
|
+
}
|
|
1962
|
+
this.connection.disconnect();
|
|
1963
|
+
}
|
|
1964
|
+
get messages$() {
|
|
1965
|
+
return (this.incomingMessages$
|
|
1966
|
+
.asObservable()
|
|
1967
|
+
// event don't respect type from argument, it's weird
|
|
1968
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
1969
|
+
.pipe(map$1((event) => event.data)));
|
|
1970
|
+
}
|
|
1971
|
+
subscribeOnSuccessfulReconnection(next) {
|
|
1972
|
+
return this.successfulReconnectionEventsProxy$
|
|
1973
|
+
.asObservable()
|
|
1974
|
+
.subscribe(next);
|
|
1975
|
+
}
|
|
1976
|
+
clearReconnectionTimer() {
|
|
1977
|
+
if (this.reconnectionTimerId) {
|
|
1978
|
+
clearTimeout(this.reconnectionTimerId);
|
|
1979
|
+
this.reconnectionTimerId = null;
|
|
1980
|
+
}
|
|
1981
|
+
}
|
|
1982
|
+
setFirstReconnectionTimeout() {
|
|
1983
|
+
const min = CentrifugoWebSocketService.timeoutsMs.reconnection -
|
|
1984
|
+
CentrifugoWebSocketService.timeoutsMs.reconnectionMaxDeviation;
|
|
1985
|
+
const max = CentrifugoWebSocketService.timeoutsMs.reconnection +
|
|
1986
|
+
CentrifugoWebSocketService.timeoutsMs.reconnectionMaxDeviation;
|
|
1987
|
+
this.reconnectionTimeoutMs =
|
|
1988
|
+
Math.floor(Math.random() * (max - min + 1)) + min;
|
|
1989
|
+
}
|
|
1990
|
+
incrementReconnectionTimeout() {
|
|
1991
|
+
this.reconnectionTimeoutMs =
|
|
1992
|
+
this.reconnectionTimeoutMs *
|
|
1993
|
+
CentrifugoWebSocketService.reconnectionTimeoutIncrementFactor;
|
|
1994
|
+
}
|
|
1995
|
+
getCentrifugoClient() {
|
|
1996
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1997
|
+
return import('centrifuge').then((module) => module.Centrifuge);
|
|
1998
|
+
});
|
|
1999
|
+
}
|
|
2000
|
+
createConnection(url, channel) {
|
|
2001
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2002
|
+
if (this.isConnectionOpen || this.isConnecting) {
|
|
2003
|
+
return;
|
|
2004
|
+
}
|
|
2005
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2006
|
+
const CentrifugeClient = yield this.getCentrifugoClient();
|
|
2007
|
+
const websocketUrl = url !== null && url !== void 0 ? url : this.url;
|
|
2008
|
+
const websocketChannel = channel !== null && channel !== void 0 ? channel : this.channel;
|
|
2009
|
+
this.connection = new CentrifugeClient(websocketUrl, {
|
|
2010
|
+
debug: true,
|
|
2011
|
+
maxReconnectDelay: 1500,
|
|
2012
|
+
maxServerPingDelay: 1000,
|
|
2013
|
+
});
|
|
2014
|
+
return new Promise((resolve, reject) => {
|
|
2015
|
+
this.connection
|
|
2016
|
+
.on('connecting', () => {
|
|
2017
|
+
this.isConnecting = true;
|
|
2018
|
+
})
|
|
2019
|
+
.on('connected', () => {
|
|
2020
|
+
this.onConnect();
|
|
2021
|
+
resolve();
|
|
2022
|
+
})
|
|
2023
|
+
.on('disconnected', (ctx) => {
|
|
2024
|
+
this.onDisconnect(ctx, websocketChannel);
|
|
2025
|
+
reject();
|
|
2026
|
+
})
|
|
2027
|
+
.on('error', (ctx) => {
|
|
2028
|
+
const message = `code ${ctx.error.code} - ${ctx.error.message}`;
|
|
2029
|
+
this.elkLoggerService.log(`connection error: ${message}`, [ErrorTags.WS], {
|
|
2030
|
+
channel: websocketChannel,
|
|
2031
|
+
});
|
|
2032
|
+
})
|
|
2033
|
+
.connect();
|
|
2034
|
+
this.subscription = this.connection.newSubscription(websocketChannel, this.getSubscriptionOptions(websocketChannel));
|
|
2035
|
+
this.subscription
|
|
2036
|
+
.on('subscribed', (ctx) => {
|
|
2037
|
+
this.subscriptionPosition = ctx.streamPosition;
|
|
2038
|
+
this.prevSubscribedChannel = websocketChannel;
|
|
2039
|
+
})
|
|
2040
|
+
.on('publication', (ctx) => {
|
|
2041
|
+
const message = ctx.data;
|
|
2042
|
+
this.elkLoggerService.log(`websocket message received: ${message}`, [ErrorTags.WS], {
|
|
2043
|
+
channel: websocketChannel,
|
|
2044
|
+
});
|
|
2045
|
+
this.incomingMessages$.next(ctx);
|
|
2046
|
+
})
|
|
2047
|
+
.on('error', (ctx) => {
|
|
2048
|
+
const message = `code ${ctx.error.code} - ${ctx.error.message}`;
|
|
2049
|
+
this.elkLoggerService.log(`subscription error: ${message}`, [ErrorTags.WS], {
|
|
2050
|
+
channel: websocketChannel,
|
|
2051
|
+
});
|
|
2052
|
+
})
|
|
2053
|
+
.subscribe();
|
|
2054
|
+
});
|
|
2055
|
+
});
|
|
2056
|
+
}
|
|
2057
|
+
onConnect() {
|
|
2058
|
+
clearTimeout(this.openConnectionTimerId);
|
|
2059
|
+
this.isConnecting = false;
|
|
2060
|
+
this.isConnectionOpen = true;
|
|
2061
|
+
}
|
|
2062
|
+
onDisconnect(ctx, websocketChannel) {
|
|
2063
|
+
this.isConnecting = false;
|
|
2064
|
+
this.isConnectionOpen = false;
|
|
2065
|
+
/* If connection error, cause any connection error isn't 0 */
|
|
2066
|
+
if (ctx.code !== 0) {
|
|
2067
|
+
const message = `code ${ctx.code} - ${ctx.reason}`;
|
|
2068
|
+
this.elkLoggerService.log(`disconnected error: ${message}`, [ErrorTags.WS], {
|
|
2069
|
+
channel: websocketChannel,
|
|
2070
|
+
});
|
|
2071
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
2072
|
+
yield this.waitWhileNotReconnect();
|
|
2073
|
+
}))();
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
reconnect() {
|
|
2077
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2078
|
+
this.clearReconnectionTimer();
|
|
2079
|
+
return new Promise((resolve) => {
|
|
2080
|
+
this.reconnectionTimerId = setTimeout(() => {
|
|
2081
|
+
this.createConnection()
|
|
2082
|
+
.then(() => resolve(true))
|
|
2083
|
+
.catch(() => resolve(false));
|
|
2084
|
+
this.incrementReconnectionTimeout();
|
|
2085
|
+
}, this.reconnectionTimeoutMs);
|
|
2086
|
+
});
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
waitWhileNotReconnect() {
|
|
2090
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2091
|
+
this.clearReconnectionTimer();
|
|
2092
|
+
this.setFirstReconnectionTimeout();
|
|
2093
|
+
let isConnected = false;
|
|
2094
|
+
const beforeTimer = performance.now();
|
|
2095
|
+
while (!isConnected) {
|
|
2096
|
+
isConnected = yield this.reconnect();
|
|
2097
|
+
}
|
|
2098
|
+
const afterTimer = performance.now();
|
|
2099
|
+
const timerDuration = afterTimer - beforeTimer;
|
|
2100
|
+
this.elkLoggerService.log(`fallback to reconnection timer: duration ${timerDuration}ms`, [ErrorTags.WS], {
|
|
2101
|
+
channel: this.channel,
|
|
2102
|
+
});
|
|
2103
|
+
this.successfulReconnectionEventsProxy$.next();
|
|
2104
|
+
});
|
|
2105
|
+
}
|
|
2106
|
+
getSubscriptionOptions(websocketChannel) {
|
|
2107
|
+
const options = {
|
|
2108
|
+
recoverable: true,
|
|
2109
|
+
};
|
|
2110
|
+
if (websocketChannel === this.prevSubscribedChannel &&
|
|
2111
|
+
this.subscriptionPosition) {
|
|
2112
|
+
options.since = this.subscriptionPosition;
|
|
2113
|
+
}
|
|
2114
|
+
return options;
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2117
|
+
CentrifugoWebSocketService.reconnectionTimeoutIncrementFactor = 2;
|
|
2118
|
+
CentrifugoWebSocketService.timeoutsMs = {
|
|
2119
|
+
reconnection: 1000,
|
|
2120
|
+
reconnectionMaxDeviation: 1000,
|
|
2121
|
+
};
|
|
2122
|
+
CentrifugoWebSocketService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CentrifugoWebSocketService, deps: [{ token: ElkLoggerService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2123
|
+
CentrifugoWebSocketService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CentrifugoWebSocketService, providedIn: 'root' });
|
|
2124
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CentrifugoWebSocketService, decorators: [{
|
|
2125
|
+
type: Injectable,
|
|
2126
|
+
args: [{
|
|
2127
|
+
providedIn: 'root',
|
|
2128
|
+
}]
|
|
2129
|
+
}], ctorParameters: function () { return [{ type: ElkLoggerService }]; } });
|
|
2130
|
+
|
|
2131
|
+
// @todo: remove this factory and switch to centrifugo client after centrifugo issues resolved
|
|
2132
|
+
class WebSocketFactory {
|
|
2133
|
+
constructor(nchanWebSocket, centrifugoWebSocket) {
|
|
2134
|
+
this.nchanWebSocket = nchanWebSocket;
|
|
2135
|
+
this.centrifugoWebSocket = centrifugoWebSocket;
|
|
2136
|
+
}
|
|
2137
|
+
createWebSocketClient(url, clientType) {
|
|
2138
|
+
if (clientType === WebSocketClientType.centrifugo) {
|
|
2139
|
+
return this.centrifugoWebSocket;
|
|
2140
|
+
}
|
|
2141
|
+
this.nchanWebSocket.url = url;
|
|
2142
|
+
return this.nchanWebSocket;
|
|
2143
|
+
}
|
|
2144
|
+
}
|
|
2145
|
+
WebSocketFactory.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: WebSocketFactory, deps: [{ token: NchanWebSocketService }, { token: CentrifugoWebSocketService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2146
|
+
WebSocketFactory.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: WebSocketFactory, providedIn: 'root' });
|
|
2147
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: WebSocketFactory, decorators: [{
|
|
2148
|
+
type: Injectable,
|
|
2149
|
+
args: [{
|
|
2150
|
+
providedIn: 'root',
|
|
2151
|
+
}]
|
|
2152
|
+
}], ctorParameters: function () { return [{ type: NchanWebSocketService }, { type: CentrifugoWebSocketService }]; } });
|
|
2153
|
+
|
|
2154
|
+
class WebsocketStatusService {
|
|
2155
|
+
get needCheckStatus$() {
|
|
2156
|
+
return this.needCheckStatusSubject.asObservable();
|
|
2157
|
+
}
|
|
2158
|
+
get statusChanged$() {
|
|
2159
|
+
return this.statusChangedSubject.asObservable();
|
|
2160
|
+
}
|
|
2161
|
+
constructor(webSocketFactory) {
|
|
2162
|
+
this.webSocketFactory = webSocketFactory;
|
|
2163
|
+
this.reinsuranceCheckStatus = {
|
|
2164
|
+
timeoutId: null,
|
|
2165
|
+
timeoutMs: 180000,
|
|
2166
|
+
};
|
|
2167
|
+
this.needCheckStatusSubject = new Subject();
|
|
2168
|
+
this.statusChangedSubject = new Subject();
|
|
2169
|
+
this.webSocketClient = null;
|
|
2170
|
+
}
|
|
2171
|
+
checkStatusWithWebSocket(webSocketUrl, webSocketChannelName, webSocketClientType) {
|
|
2172
|
+
var _a;
|
|
2173
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2174
|
+
this.webSocketClient = this.webSocketFactory.createWebSocketClient(webSocketUrl, webSocketClientType);
|
|
2175
|
+
yield this.webSocketClient.open(webSocketUrl, webSocketChannelName);
|
|
2176
|
+
(_a = this.webSocketSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
2177
|
+
this.webSocketSubscription = this.webSocketClient.messages$.subscribe((message) => this.statusProcessing(message));
|
|
2178
|
+
this.webSocketReconnectionSubscription =
|
|
2179
|
+
this.webSocketClient.subscribeOnSuccessfulReconnection(() => {
|
|
2180
|
+
this.needCheckStatusSubject.next();
|
|
2181
|
+
});
|
|
2182
|
+
this.needCheckStatusSubject.next();
|
|
2183
|
+
this.startReinsuranceCheckTimeout();
|
|
2184
|
+
});
|
|
2185
|
+
}
|
|
2186
|
+
closeWebSocket() {
|
|
2187
|
+
var _a;
|
|
2188
|
+
this.removeSubscription();
|
|
2189
|
+
(_a = this.webSocketClient) === null || _a === void 0 ? void 0 : _a.close();
|
|
2190
|
+
this.clearReinsuranceCheckTimeout();
|
|
2191
|
+
}
|
|
2192
|
+
startReinsuranceCheckTimeout() {
|
|
2193
|
+
this.clearReinsuranceCheckTimeout();
|
|
2194
|
+
this.reinsuranceCheckStatus.timeoutId = setTimeout(() => {
|
|
2195
|
+
this.needCheckStatusSubject.next();
|
|
2196
|
+
}, this.reinsuranceCheckStatus.timeoutMs);
|
|
2197
|
+
}
|
|
2198
|
+
clearReinsuranceCheckTimeout() {
|
|
2199
|
+
if (this.reinsuranceCheckStatus.timeoutId) {
|
|
2200
|
+
clearTimeout(this.reinsuranceCheckStatus.timeoutId);
|
|
2201
|
+
this.reinsuranceCheckStatus.timeoutId = null;
|
|
2202
|
+
}
|
|
2203
|
+
}
|
|
2204
|
+
statusProcessing(message) {
|
|
2205
|
+
if (message === WebSocketStatus.statusChanged) {
|
|
2206
|
+
this.statusChangedSubject.next();
|
|
2207
|
+
this.closeWebSocket();
|
|
2208
|
+
this.clearReinsuranceCheckTimeout();
|
|
2209
|
+
}
|
|
2210
|
+
if (message === WebSocketStatus.troubledStatus) {
|
|
2211
|
+
this.clearReinsuranceCheckTimeout();
|
|
2212
|
+
this.closeWebSocket();
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
removeSubscription() {
|
|
2216
|
+
var _a, _b;
|
|
2217
|
+
(_a = this.webSocketSubscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
|
|
2218
|
+
(_b = this.webSocketReconnectionSubscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
WebsocketStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: WebsocketStatusService, deps: [{ token: WebSocketFactory }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2222
|
+
WebsocketStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: WebsocketStatusService, providedIn: 'root' });
|
|
2223
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: WebsocketStatusService, decorators: [{
|
|
2224
|
+
type: Injectable,
|
|
2225
|
+
args: [{
|
|
2226
|
+
providedIn: 'root',
|
|
2227
|
+
}]
|
|
2228
|
+
}], ctorParameters: function () { return [{ type: WebSocketFactory }]; } });
|
|
2229
|
+
|
|
2230
|
+
class ListenStatusService {
|
|
2231
|
+
get websocketOpened$() {
|
|
2232
|
+
return this.websocketOpenedSubject.asObservable();
|
|
2233
|
+
}
|
|
2234
|
+
get statusUpdated$() {
|
|
2235
|
+
return this.statusUpdatedSubject.asObservable();
|
|
2236
|
+
}
|
|
2237
|
+
constructor(statusService, checkStatusService, websocketStatusService) {
|
|
2238
|
+
this.statusService = statusService;
|
|
2239
|
+
this.checkStatusService = checkStatusService;
|
|
2240
|
+
this.websocketStatusService = websocketStatusService;
|
|
2241
|
+
this.isListening = false;
|
|
2242
|
+
this.websocketOpenedSubject = new Subject();
|
|
2243
|
+
this.statusUpdatedSubject = new Subject();
|
|
2244
|
+
this.statusDoneSubject = new Subject();
|
|
2245
|
+
this.destroy$ = new Subject();
|
|
2246
|
+
}
|
|
2247
|
+
listen(invoice) {
|
|
2248
|
+
if (this.isListening) {
|
|
2249
|
+
this.stopListening();
|
|
2250
|
+
}
|
|
2251
|
+
this.destroy$ = new Subject();
|
|
2252
|
+
this.isListening = true;
|
|
2253
|
+
this.subscribeStatusUpdate(invoice);
|
|
2254
|
+
this.subscribeCheckStatusUpdate();
|
|
2255
|
+
this.subscribeWebsocketEvent();
|
|
2256
|
+
this.checkStatusService.setRequestParams(invoice);
|
|
2257
|
+
return this.statusDoneSubject.asObservable();
|
|
2258
|
+
}
|
|
2259
|
+
stopListening() {
|
|
2260
|
+
this.isListening = false;
|
|
2261
|
+
this.websocketStatusService.closeWebSocket();
|
|
2262
|
+
this.destroy$.next();
|
|
2263
|
+
this.destroy$.complete();
|
|
2264
|
+
}
|
|
2265
|
+
subscribeStatusUpdate(invoice) {
|
|
2266
|
+
this.statusService.response$
|
|
2267
|
+
.pipe(filter$1((statusResponse) => {
|
|
2268
|
+
var _a;
|
|
2269
|
+
return ((_a = statusResponse === null || statusResponse === void 0 ? void 0 : statusResponse.status) === null || _a === void 0 ? void 0 : _a.invoice) === Number(invoice);
|
|
2270
|
+
}), takeUntil(this.destroy$))
|
|
2271
|
+
.subscribe((statusResponse) => {
|
|
2272
|
+
if (!(statusResponse === null || statusResponse === void 0 ? void 0 : statusResponse.status)) {
|
|
2273
|
+
return;
|
|
2274
|
+
}
|
|
2275
|
+
const statusSettings = {
|
|
2276
|
+
statusState: statusResponse.status.statusState,
|
|
2277
|
+
isCancelUser: statusResponse.status.isCancelUser,
|
|
2278
|
+
needWebSocket: statusResponse.status.needToCheck,
|
|
2279
|
+
backUrlSettings: statusResponse.status.backUrlSettings,
|
|
2280
|
+
autoRedirect: statusResponse.status.autoRedirect,
|
|
2281
|
+
webSocketUrl: statusResponse.status.webSocketUrl,
|
|
2282
|
+
webSocketChannelName: statusResponse.status.webSocketChannelName,
|
|
2283
|
+
webSocketClientType: statusResponse.status.webSocketClientType,
|
|
2284
|
+
};
|
|
2285
|
+
this.statusUpdatedSubject.next({
|
|
2286
|
+
statusResponse: statusResponse,
|
|
2287
|
+
statusSettings: statusSettings,
|
|
2288
|
+
});
|
|
2289
|
+
if (statusSettings.needWebSocket) {
|
|
2290
|
+
this.openWebsocket(statusSettings);
|
|
2291
|
+
return;
|
|
2292
|
+
}
|
|
2293
|
+
this.stopListening();
|
|
2294
|
+
this.statusDoneSubject.next(statusSettings);
|
|
2295
|
+
});
|
|
2296
|
+
}
|
|
2297
|
+
subscribeCheckStatusUpdate() {
|
|
2298
|
+
this.checkStatusService.response$
|
|
2299
|
+
.pipe(takeUntil(this.destroy$))
|
|
2300
|
+
.subscribe((checkStatusResponse) => {
|
|
2301
|
+
if (!(checkStatusResponse === null || checkStatusResponse === void 0 ? void 0 : checkStatusResponse.status))
|
|
2302
|
+
return;
|
|
2303
|
+
if (checkStatusResponse.status === StatusEnum.done) {
|
|
2304
|
+
this.statusService.request();
|
|
2305
|
+
this.websocketStatusService.closeWebSocket();
|
|
2306
|
+
return;
|
|
2307
|
+
}
|
|
2308
|
+
if (checkStatusResponse.final === false) {
|
|
2309
|
+
this.websocketStatusService.startReinsuranceCheckTimeout();
|
|
2310
|
+
return;
|
|
2311
|
+
}
|
|
2312
|
+
});
|
|
2313
|
+
}
|
|
2314
|
+
subscribeWebsocketEvent() {
|
|
2315
|
+
this.websocketStatusService.needCheckStatus$
|
|
2316
|
+
.pipe(takeUntil(this.destroy$))
|
|
2317
|
+
.subscribe(() => this.checkStatusService.request());
|
|
2318
|
+
this.websocketStatusService.statusChanged$
|
|
2319
|
+
.pipe(takeUntil(this.destroy$))
|
|
2320
|
+
.subscribe(() => this.statusService.request());
|
|
2321
|
+
}
|
|
2322
|
+
openWebsocket(statusSettings) {
|
|
2323
|
+
void this.websocketStatusService.checkStatusWithWebSocket(statusSettings.webSocketUrl, statusSettings.webSocketChannelName, statusSettings.webSocketClientType);
|
|
2324
|
+
this.websocketOpenedSubject.next(statusSettings);
|
|
2325
|
+
}
|
|
2326
|
+
}
|
|
2327
|
+
ListenStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ListenStatusService, deps: [{ token: StatusRequestService }, { token: CheckStatusService }, { token: WebsocketStatusService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2328
|
+
ListenStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ListenStatusService, providedIn: 'root' });
|
|
2329
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ListenStatusService, decorators: [{
|
|
2330
|
+
type: Injectable,
|
|
2331
|
+
args: [{
|
|
2332
|
+
providedIn: 'root',
|
|
2333
|
+
}]
|
|
2334
|
+
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: CheckStatusService }, { type: WebsocketStatusService }]; } });
|
|
2335
|
+
|
|
2336
|
+
class ShowFieldsAction {
|
|
2337
|
+
constructor(submitResponse) {
|
|
2338
|
+
this.type = 'show_fields';
|
|
2339
|
+
this.data = {
|
|
2340
|
+
fields: [],
|
|
2341
|
+
errors: [],
|
|
2342
|
+
messages: [],
|
|
2343
|
+
order: {},
|
|
2344
|
+
};
|
|
2345
|
+
this.data.fields = submitResponse.fields;
|
|
2346
|
+
this.data.errors = submitResponse.errors;
|
|
2347
|
+
this.data.messages = submitResponse.messages;
|
|
2348
|
+
this.data.order = submitResponse.summary;
|
|
2349
|
+
}
|
|
2350
|
+
}
|
|
2351
|
+
|
|
2352
|
+
const showFieldsActionFactoryToken = new InjectionToken('ShowFieldsAction');
|
|
2353
|
+
const showFieldsActionFactoryProvider = {
|
|
2354
|
+
provide: showFieldsActionFactoryToken,
|
|
2355
|
+
useValue: {
|
|
2356
|
+
factory: (...args) => new ShowFieldsAction(...args),
|
|
2357
|
+
type: 'show_fields',
|
|
2358
|
+
},
|
|
2359
|
+
};
|
|
2360
|
+
|
|
2361
|
+
class CheckStatusAction {
|
|
2362
|
+
constructor(submitResponse) {
|
|
2363
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2364
|
+
this.type = 'check_status';
|
|
2365
|
+
const status = submitResponse.parameters.status;
|
|
2366
|
+
this.data = {
|
|
2367
|
+
invoice: status === null || status === void 0 ? void 0 : status.invoice,
|
|
2368
|
+
signature: (_a = submitResponse.parameters.form.signature) === null || _a === void 0 ? void 0 : _a.value,
|
|
2369
|
+
locale: (_b = submitResponse.parameters.form.locale) === null || _b === void 0 ? void 0 : _b.value,
|
|
2370
|
+
testPs: (_c = submitResponse.parameters.form.testPs) === null || _c === void 0 ? void 0 : _c.value,
|
|
2371
|
+
testXsolla: (_d = submitResponse.parameters.form.testXsolla) === null || _d === void 0 ? void 0 : _d.value,
|
|
2372
|
+
testProject: (_e = submitResponse.parameters.form.testProject) === null || _e === void 0 ? void 0 : _e.value,
|
|
2373
|
+
userReturnStatus: (_f = submitResponse.parameters.form.userReturnStatus) === null || _f === void 0 ? void 0 : _f.value,
|
|
2374
|
+
};
|
|
2375
|
+
}
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
const checkStatusActionFactoryToken = new InjectionToken('CheckStatusAction');
|
|
2379
|
+
const checkStatusActionFactoryProvider = {
|
|
2380
|
+
provide: checkStatusActionFactoryToken,
|
|
2381
|
+
useValue: {
|
|
2382
|
+
factory: (...args) => new CheckStatusAction(...args),
|
|
2383
|
+
type: 'check_status',
|
|
2384
|
+
},
|
|
2385
|
+
};
|
|
2386
|
+
|
|
2387
|
+
const statusUpdatedActionFactoryToken = new InjectionToken('StatusUpdatedAction');
|
|
2388
|
+
const statusUpdatedActionFactoryProvider = {
|
|
2389
|
+
provide: statusUpdatedActionFactoryToken,
|
|
2390
|
+
useValue: {
|
|
2391
|
+
factory: (...args) => new StatusUpdatedAction(...args),
|
|
2392
|
+
type: 'status_updated',
|
|
2393
|
+
},
|
|
2394
|
+
};
|
|
2395
|
+
|
|
2396
|
+
const nextActionsToken = new InjectionToken('Action');
|
|
2397
|
+
const nextActions = [
|
|
2398
|
+
showFieldsActionFactoryProvider,
|
|
2399
|
+
checkStatusActionFactoryProvider,
|
|
2400
|
+
statusUpdatedActionFactoryProvider,
|
|
2401
|
+
];
|
|
2402
|
+
|
|
2403
|
+
const actionTypeCommandMap = {
|
|
2404
|
+
[XpsCommand.check]: 'show_fields',
|
|
2405
|
+
[XpsCommand.status]: 'check_status',
|
|
2406
|
+
};
|
|
2407
|
+
|
|
2408
|
+
class NextActionService {
|
|
2409
|
+
get flowUpdates$() {
|
|
2410
|
+
return this.flowUpdatesSubject.asObservable();
|
|
2411
|
+
}
|
|
2412
|
+
constructor(nextActionTokens, injector) {
|
|
2413
|
+
this.nextActionTokens = nextActionTokens;
|
|
2414
|
+
this.injector = injector;
|
|
2415
|
+
this.flowUpdatesSubject = new Subject();
|
|
2416
|
+
this.nextActionsMap = new Map();
|
|
2417
|
+
this.fillNextActionsMap();
|
|
2418
|
+
}
|
|
2419
|
+
getNextAction(submitResponse) {
|
|
2420
|
+
if (!submitResponse.currentCommand) {
|
|
2421
|
+
return null;
|
|
2422
|
+
}
|
|
2423
|
+
const nextActionFactory = this.findNextAction(submitResponse.currentCommand);
|
|
2424
|
+
if (nextActionFactory) {
|
|
2425
|
+
return nextActionFactory(submitResponse);
|
|
2426
|
+
}
|
|
2427
|
+
throw new Error('Next action is undefined.');
|
|
2428
|
+
}
|
|
2429
|
+
emitFlowUpdates(action) {
|
|
2430
|
+
this.flowUpdatesSubject.next(action);
|
|
2431
|
+
}
|
|
2432
|
+
fillNextActionsMap() {
|
|
2433
|
+
this.nextActionTokens.forEach((nextAction) => {
|
|
2434
|
+
const item = this.injector.get(nextAction.provide);
|
|
2435
|
+
this.nextActionsMap.set(item.type, item.factory);
|
|
2436
|
+
});
|
|
2437
|
+
}
|
|
2438
|
+
findNextAction(command) {
|
|
2439
|
+
const actionType = actionTypeCommandMap[command];
|
|
2440
|
+
if (!actionType) {
|
|
2441
|
+
return;
|
|
2442
|
+
}
|
|
2443
|
+
return this.nextActionsMap.get(actionType);
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
NextActionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NextActionService, deps: [{ token: nextActionsToken }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2447
|
+
NextActionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NextActionService, providedIn: 'root' });
|
|
2448
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NextActionService, decorators: [{
|
|
2449
|
+
type: Injectable,
|
|
2450
|
+
args: [{
|
|
2451
|
+
providedIn: 'root',
|
|
2452
|
+
}]
|
|
2453
|
+
}], ctorParameters: function () {
|
|
2454
|
+
return [{ type: undefined, decorators: [{
|
|
2455
|
+
type: Inject,
|
|
2456
|
+
args: [nextActionsToken]
|
|
2457
|
+
}] }, { type: i0.Injector }];
|
|
2458
|
+
} });
|
|
2459
|
+
|
|
2460
|
+
class StatusService {
|
|
2461
|
+
constructor(statusRequestService, listenStatusService, nextActionService) {
|
|
2462
|
+
this.statusRequestService = statusRequestService;
|
|
2463
|
+
this.listenStatusService = listenStatusService;
|
|
2464
|
+
this.nextActionService = nextActionService;
|
|
2465
|
+
}
|
|
2466
|
+
getStatus(params) {
|
|
2467
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2468
|
+
this.statusRequestService.setRequestParams(params);
|
|
2469
|
+
this.startWaitingStatusUpdates(params.invoice);
|
|
2470
|
+
this.statusRequestService.request();
|
|
2471
|
+
const statusResponse = yield firstValueFrom(this.listenStatusService.statusUpdated$);
|
|
2472
|
+
return statusResponse.statusResponse.status;
|
|
2473
|
+
});
|
|
2474
|
+
}
|
|
2475
|
+
startWaitingStatusUpdates(invoice) {
|
|
2476
|
+
this.listenStatusService.listen(invoice);
|
|
2477
|
+
this.listenStatusService.statusUpdated$
|
|
2478
|
+
.pipe(skip(1))
|
|
2479
|
+
.subscribe(({ statusResponse }) => {
|
|
2480
|
+
this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(statusResponse));
|
|
2481
|
+
});
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
StatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, deps: [{ token: StatusRequestService }, { token: ListenStatusService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2485
|
+
StatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, providedIn: 'root' });
|
|
2486
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusService, decorators: [{
|
|
2487
|
+
type: Injectable,
|
|
2488
|
+
args: [{
|
|
2489
|
+
providedIn: 'root',
|
|
2490
|
+
}]
|
|
2491
|
+
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: NextActionService }]; } });
|
|
2492
|
+
|
|
2493
|
+
class PaymentService {
|
|
2494
|
+
constructor(initializeService, submitService, syncService, formService, statusService, nextActionService) {
|
|
2495
|
+
this.initializeService = initializeService;
|
|
2496
|
+
this.submitService = submitService;
|
|
2497
|
+
this.syncService = syncService;
|
|
2498
|
+
this.formService = formService;
|
|
2499
|
+
this.statusService = statusService;
|
|
2500
|
+
this.nextActionService = nextActionService;
|
|
2501
|
+
this.form = null;
|
|
2502
|
+
this.data = null;
|
|
2503
|
+
this.fields = [];
|
|
2504
|
+
}
|
|
2505
|
+
initialize(config) {
|
|
2506
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2507
|
+
this.config = config;
|
|
2508
|
+
this.data = yield this.initializeService.request(config);
|
|
2509
|
+
this.fields = this.getFields();
|
|
2510
|
+
this.form = this.formService.createForm(this.fields);
|
|
2511
|
+
this.syncService.setup(this.form, this.fields);
|
|
2512
|
+
return this.fields;
|
|
2513
|
+
});
|
|
2514
|
+
}
|
|
2515
|
+
submit(fields, form) {
|
|
2516
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2517
|
+
const submitResponse = yield this.submitService.request(fields, form);
|
|
2518
|
+
return this.nextActionService.getNextAction(submitResponse);
|
|
2519
|
+
});
|
|
2520
|
+
}
|
|
2521
|
+
getFields() {
|
|
2522
|
+
var _a, _b, _c;
|
|
2523
|
+
return (_c = (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.paymentForm) === null || _b === void 0 ? void 0 : _b.fields) !== null && _c !== void 0 ? _c : [];
|
|
2524
|
+
}
|
|
2525
|
+
validate(field) {
|
|
2526
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2527
|
+
return this.syncService.validate(field);
|
|
2528
|
+
});
|
|
2529
|
+
}
|
|
2530
|
+
runThreeDs() {
|
|
2531
|
+
throw new Error('Method not implemented.');
|
|
2532
|
+
}
|
|
2533
|
+
getFinanceDetails() {
|
|
2534
|
+
throw new Error('Method not implemented.');
|
|
2535
|
+
}
|
|
2536
|
+
getStatus(params) {
|
|
2537
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2538
|
+
return this.statusService.getStatus(Object.assign(Object.assign({}, params), { pid: this.config.paymentMethodId }));
|
|
2539
|
+
});
|
|
2540
|
+
}
|
|
2541
|
+
changeFieldValue(name, value) {
|
|
2542
|
+
var _a;
|
|
2543
|
+
const formControl = (_a = this.form) === null || _a === void 0 ? void 0 : _a.get(name);
|
|
2544
|
+
formControl === null || formControl === void 0 ? void 0 : formControl.setValue(value);
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
PaymentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, deps: [{ token: InitializeService }, { token: SubmitService }, { token: SyncService }, { token: FormService }, { token: StatusService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2548
|
+
PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
|
|
2549
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
|
|
2550
|
+
type: Injectable,
|
|
2551
|
+
args: [{
|
|
2552
|
+
providedIn: 'root',
|
|
2553
|
+
}]
|
|
2554
|
+
}], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: NextActionService }]; } });
|
|
2555
|
+
|
|
427
2556
|
class RefundPolicyService {
|
|
428
2557
|
constructor(settingsService) {
|
|
429
2558
|
this.settingsService = settingsService;
|
|
@@ -529,88 +2658,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
529
2658
|
}]
|
|
530
2659
|
}], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }, { type: SecureConnectionService }, { type: DisclaimerService }]; } });
|
|
531
2660
|
|
|
532
|
-
class InitializeService {
|
|
533
|
-
constructor(secureApi, settingsService, countryService) {
|
|
534
|
-
this.secureApi = secureApi;
|
|
535
|
-
this.settingsService = settingsService;
|
|
536
|
-
this.countryService = countryService;
|
|
537
|
-
this.apiRoute = 'directpayment';
|
|
538
|
-
}
|
|
539
|
-
request(config) {
|
|
540
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
541
|
-
const requestParams = {
|
|
542
|
-
access_token: this.settingsService.token,
|
|
543
|
-
pid: String(config.paymentMethodId),
|
|
544
|
-
country: this.countryService.getCountry(),
|
|
545
|
-
returnUrl: config.returnUrl,
|
|
546
|
-
};
|
|
547
|
-
return lastValueFrom(this.secureApi.post(this.apiRoute, new URLSearchParams(Object.assign({}, requestParams)), {
|
|
548
|
-
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
549
|
-
responseType: 'json',
|
|
550
|
-
})).catch((error) => {
|
|
551
|
-
throw new ResponseError(error.message);
|
|
552
|
-
});
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
InitializeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, deps: [{ token: SecureApiClient }, { token: SettingsService }, { token: CountryService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
557
|
-
InitializeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, providedIn: 'root' });
|
|
558
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, decorators: [{
|
|
559
|
-
type: Injectable,
|
|
560
|
-
args: [{
|
|
561
|
-
providedIn: 'root',
|
|
562
|
-
}]
|
|
563
|
-
}], ctorParameters: function () { return [{ type: SecureApiClient }, { type: SettingsService }, { type: CountryService }]; } });
|
|
564
|
-
|
|
565
|
-
class PaymentService {
|
|
566
|
-
constructor(initializeService) {
|
|
567
|
-
this.initializeService = initializeService;
|
|
568
|
-
this.data = null;
|
|
569
|
-
}
|
|
570
|
-
initialize(config) {
|
|
571
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
572
|
-
this.data = yield this.initializeService.request(config);
|
|
573
|
-
return this.data;
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
|
-
submit() {
|
|
577
|
-
throw new Error('Method not implemented.');
|
|
578
|
-
}
|
|
579
|
-
getFields() {
|
|
580
|
-
throw new Error('Method not implemented.');
|
|
581
|
-
}
|
|
582
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
583
|
-
validate(field) {
|
|
584
|
-
throw new Error('Method not implemented.');
|
|
585
|
-
}
|
|
586
|
-
runThreeDs() {
|
|
587
|
-
throw new Error('Method not implemented.');
|
|
588
|
-
}
|
|
589
|
-
getFinanceDetails() {
|
|
590
|
-
throw new Error('Method not implemented.');
|
|
591
|
-
}
|
|
592
|
-
getStatus() {
|
|
593
|
-
throw new Error('Method not implemented.');
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
PaymentService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, deps: [{ token: InitializeService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
597
|
-
PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
|
|
598
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
|
|
599
|
-
type: Injectable,
|
|
600
|
-
args: [{
|
|
601
|
-
providedIn: 'root',
|
|
602
|
-
}]
|
|
603
|
-
}], ctorParameters: function () { return [{ type: InitializeService }]; } });
|
|
604
|
-
|
|
605
2661
|
class CoreLibraryService {
|
|
606
|
-
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, legalService,
|
|
2662
|
+
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentService, deviceFingerPrintService, legalService, nextActionService) {
|
|
607
2663
|
this.settingsService = settingsService;
|
|
608
2664
|
this.countryService = countryService;
|
|
609
2665
|
this.paymentMethodsService = paymentMethodsService;
|
|
610
2666
|
this.savedMethodsService = savedMethodsService;
|
|
611
2667
|
this.userBalanceService = userBalanceService;
|
|
612
|
-
this.legalService = legalService;
|
|
613
2668
|
this.paymentService = paymentService;
|
|
2669
|
+
this.deviceFingerPrintService = deviceFingerPrintService;
|
|
2670
|
+
this.legalService = legalService;
|
|
2671
|
+
this.nextActionService = nextActionService;
|
|
614
2672
|
this.paymentMethods = {
|
|
615
2673
|
getList: () => __awaiter(this, void 0, void 0, function* () { return this.paymentMethodsService.getList(); }),
|
|
616
2674
|
getQuickMethods: () => __awaiter(this, void 0, void 0, function* () { return this.paymentMethodsService.getQuickMethods(); }),
|
|
@@ -620,7 +2678,8 @@ class CoreLibraryService {
|
|
|
620
2678
|
}
|
|
621
2679
|
init(configuration) {
|
|
622
2680
|
return __awaiter(this, void 0, void 0, function* () {
|
|
623
|
-
|
|
2681
|
+
yield this.settingsService.init(configuration);
|
|
2682
|
+
yield this.deviceFingerPrintService.init();
|
|
624
2683
|
});
|
|
625
2684
|
}
|
|
626
2685
|
setCountry(country) {
|
|
@@ -629,26 +2688,28 @@ class CoreLibraryService {
|
|
|
629
2688
|
createPayment(config) {
|
|
630
2689
|
return {
|
|
631
2690
|
initialize: () => __awaiter(this, void 0, void 0, function* () { return this.paymentService.initialize(config); }),
|
|
632
|
-
submit: () => this.paymentService.submit(),
|
|
2691
|
+
submit: (fields, form) => __awaiter(this, void 0, void 0, function* () { return this.paymentService.submit(fields, form); }),
|
|
633
2692
|
getFields: () => this.paymentService.getFields(),
|
|
634
|
-
|
|
2693
|
+
changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
|
|
2694
|
+
validate: (field) => __awaiter(this, void 0, void 0, function* () { return this.paymentService.validate(field); }),
|
|
635
2695
|
getFinanceDetails: () => this.paymentService.getFinanceDetails(),
|
|
636
2696
|
runThreeDs: () => this.paymentService.runThreeDs(),
|
|
637
|
-
getStatus: () => this.paymentService.getStatus(),
|
|
2697
|
+
getStatus: (params) => __awaiter(this, void 0, void 0, function* () { return this.paymentService.getStatus(params); }),
|
|
2698
|
+
flowUpdates$: this.nextActionService.flowUpdates$,
|
|
638
2699
|
};
|
|
639
2700
|
}
|
|
640
2701
|
getLegalComponentConfig() {
|
|
641
2702
|
return this.legalService.getLegalComponentConfig();
|
|
642
2703
|
}
|
|
643
2704
|
}
|
|
644
|
-
CoreLibraryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, deps: [{ token: SettingsService }, { token: CountryService }, { token: PaymentMethodsService }, { token: SavedMethodsService }, { token: UserBalanceService }, { token: LegalService }, { token:
|
|
2705
|
+
CoreLibraryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, deps: [{ token: SettingsService }, { token: CountryService }, { token: PaymentMethodsService }, { token: SavedMethodsService }, { token: UserBalanceService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: LegalService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
645
2706
|
CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
|
|
646
2707
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
|
|
647
2708
|
type: Injectable,
|
|
648
2709
|
args: [{
|
|
649
2710
|
providedIn: 'root',
|
|
650
2711
|
}]
|
|
651
|
-
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: LegalService }, { type:
|
|
2712
|
+
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: LegalService }, { type: NextActionService }]; } });
|
|
652
2713
|
|
|
653
2714
|
class HttpError extends AppError {
|
|
654
2715
|
constructor(error, req) {
|
|
@@ -703,10 +2764,35 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
703
2764
|
type: Injectable
|
|
704
2765
|
}], ctorParameters: function () { return [{ type: i1$1.Router }]; } });
|
|
705
2766
|
|
|
2767
|
+
class FormModule {
|
|
2768
|
+
}
|
|
2769
|
+
FormModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
2770
|
+
FormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: FormModule, imports: [ReactiveFormsModule] });
|
|
2771
|
+
FormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, providers: [
|
|
2772
|
+
FormService,
|
|
2773
|
+
ControlConfigService,
|
|
2774
|
+
ZipConverter,
|
|
2775
|
+
EmailConverter,
|
|
2776
|
+
{ provide: convertersMapToken, useValue: convertersMap },
|
|
2777
|
+
], imports: [ReactiveFormsModule] });
|
|
2778
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, decorators: [{
|
|
2779
|
+
type: NgModule,
|
|
2780
|
+
args: [{
|
|
2781
|
+
imports: [ReactiveFormsModule],
|
|
2782
|
+
providers: [
|
|
2783
|
+
FormService,
|
|
2784
|
+
ControlConfigService,
|
|
2785
|
+
ZipConverter,
|
|
2786
|
+
EmailConverter,
|
|
2787
|
+
{ provide: convertersMapToken, useValue: convertersMap },
|
|
2788
|
+
],
|
|
2789
|
+
}]
|
|
2790
|
+
}] });
|
|
2791
|
+
|
|
706
2792
|
class CoreLibraryModule {
|
|
707
2793
|
}
|
|
708
2794
|
CoreLibraryModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
709
|
-
CoreLibraryModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, imports: [HttpClientModule] });
|
|
2795
|
+
CoreLibraryModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, imports: [HttpClientModule, FormModule] });
|
|
710
2796
|
CoreLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, providers: [
|
|
711
2797
|
{
|
|
712
2798
|
provide: HTTP_INTERCEPTORS,
|
|
@@ -717,11 +2803,25 @@ CoreLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", versi
|
|
|
717
2803
|
paymentMethodsResponseFactoryProvider,
|
|
718
2804
|
savedMethodsResponseFactoryProvider,
|
|
719
2805
|
userBalanceResponseFactoryProvider,
|
|
720
|
-
|
|
2806
|
+
initializeResponseFactoryProvider,
|
|
2807
|
+
submitRequestFactoryProvider,
|
|
2808
|
+
submitResponseFactoryProvider,
|
|
2809
|
+
syncRequestFactoryProvider,
|
|
2810
|
+
syncResponseFactoryProvider,
|
|
2811
|
+
statusRequestFactoryProvider,
|
|
2812
|
+
statusResponseFactoryProvider,
|
|
2813
|
+
checkStatusRequestFactoryProvider,
|
|
2814
|
+
checkStatusResponseFactoryProvider,
|
|
2815
|
+
{
|
|
2816
|
+
provide: nextActionsToken,
|
|
2817
|
+
useValue: nextActions,
|
|
2818
|
+
},
|
|
2819
|
+
...nextActions,
|
|
2820
|
+
], imports: [HttpClientModule, FormModule] });
|
|
721
2821
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, decorators: [{
|
|
722
2822
|
type: NgModule,
|
|
723
2823
|
args: [{
|
|
724
|
-
imports: [HttpClientModule],
|
|
2824
|
+
imports: [HttpClientModule, FormModule],
|
|
725
2825
|
providers: [
|
|
726
2826
|
{
|
|
727
2827
|
provide: HTTP_INTERCEPTORS,
|
|
@@ -732,6 +2832,20 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
732
2832
|
paymentMethodsResponseFactoryProvider,
|
|
733
2833
|
savedMethodsResponseFactoryProvider,
|
|
734
2834
|
userBalanceResponseFactoryProvider,
|
|
2835
|
+
initializeResponseFactoryProvider,
|
|
2836
|
+
submitRequestFactoryProvider,
|
|
2837
|
+
submitResponseFactoryProvider,
|
|
2838
|
+
syncRequestFactoryProvider,
|
|
2839
|
+
syncResponseFactoryProvider,
|
|
2840
|
+
statusRequestFactoryProvider,
|
|
2841
|
+
statusResponseFactoryProvider,
|
|
2842
|
+
checkStatusRequestFactoryProvider,
|
|
2843
|
+
checkStatusResponseFactoryProvider,
|
|
2844
|
+
{
|
|
2845
|
+
provide: nextActionsToken,
|
|
2846
|
+
useValue: nextActions,
|
|
2847
|
+
},
|
|
2848
|
+
...nextActions,
|
|
735
2849
|
],
|
|
736
2850
|
}]
|
|
737
2851
|
}] });
|