@xsolla/payment-client-core 0.2.36 → 0.2.38
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/esm2022/lib/core/payment/config/config.service.mjs +1 -1
- package/esm2022/lib/core/payment/credit-card-payment-methods-id.variable.mjs +2 -1
- package/esm2022/lib/core/payment/field-names.enum.mjs +2 -1
- package/esm2022/lib/core/payment/form/converters/card-expiration/card-expiration.converter.mjs +39 -0
- package/esm2022/lib/core/payment/form/converters/converters-map.mjs +3 -1
- package/esm2022/lib/core/payment/form/form.module.mjs +4 -1
- package/esm2022/lib/core/payment/form/validators/card-expiration-date-validator/card-expiration-date.validator.mjs +61 -0
- package/esm2022/lib/core/payment/initialize/initialize.service.mjs +8 -4
- package/esm2022/lib/core/payment/payment-configuration.interface.mjs +2 -0
- package/esm2022/lib/core/payment/payment-settings/payment-settings-request-params.interface.mjs +2 -0
- package/esm2022/lib/core/payment/payment-settings/payment-settings.service.mjs +20 -0
- package/esm2022/lib/core/payment/payment.service.mjs +6 -6
- package/esm2022/lib/core/payment/submit/request/submit-request.class.mjs +15 -3
- package/esm2022/lib/core/payment/submit/submit.service.mjs +9 -5
- package/esm2022/lib/core/payment/sync/request/sync-request.class.mjs +6 -5
- package/esm2022/lib/core/payment/sync/sync.service.mjs +12 -5
- package/esm2022/lib/core/payment/xps-api-part-request.abstract.mjs +6 -1
- package/esm2022/lib/core/saved-methods/saved-method-api.interface.mjs +1 -1
- package/esm2022/lib/core/saved-methods/saved-method.interface.mjs +1 -1
- package/esm2022/lib/core/saved-methods/saved-methods-response.class.mjs +3 -1
- package/esm2022/lib/core-library.service.mjs +1 -1
- package/fesm2022/xsolla-payment-client-core.mjs +187 -40
- package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/config/config.service.d.ts +2 -2
- package/lib/core/payment/credit-card-payment-methods-id.variable.d.ts +1 -1
- package/lib/core/payment/field-names.enum.d.ts +1 -0
- package/lib/core/payment/form/converters/card-expiration/card-expiration.converter.d.ts +17 -0
- package/lib/core/payment/form/validators/card-expiration-date-validator/card-expiration-date.validator.d.ts +10 -0
- package/lib/core/payment/initialize/initialize.service.d.ts +5 -3
- package/lib/core/payment/payment-configuration.interface.d.ts +22 -0
- package/lib/core/payment/payment-settings/payment-settings-request-params.interface.d.ts +4 -0
- package/lib/core/payment/payment-settings/payment-settings.service.d.ts +8 -0
- package/lib/core/payment/payment.service.d.ts +2 -2
- package/lib/core/payment/submit/request/submit-request.class.d.ts +1 -0
- package/lib/core/payment/submit/submit.service.d.ts +5 -2
- package/lib/core/payment/sync/request/sync-request.class.d.ts +2 -1
- package/lib/core/payment/sync/sync.service.d.ts +6 -2
- package/lib/core/payment/xps-api-part-request.abstract.d.ts +4 -1
- package/lib/core/saved-methods/saved-method-api.interface.d.ts +6 -0
- package/lib/core/saved-methods/saved-method.interface.d.ts +6 -0
- package/lib/core-library.service.d.ts +2 -2
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.2.38.tgz +0 -0
- package/esm2022/lib/core/payment/payment-config.interface.mjs +0 -2
- package/lib/core/payment/payment-config.interface.d.ts +0 -8
- package/xsolla-payment-client-core-0.2.36.tgz +0 -0
|
@@ -321,6 +321,8 @@ class SavedMethodsResponse {
|
|
|
321
321
|
replaced: method.replaced,
|
|
322
322
|
type: method.type,
|
|
323
323
|
cardExpiryDate: method.card_expiry_date,
|
|
324
|
+
dateCreate: method.date_create,
|
|
325
|
+
dateLastCharge: method.date_last_charge,
|
|
324
326
|
iconName: method.switch_icon_name,
|
|
325
327
|
partner: method.partner,
|
|
326
328
|
};
|
|
@@ -526,6 +528,7 @@ var FieldNames;
|
|
|
526
528
|
FieldNames["birthDate"] = "birth_date";
|
|
527
529
|
FieldNames["cardMonth"] = "card_month";
|
|
528
530
|
FieldNames["cardYear"] = "card_year";
|
|
531
|
+
FieldNames["cardExpire"] = "card_expire";
|
|
529
532
|
FieldNames["cardNumber"] = "card_number";
|
|
530
533
|
FieldNames["cardholdername"] = "cardholdername";
|
|
531
534
|
FieldNames["city"] = "city";
|
|
@@ -705,6 +708,7 @@ const userBehaviourEventTypes = {
|
|
|
705
708
|
|
|
706
709
|
const masterCardAndVisaPaymentMethodId = 26;
|
|
707
710
|
const maestroPaymentMethodId = 490;
|
|
711
|
+
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
708
712
|
const creditCardPaymentMethodId = 1380;
|
|
709
713
|
const americanExpressMethodId = 714;
|
|
710
714
|
const specialCards = [
|
|
@@ -2622,8 +2626,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
2622
2626
|
}]
|
|
2623
2627
|
}], ctorParameters: () => [{ type: i1.HttpClient }, { type: EventBuilderService }, { type: SettingsService }] });
|
|
2624
2628
|
|
|
2629
|
+
class PaymentSettingsService {
|
|
2630
|
+
getPaymentSettingsParams(config) {
|
|
2631
|
+
return {
|
|
2632
|
+
...(config?.paymentMethodSettings?.useSingleExpirationDateField
|
|
2633
|
+
? { useSingleExpirationDateField: "1" /* XpsBoolean.true */ }
|
|
2634
|
+
: {}),
|
|
2635
|
+
};
|
|
2636
|
+
}
|
|
2637
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentSettingsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2638
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentSettingsService, providedIn: 'root' }); }
|
|
2639
|
+
}
|
|
2640
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: PaymentSettingsService, decorators: [{
|
|
2641
|
+
type: Injectable,
|
|
2642
|
+
args: [{
|
|
2643
|
+
providedIn: 'root',
|
|
2644
|
+
}]
|
|
2645
|
+
}] });
|
|
2646
|
+
|
|
2625
2647
|
class InitializeService {
|
|
2626
|
-
constructor(responseFactory, xpsApiService, settingsService, countryService, nextActionService, xpsResponseErrorsMappingService, encryptCreditCardService, showErrorsActionCreator, userBehaviourAnalyticsService) {
|
|
2648
|
+
constructor(responseFactory, xpsApiService, settingsService, countryService, nextActionService, xpsResponseErrorsMappingService, encryptCreditCardService, showErrorsActionCreator, userBehaviourAnalyticsService, paymentSettingsService) {
|
|
2627
2649
|
this.responseFactory = responseFactory;
|
|
2628
2650
|
this.xpsApiService = xpsApiService;
|
|
2629
2651
|
this.settingsService = settingsService;
|
|
@@ -2633,8 +2655,10 @@ class InitializeService {
|
|
|
2633
2655
|
this.encryptCreditCardService = encryptCreditCardService;
|
|
2634
2656
|
this.showErrorsActionCreator = showErrorsActionCreator;
|
|
2635
2657
|
this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
|
|
2658
|
+
this.paymentSettingsService = paymentSettingsService;
|
|
2636
2659
|
}
|
|
2637
2660
|
async request(config) {
|
|
2661
|
+
const paymentSettingsParams = this.paymentSettingsService.getPaymentSettingsParams(config);
|
|
2638
2662
|
const requestParams = {
|
|
2639
2663
|
access_token: this.settingsService.token,
|
|
2640
2664
|
pid: String(config.paymentMethodId),
|
|
@@ -2646,6 +2670,7 @@ class InitializeService {
|
|
|
2646
2670
|
save_payment_account_only: config.savePaymentMethod
|
|
2647
2671
|
? "1" /* XpsBoolean.true */
|
|
2648
2672
|
: "0" /* XpsBoolean.false */,
|
|
2673
|
+
...paymentSettingsParams,
|
|
2649
2674
|
};
|
|
2650
2675
|
if (config.savedMethodId) {
|
|
2651
2676
|
requestParams.saved_method_id = config.savedMethodId;
|
|
@@ -2680,7 +2705,7 @@ class InitializeService {
|
|
|
2680
2705
|
}
|
|
2681
2706
|
this.encryptCreditCardService.setPublicKey(atob(publicKeyField.value));
|
|
2682
2707
|
}
|
|
2683
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeService, deps: [{ token: initializeResponseFactoryToken }, { token: XpsApiService }, { token: SettingsService }, { token: CountryService }, { token: NextActionService }, { token: XpsResponseErrorsMappingService }, { token: EncryptCreditCardService }, { token: ShowErrorsActionCreator }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2708
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeService, deps: [{ token: initializeResponseFactoryToken }, { token: XpsApiService }, { token: SettingsService }, { token: CountryService }, { token: NextActionService }, { token: XpsResponseErrorsMappingService }, { token: EncryptCreditCardService }, { token: ShowErrorsActionCreator }, { token: UserBehaviourAnalyticsService }, { token: PaymentSettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2684
2709
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeService, providedIn: 'root' }); }
|
|
2685
2710
|
}
|
|
2686
2711
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: InitializeService, decorators: [{
|
|
@@ -2691,7 +2716,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
2691
2716
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
2692
2717
|
type: Inject,
|
|
2693
2718
|
args: [initializeResponseFactoryToken]
|
|
2694
|
-
}] }, { type: XpsApiService }, { type: SettingsService }, { type: CountryService }, { type: NextActionService }, { type: XpsResponseErrorsMappingService }, { type: EncryptCreditCardService }, { type: ShowErrorsActionCreator }, { type: UserBehaviourAnalyticsService }] });
|
|
2719
|
+
}] }, { type: XpsApiService }, { type: SettingsService }, { type: CountryService }, { type: NextActionService }, { type: XpsResponseErrorsMappingService }, { type: EncryptCreditCardService }, { type: ShowErrorsActionCreator }, { type: UserBehaviourAnalyticsService }, { type: PaymentSettingsService }] });
|
|
2695
2720
|
|
|
2696
2721
|
class XpsApiPartRequest {
|
|
2697
2722
|
addXpsParameters(parameters) {
|
|
@@ -2699,6 +2724,11 @@ class XpsApiPartRequest {
|
|
|
2699
2724
|
this[`xps_${key}`] = parameters[key];
|
|
2700
2725
|
}
|
|
2701
2726
|
}
|
|
2727
|
+
addParameters(parameters) {
|
|
2728
|
+
for (const key in parameters) {
|
|
2729
|
+
this[key] = parameters[key];
|
|
2730
|
+
}
|
|
2731
|
+
}
|
|
2702
2732
|
}
|
|
2703
2733
|
|
|
2704
2734
|
class TokenError extends AppError {
|
|
@@ -2710,10 +2740,11 @@ class TokenError extends AppError {
|
|
|
2710
2740
|
class SubmitRequest extends XpsApiPartRequest {
|
|
2711
2741
|
constructor(parameters) {
|
|
2712
2742
|
super();
|
|
2713
|
-
const { token, fields, form, dfpHash } = parameters;
|
|
2743
|
+
const { token, fields, form, dfpHash, ...restParameters } = parameters;
|
|
2714
2744
|
if (token === null) {
|
|
2715
2745
|
throw new TokenError();
|
|
2716
2746
|
}
|
|
2747
|
+
this.addParameters(restParameters);
|
|
2717
2748
|
this.access_token = token;
|
|
2718
2749
|
if (dfpHash) {
|
|
2719
2750
|
this.xps_dfp_hash = dfpHash;
|
|
@@ -2721,11 +2752,21 @@ class SubmitRequest extends XpsApiPartRequest {
|
|
|
2721
2752
|
this.addXpsParameters(this.getFieldsValues(fields, form));
|
|
2722
2753
|
}
|
|
2723
2754
|
getFieldsValues(fields, form) {
|
|
2724
|
-
|
|
2755
|
+
const fieldValues = fields.reduce((xpsParams, field) => {
|
|
2725
2756
|
const formControl = form.get(field.name);
|
|
2726
2757
|
xpsParams[field.name] = formControl ? formControl.value : field?.value;
|
|
2727
2758
|
return xpsParams;
|
|
2728
2759
|
}, {});
|
|
2760
|
+
return this.splitCreditCardExpiration(fieldValues);
|
|
2761
|
+
}
|
|
2762
|
+
splitCreditCardExpiration(fieldsValues) {
|
|
2763
|
+
const creditCardExpiration = fieldsValues[FieldNames.cardExpire];
|
|
2764
|
+
if (creditCardExpiration) {
|
|
2765
|
+
const [month, year] = creditCardExpiration.split('/');
|
|
2766
|
+
fieldsValues['card_month'] = month;
|
|
2767
|
+
fieldsValues['card_year'] = year;
|
|
2768
|
+
}
|
|
2769
|
+
return fieldsValues;
|
|
2729
2770
|
}
|
|
2730
2771
|
}
|
|
2731
2772
|
|
|
@@ -2806,7 +2847,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
2806
2847
|
}], ctorParameters: () => [{ type: SettingsService }] });
|
|
2807
2848
|
|
|
2808
2849
|
class SubmitService {
|
|
2809
|
-
constructor(requestFactory, responseFactory, settingsService, deviceFingerPrintService, xpsApiService, xpsResponseErrorsMappingService, encryptCreditCardService, userBehaviourAnalyticsService) {
|
|
2850
|
+
constructor(requestFactory, responseFactory, settingsService, deviceFingerPrintService, xpsApiService, xpsResponseErrorsMappingService, encryptCreditCardService, userBehaviourAnalyticsService, paymentSettingsService) {
|
|
2810
2851
|
this.requestFactory = requestFactory;
|
|
2811
2852
|
this.responseFactory = responseFactory;
|
|
2812
2853
|
this.settingsService = settingsService;
|
|
@@ -2815,21 +2856,24 @@ class SubmitService {
|
|
|
2815
2856
|
this.xpsResponseErrorsMappingService = xpsResponseErrorsMappingService;
|
|
2816
2857
|
this.encryptCreditCardService = encryptCreditCardService;
|
|
2817
2858
|
this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
|
|
2859
|
+
this.paymentSettingsService = paymentSettingsService;
|
|
2818
2860
|
}
|
|
2819
2861
|
// NB: Never add 'async' statement for this method!
|
|
2820
2862
|
// 'Async' statement wraps current promise into another.
|
|
2821
2863
|
// In this way two promises become unequal, that can broke XPS API requests logic.
|
|
2822
2864
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
2823
|
-
request(fields, form) {
|
|
2865
|
+
request(fields, form, config) {
|
|
2824
2866
|
return (this.deviceFingerPrintService
|
|
2825
2867
|
.getHash()
|
|
2826
2868
|
// eslint-disable-next-line @typescript-eslint/promise-function-async
|
|
2827
2869
|
.then((dfpHash) => {
|
|
2870
|
+
const paymentSettingsParams = this.paymentSettingsService.getPaymentSettingsParams(config);
|
|
2828
2871
|
const requestParams = this.requestFactory({
|
|
2829
2872
|
token: this.settingsService.token,
|
|
2830
2873
|
fields,
|
|
2831
2874
|
form,
|
|
2832
2875
|
dfpHash,
|
|
2876
|
+
...paymentSettingsParams,
|
|
2833
2877
|
});
|
|
2834
2878
|
const encryptedRequest = this.encryptCreditCardService.encryptCreditCard(requestParams);
|
|
2835
2879
|
return this.xpsApiService
|
|
@@ -2856,7 +2900,7 @@ class SubmitService {
|
|
|
2856
2900
|
fields: Object.keys(xpsResponse.form).map((key) => xpsResponse.form[key]),
|
|
2857
2901
|
});
|
|
2858
2902
|
}
|
|
2859
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SubmitService, deps: [{ token: submitRequestFactoryToken }, { token: submitResponseFactoryToken }, { token: SettingsService }, { token: DeviceFingerPrintService }, { token: XpsApiService }, { token: XpsResponseErrorsMappingService }, { token: EncryptCreditCardService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2903
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SubmitService, deps: [{ token: submitRequestFactoryToken }, { token: submitResponseFactoryToken }, { token: SettingsService }, { token: DeviceFingerPrintService }, { token: XpsApiService }, { token: XpsResponseErrorsMappingService }, { token: EncryptCreditCardService }, { token: UserBehaviourAnalyticsService }, { token: PaymentSettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2860
2904
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SubmitService, providedIn: 'root' }); }
|
|
2861
2905
|
}
|
|
2862
2906
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SubmitService, decorators: [{
|
|
@@ -2868,7 +2912,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
2868
2912
|
}] }, { type: undefined, decorators: [{
|
|
2869
2913
|
type: Inject,
|
|
2870
2914
|
args: [submitResponseFactoryToken]
|
|
2871
|
-
}] }, { type: SettingsService }, { type: DeviceFingerPrintService }, { type: XpsApiService }, { type: XpsResponseErrorsMappingService }, { type: EncryptCreditCardService }, { type: UserBehaviourAnalyticsService }] });
|
|
2915
|
+
}] }, { type: SettingsService }, { type: DeviceFingerPrintService }, { type: XpsApiService }, { type: XpsResponseErrorsMappingService }, { type: EncryptCreditCardService }, { type: UserBehaviourAnalyticsService }, { type: PaymentSettingsService }] });
|
|
2872
2916
|
|
|
2873
2917
|
class EmitDataService {
|
|
2874
2918
|
constructor() {
|
|
@@ -2882,14 +2926,15 @@ class EmitDataService {
|
|
|
2882
2926
|
|
|
2883
2927
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2884
2928
|
class SyncRequest extends XpsApiPartRequest {
|
|
2885
|
-
constructor(parameters) {
|
|
2929
|
+
constructor({ token, changedField, fields, form, ...parameters }) {
|
|
2886
2930
|
super();
|
|
2887
2931
|
this.xps_fix_command = 'calculate';
|
|
2888
|
-
this.access_token =
|
|
2889
|
-
const fieldsValues = this.getFieldsValues(
|
|
2932
|
+
this.access_token = token;
|
|
2933
|
+
const fieldsValues = this.getFieldsValues(changedField, fields, form);
|
|
2934
|
+
this.addParameters(parameters);
|
|
2890
2935
|
this.addXpsParameters({
|
|
2891
2936
|
...fieldsValues,
|
|
2892
|
-
change_element:
|
|
2937
|
+
change_element: changedField.name,
|
|
2893
2938
|
});
|
|
2894
2939
|
}
|
|
2895
2940
|
getFieldsValues(changedField, fields, form) {
|
|
@@ -2940,7 +2985,7 @@ const syncResponseFactoryProvider = {
|
|
|
2940
2985
|
};
|
|
2941
2986
|
|
|
2942
2987
|
class SyncService extends EmitDataService {
|
|
2943
|
-
constructor(requestFactory, responseFactory, xpsApiService, nextActionService, settingsService, xpsResponseErrorsMappingService, encryptCreditCardService, showErrorsActionCreator, userBehaviourAnalyticsService) {
|
|
2988
|
+
constructor(requestFactory, responseFactory, xpsApiService, nextActionService, settingsService, xpsResponseErrorsMappingService, encryptCreditCardService, showErrorsActionCreator, userBehaviourAnalyticsService, paymentSettingsService) {
|
|
2944
2989
|
super();
|
|
2945
2990
|
this.requestFactory = requestFactory;
|
|
2946
2991
|
this.responseFactory = responseFactory;
|
|
@@ -2951,8 +2996,10 @@ class SyncService extends EmitDataService {
|
|
|
2951
2996
|
this.encryptCreditCardService = encryptCreditCardService;
|
|
2952
2997
|
this.showErrorsActionCreator = showErrorsActionCreator;
|
|
2953
2998
|
this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
|
|
2999
|
+
this.paymentSettingsService = paymentSettingsService;
|
|
2954
3000
|
this.prevFieldSyncStates = {};
|
|
2955
3001
|
this.form = new UntypedFormGroup({});
|
|
3002
|
+
this.paymentConfiguration = null;
|
|
2956
3003
|
this.fields = [];
|
|
2957
3004
|
this.fieldSyncTimers = {};
|
|
2958
3005
|
this.fieldAsyncValidation = new Subject();
|
|
@@ -2960,15 +3007,17 @@ class SyncService extends EmitDataService {
|
|
|
2960
3007
|
get fieldAsyncValidation$() {
|
|
2961
3008
|
return this.fieldAsyncValidation.asObservable();
|
|
2962
3009
|
}
|
|
2963
|
-
setup(form, fields) {
|
|
3010
|
+
setup(form, fields, config) {
|
|
2964
3011
|
this.reset();
|
|
2965
3012
|
this.form = form;
|
|
2966
3013
|
this.fields = fields;
|
|
3014
|
+
this.paymentConfiguration = config;
|
|
2967
3015
|
}
|
|
2968
3016
|
reset() {
|
|
2969
3017
|
this.prevFieldSyncStates = {};
|
|
2970
3018
|
this.form = new UntypedFormGroup({});
|
|
2971
3019
|
this.fields = [];
|
|
3020
|
+
this.paymentConfiguration = null;
|
|
2972
3021
|
}
|
|
2973
3022
|
async validate(field, delay = Number('750')) {
|
|
2974
3023
|
if (!this.isReadyField(field)) {
|
|
@@ -3018,11 +3067,13 @@ class SyncService extends EmitDataService {
|
|
|
3018
3067
|
return control?.errors ?? null;
|
|
3019
3068
|
}
|
|
3020
3069
|
async request(field) {
|
|
3070
|
+
const paymentSettingsParams = this.paymentSettingsService.getPaymentSettingsParams(this.paymentConfiguration);
|
|
3021
3071
|
const requestParams = this.requestFactory({
|
|
3022
3072
|
token: this.settingsService.token,
|
|
3023
3073
|
changedField: field,
|
|
3024
3074
|
fields: this.fields,
|
|
3025
3075
|
form: this.form,
|
|
3076
|
+
...paymentSettingsParams,
|
|
3026
3077
|
});
|
|
3027
3078
|
const encryptedRequest = this.encryptCreditCardService.encryptCreditCard(requestParams);
|
|
3028
3079
|
return this.xpsApiService
|
|
@@ -3064,7 +3115,7 @@ class SyncService extends EmitDataService {
|
|
|
3064
3115
|
}
|
|
3065
3116
|
this.fieldSyncTimers[field.name] = timerId;
|
|
3066
3117
|
}
|
|
3067
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SyncService, deps: [{ token: syncRequestFactoryToken }, { token: syncResponseFactoryToken }, { token: XpsApiService }, { token: NextActionService }, { token: SettingsService }, { token: XpsResponseErrorsMappingService }, { token: EncryptCreditCardService }, { token: ShowErrorsActionCreator }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3118
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SyncService, deps: [{ token: syncRequestFactoryToken }, { token: syncResponseFactoryToken }, { token: XpsApiService }, { token: NextActionService }, { token: SettingsService }, { token: XpsResponseErrorsMappingService }, { token: EncryptCreditCardService }, { token: ShowErrorsActionCreator }, { token: UserBehaviourAnalyticsService }, { token: PaymentSettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3068
3119
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SyncService, providedIn: 'root' }); }
|
|
3069
3120
|
}
|
|
3070
3121
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: SyncService, decorators: [{
|
|
@@ -3078,7 +3129,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
3078
3129
|
}] }, { type: undefined, decorators: [{
|
|
3079
3130
|
type: Inject,
|
|
3080
3131
|
args: [syncResponseFactoryToken]
|
|
3081
|
-
}] }, { type: XpsApiService }, { type: NextActionService }, { type: SettingsService }, { type: XpsResponseErrorsMappingService }, { type: EncryptCreditCardService }, { type: ShowErrorsActionCreator }, { type: UserBehaviourAnalyticsService }] });
|
|
3132
|
+
}] }, { type: XpsApiService }, { type: NextActionService }, { type: SettingsService }, { type: XpsResponseErrorsMappingService }, { type: EncryptCreditCardService }, { type: ShowErrorsActionCreator }, { type: UserBehaviourAnalyticsService }, { type: PaymentSettingsService }] });
|
|
3082
3133
|
|
|
3083
3134
|
function convert(validator, message) {
|
|
3084
3135
|
return (control) => {
|
|
@@ -3404,15 +3455,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
3404
3455
|
type: Injectable
|
|
3405
3456
|
}], ctorParameters: () => [{ type: SyncService }, { type: CreditCardMinLengthValidator }, { type: CreditCardMinLengthValidator }] });
|
|
3406
3457
|
|
|
3407
|
-
const maxMonths = 12;
|
|
3408
|
-
const getMinMonth = (parsedYear) => {
|
|
3458
|
+
const maxMonths$1 = 12;
|
|
3459
|
+
const getMinMonth$1 = (parsedYear) => {
|
|
3409
3460
|
let minMonth = 1;
|
|
3410
3461
|
const year = parsedYear ? Number('20' + parsedYear) : null;
|
|
3411
3462
|
const today = new Date();
|
|
3412
3463
|
minMonth = year === today.getFullYear() ? today.getMonth() + 1 : 1;
|
|
3413
3464
|
return minMonth;
|
|
3414
3465
|
};
|
|
3415
|
-
const sendErrMessage$
|
|
3466
|
+
const sendErrMessage$2 = (fn) => ({
|
|
3416
3467
|
cardMonthExpiration: {
|
|
3417
3468
|
message: fn,
|
|
3418
3469
|
},
|
|
@@ -3422,20 +3473,20 @@ function cardMonthValidator(formState) {
|
|
|
3422
3473
|
const { value } = control;
|
|
3423
3474
|
if (typeof value !== 'string')
|
|
3424
3475
|
return null;
|
|
3425
|
-
const minMonth = getMinMonth(formState?.cardYearValue ?? null);
|
|
3476
|
+
const minMonth = getMinMonth$1(formState?.cardYearValue ?? null);
|
|
3426
3477
|
const twoDigitsRegex = new RegExp(/^\d{2}$/);
|
|
3427
3478
|
const fieldCommonLength = 2;
|
|
3428
3479
|
if (value.length !== fieldCommonLength) {
|
|
3429
|
-
return sendErrMessage$
|
|
3480
|
+
return sendErrMessage$2(`Enter ${fieldCommonLength} characters`);
|
|
3430
3481
|
}
|
|
3431
3482
|
if (!twoDigitsRegex.test(value)) {
|
|
3432
|
-
return sendErrMessage$
|
|
3483
|
+
return sendErrMessage$2(`Enter a valid expiration month`);
|
|
3433
3484
|
}
|
|
3434
3485
|
if (Number(value) < minMonth) {
|
|
3435
|
-
return sendErrMessage$
|
|
3486
|
+
return sendErrMessage$2(`Enter a month greater than or equal to ${minMonth}`);
|
|
3436
3487
|
}
|
|
3437
|
-
if (Number(value) > maxMonths) {
|
|
3438
|
-
return sendErrMessage$
|
|
3488
|
+
if (Number(value) > maxMonths$1) {
|
|
3489
|
+
return sendErrMessage$2(`Enter a month less than or equal to ${maxMonths$1}`);
|
|
3439
3490
|
}
|
|
3440
3491
|
return null;
|
|
3441
3492
|
};
|
|
@@ -3864,36 +3915,36 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
3864
3915
|
type: Injectable
|
|
3865
3916
|
}], ctorParameters: () => [{ type: SyncService }] });
|
|
3866
3917
|
|
|
3867
|
-
const sendErrMessage = (fn) => ({
|
|
3918
|
+
const sendErrMessage$1 = (fn) => ({
|
|
3868
3919
|
cardYearExpiration: {
|
|
3869
3920
|
message: fn,
|
|
3870
3921
|
},
|
|
3871
3922
|
});
|
|
3872
|
-
const getLastCharactersInYear = (str = new Date().getFullYear().toString()) => {
|
|
3923
|
+
const getLastCharactersInYear$1 = (str = new Date().getFullYear().toString()) => {
|
|
3873
3924
|
// for getting last characters in year; need to check in future
|
|
3874
3925
|
return str.slice(str.length - 2);
|
|
3875
3926
|
};
|
|
3876
3927
|
// Карта выдается максимум на 50 лет
|
|
3877
|
-
const maxYearsCount = 50;
|
|
3928
|
+
const maxYearsCount$1 = 50;
|
|
3878
3929
|
function cardYearValidator(control) {
|
|
3879
3930
|
const { value } = control;
|
|
3880
3931
|
if (typeof value !== 'string')
|
|
3881
3932
|
return null;
|
|
3882
|
-
const minYear = parseInt(getLastCharactersInYear(), 10);
|
|
3933
|
+
const minYear = parseInt(getLastCharactersInYear$1(), 10);
|
|
3883
3934
|
const twoDigitsRegex = new RegExp(/^\d{2}$/);
|
|
3884
3935
|
const fieldCommonLength = 2;
|
|
3885
3936
|
if (value.length !== fieldCommonLength) {
|
|
3886
|
-
return sendErrMessage(`Enter ${fieldCommonLength} characters`);
|
|
3937
|
+
return sendErrMessage$1(`Enter ${fieldCommonLength} characters`);
|
|
3887
3938
|
}
|
|
3888
3939
|
if (!twoDigitsRegex.test(value)) {
|
|
3889
|
-
return sendErrMessage(`Enter a valid expiration year`);
|
|
3940
|
+
return sendErrMessage$1(`Enter a valid expiration year`);
|
|
3890
3941
|
}
|
|
3891
3942
|
if (Number(value) < minYear) {
|
|
3892
|
-
return sendErrMessage(`Enter a year greater than or equal to ${minYear}`);
|
|
3943
|
+
return sendErrMessage$1(`Enter a year greater than or equal to ${minYear}`);
|
|
3893
3944
|
}
|
|
3894
|
-
const maxValidYear = minYear + maxYearsCount;
|
|
3945
|
+
const maxValidYear = minYear + maxYearsCount$1;
|
|
3895
3946
|
if (Number(value) > maxValidYear) {
|
|
3896
|
-
return sendErrMessage(`Enter a year less than or equal to ${maxValidYear}`);
|
|
3947
|
+
return sendErrMessage$1(`Enter a year less than or equal to ${maxValidYear}`);
|
|
3897
3948
|
}
|
|
3898
3949
|
return null;
|
|
3899
3950
|
}
|
|
@@ -3979,11 +4030,105 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
3979
4030
|
type: Injectable
|
|
3980
4031
|
}], ctorParameters: () => [{ type: SyncService }] });
|
|
3981
4032
|
|
|
4033
|
+
const getMinMonth = (parsedYear) => {
|
|
4034
|
+
let minMonth = 1;
|
|
4035
|
+
if (parsedYear) {
|
|
4036
|
+
const year = parsedYear ? Number('20' + parsedYear) : null;
|
|
4037
|
+
const today = new Date();
|
|
4038
|
+
minMonth = year === today.getFullYear() ? today.getMonth() + 1 : 1;
|
|
4039
|
+
}
|
|
4040
|
+
return minMonth;
|
|
4041
|
+
};
|
|
4042
|
+
const sendErrMessage = (fn) => ({
|
|
4043
|
+
rewritableError: {
|
|
4044
|
+
message: fn,
|
|
4045
|
+
},
|
|
4046
|
+
});
|
|
4047
|
+
const getLastCharactersInYear = (str = new Date().getFullYear().toString()) => {
|
|
4048
|
+
// for getting last characters in year; need to check in future
|
|
4049
|
+
return str.slice(str.length - 2);
|
|
4050
|
+
};
|
|
4051
|
+
const sliceMmYy = (value) => {
|
|
4052
|
+
const sliceIndex = 2;
|
|
4053
|
+
const month = value.slice(0, sliceIndex);
|
|
4054
|
+
const year = value.slice(-sliceIndex);
|
|
4055
|
+
return { month, year };
|
|
4056
|
+
};
|
|
4057
|
+
const maxYearsCount = 50;
|
|
4058
|
+
function cardExpValidator(control) {
|
|
4059
|
+
const { value } = control;
|
|
4060
|
+
if (typeof value !== 'string')
|
|
4061
|
+
return null;
|
|
4062
|
+
const { month, year } = sliceMmYy(value);
|
|
4063
|
+
const minMonth = getMinMonth(year);
|
|
4064
|
+
const minYear = parseInt(getLastCharactersInYear(), 10);
|
|
4065
|
+
const twoDigitsRegex = new RegExp(/^\d{2}$/);
|
|
4066
|
+
const fieldCommonLength = 4;
|
|
4067
|
+
const trickyFieldLength = fieldCommonLength + 1;
|
|
4068
|
+
if (value.length !== trickyFieldLength) {
|
|
4069
|
+
return sendErrMessage(`Enter ${fieldCommonLength} characters`);
|
|
4070
|
+
}
|
|
4071
|
+
if (!twoDigitsRegex.test(month)) {
|
|
4072
|
+
return sendErrMessage('Enter a valid expiration month');
|
|
4073
|
+
}
|
|
4074
|
+
if (Number(month) < minMonth) {
|
|
4075
|
+
return sendErrMessage(`Enter a month greater than or equal to ${minMonth}`);
|
|
4076
|
+
}
|
|
4077
|
+
if (Number(month) > maxMonths) {
|
|
4078
|
+
return sendErrMessage(`Enter a month less than or equal to ${maxMonths}`);
|
|
4079
|
+
}
|
|
4080
|
+
if (!twoDigitsRegex.test(year)) {
|
|
4081
|
+
return sendErrMessage(`Enter a valid expiration year`);
|
|
4082
|
+
}
|
|
4083
|
+
if (Number(year) < minYear) {
|
|
4084
|
+
return sendErrMessage(`Enter a year greater than or equal to ${minYear}`);
|
|
4085
|
+
}
|
|
4086
|
+
const maxValidYear = minYear + maxYearsCount;
|
|
4087
|
+
if (Number(year) > maxValidYear) {
|
|
4088
|
+
return sendErrMessage(`Enter a year less than or equal to ${maxValidYear}`);
|
|
4089
|
+
}
|
|
4090
|
+
return null;
|
|
4091
|
+
}
|
|
4092
|
+
|
|
4093
|
+
const maxMonths = 12;
|
|
4094
|
+
class CardExpirationConverter extends Converter {
|
|
4095
|
+
constructor(syncService) {
|
|
4096
|
+
super(syncService);
|
|
4097
|
+
}
|
|
4098
|
+
getValidators(field) {
|
|
4099
|
+
return super.getValidators(field).concat([cardExpValidator]);
|
|
4100
|
+
}
|
|
4101
|
+
createControlConfig(field, formState) {
|
|
4102
|
+
const config = this.createDefaultControlConfig(TextControlConfig, field);
|
|
4103
|
+
config.maskConfig = {
|
|
4104
|
+
mask: '99/99',
|
|
4105
|
+
guide: false,
|
|
4106
|
+
};
|
|
4107
|
+
config.inputMode = 'numeric';
|
|
4108
|
+
config.placeholder = 'MM/YY';
|
|
4109
|
+
config.title = 'MM/YY';
|
|
4110
|
+
config.disabled = formState?.disabled ?? false;
|
|
4111
|
+
return config;
|
|
4112
|
+
}
|
|
4113
|
+
getAutocomplete() {
|
|
4114
|
+
return 'cc-exp';
|
|
4115
|
+
}
|
|
4116
|
+
getDataType() {
|
|
4117
|
+
return 'text';
|
|
4118
|
+
}
|
|
4119
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CardExpirationConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
4120
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CardExpirationConverter }); }
|
|
4121
|
+
}
|
|
4122
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: CardExpirationConverter, decorators: [{
|
|
4123
|
+
type: Injectable
|
|
4124
|
+
}], ctorParameters: () => [{ type: SyncService }] });
|
|
4125
|
+
|
|
3982
4126
|
const convertersMapToken = new InjectionToken('ConvertersTokensMap');
|
|
3983
4127
|
const convertersMap = {
|
|
3984
4128
|
card_number: CardNumberConverter,
|
|
3985
4129
|
card_month: CardMonthConverter,
|
|
3986
4130
|
card_year: CardYearConverter,
|
|
4131
|
+
card_expire: CardExpirationConverter,
|
|
3987
4132
|
cvv: CvvConverter,
|
|
3988
4133
|
extra_cvv: CvvConverter,
|
|
3989
4134
|
zip: ZipConverter,
|
|
@@ -6490,7 +6635,7 @@ class PaymentService {
|
|
|
6490
6635
|
this.fields = this.getFields();
|
|
6491
6636
|
this.form = this.formService.createForm(this.fields);
|
|
6492
6637
|
this.updatePidConfig();
|
|
6493
|
-
this.setupSyncService(this.form, this.fields);
|
|
6638
|
+
this.setupSyncService(this.form, this.fields, config);
|
|
6494
6639
|
this.listenFormStatusChanges(this.form);
|
|
6495
6640
|
const isNeedAutoSubmit = this.canAutoSubmit();
|
|
6496
6641
|
if (isNeedAutoSubmit) {
|
|
@@ -6517,7 +6662,7 @@ class PaymentService {
|
|
|
6517
6662
|
return;
|
|
6518
6663
|
}
|
|
6519
6664
|
this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
|
|
6520
|
-
const submitResponse = await this.submitService.request(this.fields, this.form);
|
|
6665
|
+
const submitResponse = await this.submitService.request(this.fields, this.form, this.config);
|
|
6521
6666
|
this.data = submitResponse;
|
|
6522
6667
|
this.emitFormResponse(this.data);
|
|
6523
6668
|
if (!this.isSavingMethodMode) {
|
|
@@ -6532,7 +6677,7 @@ class PaymentService {
|
|
|
6532
6677
|
}
|
|
6533
6678
|
this.fields = this.getFields();
|
|
6534
6679
|
this.form = this.formService.createForm(this.fields);
|
|
6535
|
-
this.syncService.setup(this.form, this.fields);
|
|
6680
|
+
this.syncService.setup(this.form, this.fields, this.config);
|
|
6536
6681
|
return this.nextActionService.getNextAction(submitResponse);
|
|
6537
6682
|
}
|
|
6538
6683
|
getFields() {
|
|
@@ -6738,8 +6883,8 @@ class PaymentService {
|
|
|
6738
6883
|
emitFormMessages(messages) {
|
|
6739
6884
|
this.formMessagesService.emitOnResponse(messages);
|
|
6740
6885
|
}
|
|
6741
|
-
setupSyncService(form, fields) {
|
|
6742
|
-
this.syncService.setup(form, fields);
|
|
6886
|
+
setupSyncService(form, fields, config) {
|
|
6887
|
+
this.syncService.setup(form, fields, config);
|
|
6743
6888
|
this.syncService.data$
|
|
6744
6889
|
.pipe(takeUntil(this.destroy$))
|
|
6745
6890
|
.subscribe((response) => {
|
|
@@ -7609,6 +7754,7 @@ class FormModule {
|
|
|
7609
7754
|
CardNumberConverter,
|
|
7610
7755
|
CardMonthConverter,
|
|
7611
7756
|
CardYearConverter,
|
|
7757
|
+
CardExpirationConverter,
|
|
7612
7758
|
CvvConverter,
|
|
7613
7759
|
CvvConverter,
|
|
7614
7760
|
ZipConverter,
|
|
@@ -7643,6 +7789,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
|
|
|
7643
7789
|
CardNumberConverter,
|
|
7644
7790
|
CardMonthConverter,
|
|
7645
7791
|
CardYearConverter,
|
|
7792
|
+
CardExpirationConverter,
|
|
7646
7793
|
CvvConverter,
|
|
7647
7794
|
CvvConverter,
|
|
7648
7795
|
ZipConverter,
|