@xsolla/payment-client-core 0.1.13 → 0.1.14-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.
@@ -238,18 +238,19 @@ class PaymentMethodsService {
238
238
  this.apiRoute = 'remained_payment_methods';
239
239
  this.cache = new Map();
240
240
  }
241
- async getList() {
242
- const response = await this.request();
241
+ async getList(isSaveMethodMode) {
242
+ const response = await this.request(isSaveMethodMode);
243
243
  return response.remained;
244
244
  }
245
245
  async getQuickMethods() {
246
246
  const response = await this.request();
247
247
  return response.especial;
248
248
  }
249
- async request() {
249
+ async request(isSaveMethodMode) {
250
250
  const requestParams = {
251
251
  access_token: this.settingsService.token,
252
252
  country: this.countryService.getCountry(),
253
+ save_payment_account_only: isSaveMethodMode ? "1" /* XpsBoolean.true */ : "0" /* XpsBoolean.false */
253
254
  };
254
255
  const cacheKey = JSON.stringify(requestParams);
255
256
  if (!this.cache.has(cacheKey)) {
@@ -5023,11 +5024,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
5023
5024
  }]
5024
5025
  }], ctorParameters: function () { return [{ type: ThreeDs20Service }, { type: NextActionService }]; } });
5025
5026
 
5027
+ class FormMessagesService extends EmitDataService {
5028
+ constructor(unescapeHtmlPipe) {
5029
+ super();
5030
+ this.unescapeHtmlPipe = unescapeHtmlPipe;
5031
+ }
5032
+ emitOnResponse(messages) {
5033
+ if (!messages) {
5034
+ return;
5035
+ }
5036
+ const mapInfoMessages = (infoMessage) => this.unescapeHtmlPipe.transform(infoMessage.message);
5037
+ super.emit(messages.map(mapInfoMessages));
5038
+ }
5039
+ }
5040
+ FormMessagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormMessagesService, deps: [{ token: UnescapeHtmlPipe }], target: i0.ɵɵFactoryTarget.Injectable });
5041
+ FormMessagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormMessagesService, providedIn: 'root' });
5042
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: FormMessagesService, decorators: [{
5043
+ type: Injectable,
5044
+ args: [{
5045
+ providedIn: 'root',
5046
+ }]
5047
+ }], ctorParameters: function () { return [{ type: UnescapeHtmlPipe }]; } });
5048
+
5026
5049
  class PaymentService {
5027
5050
  get formFieldsStatus$() {
5028
5051
  return this.formFieldsStatusSubject.asObservable().pipe(filter$1(Boolean));
5029
5052
  }
5030
- constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService) {
5053
+ constructor(initializeService, submitService, syncService, formService, statusService, financeDetailsService, creditCardStateService, nextActionService, controlConfigService, threeDsService, formMessagesService) {
5031
5054
  this.initializeService = initializeService;
5032
5055
  this.submitService = submitService;
5033
5056
  this.syncService = syncService;
@@ -5038,6 +5061,7 @@ class PaymentService {
5038
5061
  this.nextActionService = nextActionService;
5039
5062
  this.controlConfigService = controlConfigService;
5040
5063
  this.threeDsService = threeDsService;
5064
+ this.formMessagesService = formMessagesService;
5041
5065
  this.form = null;
5042
5066
  this.data = null;
5043
5067
  this.financeDetails = null;
@@ -5059,6 +5083,7 @@ class PaymentService {
5059
5083
  this.listenFormStatusChanges(this.form);
5060
5084
  this.emitFinanceDetails(this.data.paymentForm?.summary);
5061
5085
  this.emitFormFieldsStatus(this.form);
5086
+ this.emitFormMessages(this.data.paymentForm?.messages);
5062
5087
  return this.fields.filter((field) => field?.isVisible === "1" /* XpsBoolean.true */);
5063
5088
  }
5064
5089
  async submit() {
@@ -5073,6 +5098,7 @@ class PaymentService {
5073
5098
  const submitResponse = await this.submitService.request(this.fields, this.form);
5074
5099
  this.data = submitResponse;
5075
5100
  this.emitFinanceDetails(submitResponse.summary);
5101
+ this.emitFormMessages(submitResponse.messages);
5076
5102
  // Handle 3ds flow
5077
5103
  if (submitResponse.currentCommand === XpsCommand.create) {
5078
5104
  this.runThreeDs();
@@ -5178,12 +5204,16 @@ class PaymentService {
5178
5204
  });
5179
5205
  this.formFieldsStatusSubject.next(formFieldsStatus);
5180
5206
  }
5207
+ emitFormMessages(messages) {
5208
+ this.formMessagesService.emitOnResponse(messages);
5209
+ }
5181
5210
  setupSyncService(form, fields) {
5182
5211
  this.syncService.setup(form, fields);
5183
5212
  this.syncService.data$
5184
5213
  .pipe(takeUntil(this.destroy$))
5185
5214
  .subscribe((response) => {
5186
5215
  this.emitFinanceDetails(response.summary);
5216
+ this.emitFormMessages(response.messages);
5187
5217
  });
5188
5218
  this.syncService.fieldAsyncValidation$
5189
5219
  .pipe(takeUntil(this.destroy$))
@@ -5205,14 +5235,14 @@ class PaymentService {
5205
5235
  .subscribe(() => this.emitFormFieldsStatus(form));
5206
5236
  }
5207
5237
  }
5208
- 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 });
5238
+ 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 });
5209
5239
  PaymentService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, providedIn: 'root' });
5210
5240
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentService, decorators: [{
5211
5241
  type: Injectable,
5212
5242
  args: [{
5213
5243
  providedIn: 'root',
5214
5244
  }]
5215
- }], ctorParameters: function () { return [{ type: InitializeService }, { type: SubmitService }, { type: SyncService }, { type: FormService }, { type: StatusService }, { type: FinanceDetailsService }, { type: CreditCardStateService }, { type: NextActionService }, { type: ControlConfigService }, { type: ThreeDsService }]; } });
5245
+ }], 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 }]; } });
5216
5246
 
5217
5247
  class RefundPolicyService {
5218
5248
  constructor(settingsService) {
@@ -5317,7 +5347,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
5317
5347
  }], ctorParameters: function () { return [{ type: SettingsService }, { type: RefundPolicyService }, { type: SecureConnectionService }, { type: DisclaimerService }]; } });
5318
5348
 
5319
5349
  class CoreLibraryService {
5320
- constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService, creditCardService, creditCardStateService) {
5350
+ constructor(settingsService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService, creditCardService, creditCardStateService, formMessagesService) {
5321
5351
  this.settingsService = settingsService;
5322
5352
  this.countryService = countryService;
5323
5353
  this.paymentMethodsService = paymentMethodsService;
@@ -5332,8 +5362,9 @@ class CoreLibraryService {
5332
5362
  this.nextActionService = nextActionService;
5333
5363
  this.creditCardService = creditCardService;
5334
5364
  this.creditCardStateService = creditCardStateService;
5365
+ this.formMessagesService = formMessagesService;
5335
5366
  this.paymentMethods = {
5336
- getList: async () => this.paymentMethodsService.getList(),
5367
+ getList: async (isSaveMethodMode) => this.paymentMethodsService.getList(isSaveMethodMode),
5337
5368
  getQuickMethods: async () => this.paymentMethodsService.getQuickMethods(),
5338
5369
  getSavedMethods: async () => this.savedMethodsService.getList(),
5339
5370
  getUserBalance: async () => this.userBalanceService.getUserBalance(),
@@ -5369,6 +5400,7 @@ class CoreLibraryService {
5369
5400
  changeFieldValue: (name, value) => this.paymentService.changeFieldValue(name, value),
5370
5401
  changeFieldState: (name, state) => this.paymentService.changeFieldState(name, state),
5371
5402
  updateFieldFormState: (fieldName, formState) => this.paymentService.updateFieldFormState(fieldName, formState),
5403
+ formMessages$: this.formMessagesService.data$,
5372
5404
  },
5373
5405
  };
5374
5406
  }
@@ -5399,14 +5431,14 @@ class CoreLibraryService {
5399
5431
  return this.userBalanceService.getUserBalanceValue();
5400
5432
  }
5401
5433
  }
5402
- 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 });
5434
+ 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 });
5403
5435
  CoreLibraryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, providedIn: 'root' });
5404
5436
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CoreLibraryService, decorators: [{
5405
5437
  type: Injectable,
5406
5438
  args: [{
5407
5439
  providedIn: 'root',
5408
5440
  }]
5409
- }], 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 }]; } });
5441
+ }], 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 }]; } });
5410
5442
 
5411
5443
  class HttpError extends AppError {
5412
5444
  constructor(error, req) {