@xsolla/payment-client-core 0.1.12 → 0.1.13-test1

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.
@@ -376,6 +376,9 @@ class UserBalanceService {
376
376
  async getUserBalance() {
377
377
  return this.request();
378
378
  }
379
+ getUserBalanceValue() {
380
+ return this.settingsService.user.user_balance;
381
+ }
379
382
  async request() {
380
383
  const requestParams = {
381
384
  access_token: this.settingsService.token,
@@ -5020,11 +5023,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
5020
5023
  }]
5021
5024
  }], ctorParameters: function () { return [{ type: ThreeDs20Service }, { type: NextActionService }]; } });
5022
5025
 
5026
+ class FormMessagesService extends EmitDataService {
5027
+ constructor(unescapeHtmlPipe) {
5028
+ super();
5029
+ this.unescapeHtmlPipe = unescapeHtmlPipe;
5030
+ }
5031
+ emitOnResponse(messages) {
5032
+ if (!messages) {
5033
+ return;
5034
+ }
5035
+ const mapInfoMessages = (infoMessage) => this.unescapeHtmlPipe.transform(infoMessage.message);
5036
+ super.emit(messages.map(mapInfoMessages));
5037
+ }
5038
+ }
5039
+ FormMessagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormMessagesService, deps: [{ token: UnescapeHtmlPipe }], target: i0.ɵɵFactoryTarget.Injectable });
5040
+ FormMessagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormMessagesService, providedIn: 'root' });
5041
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormMessagesService, decorators: [{
5042
+ type: Injectable,
5043
+ args: [{
5044
+ providedIn: 'root',
5045
+ }]
5046
+ }], ctorParameters: function () { return [{ type: UnescapeHtmlPipe }]; } });
5047
+
5023
5048
  class PaymentService {
5024
5049
  get formFieldsStatus$() {
5025
5050
  return this.formFieldsStatusSubject.asObservable().pipe(filter$1(Boolean));
5026
5051
  }
5027
- constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService) {
5052
+ constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService, formMessagesService) {
5028
5053
  this.initializeService = initializeService;
5029
5054
  this.submitService = submitService;
5030
5055
  this.syncService = syncService;
@@ -5035,6 +5060,7 @@ class PaymentService {
5035
5060
  this.nextActionService = nextActionService;
5036
5061
  this.controlConfigService = controlConfigService;
5037
5062
  this.threeDsService = threeDsService;
5063
+ this.formMessagesService = formMessagesService;
5038
5064
  this.form = null;
5039
5065
  this.data = null;
5040
5066
  this.financeDetails = null;
@@ -5056,6 +5082,7 @@ class PaymentService {
5056
5082
  this.listenFormStatusChanges(this.form);
5057
5083
  this.emitFinanceDetails(this.data.paymentForm?.summary);
5058
5084
  this.emitFormFieldsStatus(this.form);
5085
+ this.emitFormMessages(this.data.paymentForm?.messages);
5059
5086
  return this.fields.filter((field) => field?.isVisible === "1" /* XpsBoolean.true */);
5060
5087
  }
5061
5088
  async submit() {
@@ -5070,6 +5097,7 @@ class PaymentService {
5070
5097
  const submitResponse = await this.submitService.request(this.fields, this.form);
5071
5098
  this.data = submitResponse;
5072
5099
  this.emitFinanceDetails(submitResponse.summary);
5100
+ this.emitFormMessages(submitResponse.messages);
5073
5101
  // Handle 3ds flow
5074
5102
  if (submitResponse.currentCommand === XpsCommand.create) {
5075
5103
  this.runThreeDs();
@@ -5175,12 +5203,16 @@ class PaymentService {
5175
5203
  });
5176
5204
  this.formFieldsStatusSubject.next(formFieldsStatus);
5177
5205
  }
5206
+ emitFormMessages(messages) {
5207
+ this.formMessagesService.emitOnResponse(messages);
5208
+ }
5178
5209
  setupSyncService(form, fields) {
5179
5210
  this.syncService.setup(form, fields);
5180
5211
  this.syncService.data$
5181
5212
  .pipe(takeUntil(this.destroy$))
5182
5213
  .subscribe((response) => {
5183
5214
  this.emitFinanceDetails(response.summary);
5215
+ this.emitFormMessages(response.messages);
5184
5216
  });
5185
5217
  this.syncService.fieldAsyncValidation$
5186
5218
  .pipe(takeUntil(this.destroy$))
@@ -5202,14 +5234,14 @@ class PaymentService {
5202
5234
  .subscribe(() => this.emitFormFieldsStatus(form));
5203
5235
  }
5204
5236
  }
5205
- 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 });
5237
+ 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 }, { token: FormMessagesService }], target: i0.ɵɵFactoryTarget.Injectable });
5206
5238
  PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
5207
5239
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
5208
5240
  type: Injectable,
5209
5241
  args: [{
5210
5242
  providedIn: 'root',
5211
5243
  }]
5212
- }], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: ControlConfigService }, { type: ThreeDsService }]; } });
5244
+ }], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: ControlConfigService }, { type: ThreeDsService }, { type: FormMessagesService }]; } });
5213
5245
 
5214
5246
  class RefundPolicyService {
5215
5247
  constructor(settingsService) {
@@ -5314,7 +5346,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
5314
5346
  }], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }, { type: SecureConnectionService }, { type: DisclaimerService }]; } });
5315
5347
 
5316
5348
  class CoreLibraryService {
5317
- constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService, creditCardService, creditCardStateService) {
5349
+ constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService, creditCardService, creditCardStateService, formMessagesService) {
5318
5350
  this.settingsService = settingsService;
5319
5351
  this.countryService = countryService;
5320
5352
  this.paymentMethodsService = paymentMethodsService;
@@ -5329,6 +5361,7 @@ class CoreLibraryService {
5329
5361
  this.nextActionService = nextActionService;
5330
5362
  this.creditCardService = creditCardService;
5331
5363
  this.creditCardStateService = creditCardStateService;
5364
+ this.formMessagesService = formMessagesService;
5332
5365
  this.paymentMethods = {
5333
5366
  getList: async () => this.paymentMethodsService.getList(),
5334
5367
  getQuickMethods: async () => this.paymentMethodsService.getQuickMethods(),
@@ -5366,6 +5399,7 @@ class CoreLibraryService {
5366
5399
  changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
5367
5400
  changeFieldState: (name, state) => this.paymentService.changeFieldState(name, state),
5368
5401
  updateFieldFormState: (fieldName, formState) => this.paymentService.updateFieldFormState(fieldName, formState),
5402
+ formMessages$: this.formMessagesService.data$,
5369
5403
  },
5370
5404
  };
5371
5405
  }
@@ -5392,15 +5426,18 @@ class CoreLibraryService {
5392
5426
  const sanitizedName = field.name.replace(/^fix_/i, '');
5393
5427
  return masksFunctionsMap[sanitizedName];
5394
5428
  }
5429
+ getUserBalanceValue() {
5430
+ return this.userBalanceService.getUserBalanceValue();
5431
+ }
5395
5432
  }
5396
- 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 });
5433
+ 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 }, { token: FormMessagesService }], target: i0.ɵɵFactoryTarget.Injectable });
5397
5434
  CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
5398
5435
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
5399
5436
  type: Injectable,
5400
5437
  args: [{
5401
5438
  providedIn: 'root',
5402
5439
  }]
5403
- }], 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 }]; } });
5440
+ }], 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 }, { type: FormMessagesService }]; } });
5404
5441
 
5405
5442
  class HttpError extends AppError {
5406
5443
  constructor(error, req) {