@xsolla/payment-client-core 0.1.14-test21 → 0.1.14-test3

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.
Files changed (27) hide show
  1. package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
  2. package/esm2020/lib/core/payment/payment.service.mjs +3 -9
  3. package/esm2020/lib/core/payment/status/save-payment-method-status/api/saved-payment-account-changes.service.mjs +3 -6
  4. package/esm2020/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.mjs +17 -153
  5. package/esm2020/lib/core/payment/status/status-request/status-request-params.interface.mjs +1 -1
  6. package/esm2020/lib/core/payment/status/status-request/status-search-param.enum.mjs +2 -2
  7. package/esm2020/lib/core/payment/status/status-request/status-search-params.map.mjs +3 -3
  8. package/esm2020/lib/core/payment/status/status.interface.mjs +1 -1
  9. package/esm2020/lib/core/payment/status/status.service.mjs +2 -3
  10. package/esm2020/lib/core/payment/submit/response/submit-response.class.mjs +8 -2
  11. package/esm2020/lib/core-library.service.mjs +1 -1
  12. package/fesm2015/xsolla-payment-client-core.mjs +31 -172
  13. package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
  14. package/fesm2020/xsolla-payment-client-core.mjs +30 -169
  15. package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
  16. package/lib/core/payment/payment.interface.d.ts +1 -1
  17. package/lib/core/payment/payment.service.d.ts +1 -2
  18. package/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.d.ts +1 -10
  19. package/lib/core/payment/status/status-request/status-request-params.interface.d.ts +1 -1
  20. package/lib/core/payment/status/status-request/status-search-param.enum.d.ts +1 -1
  21. package/lib/core/payment/status/status.interface.d.ts +0 -1
  22. package/lib/core/payment/status/status.service.d.ts +2 -2
  23. package/lib/core/payment/submit/response/submit-response.class.d.ts +1 -0
  24. package/lib/core-library.service.d.ts +1 -1
  25. package/package.json +1 -1
  26. package/xsolla-payment-client-core-0.1.14-test3.tgz +0 -0
  27. package/xsolla-payment-client-core-0.1.14-test21.tgz +0 -0
@@ -555,9 +555,15 @@ var FieldNames;
555
555
  class SubmitResponse {
556
556
  constructor(parameters, responseNumber = 0) {
557
557
  this.responseNumber = responseNumber;
558
+ this.isSavingMethodMode = false;
558
559
  /* Todo split into properties */
559
560
  this.parameters = parameters;
560
- this.fields = Object.keys(parameters.form).map((key) => parameters.form[key]);
561
+ this.fields = Object.keys(parameters.form).map((key) => {
562
+ if (key === 'save_payment_account_only') {
563
+ this.isSavingMethodMode = parameters.form[key].value === "1" /* XpsBoolean.true */;
564
+ }
565
+ return parameters.form[key];
566
+ });
561
567
  if (parameters.onlineBanking) {
562
568
  this.onlineBanking = {
563
569
  url: parameters.onlineBanking.value,
@@ -2960,7 +2966,7 @@ var StatusSearchParam;
2960
2966
  StatusSearchParam["testPs"] = "fix_testPs";
2961
2967
  StatusSearchParam["testXsolla"] = "fix_testXsolla";
2962
2968
  StatusSearchParam["userReturnStatus"] = "fix_userReturnStatus";
2963
- StatusSearchParam["isSavePaymentAccount"] = "isSavePaymentAccount";
2969
+ StatusSearchParam["savePaymentMethod"] = "savePaymentMethod";
2964
2970
  })(StatusSearchParam || (StatusSearchParam = {}));
2965
2971
 
2966
2972
  const requiredStatusSearchParams = [
@@ -3041,9 +3047,9 @@ const statusSearchParamsMap = new Map([
3041
3047
  },
3042
3048
  ],
3043
3049
  [
3044
- StatusSearchParam.isSavePaymentAccount,
3050
+ StatusSearchParam.savePaymentMethod,
3045
3051
  {
3046
- key: 'isSavePaymentAccount',
3052
+ key: 'savePaymentMethod',
3047
3053
  converter: numberConverter,
3048
3054
  },
3049
3055
  ],
@@ -4615,166 +4621,39 @@ class SavedPaymentAccountChangesService {
4615
4621
  }
4616
4622
  }
4617
4623
  SavedPaymentAccountChangesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, deps: [{ token: SettingsService }, { token: SecureApiClient }], target: i0.ɵɵFactoryTarget.Injectable });
4618
- SavedPaymentAccountChangesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, providedIn: 'root' });
4624
+ SavedPaymentAccountChangesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService });
4619
4625
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, decorators: [{
4620
- type: Injectable,
4621
- args: [{
4622
- providedIn: 'root'
4623
- }]
4626
+ type: Injectable
4624
4627
  }], ctorParameters: function () { return [{ type: SettingsService }, { type: SecureApiClient }]; } });
4625
4628
 
4626
4629
  class SavePaymentMethodStatusService {
4627
- constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService, checkStatusService) {
4630
+ constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService) {
4628
4631
  this.statusRequestService = statusRequestService;
4629
4632
  this.listenStatusService = listenStatusService;
4630
4633
  this.savedPaymentAccountChangesService = savedPaymentAccountChangesService;
4631
4634
  this.nextActionService = nextActionService;
4632
- this.checkStatusService = checkStatusService;
4633
- this.statusChecked = false;
4634
4635
  }
4635
4636
  async getStatus(params) {
4636
- if (this.listenStatusSubscription) {
4637
- this.listenStatusSubscription.unsubscribe();
4638
- this.listenStatusService.stopListening();
4639
- }
4640
4637
  this.statusRequestService.setRequestParams(params);
4641
- this.statusRequestService.request();
4642
- const statusResponse = await firstValueFrom(this.statusRequestService.response$);
4643
- statusResponse.status.isSavePaymentAccount = true;
4644
- // this.listenStatusService.stopListening();
4645
- const accountData = await this.getPaymentAccountData(params.invoice);
4646
- if (this.savingFailedOrCancel(statusResponse?.status) || this.savingSuccessful(accountData, statusResponse?.status)) {
4647
- return statusResponse.status;
4648
- }
4649
- if (!this.statusChecked) {
4650
- this.checkStatus(params);
4651
- statusResponse.status.statusState = StatusEnum.processing;
4652
- return statusResponse.status;
4653
- }
4654
- statusResponse.status.statusState = StatusEnum.error;
4655
- return statusResponse.status;
4656
- }
4657
- checkStatus(params) {
4658
- if (!this.statusChecked) {
4659
- this.statusChecked = true;
4660
- }
4661
4638
  this.startWaitingStatusUpdates(params.invoice);
4662
4639
  this.statusRequestService.request();
4663
- }
4664
- async getStatusOld(params) {
4665
- console.log('getStatus', params);
4666
- this.statusRequestService.setRequestParams(params);
4667
- // this.startWaitingStatusUpdates(params.invoice);
4668
- this.statusRequestService.request();
4669
4640
  const statusResponse = await firstValueFrom(this.statusRequestService.response$);
4670
- this.checkStatusService.setRequestParams(params.invoice);
4671
- this.checkStatusService.request();
4672
- const checkStatusResponse = await firstValueFrom(this.checkStatusService.response$);
4673
- if (!checkStatusResponse.final) {
4674
- this.startWaitingStatusUpdates(params.invoice);
4675
- statusResponse.status.isSavePaymentAccount = true;
4676
- statusResponse.status.statusState = StatusEnum.processing;
4677
- return statusResponse.status;
4678
- }
4679
- // todo: get account
4680
- const accountData = await this.getPaymentAccountData(params.invoice);
4681
- if (!this.savingFailedOrCancel(statusResponse?.status) && !this.savingSuccessful(accountData, statusResponse?.status)) {
4682
- // todo is proccessing
4683
- this.startWaitingStatusUpdates(params.invoice);
4641
+ if (!this.savePaymentMethodStatus) {
4684
4642
  statusResponse.status.statusState = StatusEnum.processing;
4685
4643
  }
4686
- statusResponse.status.isSavePaymentAccount = true;
4687
4644
  return statusResponse.status;
4688
- // this.listenStatusService.listen(params.invoice);
4689
- // this.statusRequestService.request();
4690
- // const paramsCheck = {
4691
- // section: 'getstatus',
4692
- // action: 'getstatus',
4693
- // // invoice: params.invoice,
4694
- // ...params,
4695
- // access_token: params.token || '8sogPLisB328Snf9M9aChSwkZn4IzOzf_lc_en'
4696
- // };
4697
- // // const check = await this.checkStatusService.requestPromise('directpayment', paramsCheck);
4698
- // // console.log('requestPromise', check);
4699
- // // todo: get account
4700
- // // const accountData = await this.getPaymentAccountData(params.invoice);
4701
- // // this.startWaitingStatusUpdates(params.invoice);
4702
- // // this.listenStatusService.statusUpdated$
4703
- // this.startWaitingStatusUpdates(params.invoice);
4704
- // this.statusRequestService.request();
4705
- // this.checkStatusService.setRequestParams(params.invoice);
4706
- // this.checkStatusService.request();
4707
- // this.checkStatusService.response$.subscribe((resp) => {
4708
- // console.log('checkSt', resp);
4709
- // });
4710
- // const statusResponse = await firstValueFrom(
4711
- // this.statusRequestService.response$
4712
- // );
4713
- // const savingFailedOrCancel = statusResponse.status?.titleClass === TitleClass.cancel || statusResponse.status?.titleClass === TitleClass.cancelUser;
4714
- // const savingSuccessful = statusResponse.status?.titleClass === TitleClass.done && accountData?.new_account;
4715
- // if (!accountData) {
4716
- // this.startWaitingStatusUpdates(params.invoice);
4717
- // statusResponse.status.statusState = StatusEnum.processing;
4718
- // }
4719
- // if (!this.savingFailedOrCancel(statusResponse?.status) && !this.savingSuccessful(accountData, statusResponse?.status)) {
4720
- // // todo is proccessing
4721
- //
4722
- // // this.startWaitingStatusUpdates(params.invoice);
4723
- // statusResponse.status.statusState = StatusEnum.processing;
4724
- // }
4725
- // statusResponse.status.isSavePaymentAccount = true;
4726
- // return statusResponse.status;
4727
- // return null;
4728
- // if (!this.savePaymentMethodStatus) {
4729
- // statusResponse.status.statusState = StatusEnum.processing;
4730
- // }
4731
- // statusResponse.status.isSavePaymentAccount = true;
4732
- // return statusResponse.status;
4733
- }
4734
- savingFailedOrCancel(status) {
4735
- return status?.titleClass === TitleClass.cancel || status?.titleClass === TitleClass.cancelUser;
4736
- }
4737
- savingSuccessful(accountData, status, checkStatus) {
4738
- return !!(status?.titleClass === TitleClass.done && (accountData?.new_account || checkStatus?.isPaymentAccountAttached));
4739
- }
4740
- getPaymentAccountData(invoice) {
4741
- return this.savedPaymentAccountChangesService
4742
- .request(invoice);
4743
- // .then((accountChanges: SavedPaymentAccountChanges) => {
4744
- // if (accountChanges) {
4745
- // this.handleSavingStatus(status, accountChanges.new_account);
4746
- // }
4747
- // });
4748
4645
  }
4749
4646
  startWaitingStatusUpdates(invoice) {
4750
- if (this.listenStatusSubscription) {
4751
- this.listenStatusSubscription.unsubscribe();
4752
- this.listenStatusService.stopListening();
4753
- }
4754
- // debugger
4755
4647
  this.listenStatusService.listen(invoice);
4756
- this.listenStatusSubscription = this.listenStatusService.statusUpdated$
4757
- .subscribe((statusSettings) => {
4758
- // this.checkStatusService.response$.subscribe((res) => {
4759
- // if (res.final) {
4760
- // if (statusSettings?.statusResponse.status) {
4761
- // this.loadNewPaymentAccountData(statusSettings?.statusResponse.status, res)
4762
- // }
4763
- // }
4764
- // });
4765
- void firstValueFrom(this.checkStatusService.response$).then((checkStatusResponse) => {
4766
- if (checkStatusResponse.final && statusSettings?.statusResponse.status) {
4767
- this.loadNewPaymentAccountData(statusSettings?.statusResponse.status, checkStatusResponse);
4768
- }
4769
- });
4770
- // this.checkStatusService.request();
4771
- // const checkStatusResponse = await firstValueFrom(
4772
- // this.checkStatusService.response$
4773
- // );
4648
+ this.listenStatusService.statusUpdated$
4649
+ .pipe(skip(1))
4650
+ .subscribe(({ statusResponse }) => {
4651
+ if (statusResponse.status) {
4652
+ this.loadNewPaymentAccountData(statusResponse.status);
4653
+ }
4774
4654
  });
4775
- // this.statusRequestService.request();
4776
4655
  }
4777
- loadNewPaymentAccountData(status, checkStatus) {
4656
+ loadNewPaymentAccountData(status) {
4778
4657
  if (!status.invoice) {
4779
4658
  return;
4780
4659
  }
@@ -4782,37 +4661,26 @@ class SavePaymentMethodStatusService {
4782
4661
  .request(status.invoice)
4783
4662
  .then((accountChanges) => {
4784
4663
  if (accountChanges) {
4785
- this.handleSavingStatus(status, accountChanges, checkStatus);
4664
+ this.handleSavingStatus(status, accountChanges.new_account);
4786
4665
  }
4787
4666
  });
4788
4667
  }
4789
- handleSavingStatus(status, account, checkStatus) {
4790
- // const savingFailedOrCancel = status?.titleClass === TitleClass.cancel || status?.titleClass === TitleClass.cancelUser;
4791
- //
4792
- // const savingSuccessful = status?.titleClass === TitleClass.done && account;
4793
- if (this.savingSuccessful(account, status, checkStatus)) {
4794
- this.savePaymentMethodStatus = SavePaymentMethodStatus.success;
4795
- }
4796
- else {
4797
- this.savePaymentMethodStatus = SavePaymentMethodStatus.failed;
4798
- }
4668
+ handleSavingStatus(status, account) {
4799
4669
  this.listenStatusService.stopListening();
4800
- this.listenStatusSubscription.unsubscribe();
4801
- // const paymentAccountWasSaved = status?.titleClass === TitleClass.done && account !== null;
4670
+ const paymentAccountWasSaved = status?.titleClass === TitleClass.done && account !== null;
4802
4671
  const isSavePaymentMethod = true;
4803
- // this.savePaymentMethodStatus = this.savingFailedOrCancel(status) ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
4804
- console.log(status, isSavePaymentMethod, this.savePaymentMethodStatus);
4672
+ this.savePaymentMethodStatus = paymentAccountWasSaved ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
4805
4673
  this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
4806
4674
  }
4807
4675
  }
4808
- 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 });
4676
+ 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 });
4809
4677
  SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, providedIn: 'root' });
4810
4678
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
4811
4679
  type: Injectable,
4812
4680
  args: [{
4813
4681
  providedIn: 'root'
4814
4682
  }]
4815
- }], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }, { type: CheckStatusService }]; } });
4683
+ }], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }]; } });
4816
4684
 
4817
4685
  class StatusService {
4818
4686
  constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService) {
@@ -4826,7 +4694,7 @@ class StatusService {
4826
4694
  async getStatus(params) {
4827
4695
  // todo: если params.savePaymentMethod, то надо выполнить логику для
4828
4696
  // account status
4829
- const isSavePaymentMethodMode = !!params?.isSavePaymentAccount;
4697
+ const isSavePaymentMethodMode = !!params?.savePaymentMethod;
4830
4698
  if (isSavePaymentMethodMode) {
4831
4699
  return this.savePaymentMethodStatusService.getStatus(params); // todo: saveMethodStatus.getStatus();
4832
4700
  }
@@ -4839,7 +4707,6 @@ class StatusService {
4839
4707
  }
4840
4708
  async getStatusWithUrlSearchParams(url) {
4841
4709
  const searchParams = this.getRequestParamsFromUrl(url);
4842
- console.log('searchParams', searchParams);
4843
4710
  if (!searchParams) {
4844
4711
  throw new Error('No required search params to get status');
4845
4712
  }
@@ -5346,7 +5213,6 @@ class PaymentService {
5346
5213
  this.destroy$ = new Subject();
5347
5214
  this.formDestroy$ = new Subject();
5348
5215
  this.formFieldsStatusSubject = new BehaviorSubject(null);
5349
- this.isSavingMethodMode = false;
5350
5216
  }
5351
5217
  async initialize(config) {
5352
5218
  this.destroy$ = new Subject();
@@ -5372,12 +5238,9 @@ class PaymentService {
5372
5238
  this.emitFormFieldsStatus(this.form);
5373
5239
  return;
5374
5240
  }
5375
- console.log('this.fields', this.fields);
5376
- console.log('this.form', this.form);
5377
- this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
5378
5241
  const submitResponse = await this.submitService.request(this.fields, this.form);
5379
5242
  this.data = submitResponse;
5380
- if (!this.isSavingMethodMode) {
5243
+ if (!submitResponse.isSavingMethodMode) {
5381
5244
  this.emitFinanceDetails(submitResponse.summary);
5382
5245
  }
5383
5246
  this.emitFormMessages(submitResponse.messages);
@@ -5428,10 +5291,8 @@ class PaymentService {
5428
5291
  signature: this.data.signature ?? '',
5429
5292
  locale: this.data.fields.find((field) => field.name === 'locale')?.value ??
5430
5293
  'en',
5431
- isSavePaymentAccount: this.isSavingMethodMode ? 1 : 0,
5294
+ savePaymentMethod: this.data.isSavingMethodMode ? 1 : 0,
5432
5295
  };
5433
- console.log('this.data', this.data);
5434
- console.log('getStatus', params);
5435
5296
  return this.statusService.getStatus(params);
5436
5297
  }
5437
5298
  getFieldConfig(field) {