@xsolla/payment-client-core 0.1.14-test10 → 0.1.14-test12
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/status/save-payment-method-status/save-payment-method-status.service.mjs +44 -10
- package/esm2020/lib/core/payment/status/status.interface.mjs +1 -1
- package/fesm2015/xsolla-payment-client-core.mjs +43 -9
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +43 -9
- package/fesm2020/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.d.ts +3 -0
- package/lib/core/payment/status/status.interface.d.ts +1 -0
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.1.14-test12.tgz +0 -0
- package/xsolla-payment-client-core-0.1.14-test10.tgz +0 -0
|
@@ -4631,16 +4631,48 @@ class SavePaymentMethodStatusService {
|
|
|
4631
4631
|
this.nextActionService = nextActionService;
|
|
4632
4632
|
}
|
|
4633
4633
|
async getStatus(params) {
|
|
4634
|
+
console.log('getStatus', params);
|
|
4634
4635
|
this.statusRequestService.setRequestParams(params);
|
|
4635
|
-
|
|
4636
|
+
// todo: get account
|
|
4637
|
+
const accountData = await this.getPaymentAccountData(params.invoice);
|
|
4638
|
+
// this.startWaitingStatusUpdates(params.invoice);
|
|
4636
4639
|
this.statusRequestService.request();
|
|
4637
4640
|
const statusResponse = await firstValueFrom(this.statusRequestService.response$);
|
|
4638
|
-
|
|
4641
|
+
// const savingFailedOrCancel = statusResponse.status?.titleClass === TitleClass.cancel || statusResponse.status?.titleClass === TitleClass.cancelUser;
|
|
4642
|
+
// const savingSuccessful = statusResponse.status?.titleClass === TitleClass.done && accountData?.new_account;
|
|
4643
|
+
if (!this.savingFailedOrCancel(statusResponse?.status) && !this.savingSuccessful(accountData, statusResponse?.status)) {
|
|
4644
|
+
// todo is proccessing
|
|
4645
|
+
this.startWaitingStatusUpdates(params.invoice);
|
|
4639
4646
|
statusResponse.status.statusState = StatusEnum.processing;
|
|
4640
4647
|
}
|
|
4648
|
+
statusResponse.status.isSavePaymentAccount = true;
|
|
4641
4649
|
return statusResponse.status;
|
|
4650
|
+
// if (!this.savePaymentMethodStatus) {
|
|
4651
|
+
// statusResponse.status.statusState = StatusEnum.processing;
|
|
4652
|
+
// }
|
|
4653
|
+
// statusResponse.status.isSavePaymentAccount = true;
|
|
4654
|
+
// return statusResponse.status;
|
|
4655
|
+
}
|
|
4656
|
+
savingFailedOrCancel(status) {
|
|
4657
|
+
return status?.titleClass === TitleClass.cancel || status?.titleClass === TitleClass.cancelUser;
|
|
4658
|
+
}
|
|
4659
|
+
savingSuccessful(accountData, status) {
|
|
4660
|
+
return !!(status?.titleClass === TitleClass.done && accountData?.new_account);
|
|
4661
|
+
}
|
|
4662
|
+
getPaymentAccountData(invoice) {
|
|
4663
|
+
return this.savedPaymentAccountChangesService
|
|
4664
|
+
.request(invoice);
|
|
4665
|
+
// .then((accountChanges: SavedPaymentAccountChanges) => {
|
|
4666
|
+
// if (accountChanges) {
|
|
4667
|
+
// this.handleSavingStatus(status, accountChanges.new_account);
|
|
4668
|
+
// }
|
|
4669
|
+
// });
|
|
4642
4670
|
}
|
|
4643
4671
|
startWaitingStatusUpdates(invoice) {
|
|
4672
|
+
if (this.listenStatusSubscription) {
|
|
4673
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4674
|
+
this.listenStatusService.stopListening();
|
|
4675
|
+
}
|
|
4644
4676
|
this.listenStatusService.listen(invoice);
|
|
4645
4677
|
this.listenStatusSubscription = this.listenStatusService.statusUpdated$
|
|
4646
4678
|
.subscribe(({ statusResponse }) => {
|
|
@@ -4657,20 +4689,22 @@ class SavePaymentMethodStatusService {
|
|
|
4657
4689
|
.request(status.invoice)
|
|
4658
4690
|
.then((accountChanges) => {
|
|
4659
4691
|
if (accountChanges) {
|
|
4660
|
-
this.handleSavingStatus(status, accountChanges
|
|
4692
|
+
this.handleSavingStatus(status, accountChanges);
|
|
4661
4693
|
}
|
|
4662
4694
|
});
|
|
4663
4695
|
}
|
|
4664
4696
|
handleSavingStatus(status, account) {
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
const
|
|
4668
|
-
if (
|
|
4697
|
+
// const savingFailedOrCancel = status?.titleClass === TitleClass.cancel || status?.titleClass === TitleClass.cancelUser;
|
|
4698
|
+
//
|
|
4699
|
+
// const savingSuccessful = status?.titleClass === TitleClass.done && account;
|
|
4700
|
+
if (!this.savingFailedOrCancel(status) && !this.savingSuccessful(account, status)) {
|
|
4669
4701
|
return;
|
|
4670
4702
|
}
|
|
4671
|
-
|
|
4703
|
+
this.listenStatusService.stopListening();
|
|
4704
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4705
|
+
// const paymentAccountWasSaved = status?.titleClass === TitleClass.done && account !== null;
|
|
4672
4706
|
const isSavePaymentMethod = true;
|
|
4673
|
-
this.savePaymentMethodStatus =
|
|
4707
|
+
this.savePaymentMethodStatus = this.savingFailedOrCancel(status) ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
|
|
4674
4708
|
this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
|
|
4675
4709
|
}
|
|
4676
4710
|
}
|