@xsolla/payment-client-core 0.1.6 → 0.1.7
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/form/controls/phone-control.config.mjs +8 -0
- package/esm2020/lib/core/payment/form/converters/converters-map.mjs +3 -1
- package/esm2020/lib/core/payment/form/converters/phone.converter.mjs +37 -0
- package/esm2020/lib/core/payment/form/form.module.mjs +6 -1
- 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-library.service.mjs +4 -1
- package/fesm2015/xsolla-payment-client-core.mjs +55 -0
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +55 -0
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/form/controls/phone-control.config.d.ts +6 -0
- package/lib/core/payment/form/converters/phone.converter.d.ts +13 -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-library.service.d.ts +1 -0
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.1.7.tgz +0 -0
- package/xsolla-payment-client-core-0.1.6.tgz +0 -0
|
@@ -2557,6 +2557,53 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
2557
2557
|
type: Injectable
|
|
2558
2558
|
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2559
2559
|
|
|
2560
|
+
function phoneValidator() {
|
|
2561
|
+
return convert(Validators.pattern(/^\d*$/), 'Enter a valid phone');
|
|
2562
|
+
}
|
|
2563
|
+
|
|
2564
|
+
function minLengthValidator(minLength) {
|
|
2565
|
+
return convert(Validators.minLength(minLength), `Enter at least ${minLength} characters`);
|
|
2566
|
+
}
|
|
2567
|
+
|
|
2568
|
+
function maxLengthValidator(maxLength) {
|
|
2569
|
+
return convert(Validators.maxLength(maxLength), `Enter no more than ${maxLength} characters`);
|
|
2570
|
+
}
|
|
2571
|
+
|
|
2572
|
+
class PhoneControlConfig extends ControlConfig {
|
|
2573
|
+
constructor() {
|
|
2574
|
+
super(...arguments);
|
|
2575
|
+
this.controlType = 'phone';
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
class PhoneConverter extends Converter {
|
|
2580
|
+
constructor(syncService) {
|
|
2581
|
+
super(syncService);
|
|
2582
|
+
}
|
|
2583
|
+
getValidators(field) {
|
|
2584
|
+
const minLength = 10;
|
|
2585
|
+
const maxLength = 15;
|
|
2586
|
+
return super
|
|
2587
|
+
.getValidators(field)
|
|
2588
|
+
.concat([
|
|
2589
|
+
convertedRequiredValidator(),
|
|
2590
|
+
phoneValidator(),
|
|
2591
|
+
minLengthValidator(minLength),
|
|
2592
|
+
maxLengthValidator(maxLength),
|
|
2593
|
+
]);
|
|
2594
|
+
}
|
|
2595
|
+
createControlConfig(field) {
|
|
2596
|
+
const config = this.createDefaultControlConfig(PhoneControlConfig, field);
|
|
2597
|
+
config.inputMode = 'numeric';
|
|
2598
|
+
return config;
|
|
2599
|
+
}
|
|
2600
|
+
}
|
|
2601
|
+
PhoneConverter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PhoneConverter, deps: [{ token: SyncService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
2602
|
+
PhoneConverter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PhoneConverter });
|
|
2603
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PhoneConverter, decorators: [{
|
|
2604
|
+
type: Injectable
|
|
2605
|
+
}], ctorParameters: function () { return [{ type: SyncService }]; } });
|
|
2606
|
+
|
|
2560
2607
|
const convertersMapToken = new InjectionToken('ConvertersTokensMap');
|
|
2561
2608
|
const convertersMap = {
|
|
2562
2609
|
card_number: CardNumberConverter,
|
|
@@ -2581,6 +2628,7 @@ const convertersMap = {
|
|
|
2581
2628
|
sum: PricepointConverter,
|
|
2582
2629
|
out: PricepointConverter,
|
|
2583
2630
|
couponCode: CouponConverter,
|
|
2631
|
+
phone: PhoneConverter,
|
|
2584
2632
|
};
|
|
2585
2633
|
|
|
2586
2634
|
class ControlConfigService {
|
|
@@ -4789,6 +4837,9 @@ class CoreLibraryService {
|
|
|
4789
4837
|
setCountry(country) {
|
|
4790
4838
|
this.countryService.setCountry(country);
|
|
4791
4839
|
}
|
|
4840
|
+
getCountry() {
|
|
4841
|
+
return this.countryService.getCountry();
|
|
4842
|
+
}
|
|
4792
4843
|
createPayment(config) {
|
|
4793
4844
|
const enrichedConfig = this.paymentConfigService.enrich(config);
|
|
4794
4845
|
return {
|
|
@@ -4935,6 +4986,8 @@ FormModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15
|
|
|
4935
4986
|
PricepointConverter,
|
|
4936
4987
|
PricepointConverter,
|
|
4937
4988
|
CouponConverter,
|
|
4989
|
+
TextConverter,
|
|
4990
|
+
PhoneConverter,
|
|
4938
4991
|
{ provide: convertersMapToken, useValue: convertersMap },
|
|
4939
4992
|
], imports: [ReactiveFormsModule, ValidatorsModule] });
|
|
4940
4993
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormModule, decorators: [{
|
|
@@ -4966,6 +5019,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
|
|
|
4966
5019
|
PricepointConverter,
|
|
4967
5020
|
PricepointConverter,
|
|
4968
5021
|
CouponConverter,
|
|
5022
|
+
TextConverter,
|
|
5023
|
+
PhoneConverter,
|
|
4969
5024
|
{ provide: convertersMapToken, useValue: convertersMap },
|
|
4970
5025
|
],
|
|
4971
5026
|
}]
|