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

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/actions/status-updated/status-updated.action.class.mjs +2 -2
  2. package/esm2020/lib/core/payment/config/config.service.mjs +5 -5
  3. package/esm2020/lib/core/payment/initialize/initialize-request-params.interface.mjs +1 -1
  4. package/esm2020/lib/core/payment/initialize/initialize.service.mjs +6 -4
  5. package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
  6. package/esm2020/lib/core/payment/payment.service.mjs +1 -5
  7. package/esm2020/lib/core/payment/status/save-payment-method-status/api/saved-payment-account-changes.service.mjs +2 -2
  8. package/esm2020/lib/core/payment/status/save-payment-method-status/save-payment-method-status.enum.mjs +1 -1
  9. package/esm2020/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.mjs +34 -125
  10. package/esm2020/lib/core/payment/status/status.service.mjs +2 -5
  11. package/esm2020/lib/core/payment-methods/payment-methods-request-params.interface.mjs +1 -1
  12. package/esm2020/lib/core/payment-methods/payment-methods.service.mjs +4 -2
  13. package/esm2020/lib/core-library.service.mjs +1 -1
  14. package/fesm2015/xsolla-payment-client-core.mjs +46 -142
  15. package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
  16. package/fesm2020/xsolla-payment-client-core.mjs +48 -142
  17. package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
  18. package/lib/core/payment/initialize/initialize-request-params.interface.d.ts +1 -1
  19. package/lib/core/payment/payment.interface.d.ts +1 -1
  20. package/lib/core/payment/payment.service.d.ts +1 -1
  21. package/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.d.ts +2 -1
  22. package/lib/core/payment/status/status.service.d.ts +2 -2
  23. package/lib/core/payment-methods/payment-methods-request-params.interface.d.ts +1 -1
  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-test22.tgz +0 -0
  27. package/xsolla-payment-client-core-0.1.14-test21.tgz +0 -0
@@ -261,7 +261,9 @@ class PaymentMethodsService {
261
261
  const requestParams = {
262
262
  access_token: this.settingsService.token,
263
263
  country: this.countryService.getCountry(),
264
- save_payment_account_only: isSaveMethodMode ? "1" /* XpsBoolean.true */ : "0" /* XpsBoolean.false */
264
+ save_payment_account_only: isSaveMethodMode
265
+ ? "1" /* XpsBoolean.true */
266
+ : "0" /* XpsBoolean.false */,
265
267
  };
266
268
  const cacheKey = JSON.stringify(requestParams);
267
269
  if (!this.cache.has(cacheKey)) {
@@ -483,11 +485,11 @@ class PaymentConfigService {
483
485
  }
484
486
  enrichReturnUrl(returnUrl, savePaymentMethod) {
485
487
  let enrichedUrl = this.urlService.addSearchParams(returnUrl, {
486
- token: this.settingsService.token
488
+ token: this.settingsService.token,
487
489
  });
488
490
  if (savePaymentMethod) {
489
491
  enrichedUrl = this.urlService.addSearchParams(returnUrl, {
490
- isSavePaymentAccount: "1" /* XpsBoolean.true */
492
+ isSavePaymentAccount: "1" /* XpsBoolean.true */,
491
493
  });
492
494
  }
493
495
  return enrichedUrl;
@@ -498,7 +500,7 @@ PaymentConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0",
498
500
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentConfigService, decorators: [{
499
501
  type: Injectable,
500
502
  args: [{
501
- providedIn: 'root'
503
+ providedIn: 'root',
502
504
  }]
503
505
  }], ctorParameters: function () { return [{ type: UrlService }, { type: SettingsService }]; } });
504
506
 
@@ -951,7 +953,7 @@ class StatusUpdatedAction {
951
953
  isCanceled: status.isCanceled,
952
954
  group: status.group,
953
955
  isSavePaymentMethodMode,
954
- savePaymentMethodStatus
956
+ savePaymentMethodStatus,
955
957
  };
956
958
  }
957
959
  }
@@ -1596,7 +1598,9 @@ class InitializeService {
1596
1598
  ? "1" /* XpsBoolean.true */
1597
1599
  : "0" /* XpsBoolean.false */,
1598
1600
  saved_method_id: config.savedMethodId,
1599
- save_payment_account_only: !!config.savePaymentMethod ? "1" /* XpsBoolean.true */ : "0" /* XpsBoolean.false */
1601
+ save_payment_account_only: !!config.savePaymentMethod
1602
+ ? "1" /* XpsBoolean.true */
1603
+ : "0" /* XpsBoolean.false */,
1600
1604
  };
1601
1605
  return this.xpsApiService
1602
1606
  .directPaymentRequest(requestParams)
@@ -1630,7 +1634,7 @@ InitializeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", ve
1630
1634
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, decorators: [{
1631
1635
  type: Injectable,
1632
1636
  args: [{
1633
- providedIn: 'root'
1637
+ providedIn: 'root',
1634
1638
  }]
1635
1639
  }], ctorParameters: function () {
1636
1640
  return [{ type: undefined, decorators: [{
@@ -4732,7 +4736,7 @@ SavedPaymentAccountChangesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersi
4732
4736
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, decorators: [{
4733
4737
  type: Injectable,
4734
4738
  args: [{
4735
- providedIn: 'root'
4739
+ providedIn: 'root',
4736
4740
  }]
4737
4741
  }], ctorParameters: function () { return [{ type: SettingsService }, { type: SecureApiClient }]; } });
4738
4742
 
@@ -4747,26 +4751,28 @@ class SavePaymentMethodStatusService {
4747
4751
  }
4748
4752
  getStatus(params) {
4749
4753
  return __awaiter(this, void 0, void 0, function* () {
4750
- if (this.listenStatusSubscription) {
4751
- this.listenStatusSubscription.unsubscribe();
4752
- this.listenStatusService.stopListening();
4754
+ if (!this.accountData || !this.status) {
4755
+ this.statusRequestService.setRequestParams(params);
4756
+ this.statusRequestService.request();
4757
+ const statusResponse = yield firstValueFrom(this.statusRequestService.response$);
4758
+ this.status = statusResponse.status;
4759
+ this.status.isSavePaymentAccount = true;
4760
+ this.accountData = yield this.getPaymentAccountData(params.invoice);
4753
4761
  }
4754
- this.statusRequestService.setRequestParams(params);
4755
- this.statusRequestService.request();
4756
- const statusResponse = yield firstValueFrom(this.statusRequestService.response$);
4757
- statusResponse.status.isSavePaymentAccount = true;
4758
- // this.listenStatusService.stopListening();
4759
- const accountData = yield this.getPaymentAccountData(params.invoice);
4760
- if (this.savingFailedOrCancel(statusResponse === null || statusResponse === void 0 ? void 0 : statusResponse.status) || this.savingSuccessful(accountData, statusResponse === null || statusResponse === void 0 ? void 0 : statusResponse.status)) {
4761
- return statusResponse.status;
4762
+ if (this.savingFailedOrCancel(this.status) ||
4763
+ (this.accountData && this.savingSuccessful(this.accountData, this.status))) {
4764
+ return this.status;
4762
4765
  }
4763
4766
  if (!this.statusChecked) {
4764
4767
  this.checkStatus(params);
4765
- statusResponse.status.statusState = StatusEnum.processing;
4766
- return statusResponse.status;
4768
+ this.status.statusState = StatusEnum.processing;
4769
+ return this.status;
4767
4770
  }
4768
- statusResponse.status.statusState = StatusEnum.error;
4769
- return statusResponse.status;
4771
+ this.statusChecked = false;
4772
+ this.status.statusState = StatusEnum.error;
4773
+ const outStatus = Object.assign({}, this.status);
4774
+ this.status = null;
4775
+ return outStatus;
4770
4776
  });
4771
4777
  }
4772
4778
  checkStatus(params) {
@@ -4776,137 +4782,45 @@ class SavePaymentMethodStatusService {
4776
4782
  this.startWaitingStatusUpdates(params.invoice);
4777
4783
  this.statusRequestService.request();
4778
4784
  }
4779
- getStatusOld(params) {
4780
- return __awaiter(this, void 0, void 0, function* () {
4781
- console.log('getStatus', params);
4782
- this.statusRequestService.setRequestParams(params);
4783
- // this.startWaitingStatusUpdates(params.invoice);
4784
- this.statusRequestService.request();
4785
- const statusResponse = yield firstValueFrom(this.statusRequestService.response$);
4786
- this.checkStatusService.setRequestParams(params.invoice);
4787
- this.checkStatusService.request();
4788
- const checkStatusResponse = yield firstValueFrom(this.checkStatusService.response$);
4789
- if (!checkStatusResponse.final) {
4790
- this.startWaitingStatusUpdates(params.invoice);
4791
- statusResponse.status.isSavePaymentAccount = true;
4792
- statusResponse.status.statusState = StatusEnum.processing;
4793
- return statusResponse.status;
4794
- }
4795
- // todo: get account
4796
- const accountData = yield this.getPaymentAccountData(params.invoice);
4797
- if (!this.savingFailedOrCancel(statusResponse === null || statusResponse === void 0 ? void 0 : statusResponse.status) && !this.savingSuccessful(accountData, statusResponse === null || statusResponse === void 0 ? void 0 : statusResponse.status)) {
4798
- // todo is proccessing
4799
- this.startWaitingStatusUpdates(params.invoice);
4800
- statusResponse.status.statusState = StatusEnum.processing;
4801
- }
4802
- statusResponse.status.isSavePaymentAccount = true;
4803
- return statusResponse.status;
4804
- // this.listenStatusService.listen(params.invoice);
4805
- // this.statusRequestService.request();
4806
- // const paramsCheck = {
4807
- // section: 'getstatus',
4808
- // action: 'getstatus',
4809
- // // invoice: params.invoice,
4810
- // ...params,
4811
- // access_token: params.token || '8sogPLisB328Snf9M9aChSwkZn4IzOzf_lc_en'
4812
- // };
4813
- // // const check = await this.checkStatusService.requestPromise('directpayment', paramsCheck);
4814
- // // console.log('requestPromise', check);
4815
- // // todo: get account
4816
- // // const accountData = await this.getPaymentAccountData(params.invoice);
4817
- // // this.startWaitingStatusUpdates(params.invoice);
4818
- // // this.listenStatusService.statusUpdated$
4819
- // this.startWaitingStatusUpdates(params.invoice);
4820
- // this.statusRequestService.request();
4821
- // this.checkStatusService.setRequestParams(params.invoice);
4822
- // this.checkStatusService.request();
4823
- // this.checkStatusService.response$.subscribe((resp) => {
4824
- // console.log('checkSt', resp);
4825
- // });
4826
- // const statusResponse = await firstValueFrom(
4827
- // this.statusRequestService.response$
4828
- // );
4829
- // const savingFailedOrCancel = statusResponse.status?.titleClass === TitleClass.cancel || statusResponse.status?.titleClass === TitleClass.cancelUser;
4830
- // const savingSuccessful = statusResponse.status?.titleClass === TitleClass.done && accountData?.new_account;
4831
- // if (!accountData) {
4832
- // this.startWaitingStatusUpdates(params.invoice);
4833
- // statusResponse.status.statusState = StatusEnum.processing;
4834
- // }
4835
- // if (!this.savingFailedOrCancel(statusResponse?.status) && !this.savingSuccessful(accountData, statusResponse?.status)) {
4836
- // // todo is proccessing
4837
- //
4838
- // // this.startWaitingStatusUpdates(params.invoice);
4839
- // statusResponse.status.statusState = StatusEnum.processing;
4840
- // }
4841
- // statusResponse.status.isSavePaymentAccount = true;
4842
- // return statusResponse.status;
4843
- // return null;
4844
- // if (!this.savePaymentMethodStatus) {
4845
- // statusResponse.status.statusState = StatusEnum.processing;
4846
- // }
4847
- // statusResponse.status.isSavePaymentAccount = true;
4848
- // return statusResponse.status;
4849
- });
4850
- }
4851
4785
  savingFailedOrCancel(status) {
4852
- return (status === null || status === void 0 ? void 0 : status.titleClass) === TitleClass.cancel || (status === null || status === void 0 ? void 0 : status.titleClass) === TitleClass.cancelUser;
4786
+ return ((status === null || status === void 0 ? void 0 : status.titleClass) === TitleClass.cancel ||
4787
+ (status === null || status === void 0 ? void 0 : status.titleClass) === TitleClass.cancelUser);
4853
4788
  }
4854
4789
  savingSuccessful(accountData, status, checkStatus) {
4855
- return !!((status === null || status === void 0 ? void 0 : status.titleClass) === TitleClass.done && ((accountData === null || accountData === void 0 ? void 0 : accountData.new_account) || (checkStatus === null || checkStatus === void 0 ? void 0 : checkStatus.isPaymentAccountAttached)));
4790
+ return !!((status === null || status === void 0 ? void 0 : status.titleClass) === TitleClass.done &&
4791
+ ((accountData === null || accountData === void 0 ? void 0 : accountData.new_account) || (checkStatus === null || checkStatus === void 0 ? void 0 : checkStatus.isPaymentAccountAttached)));
4856
4792
  }
4857
4793
  getPaymentAccountData(invoice) {
4858
- return this.savedPaymentAccountChangesService
4859
- .request(invoice);
4860
- // .then((accountChanges: SavedPaymentAccountChanges) => {
4861
- // if (accountChanges) {
4862
- // this.handleSavingStatus(status, accountChanges.new_account);
4863
- // }
4864
- // });
4794
+ return this.savedPaymentAccountChangesService.request(invoice);
4865
4795
  }
4866
4796
  startWaitingStatusUpdates(invoice) {
4867
4797
  if (this.listenStatusSubscription) {
4868
4798
  this.listenStatusSubscription.unsubscribe();
4869
4799
  this.listenStatusService.stopListening();
4870
4800
  }
4871
- // debugger
4872
4801
  this.listenStatusService.listen(invoice);
4873
- this.listenStatusSubscription = this.listenStatusService.statusUpdated$
4874
- .subscribe((statusSettings) => {
4875
- // this.checkStatusService.response$.subscribe((res) => {
4876
- // if (res.final) {
4877
- // if (statusSettings?.statusResponse.status) {
4878
- // this.loadNewPaymentAccountData(statusSettings?.statusResponse.status, res)
4879
- // }
4880
- // }
4881
- // });
4882
- void firstValueFrom(this.checkStatusService.response$).then((checkStatusResponse) => {
4883
- if (checkStatusResponse.final && (statusSettings === null || statusSettings === void 0 ? void 0 : statusSettings.statusResponse.status)) {
4884
- this.loadNewPaymentAccountData(statusSettings === null || statusSettings === void 0 ? void 0 : statusSettings.statusResponse.status, checkStatusResponse);
4885
- }
4802
+ this.listenStatusSubscription =
4803
+ this.listenStatusService.statusUpdated$.subscribe(({ statusResponse }) => {
4804
+ this.status = statusResponse.status;
4805
+ void firstValueFrom(this.checkStatusService.response$).then((checkStatusResponse) => {
4806
+ if (checkStatusResponse.final && statusResponse.status) {
4807
+ this.loadNewPaymentAccountData(statusResponse.status, checkStatusResponse);
4808
+ }
4809
+ });
4886
4810
  });
4887
- // this.checkStatusService.request();
4888
- // const checkStatusResponse = await firstValueFrom(
4889
- // this.checkStatusService.response$
4890
- // );
4891
- });
4892
- // this.statusRequestService.request();
4893
4811
  }
4894
4812
  loadNewPaymentAccountData(status, checkStatus) {
4895
4813
  if (!status.invoice) {
4896
4814
  return;
4897
4815
  }
4898
- void this.savedPaymentAccountChangesService
4899
- .request(status.invoice)
4900
- .then((accountChanges) => {
4816
+ void this.getPaymentAccountData(status.invoice).then((accountChanges) => {
4901
4817
  if (accountChanges) {
4818
+ this.accountData = accountChanges;
4902
4819
  this.handleSavingStatus(status, accountChanges, checkStatus);
4903
4820
  }
4904
4821
  });
4905
4822
  }
4906
4823
  handleSavingStatus(status, account, checkStatus) {
4907
- // const savingFailedOrCancel = status?.titleClass === TitleClass.cancel || status?.titleClass === TitleClass.cancelUser;
4908
- //
4909
- // const savingSuccessful = status?.titleClass === TitleClass.done && account;
4910
4824
  if (this.savingSuccessful(account, status, checkStatus)) {
4911
4825
  this.savePaymentMethodStatus = SavePaymentMethodStatus.success;
4912
4826
  }
@@ -4915,10 +4829,7 @@ class SavePaymentMethodStatusService {
4915
4829
  }
4916
4830
  this.listenStatusService.stopListening();
4917
4831
  this.listenStatusSubscription.unsubscribe();
4918
- // const paymentAccountWasSaved = status?.titleClass === TitleClass.done && account !== null;
4919
4832
  const isSavePaymentMethod = true;
4920
- // this.savePaymentMethodStatus = this.savingFailedOrCancel(status) ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
4921
- console.log(status, isSavePaymentMethod, this.savePaymentMethodStatus);
4922
4833
  this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
4923
4834
  }
4924
4835
  }
@@ -4927,7 +4838,7 @@ SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion:
4927
4838
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
4928
4839
  type: Injectable,
4929
4840
  args: [{
4930
- providedIn: 'root'
4841
+ providedIn: 'root',
4931
4842
  }]
4932
4843
  }], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }, { type: CheckStatusService }]; } });
4933
4844
 
@@ -4942,11 +4853,9 @@ class StatusService {
4942
4853
  }
4943
4854
  getStatus(params) {
4944
4855
  return __awaiter(this, void 0, void 0, function* () {
4945
- // todo: если params.savePaymentMethod, то надо выполнить логику для
4946
- // account status
4947
4856
  const isSavePaymentMethodMode = !!(params === null || params === void 0 ? void 0 : params.isSavePaymentAccount);
4948
4857
  if (isSavePaymentMethodMode) {
4949
- return this.savePaymentMethodStatusService.getStatus(params); // todo: saveMethodStatus.getStatus();
4858
+ return this.savePaymentMethodStatusService.getStatus(params);
4950
4859
  }
4951
4860
  this.statusRequestService.setRequestParams(params);
4952
4861
  this.startWaitingStatusUpdates(params.invoice);
@@ -4959,7 +4868,6 @@ class StatusService {
4959
4868
  getStatusWithUrlSearchParams(url) {
4960
4869
  return __awaiter(this, void 0, void 0, function* () {
4961
4870
  const searchParams = this.getRequestParamsFromUrl(url);
4962
- console.log('searchParams', searchParams);
4963
4871
  if (!searchParams) {
4964
4872
  throw new Error('No required search params to get status');
4965
4873
  }
@@ -5512,8 +5420,6 @@ class PaymentService {
5512
5420
  this.emitFormFieldsStatus(this.form);
5513
5421
  return;
5514
5422
  }
5515
- console.log('this.fields', this.fields);
5516
- console.log('this.form', this.form);
5517
5423
  this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
5518
5424
  const submitResponse = yield this.submitService.request(this.fields, this.form);
5519
5425
  this.data = submitResponse;
@@ -5575,8 +5481,6 @@ class PaymentService {
5575
5481
  locale: (_d = (_c = this.data.fields.find((field) => field.name === 'locale')) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 'en',
5576
5482
  isSavePaymentAccount: this.isSavingMethodMode ? 1 : 0,
5577
5483
  };
5578
- console.log('this.data', this.data);
5579
- console.log('getStatus', params);
5580
5484
  return this.statusService.getStatus(params);
5581
5485
  });
5582
5486
  }