@xsolla/payment-client-core 0.1.14-test11 → 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 +43 -10
- package/fesm2015/xsolla-payment-client-core.mjs +42 -9
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +42 -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/package.json +1 -1
- package/xsolla-payment-client-core-0.1.14-test12.tgz +0 -0
- package/xsolla-payment-client-core-0.1.14-test11.tgz +0 -0
|
@@ -4631,17 +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
|
}
|
|
4641
4648
|
statusResponse.status.isSavePaymentAccount = true;
|
|
4642
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
|
+
// });
|
|
4643
4670
|
}
|
|
4644
4671
|
startWaitingStatusUpdates(invoice) {
|
|
4672
|
+
if (this.listenStatusSubscription) {
|
|
4673
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4674
|
+
this.listenStatusService.stopListening();
|
|
4675
|
+
}
|
|
4645
4676
|
this.listenStatusService.listen(invoice);
|
|
4646
4677
|
this.listenStatusSubscription = this.listenStatusService.statusUpdated$
|
|
4647
4678
|
.subscribe(({ statusResponse }) => {
|
|
@@ -4658,20 +4689,22 @@ class SavePaymentMethodStatusService {
|
|
|
4658
4689
|
.request(status.invoice)
|
|
4659
4690
|
.then((accountChanges) => {
|
|
4660
4691
|
if (accountChanges) {
|
|
4661
|
-
this.handleSavingStatus(status, accountChanges
|
|
4692
|
+
this.handleSavingStatus(status, accountChanges);
|
|
4662
4693
|
}
|
|
4663
4694
|
});
|
|
4664
4695
|
}
|
|
4665
4696
|
handleSavingStatus(status, account) {
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
const
|
|
4669
|
-
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)) {
|
|
4670
4701
|
return;
|
|
4671
4702
|
}
|
|
4672
|
-
|
|
4703
|
+
this.listenStatusService.stopListening();
|
|
4704
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4705
|
+
// const paymentAccountWasSaved = status?.titleClass === TitleClass.done && account !== null;
|
|
4673
4706
|
const isSavePaymentMethod = true;
|
|
4674
|
-
this.savePaymentMethodStatus =
|
|
4707
|
+
this.savePaymentMethodStatus = this.savingFailedOrCancel(status) ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
|
|
4675
4708
|
this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
|
|
4676
4709
|
}
|
|
4677
4710
|
}
|