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

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,29 @@ 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
+ emitOnResponse(messages) {
5028
+ if (!messages) {
5029
+ return;
5030
+ }
5031
+ const mapInfoMessages = (infoMessage) => infoMessage.message;
5032
+ super.emit(messages.map(mapInfoMessages));
5033
+ }
5034
+ }
5035
+ FormMessagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormMessagesService, deps: null, target: i0.ɵɵFactoryTarget.Injectable });
5036
+ FormMessagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormMessagesService, providedIn: 'root' });
5037
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormMessagesService, decorators: [{
5038
+ type: Injectable,
5039
+ args: [{
5040
+ providedIn: 'root',
5041
+ }]
5042
+ }] });
5043
+
5023
5044
  class PaymentService {
5024
5045
  get formFieldsStatus$() {
5025
5046
  return this.formFieldsStatusSubject.asObservable().pipe(filter$1(Boolean));
5026
5047
  }
5027
- constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService) {
5048
+ constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService, formMessagesService) {
5028
5049
  this.initializeService = initializeService;
5029
5050
  this.submitService = submitService;
5030
5051
  this.syncService = syncService;
@@ -5035,6 +5056,7 @@ class PaymentService {
5035
5056
  this.nextActionService = nextActionService;
5036
5057
  this.controlConfigService = controlConfigService;
5037
5058
  this.threeDsService = threeDsService;
5059
+ this.formMessagesService = formMessagesService;
5038
5060
  this.form = null;
5039
5061
  this.data = null;
5040
5062
  this.financeDetails = null;
@@ -5056,6 +5078,7 @@ class PaymentService {
5056
5078
  this.listenFormStatusChanges(this.form);
5057
5079
  this.emitFinanceDetails(this.data.paymentForm?.summary);
5058
5080
  this.emitFormFieldsStatus(this.form);
5081
+ this.emitFormMessages(this.data.paymentForm?.messages);
5059
5082
  return this.fields.filter((field) => field?.isVisible === "1" /* XpsBoolean.true */);
5060
5083
  }
5061
5084
  async submit() {
@@ -5070,6 +5093,7 @@ class PaymentService {
5070
5093
  const submitResponse = await this.submitService.request(this.fields, this.form);
5071
5094
  this.data = submitResponse;
5072
5095
  this.emitFinanceDetails(submitResponse.summary);
5096
+ this.emitFormMessages(submitResponse.messages);
5073
5097
  // Handle 3ds flow
5074
5098
  if (submitResponse.currentCommand === XpsCommand.create) {
5075
5099
  this.runThreeDs();
@@ -5175,12 +5199,16 @@ class PaymentService {
5175
5199
  });
5176
5200
  this.formFieldsStatusSubject.next(formFieldsStatus);
5177
5201
  }
5202
+ emitFormMessages(messages) {
5203
+ this.formMessagesService.emitOnResponse(messages);
5204
+ }
5178
5205
  setupSyncService(form, fields) {
5179
5206
  this.syncService.setup(form, fields);
5180
5207
  this.syncService.data$
5181
5208
  .pipe(takeUntil(this.destroy$))
5182
5209
  .subscribe((response) => {
5183
5210
  this.emitFinanceDetails(response.summary);
5211
+ this.emitFormMessages(response.messages);
5184
5212
  });
5185
5213
  this.syncService.fieldAsyncValidation$
5186
5214
  .pipe(takeUntil(this.destroy$))
@@ -5202,14 +5230,14 @@ class PaymentService {
5202
5230
  .subscribe(() => this.emitFormFieldsStatus(form));
5203
5231
  }
5204
5232
  }
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 });
5233
+ 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
5234
  PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
5207
5235
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
5208
5236
  type: Injectable,
5209
5237
  args: [{
5210
5238
  providedIn: 'root',
5211
5239
  }]
5212
- }], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: ControlConfigService }, { type: ThreeDsService }]; } });
5240
+ }], 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
5241
 
5214
5242
  class RefundPolicyService {
5215
5243
  constructor(settingsService) {
@@ -5314,7 +5342,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
5314
5342
  }], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }, { type: SecureConnectionService }, { type: DisclaimerService }]; } });
5315
5343
 
5316
5344
  class CoreLibraryService {
5317
- constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService, creditCardService, creditCardStateService) {
5345
+ constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService, creditCardService, creditCardStateService, formMessagesService) {
5318
5346
  this.settingsService = settingsService;
5319
5347
  this.countryService = countryService;
5320
5348
  this.paymentMethodsService = paymentMethodsService;
@@ -5329,6 +5357,7 @@ class CoreLibraryService {
5329
5357
  this.nextActionService = nextActionService;
5330
5358
  this.creditCardService = creditCardService;
5331
5359
  this.creditCardStateService = creditCardStateService;
5360
+ this.formMessagesService = formMessagesService;
5332
5361
  this.paymentMethods = {
5333
5362
  getList: async () => this.paymentMethodsService.getList(),
5334
5363
  getQuickMethods: async () => this.paymentMethodsService.getQuickMethods(),
@@ -5366,6 +5395,7 @@ class CoreLibraryService {
5366
5395
  changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
5367
5396
  changeFieldState: (name, state) => this.paymentService.changeFieldState(name, state),
5368
5397
  updateFieldFormState: (fieldName, formState) => this.paymentService.updateFieldFormState(fieldName, formState),
5398
+ formMessages$: this.formMessagesService.data$,
5369
5399
  },
5370
5400
  };
5371
5401
  }
@@ -5392,15 +5422,18 @@ class CoreLibraryService {
5392
5422
  const sanitizedName = field.name.replace(/^fix_/i, '');
5393
5423
  return masksFunctionsMap[sanitizedName];
5394
5424
  }
5425
+ getUserBalanceValue() {
5426
+ return this.userBalanceService.getUserBalanceValue();
5427
+ }
5395
5428
  }
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 });
5429
+ 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
5430
  CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
5398
5431
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
5399
5432
  type: Injectable,
5400
5433
  args: [{
5401
5434
  providedIn: 'root',
5402
5435
  }]
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 }]; } });
5436
+ }], 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
5437
 
5405
5438
  class HttpError extends AppError {
5406
5439
  constructor(error, req) {