@xsolla/payment-client-core 0.1.3 → 0.1.5-1
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/credit-card/credit-card-settings.interface.mjs +2 -0
- package/esm2020/lib/core/credit-card/credit-card-types.enum.mjs +20 -0
- package/esm2020/lib/core/credit-card/credit-card.interface.mjs +2 -0
- package/esm2020/lib/core/credit-card/credit-card.service.mjs +41 -0
- package/esm2020/lib/core/credit-card/credit-cards-map.const.mjs +36 -0
- package/esm2020/lib/core/credit-card/default-mask.const.mjs +2 -0
- package/esm2020/lib/core/credit-card/four-block-mask.const.mjs +2 -0
- package/esm2020/lib/core/credit-card/ordered-cards-settings.const.mjs +45 -0
- package/esm2020/lib/core/credit-card/types/american-express.mjs +13 -0
- package/esm2020/lib/core/credit-card/types/aura.mjs +15 -0
- package/esm2020/lib/core/credit-card/types/china-union-pay.mjs +12 -0
- package/esm2020/lib/core/credit-card/types/dankort.mjs +15 -0
- package/esm2020/lib/core/credit-card/types/default-card.mjs +13 -0
- package/esm2020/lib/core/credit-card/types/diners-clubs.mjs +13 -0
- package/esm2020/lib/core/credit-card/types/discover.mjs +13 -0
- package/esm2020/lib/core/credit-card/types/elo.mjs +13 -0
- package/esm2020/lib/core/credit-card/types/hipercard.mjs +13 -0
- package/esm2020/lib/core/credit-card/types/jcb.mjs +13 -0
- package/esm2020/lib/core/credit-card/types/maestro.mjs +14 -0
- package/esm2020/lib/core/credit-card/types/mastercard.mjs +16 -0
- package/esm2020/lib/core/credit-card/types/mir.mjs +15 -0
- package/esm2020/lib/core/credit-card/types/naranja.mjs +15 -0
- package/esm2020/lib/core/credit-card/types/postepay.mjs +13 -0
- package/esm2020/lib/core/credit-card/types/visa.mjs +13 -0
- package/esm2020/lib/core/device-finger-print/device-finger-print.service.mjs +26 -126
- package/esm2020/lib/core/device-finger-print/hash.type.mjs +1 -1
- package/esm2020/lib/core/encrypt-credit-card/encrypt-credit-card.service.mjs +72 -0
- package/esm2020/lib/core/encrypt-credit-card/encrypted-card.interface.mjs +2 -0
- package/esm2020/lib/core/encrypt-credit-card/open-card.interface.mjs +2 -0
- package/esm2020/lib/core/exceptions-handling/errors/encrypt-card-error.mjs +9 -0
- package/esm2020/lib/core/payment/actions/check-status/check-status.action.class.mjs +2 -3
- package/esm2020/lib/core/payment/actions/next-action.interface.mjs +1 -1
- package/esm2020/lib/core/payment/actions/next-actions.mjs +3 -1
- package/esm2020/lib/core/payment/actions/three-ds/three-ds.action.class.mjs +7 -0
- package/esm2020/lib/core/payment/actions/three-ds/three-ds.action.token.mjs +11 -0
- package/esm2020/lib/core/payment/actions/three-ds/three-ds.action.type.mjs +2 -0
- package/esm2020/lib/core/payment/credit-card-payment-methods-id.variable.mjs +15 -0
- package/esm2020/lib/core/payment/credit-card-state/credit-card-state.interface.mjs +2 -0
- package/esm2020/lib/core/payment/credit-card-state/credit-card-state.service.mjs +14 -0
- package/esm2020/lib/core/payment/form/controls/card-number-control.config.mjs +10 -0
- package/esm2020/lib/core/payment/form/controls/phone-control.config.mjs +8 -0
- package/esm2020/lib/core/payment/form/converters/birth-date.converter.mjs +38 -0
- package/esm2020/lib/core/payment/form/converters/card-expiration.converter.mjs +36 -0
- package/esm2020/lib/core/payment/form/converters/card-number.converter.mjs +45 -0
- package/esm2020/lib/core/payment/form/converters/cardholder-name.converter.mjs +25 -0
- package/esm2020/lib/core/payment/form/converters/converters-map.mjs +23 -1
- package/esm2020/lib/core/payment/form/converters/cpf-name-regex.variable.mjs +2 -0
- package/esm2020/lib/core/payment/form/converters/cpf-name.converter.mjs +34 -0
- package/esm2020/lib/core/payment/form/converters/cpf-number.converter.mjs +31 -0
- package/esm2020/lib/core/payment/form/converters/cvv.converter.mjs +50 -0
- package/esm2020/lib/core/payment/form/converters/phone.converter.mjs +37 -0
- package/esm2020/lib/core/payment/form/converters/street-number/street-number-from-state.interface.mjs +2 -0
- package/esm2020/lib/core/payment/form/converters/street-number/street-number.converter.mjs +28 -0
- package/esm2020/lib/core/payment/form/converters/text.converter.mjs +19 -0
- package/esm2020/lib/core/payment/form/form.module.mjs +32 -4
- package/esm2020/lib/core/payment/form/validators/birth-date.validator.mjs +37 -0
- package/esm2020/lib/core/payment/form/validators/credit-card-min-length.validator.mjs +32 -0
- package/esm2020/lib/core/payment/form/validators/is-empty-input-value.function.mjs +4 -0
- package/esm2020/lib/core/payment/form/validators/luhn-formula-validator/luhn-formula.validator.mjs +40 -0
- package/esm2020/lib/core/payment/form/validators/max-length-validator.mjs +6 -0
- package/esm2020/lib/core/payment/form/validators/min-length-validator.mjs +6 -0
- package/esm2020/lib/core/payment/form/validators/phone-validator.mjs +6 -0
- package/esm2020/lib/core/payment/form/validators/validators.module.mjs +18 -0
- package/esm2020/lib/core/payment/initialize/initialize-request-params.interface.mjs +1 -1
- package/esm2020/lib/core/payment/initialize/initialize.service.mjs +28 -19
- package/esm2020/lib/core/payment/initialize/response/initialize-response.class.mjs +43 -0
- package/esm2020/lib/core/payment/initialize/response/initialize-response.token.mjs +8 -0
- package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
- package/esm2020/lib/core/payment/payment.service.mjs +38 -8
- package/esm2020/lib/core/payment/status/check-status/check-status.service.mjs +8 -13
- package/esm2020/lib/core/payment/status/check-status/response/check-status-response.class.mjs +1 -1
- package/esm2020/lib/core/payment/submit/submit.service.mjs +13 -16
- package/esm2020/lib/core/payment/sync/field-async-validation.interface.mjs +2 -0
- package/esm2020/lib/core/payment/sync/field-sync-state.interface.mjs +1 -1
- package/esm2020/lib/core/payment/sync/request/sync-request.class.mjs +31 -0
- package/esm2020/lib/core/payment/sync/request/sync-request.token.mjs +8 -0
- package/esm2020/lib/core/payment/sync/response/sync-response.class.mjs +17 -0
- package/esm2020/lib/core/payment/sync/response/sync-response.token.mjs +8 -0
- package/esm2020/lib/core/payment/sync/sync.service.mjs +24 -15
- package/esm2020/lib/core/payment/three-ds/api/notify-dfp-status/notify-dfp-status.service.mjs +49 -0
- package/esm2020/lib/core/payment/three-ds/api/notify-dfp-status/request/notify-dfp-status-request.class.mjs +8 -0
- package/esm2020/lib/core/payment/three-ds/api/notify-dfp-status/request/notify-dfp-status-request.token.mjs +8 -0
- package/esm2020/lib/core/payment/three-ds/api/status-three-ds/request/status-three-ds-request.class.mjs +7 -0
- package/esm2020/lib/core/payment/three-ds/api/status-three-ds/request/status-three-ds-request.token.mjs +8 -0
- package/esm2020/lib/core/payment/three-ds/api/status-three-ds/response/status-three-ds-response.class.mjs +7 -0
- package/esm2020/lib/core/payment/three-ds/api/status-three-ds/response/status-three-ds-response.token.mjs +8 -0
- package/esm2020/lib/core/payment/three-ds/api/status-three-ds/status-three-ds-response.interface.mjs +2 -0
- package/esm2020/lib/core/payment/three-ds/api/status-three-ds/status-three-ds.service.mjs +60 -0
- package/esm2020/lib/core/payment/three-ds/api/status-three-ds/status-types.enum.mjs +7 -0
- package/esm2020/lib/core/payment/three-ds/api/status-three-ds/three-ds-checkout-form.interface.mjs +2 -0
- package/esm2020/lib/core/payment/three-ds/dfp-collect/dfp-collect.service.mjs +105 -0
- package/esm2020/lib/core/payment/three-ds/reinsurance-check/reinsurance-check.service.mjs +41 -0
- package/esm2020/lib/core/payment/three-ds/reinsurance-check/timer.interface.mjs +2 -0
- package/esm2020/lib/core/payment/three-ds/three-ds-20/status-update.interface.mjs +2 -0
- package/esm2020/lib/core/payment/three-ds/three-ds-20/three-ds20.service.mjs +109 -0
- package/esm2020/lib/core/payment/three-ds/three-ds-form.interface.mjs +2 -0
- package/esm2020/lib/core/payment/three-ds/three-ds-status-websocket-types.enum.mjs +5 -0
- package/esm2020/lib/core/payment/three-ds/three-ds.service.mjs +40 -0
- package/esm2020/lib/core/payment/xps-api/xps-api.service.mjs +79 -0
- package/esm2020/lib/core/payment/xps-request-params.interface.mjs +2 -0
- package/esm2020/lib/core/payment/xps-request.interface.mjs +2 -0
- package/esm2020/lib/core/payment/xps-response.error.mjs +7 -0
- package/esm2020/lib/core/payment/xps-response.interface.mjs +1 -1
- package/esm2020/lib/core/type-guards/is-string.function.mjs +4 -0
- package/esm2020/lib/core-library.module.mjs +13 -4
- package/esm2020/lib/core-library.service.mjs +19 -5
- package/fesm2015/xsolla-payment-client-core.mjs +1585 -261
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +1574 -258
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/credit-card/credit-card-settings.interface.d.ts +10 -0
- package/lib/core/credit-card/credit-card-types.enum.d.ts +18 -0
- package/lib/core/credit-card/credit-card.interface.d.ts +9 -0
- package/lib/core/credit-card/credit-card.service.d.ts +11 -0
- package/lib/core/credit-card/credit-cards-map.const.d.ts +5 -0
- package/lib/core/credit-card/default-mask.const.d.ts +1 -0
- package/lib/core/credit-card/four-block-mask.const.d.ts +1 -0
- package/lib/core/credit-card/ordered-cards-settings.const.d.ts +12 -0
- package/lib/core/credit-card/types/american-express.d.ts +2 -0
- package/lib/core/credit-card/types/aura.d.ts +2 -0
- package/lib/core/credit-card/types/china-union-pay.d.ts +2 -0
- package/lib/core/credit-card/types/dankort.d.ts +2 -0
- package/lib/core/credit-card/types/default-card.d.ts +2 -0
- package/lib/core/credit-card/types/diners-clubs.d.ts +2 -0
- package/lib/core/credit-card/types/discover.d.ts +2 -0
- package/lib/core/credit-card/types/elo.d.ts +2 -0
- package/lib/core/credit-card/types/hipercard.d.ts +2 -0
- package/lib/core/credit-card/types/jcb.d.ts +2 -0
- package/lib/core/credit-card/types/maestro.d.ts +2 -0
- package/lib/core/credit-card/types/mastercard.d.ts +2 -0
- package/lib/core/credit-card/types/mir.d.ts +2 -0
- package/lib/core/credit-card/types/naranja.d.ts +2 -0
- package/lib/core/credit-card/types/postepay.d.ts +2 -0
- package/lib/core/credit-card/types/visa.d.ts +2 -0
- package/lib/core/device-finger-print/device-finger-print.service.d.ts +3 -31
- package/lib/core/device-finger-print/hash.type.d.ts +1 -1
- package/lib/core/encrypt-credit-card/encrypt-credit-card.service.d.ts +16 -0
- package/lib/core/encrypt-credit-card/encrypted-card.interface.d.ts +6 -0
- package/lib/core/encrypt-credit-card/open-card.interface.d.ts +6 -0
- package/lib/core/exceptions-handling/errors/encrypt-card-error.d.ts +5 -0
- package/lib/core/payment/actions/next-action.interface.d.ts +2 -1
- package/lib/core/payment/actions/three-ds/three-ds.action.class.d.ts +8 -0
- package/lib/core/payment/actions/three-ds/three-ds.action.token.d.ts +4 -0
- package/lib/core/payment/actions/three-ds/three-ds.action.type.d.ts +5 -0
- package/lib/core/payment/credit-card-payment-methods-id.variable.d.ts +6 -0
- package/lib/core/payment/credit-card-state/credit-card-state.interface.d.ts +3 -0
- package/lib/core/payment/credit-card-state/credit-card-state.service.d.ts +7 -0
- package/lib/core/payment/form/controls/card-number-control.config.d.ts +11 -0
- package/lib/core/payment/form/controls/phone-control.config.d.ts +6 -0
- package/lib/core/payment/form/converters/birth-date.converter.d.ts +13 -0
- package/lib/core/payment/form/converters/card-expiration.converter.d.ts +16 -0
- package/lib/core/payment/form/converters/card-number.converter.d.ts +19 -0
- package/lib/core/payment/form/converters/cardholder-name.converter.d.ts +13 -0
- package/lib/core/payment/form/converters/cpf-name-regex.variable.d.ts +1 -0
- package/lib/core/payment/form/converters/cpf-name.converter.d.ts +13 -0
- package/lib/core/payment/form/converters/cpf-number.converter.d.ts +11 -0
- package/lib/core/payment/form/converters/cvv.converter.d.ts +18 -0
- package/lib/core/payment/form/converters/phone.converter.d.ts +13 -0
- package/lib/core/payment/form/converters/street-number/street-number-from-state.interface.d.ts +3 -0
- package/lib/core/payment/form/converters/street-number/street-number.converter.d.ts +14 -0
- package/lib/core/payment/form/converters/text.converter.d.ts +11 -0
- package/lib/core/payment/form/form.module.d.ts +2 -1
- package/lib/core/payment/form/validators/birth-date.validator.d.ts +2 -0
- package/lib/core/payment/form/validators/credit-card-min-length.validator.d.ts +12 -0
- package/lib/core/payment/form/validators/is-empty-input-value.function.d.ts +1 -0
- package/lib/core/payment/form/validators/luhn-formula-validator/luhn-formula.validator.d.ts +6 -0
- package/lib/core/payment/form/validators/max-length-validator.d.ts +2 -0
- package/lib/core/payment/form/validators/min-length-validator.d.ts +2 -0
- package/lib/core/payment/form/validators/phone-validator.d.ts +2 -0
- package/lib/core/payment/form/validators/validators.module.d.ts +7 -0
- package/lib/core/payment/initialize/initialize-request-params.interface.d.ts +1 -0
- package/lib/core/payment/initialize/initialize.service.d.ts +8 -6
- package/lib/core/payment/initialize/{initialize-response.class.d.ts → response/initialize-response.class.d.ts} +2 -2
- package/lib/core/payment/payment.interface.d.ts +2 -2
- package/lib/core/payment/payment.service.d.ts +7 -2
- package/lib/core/payment/status/check-status/check-status.service.d.ts +3 -4
- package/lib/core/payment/submit/submit.service.d.ts +5 -4
- package/lib/core/payment/sync/field-async-validation.interface.d.ts +7 -0
- package/lib/core/payment/sync/field-sync-state.interface.d.ts +1 -1
- package/lib/core/payment/sync/{sync-request.class.d.ts → request/sync-request.class.d.ts} +3 -3
- package/lib/core/payment/sync/{sync-response.class.d.ts → response/sync-response.class.d.ts} +2 -2
- package/lib/core/payment/sync/sync.service.d.ts +12 -7
- package/lib/core/payment/three-ds/api/notify-dfp-status/notify-dfp-status.service.d.ts +14 -0
- package/lib/core/payment/three-ds/api/notify-dfp-status/request/notify-dfp-status-request.class.d.ts +10 -0
- package/lib/core/payment/three-ds/api/notify-dfp-status/request/notify-dfp-status-request.token.d.ts +6 -0
- package/lib/core/payment/three-ds/api/status-three-ds/request/status-three-ds-request.class.d.ts +5 -0
- package/lib/core/payment/three-ds/api/status-three-ds/request/status-three-ds-request.token.d.ts +6 -0
- package/lib/core/payment/three-ds/api/status-three-ds/response/status-three-ds-response.class.d.ts +7 -0
- package/lib/core/payment/three-ds/api/status-three-ds/response/status-three-ds-response.token.d.ts +6 -0
- package/lib/core/payment/three-ds/api/status-three-ds/status-three-ds-response.interface.d.ts +7 -0
- package/lib/core/payment/three-ds/api/status-three-ds/status-three-ds.service.d.ts +21 -0
- package/lib/core/payment/three-ds/api/status-three-ds/status-types.enum.d.ts +5 -0
- package/lib/core/payment/three-ds/api/status-three-ds/three-ds-checkout-form.interface.d.ts +7 -0
- package/lib/core/payment/three-ds/dfp-collect/dfp-collect.service.d.ts +20 -0
- package/lib/core/payment/three-ds/reinsurance-check/reinsurance-check.service.d.ts +12 -0
- package/lib/core/payment/three-ds/reinsurance-check/timer.interface.d.ts +9 -0
- package/lib/core/payment/three-ds/three-ds-20/status-update.interface.d.ts +12 -0
- package/lib/core/payment/three-ds/three-ds-20/three-ds20.service.d.ts +32 -0
- package/lib/core/payment/three-ds/three-ds-form.interface.d.ts +11 -0
- package/lib/core/payment/three-ds/three-ds-status-websocket-types.enum.d.ts +3 -0
- package/lib/core/payment/three-ds/three-ds.service.d.ts +14 -0
- package/lib/core/payment/xps-api/xps-api.service.d.ts +20 -0
- package/lib/core/payment/xps-request-params.interface.d.ts +3 -0
- package/lib/core/payment/xps-request.interface.d.ts +10 -0
- package/lib/core/payment/xps-response.error.d.ts +4 -0
- package/lib/core/payment/xps-response.interface.d.ts +3 -10
- package/lib/core/type-guards/is-string.function.d.ts +1 -0
- package/lib/core-library.service.d.ts +10 -1
- package/package.json +2 -3
- package/xsolla-payment-client-core-0.1.5-1.tgz +0 -0
- package/esm2020/lib/core/device-finger-print/device-finger-print-components.interface.mjs +0 -2
- package/esm2020/lib/core/device-finger-print/fingerprint-js.interface.mjs +0 -2
- package/esm2020/lib/core/exceptions-handling/errors/default-terminal-error.class.mjs +0 -8
- package/esm2020/lib/core/payment/initialize/initialize-response.class.mjs +0 -43
- package/esm2020/lib/core/payment/initialize/initialize-response.token.mjs +0 -8
- package/esm2020/lib/core/payment/sync/sync-request.class.mjs +0 -31
- package/esm2020/lib/core/payment/sync/sync-request.token.mjs +0 -8
- package/esm2020/lib/core/payment/sync/sync-response.class.mjs +0 -17
- package/esm2020/lib/core/payment/sync/sync-response.token.mjs +0 -8
- package/esm2020/lib/core/payment/xps-request.abstract.mjs +0 -8
- package/lib/core/device-finger-print/device-finger-print-components.interface.d.ts +0 -4
- package/lib/core/device-finger-print/fingerprint-js.interface.d.ts +0 -6
- package/lib/core/exceptions-handling/errors/default-terminal-error.class.d.ts +0 -4
- package/lib/core/payment/xps-request.abstract.d.ts +0 -6
- package/xsolla-payment-client-core-0.1.3.tgz +0 -0
- /package/lib/core/payment/initialize/{initialize-response.token.d.ts → response/initialize-response.token.d.ts} +0 -0
- /package/lib/core/payment/sync/{sync-request.token.d.ts → request/sync-request.token.d.ts} +0 -0
- /package/lib/core/payment/sync/{sync-response.token.d.ts → response/sync-response.token.d.ts} +0 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, Injectable, Inject, isDevMode, NgModule } from '@angular/core';
|
|
3
|
-
import { firstValueFrom, lastValueFrom, map, Subject,
|
|
3
|
+
import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, skip, throwError } from 'rxjs';
|
|
4
4
|
import * as i1 from '@angular/common/http';
|
|
5
5
|
import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
|
|
6
|
+
import JSEncrypt from 'jsencrypt';
|
|
6
7
|
import { UntypedFormGroup, Validators, UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
|
|
7
8
|
import { filter, map as map$1, catchError } from 'rxjs/operators';
|
|
8
9
|
import * as i1$1 from '@angular/router';
|
|
10
|
+
import { CommonModule } from '@angular/common';
|
|
9
11
|
|
|
10
12
|
const masksFunctionsMap = {
|
|
11
13
|
zip: () => {
|
|
@@ -579,6 +581,15 @@ var InputEventName;
|
|
|
579
581
|
InputEventName["focus"] = "focus";
|
|
580
582
|
})(InputEventName || (InputEventName = {}));
|
|
581
583
|
|
|
584
|
+
class ShowErrorsAction {
|
|
585
|
+
constructor(errors) {
|
|
586
|
+
this.type = 'show_errors';
|
|
587
|
+
this.data = {
|
|
588
|
+
errors,
|
|
589
|
+
};
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
582
593
|
class InitializeResponse {
|
|
583
594
|
constructor(response) {
|
|
584
595
|
this.paymentForm = null;
|
|
@@ -628,14 +639,90 @@ const initializeResponseFactoryProvider = {
|
|
|
628
639
|
useValue: (...args) => new InitializeResponse(...args),
|
|
629
640
|
};
|
|
630
641
|
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
642
|
+
const masterCardAndVisaPaymentMethodId = 26;
|
|
643
|
+
const maestroPaymentMethodId = 490;
|
|
644
|
+
const creditCardPaymentMethodId = 1380;
|
|
645
|
+
const americanExpressMethodId = 714;
|
|
646
|
+
const specialCards = [
|
|
647
|
+
maestroPaymentMethodId,
|
|
648
|
+
masterCardAndVisaPaymentMethodId,
|
|
649
|
+
americanExpressMethodId,
|
|
650
|
+
];
|
|
651
|
+
const cardsWith3ds = [
|
|
652
|
+
masterCardAndVisaPaymentMethodId,
|
|
653
|
+
maestroPaymentMethodId,
|
|
654
|
+
creditCardPaymentMethodId,
|
|
655
|
+
];
|
|
656
|
+
|
|
657
|
+
class XpsApiService {
|
|
658
|
+
constructor(window, secureApiClient, settingsService, countryService) {
|
|
659
|
+
this.window = window;
|
|
660
|
+
this.secureApiClient = secureApiClient;
|
|
661
|
+
this.settingsService = settingsService;
|
|
662
|
+
this.countryService = countryService;
|
|
663
|
+
this.directPaymentApiRoute = 'directpayment';
|
|
664
|
+
}
|
|
665
|
+
async directPaymentRequest(parameters) {
|
|
666
|
+
const pid = parameters.pid?.toString() ??
|
|
667
|
+
parameters.xps_fix_pid ??
|
|
668
|
+
'';
|
|
669
|
+
const paymentWithSavedMethod = parameters.paymentWithSavedMethod ??
|
|
670
|
+
parameters.xps_paymentWithSavedMethod ??
|
|
671
|
+
'';
|
|
672
|
+
const requestParams = {
|
|
673
|
+
...this.collectAnalyticsParameters(pid, paymentWithSavedMethod),
|
|
674
|
+
...this.collectUserSessionId(),
|
|
675
|
+
country: this.countryService.getCountry(),
|
|
676
|
+
...parameters,
|
|
636
677
|
};
|
|
678
|
+
return lastValueFrom(this.secureApiClient.post(this.directPaymentApiRoute, new URLSearchParams({ ...requestParams }), {
|
|
679
|
+
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
680
|
+
responseType: 'json',
|
|
681
|
+
}));
|
|
682
|
+
}
|
|
683
|
+
collectAnalyticsParameters(paymentMethodId, paymentWithSavedMethod) {
|
|
684
|
+
const parameters = {};
|
|
685
|
+
parameters.paymentWithSavedMethod = paymentWithSavedMethod
|
|
686
|
+
? paymentWithSavedMethod
|
|
687
|
+
: "0" /* XpsBoolean.false */;
|
|
688
|
+
if (!paymentMethodId) {
|
|
689
|
+
return parameters;
|
|
690
|
+
}
|
|
691
|
+
/* If payment method with 3DSecure */
|
|
692
|
+
if (cardsWith3ds.includes(Number(paymentMethodId))) {
|
|
693
|
+
parameters.container3DS = JSON.stringify({
|
|
694
|
+
browserjavaenabled: this.window.navigator.javaEnabled(),
|
|
695
|
+
browserlanguage: this.window.navigator.language,
|
|
696
|
+
browsercolordepth: this.window.screen.colorDepth,
|
|
697
|
+
browserscreenheight: this.window.screen.availHeight,
|
|
698
|
+
browserscreenwidth: this.window.screen.availWidth,
|
|
699
|
+
browsertz: new Date().getTimezoneOffset(),
|
|
700
|
+
browserappname: this.window.navigator.appName,
|
|
701
|
+
browserlocaltime: new Date().toString(),
|
|
702
|
+
browserplatform: this.window.navigator.platform || '',
|
|
703
|
+
browsercookiesenabled: this.window.navigator.cookieEnabled,
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
return parameters;
|
|
707
|
+
}
|
|
708
|
+
collectUserSessionId() {
|
|
709
|
+
const parameters = {};
|
|
710
|
+
parameters.xps_idUserSession = this.settingsService.user.session_id ?? '';
|
|
711
|
+
parameters.user_session_id = this.settingsService.user.session_id ?? '';
|
|
712
|
+
return parameters;
|
|
637
713
|
}
|
|
638
714
|
}
|
|
715
|
+
XpsApiService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: XpsApiService, deps: [{ token: windowToken }, { token: SecureApiClient }, { token: SettingsService }, { token: CountryService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
716
|
+
XpsApiService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: XpsApiService, providedIn: 'root' });
|
|
717
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: XpsApiService, decorators: [{
|
|
718
|
+
type: Injectable,
|
|
719
|
+
args: [{
|
|
720
|
+
providedIn: 'root',
|
|
721
|
+
}]
|
|
722
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
723
|
+
type: Inject,
|
|
724
|
+
args: [windowToken]
|
|
725
|
+
}] }, { type: SecureApiClient }, { type: SettingsService }, { type: CountryService }]; } });
|
|
639
726
|
|
|
640
727
|
class ShowFieldsAction {
|
|
641
728
|
constructor(submitResponse) {
|
|
@@ -668,9 +755,8 @@ const showFieldsActionFactoryProvider = {
|
|
|
668
755
|
class CheckStatusAction {
|
|
669
756
|
constructor(submitResponse) {
|
|
670
757
|
this.type = 'check_status';
|
|
671
|
-
const status = submitResponse.parameters.status;
|
|
672
758
|
this.data = {
|
|
673
|
-
invoice:
|
|
759
|
+
invoice: parseInt(submitResponse.parameters.form.fix_invoice?.value),
|
|
674
760
|
signature: submitResponse.parameters.form.signature?.value,
|
|
675
761
|
locale: submitResponse.parameters.form.locale?.value,
|
|
676
762
|
testPs: submitResponse.parameters.form.testPs?.value,
|
|
@@ -758,6 +844,22 @@ const showErrorsActionFactoryProvider = {
|
|
|
758
844
|
},
|
|
759
845
|
};
|
|
760
846
|
|
|
847
|
+
class ThreeDsAction {
|
|
848
|
+
constructor(statusUpdate) {
|
|
849
|
+
this.type = '3DS';
|
|
850
|
+
this.data = statusUpdate;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
const threeDsActionFactoryToken = new InjectionToken('ThreeDsAction');
|
|
855
|
+
const threeDsActionFactoryProvider = {
|
|
856
|
+
provide: threeDsActionFactoryToken,
|
|
857
|
+
useValue: {
|
|
858
|
+
factory: (...args) => new ThreeDsAction(...args),
|
|
859
|
+
isSuitable: () => false,
|
|
860
|
+
},
|
|
861
|
+
};
|
|
862
|
+
|
|
761
863
|
const nextActionsToken = new InjectionToken('Action');
|
|
762
864
|
const nextActions = [
|
|
763
865
|
showFieldsActionFactoryProvider,
|
|
@@ -767,6 +869,7 @@ const nextActions = [
|
|
|
767
869
|
const flowUpdateNextActions = [
|
|
768
870
|
statusUpdatedActionFactoryProvider,
|
|
769
871
|
showErrorsActionFactoryProvider,
|
|
872
|
+
threeDsActionFactoryProvider,
|
|
770
873
|
];
|
|
771
874
|
|
|
772
875
|
class NextActionService {
|
|
@@ -824,14 +927,415 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
824
927
|
args: [nextActionsToken]
|
|
825
928
|
}] }, { type: i0.Injector }]; } });
|
|
826
929
|
|
|
930
|
+
var ErrorTags;
|
|
931
|
+
(function (ErrorTags) {
|
|
932
|
+
ErrorTags["APP"] = "appError";
|
|
933
|
+
ErrorTags["HTTP"] = "httpError";
|
|
934
|
+
ErrorTags["JS"] = "jsError";
|
|
935
|
+
ErrorTags["WS"] = "webSocket";
|
|
936
|
+
ErrorTags["ENCRYPT"] = "encrypt";
|
|
937
|
+
ErrorTags["APPLEPAY"] = "applepay";
|
|
938
|
+
ErrorTags["HEADLESS_UI"] = "headlessUi";
|
|
939
|
+
ErrorTags["GOOGLEPAY"] = "googlepay";
|
|
940
|
+
ErrorTags["PAYTM"] = "paytm";
|
|
941
|
+
})(ErrorTags || (ErrorTags = {}));
|
|
942
|
+
|
|
943
|
+
class TaggedError extends Error {
|
|
944
|
+
constructor(message, tags) {
|
|
945
|
+
super(message);
|
|
946
|
+
this.tags = [];
|
|
947
|
+
this.parentTag = ErrorTags.HEADLESS_UI;
|
|
948
|
+
this.tags = this.childTag
|
|
949
|
+
? [this.parentTag, this.childTag]
|
|
950
|
+
: [this.parentTag];
|
|
951
|
+
if (tags) {
|
|
952
|
+
const newTags = tags.filter((t, i, arr) => !this.tags.includes(t) && arr.indexOf(t) == i);
|
|
953
|
+
this.tags = [...this.tags, ...newTags];
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
|
|
958
|
+
class EncryptCreditCardError extends TaggedError {
|
|
959
|
+
constructor(message, tags) {
|
|
960
|
+
tags = tags ? [...tags, ErrorTags.ENCRYPT] : [ErrorTags.ENCRYPT];
|
|
961
|
+
super(message, tags);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
const fourBlockMask = '9999 9999 9999 9999';
|
|
966
|
+
|
|
967
|
+
var CreditCardTypes;
|
|
968
|
+
(function (CreditCardTypes) {
|
|
969
|
+
CreditCardTypes["DEFAULT"] = "0";
|
|
970
|
+
CreditCardTypes["VISA"] = "1";
|
|
971
|
+
CreditCardTypes["MASTERCARD"] = "2";
|
|
972
|
+
CreditCardTypes["MAESTRO"] = "3";
|
|
973
|
+
CreditCardTypes["AMERICAN_EXPRESS"] = "4";
|
|
974
|
+
CreditCardTypes["DINERS_CLUBS"] = "5";
|
|
975
|
+
CreditCardTypes["DISCOVER"] = "6";
|
|
976
|
+
CreditCardTypes["JCB"] = "9";
|
|
977
|
+
CreditCardTypes["DANKORT"] = "11";
|
|
978
|
+
CreditCardTypes["HIPERCARD"] = "12";
|
|
979
|
+
CreditCardTypes["ELO"] = "13";
|
|
980
|
+
CreditCardTypes["AURA"] = "14";
|
|
981
|
+
CreditCardTypes["NARANJA"] = "15";
|
|
982
|
+
CreditCardTypes["MIR"] = "16";
|
|
983
|
+
CreditCardTypes["CHINA_UNION_PAY"] = "17";
|
|
984
|
+
CreditCardTypes["POSTEPAY"] = "18";
|
|
985
|
+
})(CreditCardTypes || (CreditCardTypes = {}));
|
|
986
|
+
|
|
987
|
+
const visa = {
|
|
988
|
+
id: CreditCardTypes.VISA,
|
|
989
|
+
minLength: 13,
|
|
990
|
+
maxLength: 16,
|
|
991
|
+
iconName: 'visa',
|
|
992
|
+
mask: fourBlockMask,
|
|
993
|
+
checkNumber(number) {
|
|
994
|
+
return number.startsWith('4');
|
|
995
|
+
},
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
const mastercard = {
|
|
999
|
+
id: CreditCardTypes.MASTERCARD,
|
|
1000
|
+
minLength: 16,
|
|
1001
|
+
maxLength: 16,
|
|
1002
|
+
iconName: 'mastercard',
|
|
1003
|
+
mask: fourBlockMask,
|
|
1004
|
+
checkNumber(number) {
|
|
1005
|
+
const subLength = 6;
|
|
1006
|
+
const cardNumberSub = number.substring(0, subLength);
|
|
1007
|
+
return (new RegExp(/^5[1-5]/).test(number) ||
|
|
1008
|
+
(cardNumberSub >= '222100' && cardNumberSub <= '272099'));
|
|
1009
|
+
},
|
|
1010
|
+
};
|
|
1011
|
+
|
|
1012
|
+
const defaultMask = '9999 9999 9999 9999 999';
|
|
1013
|
+
|
|
1014
|
+
const maestro = {
|
|
1015
|
+
id: CreditCardTypes.MAESTRO,
|
|
1016
|
+
minLength: 12,
|
|
1017
|
+
maxLength: 19,
|
|
1018
|
+
iconName: 'maestro',
|
|
1019
|
+
mask: defaultMask,
|
|
1020
|
+
checkNumber(number) {
|
|
1021
|
+
return new RegExp(/^(5018)|^(5020)|^(5038)|^(5893)|^(6304)|^(6759)|^(6761)|^(6762)|^(6763)|^(0604)|^(6706)|^(6771)|^(6709)/).test(number);
|
|
1022
|
+
},
|
|
1023
|
+
maxCvvLength: 3,
|
|
1024
|
+
};
|
|
1025
|
+
|
|
1026
|
+
const americanExpress = {
|
|
1027
|
+
id: CreditCardTypes.AMERICAN_EXPRESS,
|
|
1028
|
+
minLength: 15,
|
|
1029
|
+
maxLength: 15,
|
|
1030
|
+
iconName: 'american-express',
|
|
1031
|
+
mask: '9999 999999 99999',
|
|
1032
|
+
checkNumber(number) {
|
|
1033
|
+
return new RegExp(/^(34)|^(37)/).test(number);
|
|
1034
|
+
},
|
|
1035
|
+
maxCvvLength: 4,
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
const dinersClubs = {
|
|
1039
|
+
id: CreditCardTypes.DINERS_CLUBS,
|
|
1040
|
+
minLength: 14,
|
|
1041
|
+
maxLength: 14,
|
|
1042
|
+
iconName: 'dinersclub',
|
|
1043
|
+
mask: '9999 9999 9999 99',
|
|
1044
|
+
checkNumber(number) {
|
|
1045
|
+
const regex = /^(36[0-9]|3(?:0[0-59]|[68][0-9])[0-9])/;
|
|
1046
|
+
return regex.test(number);
|
|
1047
|
+
},
|
|
1048
|
+
};
|
|
1049
|
+
|
|
1050
|
+
const discover = {
|
|
1051
|
+
id: CreditCardTypes.DISCOVER,
|
|
1052
|
+
minLength: 16,
|
|
1053
|
+
maxLength: 19,
|
|
1054
|
+
iconName: 'discover',
|
|
1055
|
+
mask: defaultMask,
|
|
1056
|
+
checkNumber(number) {
|
|
1057
|
+
return new RegExp(/^(6011)|^(622(1(2[6-9]|[3-9][0-9])|[2-8][0-9]{2}|9([01][0-9]|2[0-5])))|^(64[4-9])|^65/).test(number);
|
|
1058
|
+
},
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
const jcb = {
|
|
1062
|
+
id: CreditCardTypes.JCB,
|
|
1063
|
+
minLength: 15,
|
|
1064
|
+
maxLength: 16,
|
|
1065
|
+
iconName: 'jcb',
|
|
1066
|
+
mask: fourBlockMask,
|
|
1067
|
+
checkNumber(number) {
|
|
1068
|
+
return new RegExp(/^35(2[89]|[3-8][0-9])/).test(number);
|
|
1069
|
+
},
|
|
1070
|
+
};
|
|
1071
|
+
|
|
1072
|
+
const dankort = {
|
|
1073
|
+
id: CreditCardTypes.DANKORT,
|
|
1074
|
+
minLength: 16,
|
|
1075
|
+
maxLength: 16,
|
|
1076
|
+
iconName: 'dankort',
|
|
1077
|
+
mask: fourBlockMask,
|
|
1078
|
+
checkNumber(number) {
|
|
1079
|
+
const subLength = 4;
|
|
1080
|
+
const cardNumberSub = number.substring(0, subLength);
|
|
1081
|
+
return cardNumberSub === '5019';
|
|
1082
|
+
},
|
|
1083
|
+
};
|
|
1084
|
+
|
|
1085
|
+
const hipercard = {
|
|
1086
|
+
id: CreditCardTypes.HIPERCARD,
|
|
1087
|
+
minLength: 13,
|
|
1088
|
+
maxLength: 19,
|
|
1089
|
+
iconName: 'hipercard',
|
|
1090
|
+
mask: defaultMask,
|
|
1091
|
+
checkNumber(number) {
|
|
1092
|
+
return new RegExp(/^((606282|637095|637568)[0-9]|38[0-9]{14,17})/).test(number);
|
|
1093
|
+
},
|
|
1094
|
+
};
|
|
1095
|
+
|
|
1096
|
+
const elo = {
|
|
1097
|
+
id: CreditCardTypes.ELO,
|
|
1098
|
+
minLength: 16,
|
|
1099
|
+
maxLength: 19,
|
|
1100
|
+
iconName: 'elo',
|
|
1101
|
+
mask: defaultMask,
|
|
1102
|
+
checkNumber(number) {
|
|
1103
|
+
return new RegExp(/^(40117[8-9]|431274|438935|451416|457393|45763[1-2]|506(699|7[0-6][0-9]|77[0-8])|509\d{3}|504175|627780|636297|636368|65003[1-3]|6500(3[5-9]|4[0-9]|5[0-1])|6504(0[5-9]|[1-3][0-9])|650(4[8-9][0-9]|5[0-2][0-9]|53[0-8])|6505(4[1-9]|[5-8][0-9]|9[0-8])|6507(0[0-9]|1[0-8])|65072[0-7]|6509(0[1-9]|1[0-9]|20)|6516(5[2-9]|[6-7][0-9])|6550([0-1][0-9]|2[1-9]|[3-4][0-9]|5[0-8]))/).test(number);
|
|
1104
|
+
},
|
|
1105
|
+
};
|
|
1106
|
+
|
|
1107
|
+
const aura = {
|
|
1108
|
+
id: CreditCardTypes.AURA,
|
|
1109
|
+
minLength: 16,
|
|
1110
|
+
maxLength: 19,
|
|
1111
|
+
iconName: 'aura',
|
|
1112
|
+
mask: defaultMask,
|
|
1113
|
+
checkNumber(number) {
|
|
1114
|
+
const subLength = 8;
|
|
1115
|
+
const cardNumberSub = number.substring(0, subLength);
|
|
1116
|
+
return ['50786000', '50786018', '50786019'].includes(cardNumberSub);
|
|
1117
|
+
},
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
const naranja = {
|
|
1121
|
+
id: CreditCardTypes.NARANJA,
|
|
1122
|
+
minLength: 12,
|
|
1123
|
+
maxLength: 19,
|
|
1124
|
+
iconName: 'naranja',
|
|
1125
|
+
mask: defaultMask,
|
|
1126
|
+
checkNumber(number) {
|
|
1127
|
+
const subLength = 6;
|
|
1128
|
+
const cardNumberSub = number.substring(0, subLength);
|
|
1129
|
+
return cardNumberSub === '589562';
|
|
1130
|
+
},
|
|
1131
|
+
};
|
|
1132
|
+
|
|
1133
|
+
const mir = {
|
|
1134
|
+
id: CreditCardTypes.MIR,
|
|
1135
|
+
minLength: 16,
|
|
1136
|
+
maxLength: 16,
|
|
1137
|
+
iconName: 'mir',
|
|
1138
|
+
mask: defaultMask,
|
|
1139
|
+
checkNumber(number) {
|
|
1140
|
+
const subLength = 4;
|
|
1141
|
+
const cardNumberSub = number.substring(0, subLength);
|
|
1142
|
+
return cardNumberSub >= '2200' && cardNumberSub <= '2204';
|
|
1143
|
+
},
|
|
1144
|
+
};
|
|
1145
|
+
|
|
1146
|
+
const chinaUnionPay = {
|
|
1147
|
+
id: CreditCardTypes.CHINA_UNION_PAY,
|
|
1148
|
+
minLength: 16,
|
|
1149
|
+
maxLength: 19,
|
|
1150
|
+
iconName: 'unionpay',
|
|
1151
|
+
mask: '999 9999 9999 99999999',
|
|
1152
|
+
checkNumber(number) {
|
|
1153
|
+
return number.startsWith('62');
|
|
1154
|
+
},
|
|
1155
|
+
};
|
|
1156
|
+
|
|
1157
|
+
const defaultCard = {
|
|
1158
|
+
id: CreditCardTypes.DEFAULT,
|
|
1159
|
+
minLength: 12,
|
|
1160
|
+
maxLength: 19,
|
|
1161
|
+
iconName: null,
|
|
1162
|
+
mask: defaultMask,
|
|
1163
|
+
checkNumber() {
|
|
1164
|
+
return false;
|
|
1165
|
+
},
|
|
1166
|
+
};
|
|
1167
|
+
|
|
1168
|
+
const postePay = {
|
|
1169
|
+
id: CreditCardTypes.POSTEPAY,
|
|
1170
|
+
minLength: 12,
|
|
1171
|
+
maxLength: 19,
|
|
1172
|
+
iconName: 'poste_pay',
|
|
1173
|
+
mask: '9999 9999 9999 9999 999',
|
|
1174
|
+
checkNumber(number) {
|
|
1175
|
+
const regex = /^(5018)|^(5020)|^(5038)|^(5893)|^(6304)|^(6759)|^(6761)|^(6762)|^(6763)|^(0604)|^(6706)|^(6771)|^(6709)/;
|
|
1176
|
+
return regex.test(number);
|
|
1177
|
+
},
|
|
1178
|
+
};
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* order does matter
|
|
1182
|
+
* settings with more specific pattern should be placed above
|
|
1183
|
+
* Example:
|
|
1184
|
+
* - 12*
|
|
1185
|
+
* - 12
|
|
1186
|
+
* - 1
|
|
1187
|
+
* "12*" pattern should be checked first, otherwise pattern "1" will be taken
|
|
1188
|
+
* before "12*" checked
|
|
1189
|
+
*/
|
|
1190
|
+
const orderedCardSettings = [
|
|
1191
|
+
aura,
|
|
1192
|
+
naranja,
|
|
1193
|
+
maestro,
|
|
1194
|
+
postePay,
|
|
1195
|
+
elo,
|
|
1196
|
+
discover,
|
|
1197
|
+
dankort,
|
|
1198
|
+
hipercard,
|
|
1199
|
+
mir,
|
|
1200
|
+
jcb,
|
|
1201
|
+
dinersClubs,
|
|
1202
|
+
americanExpress,
|
|
1203
|
+
mastercard,
|
|
1204
|
+
chinaUnionPay,
|
|
1205
|
+
visa,
|
|
1206
|
+
defaultCard,
|
|
1207
|
+
];
|
|
1208
|
+
|
|
1209
|
+
const creditCardsMap = {
|
|
1210
|
+
[CreditCardTypes.DEFAULT]: defaultCard,
|
|
1211
|
+
[CreditCardTypes.VISA]: visa,
|
|
1212
|
+
[CreditCardTypes.MASTERCARD]: mastercard,
|
|
1213
|
+
[CreditCardTypes.MAESTRO]: maestro,
|
|
1214
|
+
[CreditCardTypes.AMERICAN_EXPRESS]: americanExpress,
|
|
1215
|
+
[CreditCardTypes.DINERS_CLUBS]: dinersClubs,
|
|
1216
|
+
[CreditCardTypes.DISCOVER]: discover,
|
|
1217
|
+
[CreditCardTypes.JCB]: jcb,
|
|
1218
|
+
[CreditCardTypes.DANKORT]: dankort,
|
|
1219
|
+
[CreditCardTypes.HIPERCARD]: hipercard,
|
|
1220
|
+
[CreditCardTypes.ELO]: elo,
|
|
1221
|
+
[CreditCardTypes.AURA]: aura,
|
|
1222
|
+
[CreditCardTypes.NARANJA]: naranja,
|
|
1223
|
+
[CreditCardTypes.MIR]: mir,
|
|
1224
|
+
[CreditCardTypes.CHINA_UNION_PAY]: chinaUnionPay,
|
|
1225
|
+
[CreditCardTypes.POSTEPAY]: postePay,
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1228
|
+
class CreditCardService {
|
|
1229
|
+
getBinNumber(cardNumber) {
|
|
1230
|
+
const binNumberLength = 6;
|
|
1231
|
+
return cardNumber.replace(/\s+/g, '').substring(0, binNumberLength);
|
|
1232
|
+
}
|
|
1233
|
+
getAccountSuffix(cardNumber) {
|
|
1234
|
+
const accountSuffixLength = 4;
|
|
1235
|
+
return cardNumber
|
|
1236
|
+
.replace(/\s+/g, '')
|
|
1237
|
+
.substring(cardNumber.length - accountSuffixLength);
|
|
1238
|
+
}
|
|
1239
|
+
getTypeByNumber(cardNumber) {
|
|
1240
|
+
cardNumber = cardNumber.replace(/\s+/g, '');
|
|
1241
|
+
const cardSettings = orderedCardSettings.find((settings) => {
|
|
1242
|
+
const isNumberMatched = settings.checkNumber(cardNumber);
|
|
1243
|
+
return isNumberMatched ? settings.id : false;
|
|
1244
|
+
});
|
|
1245
|
+
return cardSettings ? cardSettings.id : defaultCard.id;
|
|
1246
|
+
}
|
|
1247
|
+
getCreditCardSettings(cardType) {
|
|
1248
|
+
const creditCard = creditCardsMap[cardType];
|
|
1249
|
+
if (!creditCard) {
|
|
1250
|
+
return defaultCard;
|
|
1251
|
+
}
|
|
1252
|
+
return creditCard;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
CreditCardService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1256
|
+
CreditCardService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardService, providedIn: 'root' });
|
|
1257
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardService, decorators: [{
|
|
1258
|
+
type: Injectable,
|
|
1259
|
+
args: [{
|
|
1260
|
+
providedIn: 'root',
|
|
1261
|
+
}]
|
|
1262
|
+
}] });
|
|
1263
|
+
|
|
1264
|
+
class EncryptCreditCardService {
|
|
1265
|
+
constructor(creditCardService) {
|
|
1266
|
+
this.creditCardService = creditCardService;
|
|
1267
|
+
this.secureFieldNames = [
|
|
1268
|
+
'xps_card_number',
|
|
1269
|
+
'xps_cvv',
|
|
1270
|
+
'xps_extra_cvv',
|
|
1271
|
+
'xps_card_year',
|
|
1272
|
+
'xps_card_month',
|
|
1273
|
+
];
|
|
1274
|
+
this.jsEncrypt = new JSEncrypt();
|
|
1275
|
+
}
|
|
1276
|
+
setPublicKey(publicKey) {
|
|
1277
|
+
this.jsEncrypt.setPublicKey(publicKey);
|
|
1278
|
+
}
|
|
1279
|
+
encryptCreditCard(request) {
|
|
1280
|
+
if (request.xps_card_number) {
|
|
1281
|
+
const openCard = this.createOpenCard(request);
|
|
1282
|
+
request.xps_open_card = JSON.stringify(openCard);
|
|
1283
|
+
}
|
|
1284
|
+
const encryptedCard = this.createEncryptedCard(request);
|
|
1285
|
+
if (!request.xps_encrypted_card && JSON.stringify(encryptedCard) !== '{}') {
|
|
1286
|
+
request.xps_encrypted_card = this.encrypt(JSON.stringify(encryptedCard));
|
|
1287
|
+
}
|
|
1288
|
+
this.secureFieldNames.forEach((secureFieldName) => {
|
|
1289
|
+
delete request[secureFieldName];
|
|
1290
|
+
});
|
|
1291
|
+
return request;
|
|
1292
|
+
}
|
|
1293
|
+
encrypt(value) {
|
|
1294
|
+
if (!this.jsEncrypt?.getPublicKey()) {
|
|
1295
|
+
throw new EncryptCreditCardError('Empty public key');
|
|
1296
|
+
}
|
|
1297
|
+
const encryptedValue = this.jsEncrypt.encrypt(value);
|
|
1298
|
+
if (!encryptedValue) {
|
|
1299
|
+
throw new EncryptCreditCardError('Encryption returns false instead of encrypted string');
|
|
1300
|
+
}
|
|
1301
|
+
return encryptedValue;
|
|
1302
|
+
}
|
|
1303
|
+
createEncryptedCard(request) {
|
|
1304
|
+
const encryptedCard = {
|
|
1305
|
+
card_number: request.xps_card_number,
|
|
1306
|
+
card_year: request.xps_card_year,
|
|
1307
|
+
card_month: request.xps_card_month,
|
|
1308
|
+
cvv: request.xps_cvv,
|
|
1309
|
+
};
|
|
1310
|
+
if (request.xps_extra_cvv) {
|
|
1311
|
+
encryptedCard.cvv = request.xps_extra_cvv;
|
|
1312
|
+
}
|
|
1313
|
+
return encryptedCard;
|
|
1314
|
+
}
|
|
1315
|
+
createOpenCard(request) {
|
|
1316
|
+
return {
|
|
1317
|
+
card_bin: this.creditCardService.getBinNumber(request.xps_card_number),
|
|
1318
|
+
card_suffix: this.creditCardService.getAccountSuffix(request.xps_card_number),
|
|
1319
|
+
card_year: request.xps_card_year,
|
|
1320
|
+
card_month: request.xps_card_month,
|
|
1321
|
+
};
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
EncryptCreditCardService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: EncryptCreditCardService, deps: [{ token: CreditCardService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1325
|
+
EncryptCreditCardService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: EncryptCreditCardService, providedIn: 'root' });
|
|
1326
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: EncryptCreditCardService, decorators: [{
|
|
1327
|
+
type: Injectable,
|
|
1328
|
+
args: [{ providedIn: 'root' }]
|
|
1329
|
+
}], ctorParameters: function () { return [{ type: CreditCardService }]; } });
|
|
1330
|
+
|
|
827
1331
|
class InitializeService {
|
|
828
|
-
constructor(responseFactory,
|
|
1332
|
+
constructor(responseFactory, xpsApiService, settingsService, countryService, nextActionService, encryptCreditCardService) {
|
|
829
1333
|
this.responseFactory = responseFactory;
|
|
830
|
-
this.
|
|
1334
|
+
this.xpsApiService = xpsApiService;
|
|
831
1335
|
this.settingsService = settingsService;
|
|
832
1336
|
this.countryService = countryService;
|
|
833
1337
|
this.nextActionService = nextActionService;
|
|
834
|
-
this.
|
|
1338
|
+
this.encryptCreditCardService = encryptCreditCardService;
|
|
835
1339
|
// TODO PAYMENTS-15743: replace with new refer id for headless core
|
|
836
1340
|
this.ps4ReferId = '22';
|
|
837
1341
|
}
|
|
@@ -843,21 +1347,31 @@ class InitializeService {
|
|
|
843
1347
|
country: this.countryService.getCountry(),
|
|
844
1348
|
returnUrl: config.returnUrl,
|
|
845
1349
|
};
|
|
846
|
-
return
|
|
847
|
-
.
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
if (response.paymentForm?.errors?.length) {
|
|
853
|
-
this.nextActionService.emitFlowUpdates(new ShowErrorsAction(response.paymentForm.errors));
|
|
1350
|
+
return this.xpsApiService
|
|
1351
|
+
.directPaymentRequest(requestParams)
|
|
1352
|
+
.then((response) => {
|
|
1353
|
+
const initializeResponse = this.responseFactory(response);
|
|
1354
|
+
if (initializeResponse.paymentForm?.errors?.length) {
|
|
1355
|
+
this.nextActionService.emitFlowUpdates(new ShowErrorsAction(initializeResponse.paymentForm.errors));
|
|
854
1356
|
}
|
|
855
|
-
|
|
1357
|
+
if (initializeResponse.paymentForm) {
|
|
1358
|
+
this.setCreditCardEncryptKey(initializeResponse.paymentForm);
|
|
1359
|
+
}
|
|
1360
|
+
return initializeResponse;
|
|
1361
|
+
})
|
|
1362
|
+
.catch((error) => {
|
|
856
1363
|
throw new ResponseError(error.message);
|
|
857
1364
|
});
|
|
858
1365
|
}
|
|
1366
|
+
setCreditCardEncryptKey(paymentForm) {
|
|
1367
|
+
const publicKeyField = paymentForm.fields.find((field) => field.name === 'public_key');
|
|
1368
|
+
if (!publicKeyField) {
|
|
1369
|
+
return;
|
|
1370
|
+
}
|
|
1371
|
+
this.encryptCreditCardService.setPublicKey(atob(publicKeyField.value));
|
|
1372
|
+
}
|
|
859
1373
|
}
|
|
860
|
-
InitializeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, deps: [{ token: initializeResponseFactoryToken }, { token:
|
|
1374
|
+
InitializeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, deps: [{ token: initializeResponseFactoryToken }, { token: XpsApiService }, { token: SettingsService }, { token: CountryService }, { token: NextActionService }, { token: EncryptCreditCardService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
861
1375
|
InitializeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, providedIn: 'root' });
|
|
862
1376
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, decorators: [{
|
|
863
1377
|
type: Injectable,
|
|
@@ -867,7 +1381,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
867
1381
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
868
1382
|
type: Inject,
|
|
869
1383
|
args: [initializeResponseFactoryToken]
|
|
870
|
-
}] }, { type:
|
|
1384
|
+
}] }, { type: XpsApiService }, { type: SettingsService }, { type: CountryService }, { type: NextActionService }, { type: EncryptCreditCardService }]; } });
|
|
871
1385
|
|
|
872
1386
|
class XpsApiPartRequest {
|
|
873
1387
|
addXpsParameters(parameters) {
|
|
@@ -917,59 +1431,47 @@ const submitResponseFactoryProvider = {
|
|
|
917
1431
|
useValue: (...args) => new SubmitResponse(...args),
|
|
918
1432
|
};
|
|
919
1433
|
|
|
920
|
-
class TerminalError extends AppError {
|
|
921
|
-
constructor(message, code) {
|
|
922
|
-
super(message);
|
|
923
|
-
this.code = code;
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
class DefaultTerminalError extends TerminalError {
|
|
928
|
-
constructor() {
|
|
929
|
-
const message = `It's not you, it's us, but we can help. Please contact our customer support.`;
|
|
930
|
-
super(message, '1000-0002');
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
|
|
934
1434
|
class DeviceFingerPrintService {
|
|
935
|
-
constructor(
|
|
936
|
-
this.secureApi = secureApi;
|
|
1435
|
+
constructor(settingsService) {
|
|
937
1436
|
this.settingsService = settingsService;
|
|
938
|
-
this.window = window;
|
|
939
|
-
this.apiRoute = 'dfp';
|
|
940
|
-
this.fingerprintApiUrl = 'https://afs.xsolla.com/dfp/api/v1/';
|
|
941
1437
|
}
|
|
942
|
-
|
|
1438
|
+
init() {
|
|
943
1439
|
if (!this.settingsService.isInitialized) {
|
|
944
1440
|
return;
|
|
945
1441
|
}
|
|
946
|
-
this.
|
|
947
|
-
this.hash =
|
|
948
|
-
this.antifraudFingerprintLibrary =
|
|
949
|
-
await this.loadAntifraudFingerprintLibrary();
|
|
1442
|
+
this.antifraudFingerprintLibrary = this.loadAntifraudFingerprintLibrary();
|
|
1443
|
+
this.hash = this.buildHash();
|
|
950
1444
|
}
|
|
951
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
952
1445
|
async getHash() {
|
|
953
1446
|
return this.hash;
|
|
954
1447
|
}
|
|
955
|
-
async loadFingerprintJs() {
|
|
956
|
-
const { default: library, murmurX64Hash128: getHash } = await import('@fingerprintjs/fingerprintjs');
|
|
957
|
-
return { library, getHash };
|
|
958
|
-
}
|
|
959
1448
|
async loadAntifraudFingerprintLibrary() {
|
|
960
1449
|
const library = await import('@xsolla/antifraud-fingerprint');
|
|
961
|
-
return library.
|
|
1450
|
+
return library.AntifraudFingerprint;
|
|
1451
|
+
}
|
|
1452
|
+
async buildHash() {
|
|
1453
|
+
const hash = await this.generate();
|
|
1454
|
+
return JSON.stringify(hash);
|
|
1455
|
+
}
|
|
1456
|
+
async generate() {
|
|
1457
|
+
const fingerprint = await this.makeAntifraudFingerprint();
|
|
1458
|
+
if (!fingerprint) {
|
|
1459
|
+
return null;
|
|
1460
|
+
}
|
|
1461
|
+
await fingerprint.dispatch().catch((err) => console.log(err));
|
|
1462
|
+
const afsHash = await fingerprint.hash();
|
|
1463
|
+
return { '301': afsHash };
|
|
962
1464
|
}
|
|
963
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
964
1465
|
async makeAntifraudFingerprint() {
|
|
965
1466
|
if (!this.settingsService.token) {
|
|
966
1467
|
return null;
|
|
967
1468
|
}
|
|
968
|
-
const antifraudFingerprint = this
|
|
1469
|
+
const antifraudFingerprint = await this
|
|
1470
|
+
.antifraudFingerprintLibrary;
|
|
969
1471
|
try {
|
|
970
1472
|
return new antifraudFingerprint({
|
|
971
1473
|
api: {
|
|
972
|
-
url:
|
|
1474
|
+
url: 'https://afs.xsolla.com/dfp/api/v1/',
|
|
973
1475
|
token: this.settingsService.token,
|
|
974
1476
|
timeout: 3000,
|
|
975
1477
|
},
|
|
@@ -983,127 +1485,31 @@ class DeviceFingerPrintService {
|
|
|
983
1485
|
return null;
|
|
984
1486
|
}
|
|
985
1487
|
}
|
|
986
|
-
/**
|
|
987
|
-
*Загружаем библиотеку, генерируем данные,
|
|
988
|
-
*хешируем с помощью BASE64 и отправляем на бэкенд,
|
|
989
|
-
*в ответ получаем dfp_hash.
|
|
990
|
-
**/
|
|
991
|
-
async buildHash() {
|
|
992
|
-
const fingerPrintData = await this.generate();
|
|
993
|
-
const hash = await this.send(fingerPrintData).catch(() => {
|
|
994
|
-
return null;
|
|
995
|
-
});
|
|
996
|
-
return JSON.stringify(hash);
|
|
997
|
-
}
|
|
998
|
-
/**
|
|
999
|
-
*Новая версия библиотеки содержит не все компоненты, некоторые приходится имплементировать самостоятельно
|
|
1000
|
-
**/
|
|
1001
|
-
getHasLiedResolution() {
|
|
1002
|
-
const { screen } = this.window;
|
|
1003
|
-
return (screen.width < screen.availWidth || screen.height < screen.availHeight);
|
|
1004
|
-
}
|
|
1005
|
-
/**
|
|
1006
|
-
*Бэкенд заточен под конкретные поля, которые необходимо смапить.
|
|
1007
|
-
**/
|
|
1008
|
-
getComponents(components) {
|
|
1009
|
-
return {
|
|
1010
|
-
user_agent: navigator.userAgent,
|
|
1011
|
-
language: components.languages.value?.shift()?.shift() ?? '',
|
|
1012
|
-
color_depth: components.colorDepth.value,
|
|
1013
|
-
device_memory: components.deviceMemory.value,
|
|
1014
|
-
hardware_concurrency: components.hardwareConcurrency.value,
|
|
1015
|
-
resolution: components.screenResolution.value,
|
|
1016
|
-
available_resolution: components.screenResolution.value,
|
|
1017
|
-
timezone_offset: new Date().getTimezoneOffset(),
|
|
1018
|
-
session_storage: components.sessionStorage.value ? 1 : 0,
|
|
1019
|
-
local_storage: components.localStorage.value ? 1 : 0,
|
|
1020
|
-
indexed_db: components.indexedDB.value ? 1 : 0,
|
|
1021
|
-
open_database: components.openDatabase.value ? 1 : 0,
|
|
1022
|
-
navigator_platform: components.platform.value,
|
|
1023
|
-
regular_plugins: components.plugins.value?.map((plugin) => plugin.name) ?? [],
|
|
1024
|
-
canvas: components.canvas.value?.text,
|
|
1025
|
-
webgl: components.canvas.value?.text,
|
|
1026
|
-
webgl_vendor: components.vendor.value,
|
|
1027
|
-
has_lied_resolution: this.getHasLiedResolution(),
|
|
1028
|
-
touch_support: Object.values(components.touchSupport.value ?? {}),
|
|
1029
|
-
js_fonts: components.fonts.value,
|
|
1030
|
-
};
|
|
1031
|
-
}
|
|
1032
|
-
/**
|
|
1033
|
-
* Получаем данные dfp с помощью FingerprintJS, мапим необходимые поля, добавляем хэш
|
|
1034
|
-
**/
|
|
1035
|
-
async generate() {
|
|
1036
|
-
const { library, getHash } = this.fingerprintJs;
|
|
1037
|
-
const fingerprint = await library.load();
|
|
1038
|
-
const commonFingerPrintData = await fingerprint.get();
|
|
1039
|
-
const fingerPrintData = this.getComponents(commonFingerPrintData.components);
|
|
1040
|
-
fingerPrintData.hash = getHash(JSON.stringify(fingerPrintData));
|
|
1041
|
-
return fingerPrintData;
|
|
1042
|
-
}
|
|
1043
|
-
/**
|
|
1044
|
-
* Отправка dfp на сервер, в ответ получаем dfp_hash
|
|
1045
|
-
**/
|
|
1046
|
-
async send(fingerPrintData) {
|
|
1047
|
-
const token = this.settingsService.token;
|
|
1048
|
-
if (token === null) {
|
|
1049
|
-
throw new DefaultTerminalError();
|
|
1050
|
-
}
|
|
1051
|
-
const requestBody = {
|
|
1052
|
-
access_token: token,
|
|
1053
|
-
'dfp[200]': '',
|
|
1054
|
-
};
|
|
1055
|
-
requestBody['dfp[200]'] = btoa(encodeURIComponent(JSON.stringify(fingerPrintData)));
|
|
1056
|
-
return lastValueFrom(this.secureApi.post(this.apiRoute, new URLSearchParams(requestBody), {
|
|
1057
|
-
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
1058
|
-
responseType: 'json',
|
|
1059
|
-
}))
|
|
1060
|
-
.then((response) => {
|
|
1061
|
-
return response.dfp_hash;
|
|
1062
|
-
})
|
|
1063
|
-
.then(async (hash) => {
|
|
1064
|
-
const fingerprint = await this.makeAntifraudFingerprint();
|
|
1065
|
-
if (!fingerprint) {
|
|
1066
|
-
return null;
|
|
1067
|
-
}
|
|
1068
|
-
await fingerprint
|
|
1069
|
-
?.dispatch(hash['200'])
|
|
1070
|
-
.catch((err) => console.log(err));
|
|
1071
|
-
const afsHash = await fingerprint.hash();
|
|
1072
|
-
return { '301': afsHash, ...hash };
|
|
1073
|
-
})
|
|
1074
|
-
.catch((error) => {
|
|
1075
|
-
const response = error.getHttpErrorData().response;
|
|
1076
|
-
throw new TerminalError(response.data?.errors[0]?.message ?? '', response.data?.errors[0]?.support_code ?? '');
|
|
1077
|
-
});
|
|
1078
|
-
}
|
|
1079
1488
|
}
|
|
1080
|
-
DeviceFingerPrintService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DeviceFingerPrintService, deps: [{ token:
|
|
1489
|
+
DeviceFingerPrintService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DeviceFingerPrintService, deps: [{ token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1081
1490
|
DeviceFingerPrintService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DeviceFingerPrintService, providedIn: 'root' });
|
|
1082
1491
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DeviceFingerPrintService, decorators: [{
|
|
1083
1492
|
type: Injectable,
|
|
1084
1493
|
args: [{
|
|
1085
1494
|
providedIn: 'root',
|
|
1086
1495
|
}]
|
|
1087
|
-
}], ctorParameters: function () { return [{ type:
|
|
1088
|
-
type: Inject,
|
|
1089
|
-
args: [windowToken]
|
|
1090
|
-
}] }]; } });
|
|
1496
|
+
}], ctorParameters: function () { return [{ type: SettingsService }]; } });
|
|
1091
1497
|
|
|
1092
1498
|
class SubmitService {
|
|
1093
|
-
constructor(requestFactory, responseFactory, settingsService, deviceFingerPrintService,
|
|
1499
|
+
constructor(requestFactory, responseFactory, settingsService, deviceFingerPrintService, xpsApiService, encryptCreditCardService) {
|
|
1094
1500
|
this.requestFactory = requestFactory;
|
|
1095
1501
|
this.responseFactory = responseFactory;
|
|
1096
1502
|
this.settingsService = settingsService;
|
|
1097
1503
|
this.deviceFingerPrintService = deviceFingerPrintService;
|
|
1098
|
-
this.
|
|
1099
|
-
this.
|
|
1504
|
+
this.xpsApiService = xpsApiService;
|
|
1505
|
+
this.encryptCreditCardService = encryptCreditCardService;
|
|
1100
1506
|
}
|
|
1101
1507
|
// NB: Never add 'async' statement for this method!
|
|
1102
1508
|
// 'Async' statement wraps current promise into another.
|
|
1103
1509
|
// In this way two promises become unequal, that can broke XPS API requests logic.
|
|
1104
1510
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1105
1511
|
request(fields, form) {
|
|
1106
|
-
|
|
1512
|
+
return (this.deviceFingerPrintService
|
|
1107
1513
|
.getHash()
|
|
1108
1514
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
1109
1515
|
.then((dfpHash) => {
|
|
@@ -1113,19 +1519,17 @@ class SubmitService {
|
|
|
1113
1519
|
form,
|
|
1114
1520
|
dfpHash,
|
|
1115
1521
|
});
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
}))
|
|
1522
|
+
const encryptedRequest = this.encryptCreditCardService.encryptCreditCard(requestParams);
|
|
1523
|
+
return this.xpsApiService
|
|
1524
|
+
.directPaymentRequest(encryptedRequest)
|
|
1120
1525
|
.then((response) => this.responseFactory(response))
|
|
1121
1526
|
.catch((error) => {
|
|
1122
1527
|
throw new ResponseError(error.message);
|
|
1123
1528
|
});
|
|
1124
|
-
});
|
|
1125
|
-
return responsePromise;
|
|
1529
|
+
}));
|
|
1126
1530
|
}
|
|
1127
1531
|
}
|
|
1128
|
-
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:
|
|
1532
|
+
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: XpsApiService }, { token: EncryptCreditCardService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1129
1533
|
SubmitService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SubmitService, providedIn: 'root' });
|
|
1130
1534
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SubmitService, decorators: [{
|
|
1131
1535
|
type: Injectable,
|
|
@@ -1136,7 +1540,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
1136
1540
|
}] }, { type: undefined, decorators: [{
|
|
1137
1541
|
type: Inject,
|
|
1138
1542
|
args: [submitResponseFactoryToken]
|
|
1139
|
-
}] }, { type: SettingsService }, { type: DeviceFingerPrintService }, { type:
|
|
1543
|
+
}] }, { type: SettingsService }, { type: DeviceFingerPrintService }, { type: XpsApiService }, { type: EncryptCreditCardService }]; } });
|
|
1140
1544
|
|
|
1141
1545
|
class EmitDataService {
|
|
1142
1546
|
constructor() {
|
|
@@ -1148,16 +1552,8 @@ class EmitDataService {
|
|
|
1148
1552
|
}
|
|
1149
1553
|
}
|
|
1150
1554
|
|
|
1151
|
-
class XpsRequest {
|
|
1152
|
-
addXpsParameters(parameters) {
|
|
1153
|
-
for (const key in parameters) {
|
|
1154
|
-
this[`xps_${key}`] = parameters[key];
|
|
1155
|
-
}
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
|
|
1159
1555
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
1160
|
-
class SyncRequest extends
|
|
1556
|
+
class SyncRequest extends XpsApiPartRequest {
|
|
1161
1557
|
constructor(parameters) {
|
|
1162
1558
|
super();
|
|
1163
1559
|
this.xps_fix_command = 'calculate';
|
|
@@ -1216,17 +1612,21 @@ const syncResponseFactoryProvider = {
|
|
|
1216
1612
|
};
|
|
1217
1613
|
|
|
1218
1614
|
class SyncService extends EmitDataService {
|
|
1219
|
-
constructor(requestFactory, responseFactory,
|
|
1615
|
+
constructor(requestFactory, responseFactory, xpsApiService, nextActionService, settingsService, encryptCreditCardService) {
|
|
1220
1616
|
super();
|
|
1221
1617
|
this.requestFactory = requestFactory;
|
|
1222
1618
|
this.responseFactory = responseFactory;
|
|
1223
|
-
this.
|
|
1619
|
+
this.xpsApiService = xpsApiService;
|
|
1224
1620
|
this.nextActionService = nextActionService;
|
|
1225
1621
|
this.settingsService = settingsService;
|
|
1226
|
-
this.
|
|
1622
|
+
this.encryptCreditCardService = encryptCreditCardService;
|
|
1227
1623
|
this.prevFieldSyncStates = {};
|
|
1228
1624
|
this.form = new UntypedFormGroup({});
|
|
1229
1625
|
this.fields = [];
|
|
1626
|
+
this.fieldAsyncValidation = new Subject();
|
|
1627
|
+
}
|
|
1628
|
+
get fieldAsyncValidation$() {
|
|
1629
|
+
return this.fieldAsyncValidation.asObservable();
|
|
1230
1630
|
}
|
|
1231
1631
|
setup(form, fields) {
|
|
1232
1632
|
this.reset();
|
|
@@ -1257,6 +1657,11 @@ class SyncService extends EmitDataService {
|
|
|
1257
1657
|
const requestPromise = this.request(field);
|
|
1258
1658
|
this.setPrevFieldSyncState(field, value, requestPromise);
|
|
1259
1659
|
return requestPromise.then((response) => {
|
|
1660
|
+
this.fieldAsyncValidation.next({
|
|
1661
|
+
value,
|
|
1662
|
+
field,
|
|
1663
|
+
response,
|
|
1664
|
+
});
|
|
1260
1665
|
return response.error ?? null;
|
|
1261
1666
|
});
|
|
1262
1667
|
}
|
|
@@ -1271,10 +1676,10 @@ class SyncService extends EmitDataService {
|
|
|
1271
1676
|
fields: this.fields,
|
|
1272
1677
|
form: this.form,
|
|
1273
1678
|
});
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1679
|
+
const encryptedRequest = this.encryptCreditCardService.encryptCreditCard(requestParams);
|
|
1680
|
+
return this.xpsApiService
|
|
1681
|
+
.directPaymentRequest(encryptedRequest)
|
|
1682
|
+
.then((response) => {
|
|
1278
1683
|
if (response.errors?.length) {
|
|
1279
1684
|
this.nextActionService.emitFlowUpdates(new ShowErrorsAction(response.errors));
|
|
1280
1685
|
}
|
|
@@ -1294,7 +1699,7 @@ class SyncService extends EmitDataService {
|
|
|
1294
1699
|
this.prevFieldSyncStates[field.name] = { value, result };
|
|
1295
1700
|
}
|
|
1296
1701
|
}
|
|
1297
|
-
SyncService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, deps: [{ token: syncRequestFactoryToken }, { token: syncResponseFactoryToken }, { token:
|
|
1702
|
+
SyncService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, deps: [{ token: syncRequestFactoryToken }, { token: syncResponseFactoryToken }, { token: XpsApiService }, { token: NextActionService }, { token: SettingsService }, { token: EncryptCreditCardService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1298
1703
|
SyncService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, providedIn: 'root' });
|
|
1299
1704
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SyncService, decorators: [{
|
|
1300
1705
|
type: Injectable,
|
|
@@ -1307,7 +1712,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
1307
1712
|
}] }, { type: undefined, decorators: [{
|
|
1308
1713
|
type: Inject,
|
|
1309
1714
|
args: [syncResponseFactoryToken]
|
|
1310
|
-
}] }, { type:
|
|
1715
|
+
}] }, { type: XpsApiService }, { type: NextActionService }, { type: SettingsService }, { type: EncryptCreditCardService }]; } });
|
|
1311
1716
|
|
|
1312
1717
|
class ControlConfig {
|
|
1313
1718
|
constructor() {
|
|
@@ -1473,41 +1878,470 @@ class ZipConverter extends Converter {
|
|
|
1473
1878
|
return validators;
|
|
1474
1879
|
}
|
|
1475
1880
|
createControlConfig(field) {
|
|
1476
|
-
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
1477
|
-
config.icon = 'location';
|
|
1478
|
-
if (this.isUsCountry) {
|
|
1479
|
-
config.maskConfig = {
|
|
1480
|
-
guide: false,
|
|
1481
|
-
unmaskModelValue: true,
|
|
1482
|
-
showMask: true,
|
|
1483
|
-
};
|
|
1484
|
-
config.inputMode = 'numeric';
|
|
1485
|
-
if (masksFunctionsMap['zip']) {
|
|
1486
|
-
config.maskConfig.mask = masksFunctionsMap['zip'];
|
|
1487
|
-
}
|
|
1488
|
-
}
|
|
1489
|
-
else {
|
|
1490
|
-
config.maxLength = this.maxLength;
|
|
1491
|
-
}
|
|
1881
|
+
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
1882
|
+
config.icon = 'location';
|
|
1883
|
+
if (this.isUsCountry) {
|
|
1884
|
+
config.maskConfig = {
|
|
1885
|
+
guide: false,
|
|
1886
|
+
unmaskModelValue: true,
|
|
1887
|
+
showMask: true,
|
|
1888
|
+
};
|
|
1889
|
+
config.inputMode = 'numeric';
|
|
1890
|
+
if (masksFunctionsMap['zip']) {
|
|
1891
|
+
config.maskConfig.mask = masksFunctionsMap['zip'];
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
else {
|
|
1895
|
+
config.maxLength = this.maxLength;
|
|
1896
|
+
}
|
|
1897
|
+
return config;
|
|
1898
|
+
}
|
|
1899
|
+
getAutocomplete() {
|
|
1900
|
+
return 'postal-code';
|
|
1901
|
+
}
|
|
1902
|
+
getDataType() {
|
|
1903
|
+
return 'text';
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
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 });
|
|
1907
|
+
ZipConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ZipConverter });
|
|
1908
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ZipConverter, decorators: [{
|
|
1909
|
+
type: Injectable
|
|
1910
|
+
}], ctorParameters: function () { return [{ type: SyncService }, { type: CountryService }]; } });
|
|
1911
|
+
|
|
1912
|
+
function isEmptyInputValue(value) {
|
|
1913
|
+
return value == null || value.length === 0;
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
function isString(value) {
|
|
1917
|
+
return typeof value === 'string';
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
/**
|
|
1921
|
+
* Checks number match Luhn algorithm.
|
|
1922
|
+
* Based on http://en.wikipedia.org/wiki/Luhn.
|
|
1923
|
+
*/
|
|
1924
|
+
const luhnFormulaValidator = ({ value }) => {
|
|
1925
|
+
if (isEmptyInputValue(value) || !isString(value)) {
|
|
1926
|
+
return null;
|
|
1927
|
+
}
|
|
1928
|
+
const error = {
|
|
1929
|
+
rewritableError: {
|
|
1930
|
+
message: `Enter a valid card number`,
|
|
1931
|
+
},
|
|
1932
|
+
};
|
|
1933
|
+
if (/[^0-9 -]+/.test(value)) {
|
|
1934
|
+
// accept only spaces, digits and dashes
|
|
1935
|
+
return error;
|
|
1936
|
+
}
|
|
1937
|
+
let resultSum = 0;
|
|
1938
|
+
let digit = 0;
|
|
1939
|
+
let isEven = false;
|
|
1940
|
+
const modBase = 10;
|
|
1941
|
+
const digitRadix = 10;
|
|
1942
|
+
const maxNumber = 9;
|
|
1943
|
+
const digits = value.replace(/\D/g, '');
|
|
1944
|
+
// Checks if number match Luhn algorithm
|
|
1945
|
+
// based on http://en.wikipedia.org/wiki/Luhn
|
|
1946
|
+
for (let index = digits.length - 1; index >= 0; index--) {
|
|
1947
|
+
const char = digits.charAt(index);
|
|
1948
|
+
digit = parseInt(char, digitRadix);
|
|
1949
|
+
if (isEven && (digit *= 2) > maxNumber) {
|
|
1950
|
+
digit -= maxNumber;
|
|
1951
|
+
}
|
|
1952
|
+
resultSum += digit;
|
|
1953
|
+
isEven = !isEven;
|
|
1954
|
+
}
|
|
1955
|
+
return resultSum % modBase === 0 ? null : error;
|
|
1956
|
+
};
|
|
1957
|
+
|
|
1958
|
+
class CardNumberConfig extends ControlConfig {
|
|
1959
|
+
constructor() {
|
|
1960
|
+
super(...arguments);
|
|
1961
|
+
this.controlType = 'card-number';
|
|
1962
|
+
this.availableCardTypes = [];
|
|
1963
|
+
this.customError = '';
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
class CreditCardMinLengthValidator {
|
|
1968
|
+
constructor(creditService) {
|
|
1969
|
+
this.creditService = creditService;
|
|
1970
|
+
this.validate = (field) => {
|
|
1971
|
+
if (isEmptyInputValue(field.value) || !isString(field.value)) {
|
|
1972
|
+
return null;
|
|
1973
|
+
}
|
|
1974
|
+
const length = field.value.length;
|
|
1975
|
+
const cardType = this.creditService.getTypeByNumber(field.value);
|
|
1976
|
+
const { minLength } = this.creditService.getCreditCardSettings(cardType);
|
|
1977
|
+
return length < minLength
|
|
1978
|
+
? {
|
|
1979
|
+
rewritableError: {
|
|
1980
|
+
message: `Enter at least ${minLength} characters`,
|
|
1981
|
+
number: minLength,
|
|
1982
|
+
},
|
|
1983
|
+
}
|
|
1984
|
+
: null;
|
|
1985
|
+
};
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
CreditCardMinLengthValidator.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardMinLengthValidator, deps: [{ token: CreditCardService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1989
|
+
CreditCardMinLengthValidator.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardMinLengthValidator });
|
|
1990
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardMinLengthValidator, decorators: [{
|
|
1991
|
+
type: Injectable
|
|
1992
|
+
}], ctorParameters: function () { return [{ type: CreditCardService }]; } });
|
|
1993
|
+
|
|
1994
|
+
class CardNumberConverter extends Converter {
|
|
1995
|
+
constructor(syncService, maxLengthValidator, minLengthValidator) {
|
|
1996
|
+
super(syncService);
|
|
1997
|
+
this.maxLengthValidator = maxLengthValidator;
|
|
1998
|
+
this.minLengthValidator = minLengthValidator;
|
|
1999
|
+
}
|
|
2000
|
+
getValidators(field) {
|
|
2001
|
+
return super
|
|
2002
|
+
.getValidators(field)
|
|
2003
|
+
.concat([
|
|
2004
|
+
luhnFormulaValidator,
|
|
2005
|
+
this.minLengthValidator.validate,
|
|
2006
|
+
this.maxLengthValidator.validate,
|
|
2007
|
+
]);
|
|
2008
|
+
}
|
|
2009
|
+
createControlConfig(field, formState) {
|
|
2010
|
+
const config = this.createDefaultControlConfig(CardNumberConfig, field);
|
|
2011
|
+
config.placeholder = config.title;
|
|
2012
|
+
config.availableCardTypes =
|
|
2013
|
+
formState?.availableCardTypes ?? [];
|
|
2014
|
+
config.activeCardType = formState?.activeCardType;
|
|
2015
|
+
config.customError = formState?.customError;
|
|
2016
|
+
config.disabled = formState?.disabled ?? false;
|
|
2017
|
+
return config;
|
|
2018
|
+
}
|
|
2019
|
+
getAutocomplete() {
|
|
2020
|
+
return 'cc-number';
|
|
2021
|
+
}
|
|
2022
|
+
getDataType() {
|
|
2023
|
+
return 'text';
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
CardNumberConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardNumberConverter, deps: [{ token: SyncService }, { token: CreditCardMinLengthValidator }, { token: CreditCardMinLengthValidator }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2027
|
+
CardNumberConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardNumberConverter });
|
|
2028
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardNumberConverter, decorators: [{
|
|
2029
|
+
type: Injectable
|
|
2030
|
+
}], ctorParameters: function () { return [{ type: SyncService }, { type: CreditCardMinLengthValidator }, { type: CreditCardMinLengthValidator }]; } });
|
|
2031
|
+
|
|
2032
|
+
class CardExpirationConverter extends Converter {
|
|
2033
|
+
constructor(syncService) {
|
|
2034
|
+
super(syncService);
|
|
2035
|
+
}
|
|
2036
|
+
getValidators() {
|
|
2037
|
+
return [];
|
|
2038
|
+
}
|
|
2039
|
+
createControlConfig(field, formState) {
|
|
2040
|
+
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
2041
|
+
config.maskConfig = {
|
|
2042
|
+
mask: '99',
|
|
2043
|
+
guide: false,
|
|
2044
|
+
};
|
|
2045
|
+
config.inputMode = 'numeric';
|
|
2046
|
+
config.title = 'date';
|
|
2047
|
+
config.disabled = formState?.disabled ?? false;
|
|
2048
|
+
return config;
|
|
2049
|
+
}
|
|
2050
|
+
getAutocomplete() {
|
|
2051
|
+
return 'cc-exp';
|
|
2052
|
+
}
|
|
2053
|
+
getDataType() {
|
|
2054
|
+
return 'text';
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
CardExpirationConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardExpirationConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2058
|
+
CardExpirationConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardExpirationConverter });
|
|
2059
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardExpirationConverter, decorators: [{
|
|
2060
|
+
type: Injectable
|
|
2061
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2062
|
+
|
|
2063
|
+
class CvvConverter extends Converter {
|
|
2064
|
+
constructor(syncService) {
|
|
2065
|
+
super(syncService);
|
|
2066
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
2067
|
+
this.maxFieldLength = 4;
|
|
2068
|
+
}
|
|
2069
|
+
getValidators() {
|
|
2070
|
+
return [];
|
|
2071
|
+
}
|
|
2072
|
+
createControlConfig(field, formState) {
|
|
2073
|
+
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
2074
|
+
config.maskConfig = {
|
|
2075
|
+
mask: () => new Array(this.maxFieldLength).fill('9').join(''),
|
|
2076
|
+
unmaskModelValue: false,
|
|
2077
|
+
guide: false,
|
|
2078
|
+
};
|
|
2079
|
+
config.tooltip = {
|
|
2080
|
+
text: 'The code is on the back of your card',
|
|
2081
|
+
image: 'cvv',
|
|
2082
|
+
parentField: FieldNames.cvv,
|
|
2083
|
+
position: 'input',
|
|
2084
|
+
analyticsAction: 'show-cvv-tooltip',
|
|
2085
|
+
};
|
|
2086
|
+
config.inputMode = 'numeric';
|
|
2087
|
+
config.shouldHideUserInput = this.shouldHideUserInput();
|
|
2088
|
+
config.disabled = formState?.disabled ?? false;
|
|
2089
|
+
return config;
|
|
2090
|
+
}
|
|
2091
|
+
getAutocomplete() {
|
|
2092
|
+
return 'cc-csc';
|
|
2093
|
+
}
|
|
2094
|
+
getDataType() {
|
|
2095
|
+
return 'password';
|
|
2096
|
+
}
|
|
2097
|
+
shouldHideUserInput() {
|
|
2098
|
+
return true;
|
|
2099
|
+
}
|
|
2100
|
+
}
|
|
2101
|
+
CvvConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CvvConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2102
|
+
CvvConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CvvConverter });
|
|
2103
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CvvConverter, decorators: [{
|
|
2104
|
+
type: Injectable
|
|
2105
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2106
|
+
|
|
2107
|
+
const birthdateValidator = ({ value }) => {
|
|
2108
|
+
if (isEmptyInputValue(value) || typeof value !== 'string') {
|
|
2109
|
+
return null;
|
|
2110
|
+
}
|
|
2111
|
+
const error = {
|
|
2112
|
+
invalidBirthDate: {
|
|
2113
|
+
message: `Enter a valid birth date`,
|
|
2114
|
+
},
|
|
2115
|
+
};
|
|
2116
|
+
const dateArr = value.split('/');
|
|
2117
|
+
const datePartsCount = 3;
|
|
2118
|
+
const dayIndex = 0;
|
|
2119
|
+
const monthIndex = 1;
|
|
2120
|
+
const yearIndex = 2;
|
|
2121
|
+
const maxMonths = 12;
|
|
2122
|
+
const maxDays = 31;
|
|
2123
|
+
const minAge = 16;
|
|
2124
|
+
const maxAge = 120;
|
|
2125
|
+
if (dateArr.length < datePartsCount) {
|
|
2126
|
+
return null;
|
|
2127
|
+
}
|
|
2128
|
+
if (+dateArr[monthIndex] > maxMonths || +dateArr[dayIndex] > maxDays) {
|
|
2129
|
+
return error;
|
|
2130
|
+
}
|
|
2131
|
+
const currentDate = new Date(+dateArr[yearIndex], +dateArr[monthIndex], +dateArr[dayIndex]);
|
|
2132
|
+
const nowDate = new Date();
|
|
2133
|
+
if (isNaN(currentDate.getFullYear()) ||
|
|
2134
|
+
nowDate.getFullYear() - currentDate.getFullYear() <= minAge ||
|
|
2135
|
+
nowDate.getFullYear() - currentDate.getFullYear() > maxAge) {
|
|
2136
|
+
return error;
|
|
2137
|
+
}
|
|
2138
|
+
else {
|
|
2139
|
+
return null;
|
|
2140
|
+
}
|
|
2141
|
+
};
|
|
2142
|
+
|
|
2143
|
+
class BirthDateConverter extends Converter {
|
|
2144
|
+
constructor(syncService) {
|
|
2145
|
+
super(syncService);
|
|
2146
|
+
}
|
|
2147
|
+
getValidators(field) {
|
|
2148
|
+
return super
|
|
2149
|
+
.getValidators(field)
|
|
2150
|
+
.concat([
|
|
2151
|
+
convert(Validators.pattern(/^[0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}$/), `Enter a valid birth date`),
|
|
2152
|
+
birthdateValidator,
|
|
2153
|
+
]);
|
|
2154
|
+
}
|
|
2155
|
+
createControlConfig(field) {
|
|
2156
|
+
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
2157
|
+
config.maskConfig = {
|
|
2158
|
+
mask: '99/99/9999',
|
|
2159
|
+
unmaskModelValue: false,
|
|
2160
|
+
guide: false,
|
|
2161
|
+
};
|
|
2162
|
+
config.placeholder = `DD/MM/YYYY`;
|
|
2163
|
+
config.inputMode = 'numeric';
|
|
2164
|
+
return config;
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
BirthDateConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BirthDateConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2168
|
+
BirthDateConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BirthDateConverter });
|
|
2169
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: BirthDateConverter, decorators: [{
|
|
2170
|
+
type: Injectable
|
|
2171
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2172
|
+
|
|
2173
|
+
class CardholderNameConverter extends Converter {
|
|
2174
|
+
constructor(syncService) {
|
|
2175
|
+
super(syncService);
|
|
2176
|
+
}
|
|
2177
|
+
createControlConfig(field) {
|
|
2178
|
+
return this.createDefaultControlConfig(TextControlConfig, field);
|
|
2179
|
+
}
|
|
2180
|
+
getAutocomplete() {
|
|
2181
|
+
return 'cc-name';
|
|
2182
|
+
}
|
|
2183
|
+
getDataType() {
|
|
2184
|
+
return 'text';
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
CardholderNameConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardholderNameConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2188
|
+
CardholderNameConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardholderNameConverter });
|
|
2189
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CardholderNameConverter, decorators: [{
|
|
2190
|
+
type: Injectable
|
|
2191
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2192
|
+
|
|
2193
|
+
const cpfNameRegex = /^[a-zA-ZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ.'-]{2,50}(?: [a-zA-ZÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ.'-]{2,50}){1,8}$/i; // tslint:disable-line
|
|
2194
|
+
|
|
2195
|
+
class CpfNameConverter extends Converter {
|
|
2196
|
+
constructor(syncService) {
|
|
2197
|
+
super(syncService);
|
|
2198
|
+
}
|
|
2199
|
+
getValidators(field) {
|
|
2200
|
+
return super
|
|
2201
|
+
.getValidators(field)
|
|
2202
|
+
.concat([
|
|
2203
|
+
convert(Validators.pattern(cpfNameRegex), `Enter a valid name`),
|
|
2204
|
+
]);
|
|
2205
|
+
}
|
|
2206
|
+
createControlConfig(field) {
|
|
2207
|
+
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
2208
|
+
config.tooltip = {
|
|
2209
|
+
text: `Where to find your name`,
|
|
2210
|
+
image: 'cpf-name',
|
|
2211
|
+
};
|
|
2212
|
+
return config;
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
CpfNameConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CpfNameConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2216
|
+
CpfNameConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CpfNameConverter });
|
|
2217
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CpfNameConverter, decorators: [{
|
|
2218
|
+
type: Injectable
|
|
2219
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2220
|
+
|
|
2221
|
+
class CpfNumberConverter extends Converter {
|
|
2222
|
+
constructor(syncService) {
|
|
2223
|
+
super(syncService);
|
|
2224
|
+
}
|
|
2225
|
+
createControlConfig(field) {
|
|
2226
|
+
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
2227
|
+
config.maskConfig = {
|
|
2228
|
+
mask: '999.999.999-99',
|
|
2229
|
+
unmaskModelValue: true,
|
|
2230
|
+
guide: false,
|
|
2231
|
+
};
|
|
2232
|
+
config.inputMode = 'numeric';
|
|
2233
|
+
config.placeholder = '000.000.000-00';
|
|
2234
|
+
config.tooltip = {
|
|
2235
|
+
text: `Where to find your registration number`,
|
|
2236
|
+
image: 'cpf-number',
|
|
2237
|
+
};
|
|
2238
|
+
return config;
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
CpfNumberConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CpfNumberConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2242
|
+
CpfNumberConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CpfNumberConverter });
|
|
2243
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CpfNumberConverter, decorators: [{
|
|
2244
|
+
type: Injectable
|
|
2245
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2246
|
+
|
|
2247
|
+
class StreetNumberConverter extends Converter {
|
|
2248
|
+
constructor(syncService) {
|
|
2249
|
+
super(syncService);
|
|
2250
|
+
}
|
|
2251
|
+
getValidators(field, formState) {
|
|
2252
|
+
const validators = super.getValidators(field);
|
|
2253
|
+
if (formState?.country === 'BL') {
|
|
2254
|
+
validators.push(convert(restrictedValueValidator('0'), `Enter a valid building number`));
|
|
2255
|
+
}
|
|
2256
|
+
return validators;
|
|
2257
|
+
}
|
|
2258
|
+
createControlConfig(field) {
|
|
2259
|
+
return this.createDefaultControlConfig(TextControlConfig, field);
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
StreetNumberConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StreetNumberConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2263
|
+
StreetNumberConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StreetNumberConverter });
|
|
2264
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StreetNumberConverter, decorators: [{
|
|
2265
|
+
type: Injectable
|
|
2266
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2267
|
+
|
|
2268
|
+
class TextConverter extends Converter {
|
|
2269
|
+
constructor(syncService) {
|
|
2270
|
+
super(syncService);
|
|
2271
|
+
}
|
|
2272
|
+
createControlConfig(field) {
|
|
2273
|
+
return this.createDefaultControlConfig(TextControlConfig, field);
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
TextConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: TextConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2277
|
+
TextConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: TextConverter });
|
|
2278
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: TextConverter, decorators: [{
|
|
2279
|
+
type: Injectable
|
|
2280
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2281
|
+
|
|
2282
|
+
function phoneValidator() {
|
|
2283
|
+
return convert(Validators.pattern(/^\d*$/), 'Enter a valid phone');
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
function minLengthValidator(minLength) {
|
|
2287
|
+
return convert(Validators.minLength(minLength), `Enter at least ${minLength} characters`);
|
|
2288
|
+
}
|
|
2289
|
+
|
|
2290
|
+
function maxLengthValidator(maxLength) {
|
|
2291
|
+
return convert(Validators.maxLength(maxLength), `Enter no more than ${maxLength} characters`);
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
class PhoneControlConfig extends ControlConfig {
|
|
2295
|
+
constructor() {
|
|
2296
|
+
super(...arguments);
|
|
2297
|
+
this.controlType = 'phone';
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
|
|
2301
|
+
class PhoneConverter extends Converter {
|
|
2302
|
+
constructor(syncService) {
|
|
2303
|
+
super(syncService);
|
|
2304
|
+
}
|
|
2305
|
+
getValidators(field) {
|
|
2306
|
+
const minLength = 10;
|
|
2307
|
+
const maxLength = 15;
|
|
2308
|
+
return super
|
|
2309
|
+
.getValidators(field)
|
|
2310
|
+
.concat([
|
|
2311
|
+
convertedRequiredValidator(),
|
|
2312
|
+
phoneValidator(),
|
|
2313
|
+
minLengthValidator(minLength),
|
|
2314
|
+
maxLengthValidator(maxLength),
|
|
2315
|
+
]);
|
|
2316
|
+
}
|
|
2317
|
+
createControlConfig(field) {
|
|
2318
|
+
const config = this.createDefaultControlConfig(PhoneControlConfig, field);
|
|
2319
|
+
config.inputMode = 'numeric';
|
|
1492
2320
|
return config;
|
|
1493
2321
|
}
|
|
1494
|
-
getAutocomplete() {
|
|
1495
|
-
return 'postal-code';
|
|
1496
|
-
}
|
|
1497
|
-
getDataType() {
|
|
1498
|
-
return 'text';
|
|
1499
|
-
}
|
|
1500
2322
|
}
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type:
|
|
2323
|
+
PhoneConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PhoneConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2324
|
+
PhoneConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PhoneConverter });
|
|
2325
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PhoneConverter, decorators: [{
|
|
1504
2326
|
type: Injectable
|
|
1505
|
-
}], ctorParameters: function () { return [{ type: SyncService }
|
|
2327
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
1506
2328
|
|
|
1507
2329
|
const convertersMapToken = new InjectionToken('ConvertersTokensMap');
|
|
1508
2330
|
const convertersMap = {
|
|
1509
2331
|
zip: ZipConverter,
|
|
1510
2332
|
email: EmailConverter,
|
|
2333
|
+
card_number: CardNumberConverter,
|
|
2334
|
+
card_month: CardExpirationConverter,
|
|
2335
|
+
card_year: CardExpirationConverter,
|
|
2336
|
+
cvv: CvvConverter,
|
|
2337
|
+
extra_cvv: CvvConverter,
|
|
2338
|
+
cardholdername: CardholderNameConverter,
|
|
2339
|
+
cpf_number: CpfNumberConverter,
|
|
2340
|
+
cpf_name: CpfNameConverter,
|
|
2341
|
+
birth_date: BirthDateConverter,
|
|
2342
|
+
street_number: StreetNumberConverter,
|
|
2343
|
+
text: TextConverter,
|
|
2344
|
+
phone: PhoneConverter,
|
|
1511
2345
|
};
|
|
1512
2346
|
|
|
1513
2347
|
class ControlConfigService {
|
|
@@ -1669,6 +2503,13 @@ const statusSearchParamsMap = new Map([
|
|
|
1669
2503
|
],
|
|
1670
2504
|
]);
|
|
1671
2505
|
|
|
2506
|
+
class TerminalError extends AppError {
|
|
2507
|
+
constructor(message, code) {
|
|
2508
|
+
super(message);
|
|
2509
|
+
this.code = code;
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
|
|
1672
2513
|
class XpsApiPart {
|
|
1673
2514
|
constructor() {
|
|
1674
2515
|
this.response = new BehaviorSubject(null);
|
|
@@ -1924,23 +2765,20 @@ const checkStatusResponseFactoryProvider = {
|
|
|
1924
2765
|
};
|
|
1925
2766
|
|
|
1926
2767
|
class CheckStatusService extends XpsApiPart {
|
|
1927
|
-
constructor(
|
|
2768
|
+
constructor(xpsApiService, settingsService, requestFactory, responseFactory) {
|
|
1928
2769
|
super();
|
|
1929
|
-
this.
|
|
2770
|
+
this.xpsApiService = xpsApiService;
|
|
1930
2771
|
this.settingsService = settingsService;
|
|
1931
2772
|
this.requestFactory = requestFactory;
|
|
1932
2773
|
this.responseFactory = responseFactory;
|
|
1933
|
-
this.apiRoute = 'directpayment';
|
|
1934
2774
|
}
|
|
1935
2775
|
setRequestParams(invoice) {
|
|
1936
2776
|
this.invoice = invoice;
|
|
1937
2777
|
}
|
|
1938
2778
|
request() {
|
|
1939
2779
|
const requestParams = this.requestFactory(this.settingsService.token, this.invoice);
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
responseType: 'json',
|
|
1943
|
-
}))
|
|
2780
|
+
this.xpsApiService
|
|
2781
|
+
.directPaymentRequest(requestParams)
|
|
1944
2782
|
.then((response) => {
|
|
1945
2783
|
const checkStatusResponse = this.responseFactory({
|
|
1946
2784
|
status: response.status,
|
|
@@ -1954,14 +2792,14 @@ class CheckStatusService extends XpsApiPart {
|
|
|
1954
2792
|
});
|
|
1955
2793
|
}
|
|
1956
2794
|
}
|
|
1957
|
-
CheckStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, deps: [{ token:
|
|
2795
|
+
CheckStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, deps: [{ token: XpsApiService }, { token: SettingsService }, { token: checkStatusRequestFactoryToken }, { token: checkStatusResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1958
2796
|
CheckStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, providedIn: 'root' });
|
|
1959
2797
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, decorators: [{
|
|
1960
2798
|
type: Injectable,
|
|
1961
2799
|
args: [{
|
|
1962
2800
|
providedIn: 'root',
|
|
1963
2801
|
}]
|
|
1964
|
-
}], ctorParameters: function () { return [{ type:
|
|
2802
|
+
}], ctorParameters: function () { return [{ type: XpsApiService }, { type: SettingsService }, { type: undefined, decorators: [{
|
|
1965
2803
|
type: Inject,
|
|
1966
2804
|
args: [checkStatusRequestFactoryToken]
|
|
1967
2805
|
}] }, { type: undefined, decorators: [{
|
|
@@ -2092,34 +2930,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2092
2930
|
}]
|
|
2093
2931
|
}] });
|
|
2094
2932
|
|
|
2095
|
-
var ErrorTags;
|
|
2096
|
-
(function (ErrorTags) {
|
|
2097
|
-
ErrorTags["APP"] = "appError";
|
|
2098
|
-
ErrorTags["HTTP"] = "httpError";
|
|
2099
|
-
ErrorTags["JS"] = "jsError";
|
|
2100
|
-
ErrorTags["WS"] = "webSocket";
|
|
2101
|
-
ErrorTags["ENCRYPT"] = "encrypt";
|
|
2102
|
-
ErrorTags["APPLEPAY"] = "applepay";
|
|
2103
|
-
ErrorTags["HEADLESS_UI"] = "headlessUi";
|
|
2104
|
-
ErrorTags["GOOGLEPAY"] = "googlepay";
|
|
2105
|
-
ErrorTags["PAYTM"] = "paytm";
|
|
2106
|
-
})(ErrorTags || (ErrorTags = {}));
|
|
2107
|
-
|
|
2108
|
-
class TaggedError extends Error {
|
|
2109
|
-
constructor(message, tags) {
|
|
2110
|
-
super(message);
|
|
2111
|
-
this.tags = [];
|
|
2112
|
-
this.parentTag = ErrorTags.HEADLESS_UI;
|
|
2113
|
-
this.tags = this.childTag
|
|
2114
|
-
? [this.parentTag, this.childTag]
|
|
2115
|
-
: [this.parentTag];
|
|
2116
|
-
if (tags) {
|
|
2117
|
-
const newTags = tags.filter((t, i, arr) => !this.tags.includes(t) && arr.indexOf(t) == i);
|
|
2118
|
-
this.tags = [...this.tags, ...newTags];
|
|
2119
|
-
}
|
|
2120
|
-
}
|
|
2121
|
-
}
|
|
2122
|
-
|
|
2123
2933
|
class WsError extends TaggedError {
|
|
2124
2934
|
constructor(message, channelName, tags) {
|
|
2125
2935
|
tags = tags ? [...tags, ErrorTags.WS] : [ErrorTags.WS];
|
|
@@ -2968,19 +3778,451 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2968
3778
|
args: [financeDetailsResponseFactoryToken]
|
|
2969
3779
|
}] }]; } });
|
|
2970
3780
|
|
|
3781
|
+
class CreditCardStateService extends EmitDataService {
|
|
3782
|
+
}
|
|
3783
|
+
CreditCardStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardStateService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
|
|
3784
|
+
CreditCardStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardStateService, providedIn: 'root' });
|
|
3785
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CreditCardStateService, decorators: [{
|
|
3786
|
+
type: Injectable,
|
|
3787
|
+
args: [{
|
|
3788
|
+
providedIn: 'root',
|
|
3789
|
+
}]
|
|
3790
|
+
}] });
|
|
3791
|
+
|
|
3792
|
+
var ThreeDsStatusWebSocketTypes;
|
|
3793
|
+
(function (ThreeDsStatusWebSocketTypes) {
|
|
3794
|
+
ThreeDsStatusWebSocketTypes["status3DS_changed"] = "status3DS_changed";
|
|
3795
|
+
})(ThreeDsStatusWebSocketTypes || (ThreeDsStatusWebSocketTypes = {}));
|
|
3796
|
+
|
|
3797
|
+
var ThreeDsStatusTypes;
|
|
3798
|
+
(function (ThreeDsStatusTypes) {
|
|
3799
|
+
ThreeDsStatusTypes["completed"] = "completed";
|
|
3800
|
+
ThreeDsStatusTypes["challenge"] = "challenge";
|
|
3801
|
+
ThreeDsStatusTypes["collectDfp"] = "collect_dfp";
|
|
3802
|
+
})(ThreeDsStatusTypes || (ThreeDsStatusTypes = {}));
|
|
3803
|
+
|
|
3804
|
+
class XpsResponseError extends AppError {
|
|
3805
|
+
constructor(message) {
|
|
3806
|
+
super('XPS response failed' + (message ? `: "${message}".` : '.'));
|
|
3807
|
+
}
|
|
3808
|
+
}
|
|
3809
|
+
|
|
3810
|
+
class StatusThreeDsRequest {
|
|
3811
|
+
constructor(token, threeDsId) {
|
|
3812
|
+
this.access_token = token;
|
|
3813
|
+
this.threeDSTrXid = threeDsId;
|
|
3814
|
+
}
|
|
3815
|
+
}
|
|
3816
|
+
|
|
3817
|
+
const statusThreeDsRequestFactoryToken = new InjectionToken('StatusThreeDsRequest');
|
|
3818
|
+
const statusThreeDsRequestFactoryProvider = {
|
|
3819
|
+
provide: statusThreeDsRequestFactoryToken,
|
|
3820
|
+
useValue: (...args) => new StatusThreeDsRequest(...args),
|
|
3821
|
+
};
|
|
3822
|
+
|
|
3823
|
+
class StatusThreeDsResponse {
|
|
3824
|
+
constructor(params) {
|
|
3825
|
+
this.status = params.status;
|
|
3826
|
+
this.checkoutForm = params.checkoutForm;
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
|
|
3830
|
+
const statusThreeDsResponseFactoryToken = new InjectionToken('StatusThreeDsResponse');
|
|
3831
|
+
const statusThreeDsResponseFactoryProvider = {
|
|
3832
|
+
provide: statusThreeDsResponseFactoryToken,
|
|
3833
|
+
useValue: (...args) => new StatusThreeDsResponse(...args),
|
|
3834
|
+
};
|
|
3835
|
+
|
|
3836
|
+
class StatusThreeDsService {
|
|
3837
|
+
get response$() {
|
|
3838
|
+
return this.response.asObservable();
|
|
3839
|
+
}
|
|
3840
|
+
constructor(secureApi, settingsService, requestFactory, responseFactory) {
|
|
3841
|
+
this.secureApi = secureApi;
|
|
3842
|
+
this.settingsService = settingsService;
|
|
3843
|
+
this.requestFactory = requestFactory;
|
|
3844
|
+
this.responseFactory = responseFactory;
|
|
3845
|
+
this.apiRoute = 'secure3d/check';
|
|
3846
|
+
this.response = new Subject();
|
|
3847
|
+
}
|
|
3848
|
+
request(data) {
|
|
3849
|
+
const token = this.settingsService.token;
|
|
3850
|
+
if (!token) {
|
|
3851
|
+
throw new TokenError();
|
|
3852
|
+
}
|
|
3853
|
+
const requestParams = this.requestFactory(token, data.threeDSTrXid);
|
|
3854
|
+
void lastValueFrom(this.secureApi
|
|
3855
|
+
.post(this.apiRoute, new URLSearchParams({ ...requestParams }), {
|
|
3856
|
+
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
3857
|
+
responseType: 'json',
|
|
3858
|
+
})
|
|
3859
|
+
.pipe(map$1((response) => {
|
|
3860
|
+
const statusResponse = this.responseFactory({
|
|
3861
|
+
status: response.secure3d.status,
|
|
3862
|
+
checkoutForm: response.secure3d.checkout_form,
|
|
3863
|
+
});
|
|
3864
|
+
this.response.next(statusResponse);
|
|
3865
|
+
}))).catch((error) => {
|
|
3866
|
+
throw new XpsResponseError(error.message);
|
|
3867
|
+
});
|
|
3868
|
+
}
|
|
3869
|
+
}
|
|
3870
|
+
StatusThreeDsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusThreeDsService, deps: [{ token: SecureApiClient }, { token: SettingsService }, { token: statusThreeDsRequestFactoryToken }, { token: statusThreeDsResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3871
|
+
StatusThreeDsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusThreeDsService, providedIn: 'root' });
|
|
3872
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: StatusThreeDsService, decorators: [{
|
|
3873
|
+
type: Injectable,
|
|
3874
|
+
args: [{
|
|
3875
|
+
providedIn: 'root',
|
|
3876
|
+
}]
|
|
3877
|
+
}], ctorParameters: function () { return [{ type: SecureApiClient }, { type: SettingsService }, { type: undefined, decorators: [{
|
|
3878
|
+
type: Inject,
|
|
3879
|
+
args: [statusThreeDsRequestFactoryToken]
|
|
3880
|
+
}] }, { type: undefined, decorators: [{
|
|
3881
|
+
type: Inject,
|
|
3882
|
+
args: [statusThreeDsResponseFactoryToken]
|
|
3883
|
+
}] }]; } });
|
|
3884
|
+
|
|
3885
|
+
class NotifyDfpStatusRequest {
|
|
3886
|
+
constructor(params) {
|
|
3887
|
+
this.access_token = params.token;
|
|
3888
|
+
this.threeDSTrXid = params.threeDsTrXid;
|
|
3889
|
+
this.secure3dCompind = params.isCompind ? 'Y' : 'N';
|
|
3890
|
+
}
|
|
3891
|
+
}
|
|
3892
|
+
|
|
3893
|
+
const notifyDfpStatusRequestFactoryToken = new InjectionToken('NotifyDfpStatusRequest');
|
|
3894
|
+
const notifyDfpStatusRequestFactoryProvider = {
|
|
3895
|
+
provide: notifyDfpStatusRequestFactoryToken,
|
|
3896
|
+
useValue: (...args) => new NotifyDfpStatusRequest(...args),
|
|
3897
|
+
};
|
|
3898
|
+
|
|
3899
|
+
class NotifyDfpStatusService {
|
|
3900
|
+
constructor(secureApi, settingsService, requestFactory) {
|
|
3901
|
+
this.secureApi = secureApi;
|
|
3902
|
+
this.settingsService = settingsService;
|
|
3903
|
+
this.requestFactory = requestFactory;
|
|
3904
|
+
this.apiRouteComplete = 'secure3d/notify';
|
|
3905
|
+
}
|
|
3906
|
+
/*
|
|
3907
|
+
* isCompind is a flag of dfp expired state
|
|
3908
|
+
*/
|
|
3909
|
+
request(threeDsId, isCompind) {
|
|
3910
|
+
const token = this.settingsService.token;
|
|
3911
|
+
if (!token) {
|
|
3912
|
+
throw new TokenError();
|
|
3913
|
+
}
|
|
3914
|
+
const requestParams = this.requestFactory({
|
|
3915
|
+
token: token,
|
|
3916
|
+
threeDsTrXid: threeDsId,
|
|
3917
|
+
isCompind,
|
|
3918
|
+
});
|
|
3919
|
+
lastValueFrom(this.secureApi.post(this.apiRouteComplete, new URLSearchParams({ ...requestParams }), {
|
|
3920
|
+
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
|
|
3921
|
+
responseType: 'json',
|
|
3922
|
+
})).catch((error) => {
|
|
3923
|
+
throw new XpsResponseError(error.message);
|
|
3924
|
+
});
|
|
3925
|
+
}
|
|
3926
|
+
}
|
|
3927
|
+
NotifyDfpStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NotifyDfpStatusService, deps: [{ token: SecureApiClient }, { token: SettingsService }, { token: notifyDfpStatusRequestFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3928
|
+
NotifyDfpStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NotifyDfpStatusService, providedIn: 'root' });
|
|
3929
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: NotifyDfpStatusService, decorators: [{
|
|
3930
|
+
type: Injectable,
|
|
3931
|
+
args: [{
|
|
3932
|
+
providedIn: 'root',
|
|
3933
|
+
}]
|
|
3934
|
+
}], ctorParameters: function () { return [{ type: SecureApiClient }, { type: SettingsService }, { type: undefined, decorators: [{
|
|
3935
|
+
type: Inject,
|
|
3936
|
+
args: [notifyDfpStatusRequestFactoryToken]
|
|
3937
|
+
}] }]; } });
|
|
3938
|
+
|
|
3939
|
+
class DfpCollectService {
|
|
3940
|
+
constructor(window, notifyDfpStatusService) {
|
|
3941
|
+
this.window = window;
|
|
3942
|
+
this.notifyDfpStatusService = notifyDfpStatusService;
|
|
3943
|
+
this.iframeName = 'iframeDFP';
|
|
3944
|
+
this.formName = 'formDFP';
|
|
3945
|
+
}
|
|
3946
|
+
collectDfpStatus(threeDsForm) {
|
|
3947
|
+
if (threeDsForm.waitCallback) {
|
|
3948
|
+
this.openIframeWithPostRequest(threeDsForm, false);
|
|
3949
|
+
}
|
|
3950
|
+
else {
|
|
3951
|
+
this.openIframeWithPostRequest(threeDsForm, true);
|
|
3952
|
+
}
|
|
3953
|
+
}
|
|
3954
|
+
/*
|
|
3955
|
+
* This method create invisible iframe with required params and after that it submit form in iframe
|
|
3956
|
+
* */
|
|
3957
|
+
openIframeWithPostRequest(threeDsForm, isNeedNotifyAfterLoad) {
|
|
3958
|
+
const iFrameElement = this.window.document.getElementById(this.iframeName);
|
|
3959
|
+
if (!iFrameElement) {
|
|
3960
|
+
this.createIframe(isNeedNotifyAfterLoad, threeDsForm.threeDSTrXid);
|
|
3961
|
+
this.postFormToIframe(threeDsForm.threeDSMethod, threeDsForm.threeDSMethodData);
|
|
3962
|
+
}
|
|
3963
|
+
}
|
|
3964
|
+
/*
|
|
3965
|
+
* isNeedNotifyAfterLoad is need to send notification of dft to server
|
|
3966
|
+
* */
|
|
3967
|
+
createIframe(isNeedNotifyAfterLoad, threeDsTrXid) {
|
|
3968
|
+
const attributes = {
|
|
3969
|
+
name: this.iframeName,
|
|
3970
|
+
id: this.iframeName,
|
|
3971
|
+
src: 'javascript:false',
|
|
3972
|
+
style: 'display:none',
|
|
3973
|
+
};
|
|
3974
|
+
const iFrame = this.window.document.createElement('iframe');
|
|
3975
|
+
this.setAttributes(iFrame, attributes);
|
|
3976
|
+
this.window.document.body.appendChild(iFrame);
|
|
3977
|
+
if (isNeedNotifyAfterLoad) {
|
|
3978
|
+
this.window.document.getElementById(this.iframeName).onload = () => {
|
|
3979
|
+
this.notifyDfpStatusService.request(threeDsTrXid, true);
|
|
3980
|
+
};
|
|
3981
|
+
}
|
|
3982
|
+
}
|
|
3983
|
+
/*
|
|
3984
|
+
* This method will submit form in our iframe. Form will be created, if it's don't exist
|
|
3985
|
+
* */
|
|
3986
|
+
postFormToIframe(url, threeDsMethod) {
|
|
3987
|
+
let form = this.window.document.getElementById(this.formName);
|
|
3988
|
+
if (!form) {
|
|
3989
|
+
form = this.createForm();
|
|
3990
|
+
this.window.document.body.appendChild(form);
|
|
3991
|
+
}
|
|
3992
|
+
form.setAttribute('action', url);
|
|
3993
|
+
form.setAttribute('target', this.iframeName);
|
|
3994
|
+
form.appendChild(this.createInput('threeDSMethodData', threeDsMethod));
|
|
3995
|
+
form.submit();
|
|
3996
|
+
}
|
|
3997
|
+
/*
|
|
3998
|
+
* This method will create invisible form with required params
|
|
3999
|
+
*/
|
|
4000
|
+
createForm() {
|
|
4001
|
+
const form = this.window.document.createElement('form');
|
|
4002
|
+
const initAttributes = {
|
|
4003
|
+
name: this.formName,
|
|
4004
|
+
id: this.formName,
|
|
4005
|
+
style: 'display:none',
|
|
4006
|
+
method: 'POST',
|
|
4007
|
+
enctype: 'application/x-www-form-urlencoded',
|
|
4008
|
+
};
|
|
4009
|
+
this.setAttributes(form, initAttributes);
|
|
4010
|
+
return form;
|
|
4011
|
+
}
|
|
4012
|
+
createInput(name, value) {
|
|
4013
|
+
const input = this.window.document.createElement('input');
|
|
4014
|
+
input.type = 'hidden';
|
|
4015
|
+
input.name = name;
|
|
4016
|
+
input.value = value;
|
|
4017
|
+
return input;
|
|
4018
|
+
}
|
|
4019
|
+
/*
|
|
4020
|
+
* This method will set attributes to form/iframe
|
|
4021
|
+
* */
|
|
4022
|
+
setAttributes(element, attributes) {
|
|
4023
|
+
Object.keys(attributes).forEach((name) => {
|
|
4024
|
+
element.setAttribute(name, attributes[name]);
|
|
4025
|
+
});
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
DfpCollectService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DfpCollectService, deps: [{ token: windowToken }, { token: NotifyDfpStatusService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4029
|
+
DfpCollectService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DfpCollectService, providedIn: 'root' });
|
|
4030
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: DfpCollectService, decorators: [{
|
|
4031
|
+
type: Injectable,
|
|
4032
|
+
args: [{
|
|
4033
|
+
providedIn: 'root',
|
|
4034
|
+
}]
|
|
4035
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
4036
|
+
type: Inject,
|
|
4037
|
+
args: [windowToken]
|
|
4038
|
+
}] }, { type: NotifyDfpStatusService }]; } });
|
|
4039
|
+
|
|
4040
|
+
class ReinsuranceCheckService {
|
|
4041
|
+
constructor(window) {
|
|
4042
|
+
this.window = window;
|
|
4043
|
+
this.timers = {};
|
|
4044
|
+
}
|
|
4045
|
+
addTimer(timer) {
|
|
4046
|
+
if (!timer) {
|
|
4047
|
+
return;
|
|
4048
|
+
}
|
|
4049
|
+
this.removeTimer(timer.id);
|
|
4050
|
+
this.timers[timer.id] = timer;
|
|
4051
|
+
const timerInStorage = this.timers[timer.id];
|
|
4052
|
+
this.window.setTimeout(() => {
|
|
4053
|
+
timerInStorage.callback();
|
|
4054
|
+
this.timers[timer.id] = null;
|
|
4055
|
+
}, timerInStorage.timeoutMs);
|
|
4056
|
+
}
|
|
4057
|
+
removeTimer(id) {
|
|
4058
|
+
const timerInStorage = this.timers[id];
|
|
4059
|
+
if (!timerInStorage) {
|
|
4060
|
+
return;
|
|
4061
|
+
}
|
|
4062
|
+
this.window.clearTimeout(timerInStorage.timeoutRef);
|
|
4063
|
+
this.timers[id] = null;
|
|
4064
|
+
}
|
|
4065
|
+
}
|
|
4066
|
+
ReinsuranceCheckService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ReinsuranceCheckService, deps: [{ token: windowToken }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4067
|
+
ReinsuranceCheckService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ReinsuranceCheckService, providedIn: 'root' });
|
|
4068
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ReinsuranceCheckService, decorators: [{
|
|
4069
|
+
type: Injectable,
|
|
4070
|
+
args: [{
|
|
4071
|
+
providedIn: 'root',
|
|
4072
|
+
}]
|
|
4073
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
4074
|
+
type: Inject,
|
|
4075
|
+
args: [windowToken]
|
|
4076
|
+
}] }]; } });
|
|
4077
|
+
|
|
4078
|
+
class ThreeDs20Service {
|
|
4079
|
+
get statusUpdates$() {
|
|
4080
|
+
return this.statusUpdates.asObservable();
|
|
4081
|
+
}
|
|
4082
|
+
constructor(statusThreeDsService, notifyDfpStatusService, webSocketFactory, dfpCollectService, reinsuranceCheckService) {
|
|
4083
|
+
this.statusThreeDsService = statusThreeDsService;
|
|
4084
|
+
this.notifyDfpStatusService = notifyDfpStatusService;
|
|
4085
|
+
this.webSocketFactory = webSocketFactory;
|
|
4086
|
+
this.dfpCollectService = dfpCollectService;
|
|
4087
|
+
this.reinsuranceCheckService = reinsuranceCheckService;
|
|
4088
|
+
this.webSocketClient = null;
|
|
4089
|
+
this.statusUpdates = new Subject();
|
|
4090
|
+
this.statusRequestSubscription = null;
|
|
4091
|
+
this.notifyDfpTimerId = 'notify-dfp';
|
|
4092
|
+
this.notifyDfpTimeoutMs = 10000;
|
|
4093
|
+
this.statusThreeDsTimerId = 'status-three-ds';
|
|
4094
|
+
this.statusThreeDsTimeoutMs = 180000;
|
|
4095
|
+
}
|
|
4096
|
+
async checkThreeDs20(threeDsForm) {
|
|
4097
|
+
if (!threeDsForm) {
|
|
4098
|
+
return;
|
|
4099
|
+
}
|
|
4100
|
+
this.reinsuranceCheckService.addTimer({
|
|
4101
|
+
id: this.notifyDfpTimerId,
|
|
4102
|
+
timeoutMs: this.notifyDfpTimeoutMs,
|
|
4103
|
+
callback: () => {
|
|
4104
|
+
this.notifyDfpStatusService.request(threeDsForm.threeDSTrXid, false);
|
|
4105
|
+
},
|
|
4106
|
+
});
|
|
4107
|
+
this.webSocketClient = this.webSocketFactory.createWebSocketClient(threeDsForm.webSocketChannelUrl, threeDsForm.webSocketClientType);
|
|
4108
|
+
await this.webSocketClient.open(threeDsForm.webSocketChannelUrl, threeDsForm.webSocketClientType);
|
|
4109
|
+
this.webSocketSubscription?.unsubscribe();
|
|
4110
|
+
this.webSocketSubscription = this.webSocketClient.messages$.subscribe((message) => {
|
|
4111
|
+
if (message !== ThreeDsStatusWebSocketTypes.status3DS_changed) {
|
|
4112
|
+
return;
|
|
4113
|
+
}
|
|
4114
|
+
this.statusThreeDsService.request(threeDsForm);
|
|
4115
|
+
});
|
|
4116
|
+
this.webSocketReconnectionSubscription?.unsubscribe();
|
|
4117
|
+
this.webSocketReconnectionSubscription =
|
|
4118
|
+
this.webSocketClient.subscribeOnSuccessfulReconnection(() => {
|
|
4119
|
+
this.statusThreeDsService.request(threeDsForm);
|
|
4120
|
+
});
|
|
4121
|
+
this.handleThreeDsUpdates(threeDsForm);
|
|
4122
|
+
this.statusThreeDsService.request(threeDsForm);
|
|
4123
|
+
this.reinsuranceCheckService.addTimer({
|
|
4124
|
+
id: this.statusThreeDsTimerId,
|
|
4125
|
+
timeoutMs: this.statusThreeDsTimeoutMs,
|
|
4126
|
+
callback: () => {
|
|
4127
|
+
this.statusThreeDsService.request(threeDsForm);
|
|
4128
|
+
},
|
|
4129
|
+
});
|
|
4130
|
+
}
|
|
4131
|
+
handleThreeDsUpdates(threeDsForm) {
|
|
4132
|
+
this.statusRequestSubscription?.unsubscribe();
|
|
4133
|
+
this.statusRequestSubscription =
|
|
4134
|
+
this.statusThreeDsService.response$.subscribe((threeDsStatus) => {
|
|
4135
|
+
if (!threeDsStatus) {
|
|
4136
|
+
return;
|
|
4137
|
+
}
|
|
4138
|
+
if (threeDsStatus.status === ThreeDsStatusTypes.completed) {
|
|
4139
|
+
this.stopReinsuranceMethods();
|
|
4140
|
+
this.statusUpdates.next({
|
|
4141
|
+
type: 'complete',
|
|
4142
|
+
data: {
|
|
4143
|
+
statusUrl: threeDsForm.statusUrl,
|
|
4144
|
+
},
|
|
4145
|
+
});
|
|
4146
|
+
return;
|
|
4147
|
+
}
|
|
4148
|
+
if (threeDsStatus.status === ThreeDsStatusTypes.challenge &&
|
|
4149
|
+
threeDsStatus.checkoutForm) {
|
|
4150
|
+
this.stopReinsuranceMethods();
|
|
4151
|
+
this.statusUpdates.next({
|
|
4152
|
+
type: 'challenge',
|
|
4153
|
+
data: threeDsStatus.checkoutForm,
|
|
4154
|
+
});
|
|
4155
|
+
}
|
|
4156
|
+
if (threeDsStatus.status === ThreeDsStatusTypes.collectDfp) {
|
|
4157
|
+
this.dfpCollectService.collectDfpStatus(threeDsForm);
|
|
4158
|
+
}
|
|
4159
|
+
});
|
|
4160
|
+
}
|
|
4161
|
+
stopReinsuranceMethods() {
|
|
4162
|
+
this.reinsuranceCheckService.removeTimer(this.notifyDfpTimerId);
|
|
4163
|
+
this.reinsuranceCheckService.removeTimer(this.statusThreeDsTimerId);
|
|
4164
|
+
this.webSocketClient?.close();
|
|
4165
|
+
this.statusRequestSubscription?.unsubscribe();
|
|
4166
|
+
}
|
|
4167
|
+
}
|
|
4168
|
+
ThreeDs20Service.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDs20Service, deps: [{ token: StatusThreeDsService }, { token: NotifyDfpStatusService }, { token: WebSocketFactory }, { token: DfpCollectService }, { token: ReinsuranceCheckService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4169
|
+
ThreeDs20Service.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDs20Service, providedIn: 'root' });
|
|
4170
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDs20Service, decorators: [{
|
|
4171
|
+
type: Injectable,
|
|
4172
|
+
args: [{
|
|
4173
|
+
providedIn: 'root',
|
|
4174
|
+
}]
|
|
4175
|
+
}], ctorParameters: function () { return [{ type: StatusThreeDsService }, { type: NotifyDfpStatusService }, { type: WebSocketFactory }, { type: DfpCollectService }, { type: ReinsuranceCheckService }]; } });
|
|
4176
|
+
|
|
4177
|
+
class ThreeDsService {
|
|
4178
|
+
constructor(threeDs20Service, nextActionService) {
|
|
4179
|
+
this.threeDs20Service = threeDs20Service;
|
|
4180
|
+
this.nextActionService = nextActionService;
|
|
4181
|
+
this.statusSubscription = null;
|
|
4182
|
+
}
|
|
4183
|
+
checkThreeDs(params) {
|
|
4184
|
+
/*
|
|
4185
|
+
At this moment we support only 3ds 2.0 version.
|
|
4186
|
+
3ds 1.0 currently working by our redirect logic (Redirect NextAction).
|
|
4187
|
+
If in future we will get new version of 3ds, we should add 3ds determination logic to this service
|
|
4188
|
+
*/
|
|
4189
|
+
void this.threeDs20Service.checkThreeDs20(params.parameters.threeDSForm);
|
|
4190
|
+
this.statusSubscription?.unsubscribe();
|
|
4191
|
+
this.statusSubscription = this.threeDs20Service.statusUpdates$.subscribe((statusUpdate) => {
|
|
4192
|
+
if (statusUpdate.type === 'complete') {
|
|
4193
|
+
return this.nextActionService.emitFlowUpdates(new CheckStatusAction(params));
|
|
4194
|
+
}
|
|
4195
|
+
this.nextActionService.emitFlowUpdates(new ThreeDsAction(statusUpdate));
|
|
4196
|
+
});
|
|
4197
|
+
}
|
|
4198
|
+
stopChecking() {
|
|
4199
|
+
this.statusSubscription?.unsubscribe();
|
|
4200
|
+
}
|
|
4201
|
+
}
|
|
4202
|
+
ThreeDsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDsService, deps: [{ token: ThreeDs20Service }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4203
|
+
ThreeDsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDsService, providedIn: 'root' });
|
|
4204
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ThreeDsService, decorators: [{
|
|
4205
|
+
type: Injectable,
|
|
4206
|
+
args: [{
|
|
4207
|
+
providedIn: 'root',
|
|
4208
|
+
}]
|
|
4209
|
+
}], ctorParameters: function () { return [{ type: ThreeDs20Service }, { type: NextActionService }]; } });
|
|
4210
|
+
|
|
2971
4211
|
class PaymentService {
|
|
2972
4212
|
get formFieldsStatus$() {
|
|
2973
4213
|
return this.formFieldsStatusSubject.asObservable().pipe(filter$1(Boolean));
|
|
2974
4214
|
}
|
|
2975
|
-
constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, nextActionService, controlConfigService) {
|
|
4215
|
+
constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService) {
|
|
2976
4216
|
this.initializeService = initializeService;
|
|
2977
4217
|
this.submitService = submitService;
|
|
2978
4218
|
this.syncService = syncService;
|
|
2979
4219
|
this.formService = formService;
|
|
2980
4220
|
this.statusService = statusService;
|
|
2981
4221
|
this.financeDetailsService = financeDetailsService;
|
|
4222
|
+
this.creditCardStateService = creditCardStateService;
|
|
2982
4223
|
this.nextActionService = nextActionService;
|
|
2983
4224
|
this.controlConfigService = controlConfigService;
|
|
4225
|
+
this.threeDsService = threeDsService;
|
|
2984
4226
|
this.form = null;
|
|
2985
4227
|
this.data = null;
|
|
2986
4228
|
this.financeDetails = null;
|
|
@@ -3016,6 +4258,13 @@ class PaymentService {
|
|
|
3016
4258
|
const submitResponse = await this.submitService.request(this.fields, this.form);
|
|
3017
4259
|
this.data = submitResponse;
|
|
3018
4260
|
this.emitFinanceDetails(submitResponse.summary);
|
|
4261
|
+
// Handle 3ds flow
|
|
4262
|
+
if (submitResponse.currentCommand === XpsCommand.create) {
|
|
4263
|
+
this.runThreeDs();
|
|
4264
|
+
return;
|
|
4265
|
+
}
|
|
4266
|
+
this.fields = this.getFields();
|
|
4267
|
+
this.form = this.formService.createForm(this.fields);
|
|
3019
4268
|
return this.nextActionService.getNextAction(submitResponse);
|
|
3020
4269
|
}
|
|
3021
4270
|
getFields() {
|
|
@@ -3032,7 +4281,10 @@ class PaymentService {
|
|
|
3032
4281
|
return this.syncService.validate(field);
|
|
3033
4282
|
}
|
|
3034
4283
|
runThreeDs() {
|
|
3035
|
-
|
|
4284
|
+
if (!isSubmitResponse(this.data)) {
|
|
4285
|
+
throw new Error('Should submit form first');
|
|
4286
|
+
}
|
|
4287
|
+
this.threeDsService.checkThreeDs(this.data);
|
|
3036
4288
|
}
|
|
3037
4289
|
getFinanceDetails() {
|
|
3038
4290
|
return this.financeDetails;
|
|
@@ -3083,10 +4335,14 @@ class PaymentService {
|
|
|
3083
4335
|
this.fields = [];
|
|
3084
4336
|
this.formDestroy$.next();
|
|
3085
4337
|
this.destroy$.next();
|
|
4338
|
+
this.threeDsService.stopChecking();
|
|
3086
4339
|
}
|
|
3087
4340
|
emitFinanceDetails(summary) {
|
|
3088
4341
|
this.financeDetailsService.emit(summary);
|
|
3089
4342
|
}
|
|
4343
|
+
emitCreditCardState(idCardType) {
|
|
4344
|
+
this.creditCardStateService.emit({ idCardType });
|
|
4345
|
+
}
|
|
3090
4346
|
emitFormFieldsStatus(form) {
|
|
3091
4347
|
const formFieldsStatus = {};
|
|
3092
4348
|
Object.keys(form.controls).forEach((name) => {
|
|
@@ -3104,7 +4360,17 @@ class PaymentService {
|
|
|
3104
4360
|
this.syncService.setup(form, fields);
|
|
3105
4361
|
this.syncService.data$
|
|
3106
4362
|
.pipe(takeUntil(this.destroy$))
|
|
3107
|
-
.subscribe((response) =>
|
|
4363
|
+
.subscribe((response) => {
|
|
4364
|
+
this.emitFinanceDetails(response.summary);
|
|
4365
|
+
});
|
|
4366
|
+
this.syncService.fieldAsyncValidation$
|
|
4367
|
+
.pipe(takeUntil(this.destroy$))
|
|
4368
|
+
.subscribe((fieldAsyncValidation) => {
|
|
4369
|
+
switch (fieldAsyncValidation.field.name) {
|
|
4370
|
+
case FieldNames.cardNumber:
|
|
4371
|
+
this.emitCreditCardState(fieldAsyncValidation.response.parameters.idCardType);
|
|
4372
|
+
}
|
|
4373
|
+
});
|
|
3108
4374
|
}
|
|
3109
4375
|
listenFinanceDetails() {
|
|
3110
4376
|
this.financeDetailsService.data$
|
|
@@ -3117,14 +4383,14 @@ class PaymentService {
|
|
|
3117
4383
|
.subscribe(() => this.emitFormFieldsStatus(form));
|
|
3118
4384
|
}
|
|
3119
4385
|
}
|
|
3120
|
-
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: FinanceDetailsService }, { token: NextActionService }, { token: ControlConfigService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4386
|
+
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: FinanceDetailsService }, { token: CreditCardStateService }, { token: NextActionService }, { token: ControlConfigService }, { token: ThreeDsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3121
4387
|
PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
|
|
3122
4388
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
|
|
3123
4389
|
type: Injectable,
|
|
3124
4390
|
args: [{
|
|
3125
4391
|
providedIn: 'root',
|
|
3126
4392
|
}]
|
|
3127
|
-
}], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: NextActionService }, { type: ControlConfigService }]; } });
|
|
4393
|
+
}], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: ControlConfigService }, { type: ThreeDsService }]; } });
|
|
3128
4394
|
|
|
3129
4395
|
class RefundPolicyService {
|
|
3130
4396
|
constructor(settingsService) {
|
|
@@ -3229,7 +4495,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
3229
4495
|
}], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }, { type: SecureConnectionService }, { type: DisclaimerService }]; } });
|
|
3230
4496
|
|
|
3231
4497
|
class CoreLibraryService {
|
|
3232
|
-
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService) {
|
|
4498
|
+
constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService, creditCardService, creditCardStateService) {
|
|
3233
4499
|
this.settingsService = settingsService;
|
|
3234
4500
|
this.countryService = countryService;
|
|
3235
4501
|
this.paymentMethodsService = paymentMethodsService;
|
|
@@ -3242,6 +4508,8 @@ class CoreLibraryService {
|
|
|
3242
4508
|
this.legalService = legalService;
|
|
3243
4509
|
this.statusService = statusService;
|
|
3244
4510
|
this.nextActionService = nextActionService;
|
|
4511
|
+
this.creditCardService = creditCardService;
|
|
4512
|
+
this.creditCardStateService = creditCardStateService;
|
|
3245
4513
|
this.paymentMethods = {
|
|
3246
4514
|
getList: async () => this.paymentMethodsService.getList(),
|
|
3247
4515
|
getQuickMethods: async () => this.paymentMethodsService.getQuickMethods(),
|
|
@@ -3251,7 +4519,7 @@ class CoreLibraryService {
|
|
|
3251
4519
|
}
|
|
3252
4520
|
async init(configuration) {
|
|
3253
4521
|
await this.settingsService.init(configuration);
|
|
3254
|
-
|
|
4522
|
+
this.deviceFingerPrintService.init();
|
|
3255
4523
|
}
|
|
3256
4524
|
async getStatus(url) {
|
|
3257
4525
|
return this.statusService.getStatusWithUrlSearchParams(url);
|
|
@@ -3279,6 +4547,16 @@ class CoreLibraryService {
|
|
|
3279
4547
|
},
|
|
3280
4548
|
};
|
|
3281
4549
|
}
|
|
4550
|
+
getCreditCardService() {
|
|
4551
|
+
return {
|
|
4552
|
+
getTypeByNumber: (cardNumber) => this.creditCardService.getTypeByNumber(cardNumber),
|
|
4553
|
+
getCreditCardSettings: (cardType) => this.creditCardService.getCreditCardSettings(cardType),
|
|
4554
|
+
cardTypeUpdates$: this.creditCardStateService.data$,
|
|
4555
|
+
};
|
|
4556
|
+
}
|
|
4557
|
+
get cardTypeUpdates$() {
|
|
4558
|
+
return this.creditCardStateService.data$;
|
|
4559
|
+
}
|
|
3282
4560
|
getLegalComponentConfig() {
|
|
3283
4561
|
return this.legalService.getLegalComponentConfig();
|
|
3284
4562
|
}
|
|
@@ -3287,14 +4565,14 @@ class CoreLibraryService {
|
|
|
3287
4565
|
return masksFunctionsMap[sanitizedName];
|
|
3288
4566
|
}
|
|
3289
4567
|
}
|
|
3290
|
-
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: PaymentConfigService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: FinanceDetailsService }, { token: LegalService }, { token: StatusService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4568
|
+
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: PaymentConfigService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: FinanceDetailsService }, { token: LegalService }, { token: StatusService }, { token: NextActionService }, { token: CreditCardService }, { token: CreditCardStateService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
3291
4569
|
CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
|
|
3292
4570
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
|
|
3293
4571
|
type: Injectable,
|
|
3294
4572
|
args: [{
|
|
3295
4573
|
providedIn: 'root',
|
|
3296
4574
|
}]
|
|
3297
|
-
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentConfigService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: StatusService }, { type: NextActionService }]; } });
|
|
4575
|
+
}], ctorParameters: function () { return [{ type: SettingsService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentConfigService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: StatusService }, { type: NextActionService }, { type: CreditCardService }, { type: CreditCardStateService }]; } });
|
|
3298
4576
|
|
|
3299
4577
|
class HttpError extends AppError {
|
|
3300
4578
|
constructor(error, req) {
|
|
@@ -3351,26 +4629,58 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
3351
4629
|
type: Injectable
|
|
3352
4630
|
}], ctorParameters: function () { return [{ type: i1$1.Router }]; } });
|
|
3353
4631
|
|
|
4632
|
+
class ValidatorsModule {
|
|
4633
|
+
}
|
|
4634
|
+
ValidatorsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ValidatorsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
4635
|
+
ValidatorsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: ValidatorsModule, imports: [CommonModule] });
|
|
4636
|
+
ValidatorsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ValidatorsModule, providers: [CreditCardMinLengthValidator], imports: [CommonModule] });
|
|
4637
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ValidatorsModule, decorators: [{
|
|
4638
|
+
type: NgModule,
|
|
4639
|
+
args: [{
|
|
4640
|
+
declarations: [],
|
|
4641
|
+
imports: [CommonModule],
|
|
4642
|
+
providers: [CreditCardMinLengthValidator],
|
|
4643
|
+
}]
|
|
4644
|
+
}] });
|
|
4645
|
+
|
|
3354
4646
|
class FormModule {
|
|
3355
4647
|
}
|
|
3356
4648
|
FormModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
3357
|
-
FormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: FormModule, imports: [ReactiveFormsModule] });
|
|
4649
|
+
FormModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.7", ngImport: i0, type: FormModule, imports: [ReactiveFormsModule, ValidatorsModule] });
|
|
3358
4650
|
FormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, providers: [
|
|
3359
4651
|
FormService,
|
|
3360
4652
|
ControlConfigService,
|
|
3361
4653
|
ZipConverter,
|
|
3362
4654
|
EmailConverter,
|
|
4655
|
+
CardNumberConverter,
|
|
4656
|
+
CardExpirationConverter,
|
|
4657
|
+
CvvConverter,
|
|
4658
|
+
CardholderNameConverter,
|
|
4659
|
+
CpfNumberConverter,
|
|
4660
|
+
CpfNameConverter,
|
|
4661
|
+
BirthDateConverter,
|
|
4662
|
+
StreetNumberConverter,
|
|
4663
|
+
TextConverter,
|
|
3363
4664
|
{ provide: convertersMapToken, useValue: convertersMap },
|
|
3364
|
-
], imports: [ReactiveFormsModule] });
|
|
4665
|
+
], imports: [ReactiveFormsModule, ValidatorsModule] });
|
|
3365
4666
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, decorators: [{
|
|
3366
4667
|
type: NgModule,
|
|
3367
4668
|
args: [{
|
|
3368
|
-
imports: [ReactiveFormsModule],
|
|
4669
|
+
imports: [ReactiveFormsModule, ValidatorsModule],
|
|
3369
4670
|
providers: [
|
|
3370
4671
|
FormService,
|
|
3371
4672
|
ControlConfigService,
|
|
3372
4673
|
ZipConverter,
|
|
3373
4674
|
EmailConverter,
|
|
4675
|
+
CardNumberConverter,
|
|
4676
|
+
CardExpirationConverter,
|
|
4677
|
+
CvvConverter,
|
|
4678
|
+
CardholderNameConverter,
|
|
4679
|
+
CpfNumberConverter,
|
|
4680
|
+
CpfNameConverter,
|
|
4681
|
+
BirthDateConverter,
|
|
4682
|
+
StreetNumberConverter,
|
|
4683
|
+
TextConverter,
|
|
3374
4684
|
{ provide: convertersMapToken, useValue: convertersMap },
|
|
3375
4685
|
],
|
|
3376
4686
|
}]
|
|
@@ -3400,6 +4710,9 @@ CoreLibraryModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", versi
|
|
|
3400
4710
|
checkStatusRequestFactoryProvider,
|
|
3401
4711
|
checkStatusResponseFactoryProvider,
|
|
3402
4712
|
financeDetailsResponseFactoryProvider,
|
|
4713
|
+
statusThreeDsRequestFactoryProvider,
|
|
4714
|
+
statusThreeDsResponseFactoryProvider,
|
|
4715
|
+
notifyDfpStatusRequestFactoryProvider,
|
|
3403
4716
|
{
|
|
3404
4717
|
provide: nextActionsToken,
|
|
3405
4718
|
useValue: nextActions,
|
|
@@ -3431,6 +4744,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
3431
4744
|
checkStatusRequestFactoryProvider,
|
|
3432
4745
|
checkStatusResponseFactoryProvider,
|
|
3433
4746
|
financeDetailsResponseFactoryProvider,
|
|
4747
|
+
statusThreeDsRequestFactoryProvider,
|
|
4748
|
+
statusThreeDsResponseFactoryProvider,
|
|
4749
|
+
notifyDfpStatusRequestFactoryProvider,
|
|
3434
4750
|
{
|
|
3435
4751
|
provide: nextActionsToken,
|
|
3436
4752
|
useValue: nextActions,
|