@xsolla/payment-client-core 0.1.0 → 0.1.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/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/show-errors/show-errors.action.class.mjs +1 -1
- package/esm2020/lib/core/payment/actions/show-errors/show-errors.action.type.mjs +1 -1
- package/esm2020/lib/core/payment/actions/show-field-state/show-field-state.action.class.mjs +11 -0
- package/esm2020/lib/core/payment/actions/show-field-state/show-field-state.action.token.mjs +13 -0
- package/esm2020/lib/core/payment/actions/show-field-state/show-field-state.action.type.mjs +2 -0
- package/esm2020/lib/core/payment/payment.service.mjs +20 -23
- package/esm2020/lib/core/payment/show-field-state.interface.mjs +2 -0
- package/fesm2015/xsolla-payment-client-core.mjs +45 -27
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +45 -25
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/actions/next-action.interface.d.ts +3 -2
- package/lib/core/payment/actions/show-errors/show-errors.action.class.d.ts +2 -2
- package/lib/core/payment/actions/show-errors/show-errors.action.type.d.ts +2 -2
- package/lib/core/payment/actions/show-field-state/show-field-state.action.class.d.ts +8 -0
- package/lib/core/payment/actions/show-field-state/show-field-state.action.token.d.ts +4 -0
- package/lib/core/payment/actions/show-field-state/show-field-state.action.type.d.ts +10 -0
- package/lib/core/payment/payment.service.d.ts +1 -0
- package/lib/core/payment/show-field-state.interface.d.ts +7 -0
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.1.1.tgz +0 -0
- package/esm2020/lib/core/payment/extended-xps-error.mjs +0 -2
- package/lib/core/payment/extended-xps-error.d.ts +0 -4
- package/xsolla-payment-client-core-0.1.0.tgz +0 -0
|
@@ -573,11 +573,13 @@ const isSubmitResponse = (value) => {
|
|
|
573
573
|
return value instanceof SubmitResponse;
|
|
574
574
|
};
|
|
575
575
|
|
|
576
|
-
class
|
|
577
|
-
constructor(
|
|
578
|
-
this.type = '
|
|
576
|
+
class ShowFieldStateAction {
|
|
577
|
+
constructor(control) {
|
|
578
|
+
this.type = 'show_field_state';
|
|
579
579
|
this.data = {
|
|
580
|
-
|
|
580
|
+
fieldName: control.fieldName,
|
|
581
|
+
fieldState: control.fieldState,
|
|
582
|
+
error: control.error,
|
|
581
583
|
};
|
|
582
584
|
}
|
|
583
585
|
}
|
|
@@ -631,6 +633,15 @@ const initializeResponseFactoryProvider = {
|
|
|
631
633
|
useValue: (...args) => new InitializeResponse(...args),
|
|
632
634
|
};
|
|
633
635
|
|
|
636
|
+
class ShowErrorsAction {
|
|
637
|
+
constructor(errors) {
|
|
638
|
+
this.type = 'show_errors';
|
|
639
|
+
this.data = {
|
|
640
|
+
errors,
|
|
641
|
+
};
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
|
|
634
645
|
class ShowFieldsAction {
|
|
635
646
|
constructor(submitResponse) {
|
|
636
647
|
this.type = 'show_fields';
|
|
@@ -751,6 +762,17 @@ const showErrorsActionFactoryProvider = {
|
|
|
751
762
|
},
|
|
752
763
|
};
|
|
753
764
|
|
|
765
|
+
const showFieldStateActionFactoryToken = new InjectionToken('ShowFieldStateAction');
|
|
766
|
+
const showFieldStateActionFactoryProvider = {
|
|
767
|
+
provide: showFieldStateActionFactoryToken,
|
|
768
|
+
useValue: {
|
|
769
|
+
factory: (...args) => new ShowFieldStateAction(...args),
|
|
770
|
+
isSuitable: () => {
|
|
771
|
+
return true;
|
|
772
|
+
},
|
|
773
|
+
},
|
|
774
|
+
};
|
|
775
|
+
|
|
754
776
|
const nextActionsToken = new InjectionToken('Action');
|
|
755
777
|
const nextActions = [
|
|
756
778
|
showFieldsActionFactoryProvider,
|
|
@@ -760,6 +782,7 @@ const nextActions = [
|
|
|
760
782
|
const flowUpdateNextActions = [
|
|
761
783
|
statusUpdatedActionFactoryProvider,
|
|
762
784
|
showErrorsActionFactoryProvider,
|
|
785
|
+
showFieldStateActionFactoryProvider,
|
|
763
786
|
];
|
|
764
787
|
|
|
765
788
|
class NextActionService {
|
|
@@ -2992,9 +3015,11 @@ class PaymentService {
|
|
|
2992
3015
|
this.financeDetails = null;
|
|
2993
3016
|
this.fields = [];
|
|
2994
3017
|
this.destroy$ = new Subject();
|
|
3018
|
+
this.formDestroy$ = new Subject();
|
|
2995
3019
|
}
|
|
2996
3020
|
async initialize(config) {
|
|
2997
3021
|
this.destroy$ = new Subject();
|
|
3022
|
+
this.formDestroy$ = new Subject();
|
|
2998
3023
|
this.listenFinanceDetails();
|
|
2999
3024
|
this.config = config;
|
|
3000
3025
|
this.data = await this.initializeService.request(config);
|
|
@@ -3058,6 +3083,7 @@ class PaymentService {
|
|
|
3058
3083
|
this.financeDetails = null;
|
|
3059
3084
|
this.form = null;
|
|
3060
3085
|
this.fields = [];
|
|
3086
|
+
this.formDestroy$.next();
|
|
3061
3087
|
this.destroy$.next();
|
|
3062
3088
|
}
|
|
3063
3089
|
emitFinanceDetails(summary) {
|
|
@@ -3075,27 +3101,21 @@ class PaymentService {
|
|
|
3075
3101
|
.subscribe((financeDetails) => (this.financeDetails = financeDetails));
|
|
3076
3102
|
}
|
|
3077
3103
|
listenSyncValidationErrors(form) {
|
|
3078
|
-
form.
|
|
3079
|
-
const
|
|
3080
|
-
if (
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
element_name: controlName,
|
|
3094
|
-
};
|
|
3095
|
-
})
|
|
3096
|
-
.filter(Boolean);
|
|
3097
|
-
this.nextActionService.emitFlowUpdates(new ShowErrorsAction(syncValidationErrors));
|
|
3098
|
-
}
|
|
3104
|
+
Object.keys(form.controls).forEach((key) => {
|
|
3105
|
+
const control = form.get(key);
|
|
3106
|
+
if (control) {
|
|
3107
|
+
control.statusChanges
|
|
3108
|
+
.pipe(takeUntil(this.formDestroy$))
|
|
3109
|
+
.subscribe((status) => {
|
|
3110
|
+
const controlError = control.errors?.['rewritableError'] ??
|
|
3111
|
+
null;
|
|
3112
|
+
const controlObject = {
|
|
3113
|
+
fieldName: key,
|
|
3114
|
+
fieldState: status,
|
|
3115
|
+
error: controlError,
|
|
3116
|
+
};
|
|
3117
|
+
this.nextActionService.emitFlowUpdates(new ShowFieldStateAction(controlObject));
|
|
3118
|
+
});
|
|
3099
3119
|
}
|
|
3100
3120
|
});
|
|
3101
3121
|
}
|