@xsolla/payment-client-core 0.1.14-test11 → 0.1.14-test13
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 +48 -10
- package/fesm2015/xsolla-payment-client-core.mjs +47 -9
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +47 -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-test13.tgz +0 -0
- package/xsolla-payment-client-core-0.1.14-test11.tgz +0 -0
|
@@ -4631,17 +4631,53 @@ 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 (!accountData) {
|
|
4644
|
+
this.startWaitingStatusUpdates(params.invoice);
|
|
4639
4645
|
statusResponse.status.statusState = StatusEnum.processing;
|
|
4640
4646
|
}
|
|
4647
|
+
// if (!this.savingFailedOrCancel(statusResponse?.status) && !this.savingSuccessful(accountData, statusResponse?.status)) {
|
|
4648
|
+
// // todo is proccessing
|
|
4649
|
+
//
|
|
4650
|
+
// this.startWaitingStatusUpdates(params.invoice);
|
|
4651
|
+
// statusResponse.status.statusState = StatusEnum.processing;
|
|
4652
|
+
// }
|
|
4641
4653
|
statusResponse.status.isSavePaymentAccount = true;
|
|
4642
4654
|
return statusResponse.status;
|
|
4655
|
+
// if (!this.savePaymentMethodStatus) {
|
|
4656
|
+
// statusResponse.status.statusState = StatusEnum.processing;
|
|
4657
|
+
// }
|
|
4658
|
+
// statusResponse.status.isSavePaymentAccount = true;
|
|
4659
|
+
// return statusResponse.status;
|
|
4660
|
+
}
|
|
4661
|
+
savingFailedOrCancel(status) {
|
|
4662
|
+
return status?.titleClass === TitleClass.cancel || status?.titleClass === TitleClass.cancelUser;
|
|
4663
|
+
}
|
|
4664
|
+
savingSuccessful(accountData, status) {
|
|
4665
|
+
return !!(status?.titleClass === TitleClass.done && accountData?.new_account);
|
|
4666
|
+
}
|
|
4667
|
+
getPaymentAccountData(invoice) {
|
|
4668
|
+
return this.savedPaymentAccountChangesService
|
|
4669
|
+
.request(invoice);
|
|
4670
|
+
// .then((accountChanges: SavedPaymentAccountChanges) => {
|
|
4671
|
+
// if (accountChanges) {
|
|
4672
|
+
// this.handleSavingStatus(status, accountChanges.new_account);
|
|
4673
|
+
// }
|
|
4674
|
+
// });
|
|
4643
4675
|
}
|
|
4644
4676
|
startWaitingStatusUpdates(invoice) {
|
|
4677
|
+
if (this.listenStatusSubscription) {
|
|
4678
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4679
|
+
this.listenStatusService.stopListening();
|
|
4680
|
+
}
|
|
4645
4681
|
this.listenStatusService.listen(invoice);
|
|
4646
4682
|
this.listenStatusSubscription = this.listenStatusService.statusUpdated$
|
|
4647
4683
|
.subscribe(({ statusResponse }) => {
|
|
@@ -4658,20 +4694,22 @@ class SavePaymentMethodStatusService {
|
|
|
4658
4694
|
.request(status.invoice)
|
|
4659
4695
|
.then((accountChanges) => {
|
|
4660
4696
|
if (accountChanges) {
|
|
4661
|
-
this.handleSavingStatus(status, accountChanges
|
|
4697
|
+
this.handleSavingStatus(status, accountChanges);
|
|
4662
4698
|
}
|
|
4663
4699
|
});
|
|
4664
4700
|
}
|
|
4665
4701
|
handleSavingStatus(status, account) {
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
const
|
|
4669
|
-
if (
|
|
4702
|
+
// const savingFailedOrCancel = status?.titleClass === TitleClass.cancel || status?.titleClass === TitleClass.cancelUser;
|
|
4703
|
+
//
|
|
4704
|
+
// const savingSuccessful = status?.titleClass === TitleClass.done && account;
|
|
4705
|
+
if (!this.savingFailedOrCancel(status) && !this.savingSuccessful(account, status)) {
|
|
4670
4706
|
return;
|
|
4671
4707
|
}
|
|
4672
|
-
|
|
4708
|
+
this.listenStatusService.stopListening();
|
|
4709
|
+
this.listenStatusSubscription.unsubscribe();
|
|
4710
|
+
// const paymentAccountWasSaved = status?.titleClass === TitleClass.done && account !== null;
|
|
4673
4711
|
const isSavePaymentMethod = true;
|
|
4674
|
-
this.savePaymentMethodStatus =
|
|
4712
|
+
this.savePaymentMethodStatus = this.savingFailedOrCancel(status) ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
|
|
4675
4713
|
this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
|
|
4676
4714
|
}
|
|
4677
4715
|
}
|