@xsolla/payment-client-core 0.0.4 → 0.0.5
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/errors/default-terminal-error.class.mjs +8 -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/payment/actions/action-factory-value.interface.mjs +2 -0
- package/esm2020/lib/core/payment/actions/action-type-command.map.mjs +5 -0
- package/esm2020/lib/core/payment/actions/action.interface.mjs +2 -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 +47 -0
- package/esm2020/lib/core/payment/actions/next-actions.mjs +5 -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/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 +29 -12
- 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-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/xps-boolean.enum.mjs +2 -0
- package/esm2020/lib/core-library.module.mjs +31 -4
- package/esm2020/lib/core-library.service.mjs +14 -10
- package/fesm2015/xsolla-payment-client-core.mjs +1093 -83
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +1047 -79
- 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/errors/default-terminal-error.class.d.ts +4 -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/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.action.type.d.ts → check-status/check-status.action.type.d.ts} +1 -1
- package/lib/core/payment/actions/next-action.interface.d.ts +3 -0
- package/lib/core/payment/actions/next-action.service.d.ts +16 -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/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 +6 -5
- package/lib/core/payment/payment.service.d.ts +18 -7
- 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-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/xps-boolean.enum.d.ts +4 -0
- package/lib/core-library.module.d.ts +2 -1
- package/lib/core-library.service.d.ts +4 -2
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.0.5.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/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
|
@@ -4,6 +4,7 @@ import { InjectionToken, Injectable, Inject, NgModule } from '@angular/core';
|
|
|
4
4
|
import { firstValueFrom, lastValueFrom, map, 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 { UntypedFormGroup, Validators, UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
|
|
7
8
|
import { catchError } from 'rxjs/operators';
|
|
8
9
|
import * as i1$1 from '@angular/router';
|
|
9
10
|
|
|
@@ -424,6 +425,1040 @@ 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 ShowFieldsAction {
|
|
1327
|
+
constructor(submitResponse) {
|
|
1328
|
+
this.type = 'show_fields';
|
|
1329
|
+
this.data = {
|
|
1330
|
+
fields: [],
|
|
1331
|
+
errors: [],
|
|
1332
|
+
messages: [],
|
|
1333
|
+
order: {},
|
|
1334
|
+
};
|
|
1335
|
+
this.data.fields = submitResponse.fields;
|
|
1336
|
+
this.data.errors = submitResponse.errors;
|
|
1337
|
+
this.data.messages = submitResponse.messages;
|
|
1338
|
+
this.data.order = submitResponse.summary;
|
|
1339
|
+
}
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
const showFieldsActionFactoryToken = new InjectionToken('ShowFieldsAction');
|
|
1343
|
+
const showFieldsActionFactoryProvider = {
|
|
1344
|
+
provide: showFieldsActionFactoryToken,
|
|
1345
|
+
useValue: {
|
|
1346
|
+
factory: (...args) => new ShowFieldsAction(...args),
|
|
1347
|
+
type: 'show_fields',
|
|
1348
|
+
},
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1351
|
+
const nextActionsToken = new InjectionToken('Action');
|
|
1352
|
+
const nextActions = [showFieldsActionFactoryProvider];
|
|
1353
|
+
|
|
1354
|
+
const actionTypeCommandMap = {
|
|
1355
|
+
[XpsCommand.check]: 'show_fields',
|
|
1356
|
+
};
|
|
1357
|
+
|
|
1358
|
+
class NextActionService {
|
|
1359
|
+
constructor(nextActionTokens, injector) {
|
|
1360
|
+
this.nextActionTokens = nextActionTokens;
|
|
1361
|
+
this.injector = injector;
|
|
1362
|
+
this.nextActionsMap = new Map();
|
|
1363
|
+
this.fillNextActionsMap();
|
|
1364
|
+
}
|
|
1365
|
+
getNextAction(submitResponse) {
|
|
1366
|
+
if (!submitResponse.currentCommand) {
|
|
1367
|
+
return null;
|
|
1368
|
+
}
|
|
1369
|
+
const nextActionFactory = this.findNextAction(submitResponse.currentCommand);
|
|
1370
|
+
if (nextActionFactory) {
|
|
1371
|
+
return nextActionFactory(submitResponse);
|
|
1372
|
+
}
|
|
1373
|
+
throw new Error('Next action is undefined.');
|
|
1374
|
+
}
|
|
1375
|
+
fillNextActionsMap() {
|
|
1376
|
+
this.nextActionTokens.forEach((nextAction) => {
|
|
1377
|
+
const item = this.injector.get(nextAction.provide);
|
|
1378
|
+
this.nextActionsMap.set(item.type, item.factory);
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
findNextAction(command) {
|
|
1382
|
+
const actionType = actionTypeCommandMap[command];
|
|
1383
|
+
if (!actionType) {
|
|
1384
|
+
return;
|
|
1385
|
+
}
|
|
1386
|
+
return this.nextActionsMap.get(actionType);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
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 });
|
|
1390
|
+
NextActionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NextActionService, providedIn: 'root' });
|
|
1391
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NextActionService, decorators: [{
|
|
1392
|
+
type: Injectable,
|
|
1393
|
+
args: [{
|
|
1394
|
+
providedIn: 'root',
|
|
1395
|
+
}]
|
|
1396
|
+
}], ctorParameters: function () {
|
|
1397
|
+
return [{ type: undefined, decorators: [{
|
|
1398
|
+
type: Inject,
|
|
1399
|
+
args: [nextActionsToken]
|
|
1400
|
+
}] }, { type: i0.Injector }];
|
|
1401
|
+
} });
|
|
1402
|
+
|
|
1403
|
+
class PaymentService {
|
|
1404
|
+
constructor(initializeService, submitService, syncService, formService, nextActionService) {
|
|
1405
|
+
this.initializeService = initializeService;
|
|
1406
|
+
this.submitService = submitService;
|
|
1407
|
+
this.syncService = syncService;
|
|
1408
|
+
this.formService = formService;
|
|
1409
|
+
this.nextActionService = nextActionService;
|
|
1410
|
+
this.form = null;
|
|
1411
|
+
this.data = null;
|
|
1412
|
+
this.fields = [];
|
|
1413
|
+
}
|
|
1414
|
+
initialize(config) {
|
|
1415
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1416
|
+
this.data = yield this.initializeService.request(config);
|
|
1417
|
+
this.fields = this.getFields();
|
|
1418
|
+
this.form = this.formService.createForm(this.fields);
|
|
1419
|
+
this.syncService.setup(this.form, this.fields);
|
|
1420
|
+
return this.fields;
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
submit(fields, form) {
|
|
1424
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1425
|
+
const submitResponse = yield this.submitService.request(fields, form);
|
|
1426
|
+
return this.nextActionService.getNextAction(submitResponse);
|
|
1427
|
+
});
|
|
1428
|
+
}
|
|
1429
|
+
getFields() {
|
|
1430
|
+
var _a, _b, _c;
|
|
1431
|
+
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 : [];
|
|
1432
|
+
}
|
|
1433
|
+
validate(field) {
|
|
1434
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1435
|
+
return this.syncService.validate(field);
|
|
1436
|
+
});
|
|
1437
|
+
}
|
|
1438
|
+
runThreeDs() {
|
|
1439
|
+
throw new Error('Method not implemented.');
|
|
1440
|
+
}
|
|
1441
|
+
getFinanceDetails() {
|
|
1442
|
+
throw new Error('Method not implemented.');
|
|
1443
|
+
}
|
|
1444
|
+
getStatus() {
|
|
1445
|
+
throw new Error('Method not implemented.');
|
|
1446
|
+
}
|
|
1447
|
+
changeFieldValue(name, value) {
|
|
1448
|
+
var _a;
|
|
1449
|
+
const formControl = (_a = this.form) === null || _a === void 0 ? void 0 : _a.get(name);
|
|
1450
|
+
formControl === null || formControl === void 0 ? void 0 : formControl.setValue(value);
|
|
1451
|
+
}
|
|
1452
|
+
}
|
|
1453
|
+
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: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1454
|
+
PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
|
|
1455
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
|
|
1456
|
+
type: Injectable,
|
|
1457
|
+
args: [{
|
|
1458
|
+
providedIn: 'root',
|
|
1459
|
+
}]
|
|
1460
|
+
}], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: NextActionService }]; } });
|
|
1461
|
+
|
|
427
1462
|
class RefundPolicyService {
|
|
428
1463
|
constructor(settingsService) {
|
|
429
1464
|
this.settingsService = settingsService;
|
|
@@ -529,88 +1564,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
529
1564
|
}]
|
|
530
1565
|
}], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }, { type: SecureConnectionService }, { type: DisclaimerService }]; } });
|
|
531
1566
|
|
|
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
1567
|
class CoreLibraryService {
|
|
606
|
-
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService,
|
|
1568
|
+
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentService, deviceFingerPrintService, legalService) {
|
|
607
1569
|
this.settingsService = settingsService;
|
|
608
1570
|
this.countryService = countryService;
|
|
609
1571
|
this.paymentMethodsService = paymentMethodsService;
|
|
610
1572
|
this.savedMethodsService = savedMethodsService;
|
|
611
1573
|
this.userBalanceService = userBalanceService;
|
|
612
|
-
this.legalService = legalService;
|
|
613
1574
|
this.paymentService = paymentService;
|
|
1575
|
+
this.deviceFingerPrintService = deviceFingerPrintService;
|
|
1576
|
+
this.legalService = legalService;
|
|
614
1577
|
this.paymentMethods = {
|
|
615
1578
|
getList: () => __awaiter(this, void 0, void 0, function* () { return this.paymentMethodsService.getList(); }),
|
|
616
1579
|
getQuickMethods: () => __awaiter(this, void 0, void 0, function* () { return this.paymentMethodsService.getQuickMethods(); }),
|
|
@@ -620,7 +1583,8 @@ class CoreLibraryService {
|
|
|
620
1583
|
}
|
|
621
1584
|
init(configuration) {
|
|
622
1585
|
return __awaiter(this, void 0, void 0, function* () {
|
|
623
|
-
|
|
1586
|
+
yield this.settingsService.init(configuration);
|
|
1587
|
+
yield this.deviceFingerPrintService.init();
|
|
624
1588
|
});
|
|
625
1589
|
}
|
|
626
1590
|
setCountry(country) {
|
|
@@ -629,9 +1593,10 @@ class CoreLibraryService {
|
|
|
629
1593
|
createPayment(config) {
|
|
630
1594
|
return {
|
|
631
1595
|
initialize: () => __awaiter(this, void 0, void 0, function* () { return this.paymentService.initialize(config); }),
|
|
632
|
-
submit: () => this.paymentService.submit(),
|
|
1596
|
+
submit: (fields, form) => __awaiter(this, void 0, void 0, function* () { return this.paymentService.submit(fields, form); }),
|
|
633
1597
|
getFields: () => this.paymentService.getFields(),
|
|
634
|
-
|
|
1598
|
+
changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
|
|
1599
|
+
validate: (field) => __awaiter(this, void 0, void 0, function* () { return this.paymentService.validate(field); }),
|
|
635
1600
|
getFinanceDetails: () => this.paymentService.getFinanceDetails(),
|
|
636
1601
|
runThreeDs: () => this.paymentService.runThreeDs(),
|
|
637
1602
|
getStatus: () => this.paymentService.getStatus(),
|
|
@@ -641,14 +1606,14 @@ class CoreLibraryService {
|
|
|
641
1606
|
return this.legalService.getLegalComponentConfig();
|
|
642
1607
|
}
|
|
643
1608
|
}
|
|
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:
|
|
1609
|
+
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 }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
645
1610
|
CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
|
|
646
1611
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
|
|
647
1612
|
type: Injectable,
|
|
648
1613
|
args: [{
|
|
649
1614
|
providedIn: 'root',
|
|
650
1615
|
}]
|
|
651
|
-
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type:
|
|
1616
|
+
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: LegalService }]; } });
|
|
652
1617
|
|
|
653
1618
|
class HttpError extends AppError {
|
|
654
1619
|
constructor(error, req) {
|
|
@@ -703,10 +1668,35 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
703
1668
|
type: Injectable
|
|
704
1669
|
}], ctorParameters: function () { return [{ type: i1$1.Router }]; } });
|
|
705
1670
|
|
|
1671
|
+
class FormModule {
|
|
1672
|
+
}
|
|
1673
|
+
FormModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
1674
|
+
FormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: FormModule, imports: [ReactiveFormsModule] });
|
|
1675
|
+
FormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, providers: [
|
|
1676
|
+
FormService,
|
|
1677
|
+
ControlConfigService,
|
|
1678
|
+
ZipConverter,
|
|
1679
|
+
EmailConverter,
|
|
1680
|
+
{ provide: convertersMapToken, useValue: convertersMap },
|
|
1681
|
+
], imports: [ReactiveFormsModule] });
|
|
1682
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, decorators: [{
|
|
1683
|
+
type: NgModule,
|
|
1684
|
+
args: [{
|
|
1685
|
+
imports: [ReactiveFormsModule],
|
|
1686
|
+
providers: [
|
|
1687
|
+
FormService,
|
|
1688
|
+
ControlConfigService,
|
|
1689
|
+
ZipConverter,
|
|
1690
|
+
EmailConverter,
|
|
1691
|
+
{ provide: convertersMapToken, useValue: convertersMap },
|
|
1692
|
+
],
|
|
1693
|
+
}]
|
|
1694
|
+
}] });
|
|
1695
|
+
|
|
706
1696
|
class CoreLibraryModule {
|
|
707
1697
|
}
|
|
708
1698
|
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] });
|
|
1699
|
+
CoreLibraryModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, imports: [HttpClientModule, FormModule] });
|
|
710
1700
|
CoreLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, providers: [
|
|
711
1701
|
{
|
|
712
1702
|
provide: HTTP_INTERCEPTORS,
|
|
@@ -717,11 +1707,21 @@ CoreLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", versi
|
|
|
717
1707
|
paymentMethodsResponseFactoryProvider,
|
|
718
1708
|
savedMethodsResponseFactoryProvider,
|
|
719
1709
|
userBalanceResponseFactoryProvider,
|
|
720
|
-
|
|
1710
|
+
initializeResponseFactoryProvider,
|
|
1711
|
+
submitRequestFactoryProvider,
|
|
1712
|
+
submitResponseFactoryProvider,
|
|
1713
|
+
syncRequestFactoryProvider,
|
|
1714
|
+
syncResponseFactoryProvider,
|
|
1715
|
+
{
|
|
1716
|
+
provide: nextActionsToken,
|
|
1717
|
+
useValue: nextActions,
|
|
1718
|
+
},
|
|
1719
|
+
...nextActions,
|
|
1720
|
+
], imports: [HttpClientModule, FormModule] });
|
|
721
1721
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryModule, decorators: [{
|
|
722
1722
|
type: NgModule,
|
|
723
1723
|
args: [{
|
|
724
|
-
imports: [HttpClientModule],
|
|
1724
|
+
imports: [HttpClientModule, FormModule],
|
|
725
1725
|
providers: [
|
|
726
1726
|
{
|
|
727
1727
|
provide: HTTP_INTERCEPTORS,
|
|
@@ -732,6 +1732,16 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
732
1732
|
paymentMethodsResponseFactoryProvider,
|
|
733
1733
|
savedMethodsResponseFactoryProvider,
|
|
734
1734
|
userBalanceResponseFactoryProvider,
|
|
1735
|
+
initializeResponseFactoryProvider,
|
|
1736
|
+
submitRequestFactoryProvider,
|
|
1737
|
+
submitResponseFactoryProvider,
|
|
1738
|
+
syncRequestFactoryProvider,
|
|
1739
|
+
syncResponseFactoryProvider,
|
|
1740
|
+
{
|
|
1741
|
+
provide: nextActionsToken,
|
|
1742
|
+
useValue: nextActions,
|
|
1743
|
+
},
|
|
1744
|
+
...nextActions,
|
|
735
1745
|
],
|
|
736
1746
|
}]
|
|
737
1747
|
}] });
|