@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.
- package/esm2020/lib/core/payment/actions/status-updated/status-updated.action.class.mjs +2 -2
- package/esm2020/lib/core/payment/config/config.service.mjs +5 -5
- package/esm2020/lib/core/payment/initialize/initialize-request-params.interface.mjs +1 -1
- package/esm2020/lib/core/payment/initialize/initialize.service.mjs +6 -4
- package/esm2020/lib/core/payment/payment.interface.mjs +1 -1
- package/esm2020/lib/core/payment/payment.service.mjs +1 -5
- package/esm2020/lib/core/payment/status/save-payment-method-status/api/saved-payment-account-changes.service.mjs +2 -2
- package/esm2020/lib/core/payment/status/save-payment-method-status/save-payment-method-status.enum.mjs +1 -1
- package/esm2020/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.mjs +34 -125
- package/esm2020/lib/core/payment/status/status.service.mjs +2 -5
- package/esm2020/lib/core/payment-methods/payment-methods-request-params.interface.mjs +1 -1
- package/esm2020/lib/core/payment-methods/payment-methods.service.mjs +4 -2
- package/esm2020/lib/core-library.service.mjs +1 -1
- package/fesm2015/xsolla-payment-client-core.mjs +46 -142
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +48 -142
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/initialize/initialize-request-params.interface.d.ts +1 -1
- package/lib/core/payment/payment.interface.d.ts +1 -1
- package/lib/core/payment/payment.service.d.ts +1 -1
- package/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.d.ts +2 -1
- package/lib/core/payment/status/status.service.d.ts +2 -2
- package/lib/core/payment-methods/payment-methods-request-params.interface.d.ts +1 -1
- package/lib/core-library.service.d.ts +1 -1
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.1.14-test22.tgz +0 -0
- package/xsolla-payment-client-core-0.1.14-test21.tgz +0 -0
|
@@ -250,7 +250,9 @@ class PaymentMethodsService {
|
|
|
250
250
|
const requestParams = {
|
|
251
251
|
access_token: this.settingsService.token,
|
|
252
252
|
country: this.countryService.getCountry(),
|
|
253
|
-
save_payment_account_only: isSaveMethodMode
|
|
253
|
+
save_payment_account_only: isSaveMethodMode
|
|
254
|
+
? "1" /* XpsBoolean.true */
|
|
255
|
+
: "0" /* XpsBoolean.false */,
|
|
254
256
|
};
|
|
255
257
|
const cacheKey = JSON.stringify(requestParams);
|
|
256
258
|
if (!this.cache.has(cacheKey)) {
|
|
@@ -454,16 +456,16 @@ class PaymentConfigService {
|
|
|
454
456
|
}
|
|
455
457
|
return {
|
|
456
458
|
...config,
|
|
457
|
-
returnUrl: this.enrichReturnUrl(config.returnUrl, !!config.savePaymentMethod)
|
|
459
|
+
returnUrl: this.enrichReturnUrl(config.returnUrl, !!config.savePaymentMethod),
|
|
458
460
|
};
|
|
459
461
|
}
|
|
460
462
|
enrichReturnUrl(returnUrl, savePaymentMethod) {
|
|
461
463
|
let enrichedUrl = this.urlService.addSearchParams(returnUrl, {
|
|
462
|
-
token: this.settingsService.token
|
|
464
|
+
token: this.settingsService.token,
|
|
463
465
|
});
|
|
464
466
|
if (savePaymentMethod) {
|
|
465
467
|
enrichedUrl = this.urlService.addSearchParams(returnUrl, {
|
|
466
|
-
isSavePaymentAccount: "1" /* XpsBoolean.true
|
|
468
|
+
isSavePaymentAccount: "1" /* XpsBoolean.true */,
|
|
467
469
|
});
|
|
468
470
|
}
|
|
469
471
|
return enrichedUrl;
|
|
@@ -474,7 +476,7 @@ PaymentConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0",
|
|
|
474
476
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentConfigService, decorators: [{
|
|
475
477
|
type: Injectable,
|
|
476
478
|
args: [{
|
|
477
|
-
providedIn: 'root'
|
|
479
|
+
providedIn: 'root',
|
|
478
480
|
}]
|
|
479
481
|
}], ctorParameters: function () { return [{ type: UrlService }, { type: SettingsService }]; } });
|
|
480
482
|
|
|
@@ -924,7 +926,7 @@ class StatusUpdatedAction {
|
|
|
924
926
|
isCanceled: status.isCanceled,
|
|
925
927
|
group: status.group,
|
|
926
928
|
isSavePaymentMethodMode,
|
|
927
|
-
savePaymentMethodStatus
|
|
929
|
+
savePaymentMethodStatus,
|
|
928
930
|
};
|
|
929
931
|
}
|
|
930
932
|
}
|
|
@@ -1570,7 +1572,9 @@ class InitializeService {
|
|
|
1570
1572
|
? "1" /* XpsBoolean.true */
|
|
1571
1573
|
: "0" /* XpsBoolean.false */,
|
|
1572
1574
|
saved_method_id: config.savedMethodId,
|
|
1573
|
-
save_payment_account_only: !!config.savePaymentMethod
|
|
1575
|
+
save_payment_account_only: !!config.savePaymentMethod
|
|
1576
|
+
? "1" /* XpsBoolean.true */
|
|
1577
|
+
: "0" /* XpsBoolean.false */,
|
|
1574
1578
|
};
|
|
1575
1579
|
return this.xpsApiService
|
|
1576
1580
|
.directPaymentRequest(requestParams)
|
|
@@ -1602,7 +1606,7 @@ InitializeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", ve
|
|
|
1602
1606
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, decorators: [{
|
|
1603
1607
|
type: Injectable,
|
|
1604
1608
|
args: [{
|
|
1605
|
-
providedIn: 'root'
|
|
1609
|
+
providedIn: 'root',
|
|
1606
1610
|
}]
|
|
1607
1611
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1608
1612
|
type: Inject,
|
|
@@ -4619,7 +4623,7 @@ SavedPaymentAccountChangesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersi
|
|
|
4619
4623
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, decorators: [{
|
|
4620
4624
|
type: Injectable,
|
|
4621
4625
|
args: [{
|
|
4622
|
-
providedIn: 'root'
|
|
4626
|
+
providedIn: 'root',
|
|
4623
4627
|
}]
|
|
4624
4628
|
}], ctorParameters: function () { return [{ type: SettingsService }, { type: SecureApiClient }]; } });
|
|
4625
4629
|
|
|
@@ -4633,26 +4637,28 @@ class SavePaymentMethodStatusService {
|
|
|
4633
4637
|
this.statusChecked = false;
|
|
4634
4638
|
}
|
|
4635
4639
|
async getStatus(params) {
|
|
4636
|
-
if (this.
|
|
4637
|
-
this.
|
|
4638
|
-
this.
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
return statusResponse.status;
|
|
4640
|
+
if (!this.accountData || !this.status) {
|
|
4641
|
+
this.statusRequestService.setRequestParams(params);
|
|
4642
|
+
this.statusRequestService.request();
|
|
4643
|
+
const statusResponse = await firstValueFrom(this.statusRequestService.response$);
|
|
4644
|
+
this.status = statusResponse.status;
|
|
4645
|
+
this.status.isSavePaymentAccount = true;
|
|
4646
|
+
this.accountData = await this.getPaymentAccountData(params.invoice);
|
|
4647
|
+
}
|
|
4648
|
+
if (this.savingFailedOrCancel(this.status) ||
|
|
4649
|
+
(this.accountData && this.savingSuccessful(this.accountData, this.status))) {
|
|
4650
|
+
return this.status;
|
|
4648
4651
|
}
|
|
4649
4652
|
if (!this.statusChecked) {
|
|
4650
4653
|
this.checkStatus(params);
|
|
4651
|
-
|
|
4652
|
-
return
|
|
4654
|
+
this.status.statusState = StatusEnum.processing;
|
|
4655
|
+
return this.status;
|
|
4653
4656
|
}
|
|
4654
|
-
|
|
4655
|
-
|
|
4657
|
+
this.statusChecked = false;
|
|
4658
|
+
this.status.statusState = StatusEnum.error;
|
|
4659
|
+
const outStatus = { ...this.status };
|
|
4660
|
+
this.status = null;
|
|
4661
|
+
return outStatus;
|
|
4656
4662
|
}
|
|
4657
4663
|
checkStatus(params) {
|
|
4658
4664
|
if (!this.statusChecked) {
|
|
@@ -4661,135 +4667,45 @@ class SavePaymentMethodStatusService {
|
|
|
4661
4667
|
this.startWaitingStatusUpdates(params.invoice);
|
|
4662
4668
|
this.statusRequestService.request();
|
|
4663
4669
|
}
|
|
4664
|
-
async getStatusOld(params) {
|
|
4665
|
-
console.log('getStatus', params);
|
|
4666
|
-
this.statusRequestService.setRequestParams(params);
|
|
4667
|
-
// this.startWaitingStatusUpdates(params.invoice);
|
|
4668
|
-
this.statusRequestService.request();
|
|
4669
|
-
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);
|
|
4684
|
-
statusResponse.status.statusState = StatusEnum.processing;
|
|
4685
|
-
}
|
|
4686
|
-
statusResponse.status.isSavePaymentAccount = true;
|
|
4687
|
-
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
4670
|
savingFailedOrCancel(status) {
|
|
4735
|
-
return status?.titleClass === TitleClass.cancel ||
|
|
4671
|
+
return (status?.titleClass === TitleClass.cancel ||
|
|
4672
|
+
status?.titleClass === TitleClass.cancelUser);
|
|
4736
4673
|
}
|
|
4737
4674
|
savingSuccessful(accountData, status, checkStatus) {
|
|
4738
|
-
return !!(status?.titleClass === TitleClass.done &&
|
|
4675
|
+
return !!(status?.titleClass === TitleClass.done &&
|
|
4676
|
+
(accountData?.new_account || checkStatus?.isPaymentAccountAttached));
|
|
4739
4677
|
}
|
|
4740
4678
|
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
|
-
// });
|
|
4679
|
+
return this.savedPaymentAccountChangesService.request(invoice);
|
|
4748
4680
|
}
|
|
4749
4681
|
startWaitingStatusUpdates(invoice) {
|
|
4750
4682
|
if (this.listenStatusSubscription) {
|
|
4751
4683
|
this.listenStatusSubscription.unsubscribe();
|
|
4752
4684
|
this.listenStatusService.stopListening();
|
|
4753
4685
|
}
|
|
4754
|
-
// debugger
|
|
4755
4686
|
this.listenStatusService.listen(invoice);
|
|
4756
|
-
this.listenStatusSubscription =
|
|
4757
|
-
.subscribe((
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
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
|
-
}
|
|
4687
|
+
this.listenStatusSubscription =
|
|
4688
|
+
this.listenStatusService.statusUpdated$.subscribe(({ statusResponse }) => {
|
|
4689
|
+
this.status = statusResponse.status;
|
|
4690
|
+
void firstValueFrom(this.checkStatusService.response$).then((checkStatusResponse) => {
|
|
4691
|
+
if (checkStatusResponse.final && statusResponse.status) {
|
|
4692
|
+
this.loadNewPaymentAccountData(statusResponse.status, checkStatusResponse);
|
|
4693
|
+
}
|
|
4694
|
+
});
|
|
4769
4695
|
});
|
|
4770
|
-
// this.checkStatusService.request();
|
|
4771
|
-
// const checkStatusResponse = await firstValueFrom(
|
|
4772
|
-
// this.checkStatusService.response$
|
|
4773
|
-
// );
|
|
4774
|
-
});
|
|
4775
|
-
// this.statusRequestService.request();
|
|
4776
4696
|
}
|
|
4777
4697
|
loadNewPaymentAccountData(status, checkStatus) {
|
|
4778
4698
|
if (!status.invoice) {
|
|
4779
4699
|
return;
|
|
4780
4700
|
}
|
|
4781
|
-
void this.
|
|
4782
|
-
.request(status.invoice)
|
|
4783
|
-
.then((accountChanges) => {
|
|
4701
|
+
void this.getPaymentAccountData(status.invoice).then((accountChanges) => {
|
|
4784
4702
|
if (accountChanges) {
|
|
4703
|
+
this.accountData = accountChanges;
|
|
4785
4704
|
this.handleSavingStatus(status, accountChanges, checkStatus);
|
|
4786
4705
|
}
|
|
4787
4706
|
});
|
|
4788
4707
|
}
|
|
4789
4708
|
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
4709
|
if (this.savingSuccessful(account, status, checkStatus)) {
|
|
4794
4710
|
this.savePaymentMethodStatus = SavePaymentMethodStatus.success;
|
|
4795
4711
|
}
|
|
@@ -4798,10 +4714,7 @@ class SavePaymentMethodStatusService {
|
|
|
4798
4714
|
}
|
|
4799
4715
|
this.listenStatusService.stopListening();
|
|
4800
4716
|
this.listenStatusSubscription.unsubscribe();
|
|
4801
|
-
// const paymentAccountWasSaved = status?.titleClass === TitleClass.done && account !== null;
|
|
4802
4717
|
const isSavePaymentMethod = true;
|
|
4803
|
-
// this.savePaymentMethodStatus = this.savingFailedOrCancel(status) ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
|
|
4804
|
-
console.log(status, isSavePaymentMethod, this.savePaymentMethodStatus);
|
|
4805
4718
|
this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
|
|
4806
4719
|
}
|
|
4807
4720
|
}
|
|
@@ -4810,7 +4723,7 @@ SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion:
|
|
|
4810
4723
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
|
|
4811
4724
|
type: Injectable,
|
|
4812
4725
|
args: [{
|
|
4813
|
-
providedIn: 'root'
|
|
4726
|
+
providedIn: 'root',
|
|
4814
4727
|
}]
|
|
4815
4728
|
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }, { type: CheckStatusService }]; } });
|
|
4816
4729
|
|
|
@@ -4824,11 +4737,9 @@ class StatusService {
|
|
|
4824
4737
|
this.savePaymentMethodStatusService = savePaymentMethodStatusService;
|
|
4825
4738
|
}
|
|
4826
4739
|
async getStatus(params) {
|
|
4827
|
-
// todo: если params.savePaymentMethod, то надо выполнить логику для
|
|
4828
|
-
// account status
|
|
4829
4740
|
const isSavePaymentMethodMode = !!params?.isSavePaymentAccount;
|
|
4830
4741
|
if (isSavePaymentMethodMode) {
|
|
4831
|
-
return this.savePaymentMethodStatusService.getStatus(params);
|
|
4742
|
+
return this.savePaymentMethodStatusService.getStatus(params);
|
|
4832
4743
|
}
|
|
4833
4744
|
this.statusRequestService.setRequestParams(params);
|
|
4834
4745
|
this.startWaitingStatusUpdates(params.invoice);
|
|
@@ -4839,7 +4750,6 @@ class StatusService {
|
|
|
4839
4750
|
}
|
|
4840
4751
|
async getStatusWithUrlSearchParams(url) {
|
|
4841
4752
|
const searchParams = this.getRequestParamsFromUrl(url);
|
|
4842
|
-
console.log('searchParams', searchParams);
|
|
4843
4753
|
if (!searchParams) {
|
|
4844
4754
|
throw new Error('No required search params to get status');
|
|
4845
4755
|
}
|
|
@@ -5372,8 +5282,6 @@ class PaymentService {
|
|
|
5372
5282
|
this.emitFormFieldsStatus(this.form);
|
|
5373
5283
|
return;
|
|
5374
5284
|
}
|
|
5375
|
-
console.log('this.fields', this.fields);
|
|
5376
|
-
console.log('this.form', this.form);
|
|
5377
5285
|
this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
|
|
5378
5286
|
const submitResponse = await this.submitService.request(this.fields, this.form);
|
|
5379
5287
|
this.data = submitResponse;
|
|
@@ -5430,8 +5338,6 @@ class PaymentService {
|
|
|
5430
5338
|
'en',
|
|
5431
5339
|
isSavePaymentAccount: this.isSavingMethodMode ? 1 : 0,
|
|
5432
5340
|
};
|
|
5433
|
-
console.log('this.data', this.data);
|
|
5434
|
-
console.log('getStatus', params);
|
|
5435
5341
|
return this.statusService.getStatus(params);
|
|
5436
5342
|
}
|
|
5437
5343
|
getFieldConfig(field) {
|