@xsolla/payment-client-core 0.1.14-test13 → 0.1.14-test15

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.
@@ -1,11 +1,11 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, Injectable, Inject, Pipe, isDevMode, NgModule } from '@angular/core';
3
- import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, skip, throwError } from 'rxjs';
3
+ import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, catchError, skip, throwError } from 'rxjs';
4
4
  import * as i1 from '@angular/common/http';
5
5
  import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
6
6
  import JSEncrypt from 'jsencrypt';
7
7
  import { UntypedFormGroup, Validators, UntypedFormControl, ReactiveFormsModule } from '@angular/forms';
8
- import { filter, map as map$1, tap, catchError } from 'rxjs/operators';
8
+ import { filter, map as map$1, tap, catchError as catchError$1 } from 'rxjs/operators';
9
9
  import * as i1$1 from '@angular/router';
10
10
  import { CommonModule } from '@angular/common';
11
11
 
@@ -3890,7 +3890,7 @@ const checkStatusResponseFactoryProvider = {
3890
3890
  useValue: (...args) => new CheckStatusResponse(...args),
3891
3891
  };
3892
3892
 
3893
- class CheckStatusService extends XpsApiPart {
3893
+ let CheckStatusService$1 = class CheckStatusService extends XpsApiPart {
3894
3894
  constructor(xpsApiService, settingsService, xpsResponseErrorsMappingService, requestFactory, responseFactory) {
3895
3895
  super();
3896
3896
  this.xpsApiService = xpsApiService;
@@ -3919,10 +3919,10 @@ class CheckStatusService extends XpsApiPart {
3919
3919
  throw new ResponseError(error.message);
3920
3920
  });
3921
3921
  }
3922
- }
3923
- CheckStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, deps: [{ token: XpsApiService }, { token: SettingsService }, { token: XpsResponseErrorsMappingService }, { token: checkStatusRequestFactoryToken }, { token: checkStatusResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
3924
- CheckStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, providedIn: 'root' });
3925
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, decorators: [{
3922
+ };
3923
+ CheckStatusService$1.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService$1, deps: [{ token: XpsApiService }, { token: SettingsService }, { token: XpsResponseErrorsMappingService }, { token: checkStatusRequestFactoryToken }, { token: checkStatusResponseFactoryToken }], target: i0.ɵɵFactoryTarget.Injectable });
3924
+ CheckStatusService$1.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService$1, providedIn: 'root' });
3925
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService$1, decorators: [{
3926
3926
  type: Injectable,
3927
3927
  args: [{
3928
3928
  providedIn: 'root',
@@ -4559,14 +4559,14 @@ class ListenStatusService {
4559
4559
  this.websocketOpenedSubject.next(statusSettings);
4560
4560
  }
4561
4561
  }
4562
- ListenStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ListenStatusService, deps: [{ token: StatusRequestService }, { token: CheckStatusService }, { token: WebsocketStatusService }], target: i0.ɵɵFactoryTarget.Injectable });
4562
+ ListenStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ListenStatusService, deps: [{ token: StatusRequestService }, { token: CheckStatusService$1 }, { token: WebsocketStatusService }], target: i0.ɵɵFactoryTarget.Injectable });
4563
4563
  ListenStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ListenStatusService, providedIn: 'root' });
4564
4564
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: ListenStatusService, decorators: [{
4565
4565
  type: Injectable,
4566
4566
  args: [{
4567
4567
  providedIn: 'root',
4568
4568
  }]
4569
- }], ctorParameters: function () { return [{ type: StatusRequestService }, { type: CheckStatusService }, { type: WebsocketStatusService }]; } });
4569
+ }], ctorParameters: function () { return [{ type: StatusRequestService }, { type: CheckStatusService$1 }, { type: WebsocketStatusService }]; } });
4570
4570
 
4571
4571
  var TitleClass;
4572
4572
  (function (TitleClass) {
@@ -4623,16 +4623,118 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImpor
4623
4623
  }]
4624
4624
  }], ctorParameters: function () { return [{ type: SettingsService }, { type: SecureApiClient }]; } });
4625
4625
 
4626
+ // import { SessionService } from '../session/session.service';
4627
+ // import { StateService } from '../state.service';
4628
+ // import { ElkLoggerService } from '../analytics/elk-logger.service';
4629
+ // import { AppError } from '../../../models/app-error.model';
4630
+ // import { SerializationHelper } from '../../../helpers/serialization.helper';
4631
+ // import { AppConfig } from '../../../models/app-config.model';
4632
+ // import { Observable } from 'rxjs/Observable';
4633
+ // import { ApiOptions } from './api-options.interface';
4634
+ // import { defaultApiUrl, sandboxApiUrl } from './api-url.const';
4635
+ class CheckStatusService {
4636
+ constructor(http) {
4637
+ this.http = http;
4638
+ this.apiUrl = sandboxApiUrl;
4639
+ }
4640
+ // public getRequestParams() {
4641
+ // return this.session.getRequest();
4642
+ // }
4643
+ /**
4644
+ * Запрос
4645
+ * @param route
4646
+ * @param params
4647
+ * @param options
4648
+ * @returns {Observable<any>}
4649
+ */
4650
+ request(route, params = {}, options = {}) {
4651
+ params = Object.assign({}, params);
4652
+ Object.keys(params).forEach((key) => {
4653
+ if (!params[key]) {
4654
+ delete params[key];
4655
+ }
4656
+ });
4657
+ // const postData = SerializationHelper.paramSerializerJQLike(params);
4658
+ // const postData = params;
4659
+ const postData = new URLSearchParams(params);
4660
+ const observable$ = this.http.post(this.apiUrl + route, postData, {
4661
+ headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8'),
4662
+ responseType: 'json'
4663
+ }).pipe(map((data) => {
4664
+ const newData = { ...data };
4665
+ if ((data.api || {}).ver !== '1.0.1') {
4666
+ // Non PayStation API answer
4667
+ // this.elkLoggerService.sendHttpError('Invalid PayStation API answer', data);
4668
+ throw new Error();
4669
+ }
4670
+ delete newData.api;
4671
+ return newData;
4672
+ }), catchError((response) => {
4673
+ // HTTP Error, Fatal PayStation API error
4674
+ // this.elkLoggerService.sendHttpError('HTTP Error', response);
4675
+ throw {
4676
+ errors: response.error && response.error.errors,
4677
+ httpCode: response.status
4678
+ };
4679
+ }));
4680
+ // .catch((response: any) => {
4681
+ // // HTTP Error, Fatal PayStation API error
4682
+ // this.elkLoggerService.sendHttpError('HTTP Error', response);
4683
+ // throw {
4684
+ // errors: response.error && response.error.errors,
4685
+ // httpCode: response.status
4686
+ // };
4687
+ // });
4688
+ // if (options.catchError) {
4689
+ // observable$.catch((reason) => {
4690
+ // this.state.showError((reason || {}).errors ||
4691
+ // (new AppError(this.translate.instant('api_error_message'), '10000001')));
4692
+ //
4693
+ // return Observable.of();
4694
+ // });
4695
+ // }
4696
+ return observable$;
4697
+ }
4698
+ /**
4699
+ * Запрос
4700
+ * @param route
4701
+ * @param params
4702
+ * @param options
4703
+ * @returns {Promise<any>}
4704
+ */
4705
+ requestPromise(route, params = {}, options = {}) {
4706
+ return this.request(route, params, options).toPromise();
4707
+ }
4708
+ }
4709
+ CheckStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
4710
+ CheckStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, providedIn: 'root' });
4711
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: CheckStatusService, decorators: [{
4712
+ type: Injectable,
4713
+ args: [{
4714
+ providedIn: 'root',
4715
+ }]
4716
+ }], ctorParameters: function () { return [{ type: i1.HttpClient }]; } });
4717
+
4626
4718
  class SavePaymentMethodStatusService {
4627
- constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService) {
4719
+ constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService, checkStatusService) {
4628
4720
  this.statusRequestService = statusRequestService;
4629
4721
  this.listenStatusService = listenStatusService;
4630
4722
  this.savedPaymentAccountChangesService = savedPaymentAccountChangesService;
4631
4723
  this.nextActionService = nextActionService;
4724
+ this.checkStatusService = checkStatusService;
4632
4725
  }
4633
4726
  async getStatus(params) {
4634
4727
  console.log('getStatus', params);
4635
4728
  this.statusRequestService.setRequestParams(params);
4729
+ const paramsCheck = {
4730
+ section: 'getstatus',
4731
+ action: 'getstatus',
4732
+ // invoice: params.invoice,
4733
+ ...params,
4734
+ access_token: params.token
4735
+ };
4736
+ const check = await this.checkStatusService.requestPromise('directpayment', paramsCheck);
4737
+ console.log('requestPromise', check);
4636
4738
  // todo: get account
4637
4739
  const accountData = await this.getPaymentAccountData(params.invoice);
4638
4740
  // this.startWaitingStatusUpdates(params.invoice);
@@ -4640,16 +4742,15 @@ class SavePaymentMethodStatusService {
4640
4742
  const statusResponse = await firstValueFrom(this.statusRequestService.response$);
4641
4743
  // const savingFailedOrCancel = statusResponse.status?.titleClass === TitleClass.cancel || statusResponse.status?.titleClass === TitleClass.cancelUser;
4642
4744
  // const savingSuccessful = statusResponse.status?.titleClass === TitleClass.done && accountData?.new_account;
4643
- if (!accountData) {
4644
- this.startWaitingStatusUpdates(params.invoice);
4645
- statusResponse.status.statusState = StatusEnum.processing;
4646
- }
4647
- // if (!this.savingFailedOrCancel(statusResponse?.status) && !this.savingSuccessful(accountData, statusResponse?.status)) {
4648
- // // todo is proccessing
4649
- //
4745
+ // if (!accountData) {
4650
4746
  // this.startWaitingStatusUpdates(params.invoice);
4651
4747
  // statusResponse.status.statusState = StatusEnum.processing;
4652
4748
  // }
4749
+ if (!this.savingFailedOrCancel(statusResponse?.status) && !this.savingSuccessful(accountData, statusResponse?.status)) {
4750
+ // todo is proccessing
4751
+ this.startWaitingStatusUpdates(params.invoice);
4752
+ statusResponse.status.statusState = StatusEnum.processing;
4753
+ }
4653
4754
  statusResponse.status.isSavePaymentAccount = true;
4654
4755
  return statusResponse.status;
4655
4756
  // if (!this.savePaymentMethodStatus) {
@@ -4713,14 +4814,14 @@ class SavePaymentMethodStatusService {
4713
4814
  this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
4714
4815
  }
4715
4816
  }
4716
- SavePaymentMethodStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, deps: [{ token: StatusRequestService }, { token: ListenStatusService }, { token: SavedPaymentAccountChangesService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
4817
+ SavePaymentMethodStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, deps: [{ token: StatusRequestService }, { token: ListenStatusService }, { token: SavedPaymentAccountChangesService }, { token: NextActionService }, { token: CheckStatusService }], target: i0.ɵɵFactoryTarget.Injectable });
4717
4818
  SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, providedIn: 'root' });
4718
4819
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
4719
4820
  type: Injectable,
4720
4821
  args: [{
4721
4822
  providedIn: 'root'
4722
4823
  }]
4723
- }], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }]; } });
4824
+ }], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }, { type: CheckStatusService }]; } });
4724
4825
 
4725
4826
  class StatusService {
4726
4827
  constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService) {
@@ -5677,7 +5778,7 @@ class HttpExceptionsInterceptor {
5677
5778
  this.router = router;
5678
5779
  }
5679
5780
  intercept(req, next) {
5680
- return next.handle(req).pipe(catchError((error) => {
5781
+ return next.handle(req).pipe(catchError$1((error) => {
5681
5782
  return throwError(() => new HttpError(error, req));
5682
5783
  }));
5683
5784
  }