@xsolla/payment-client-core 0.1.14-test22 → 0.1.14-test4
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 +4 -6
- package/esm2020/lib/core/payment/payment.service.mjs +3 -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 +27 -72
- package/esm2020/lib/core/payment/status/status-request/status-request-params.interface.mjs +1 -1
- package/esm2020/lib/core/payment/status/status-request/status-search-param.enum.mjs +2 -2
- package/esm2020/lib/core/payment/status/status-request/status-search-params.map.mjs +3 -3
- package/esm2020/lib/core/payment/status/status.interface.mjs +1 -1
- package/esm2020/lib/core/payment/status/status.service.mjs +5 -3
- package/esm2020/lib/core/payment/submit/response/submit-response.class.mjs +8 -2
- package/esm2020/lib/core/payment-methods/payment-methods-request-params.interface.mjs +1 -1
- package/esm2020/lib/core/payment-methods/payment-methods.service.mjs +2 -4
- package/fesm2015/xsolla-payment-client-core.mjs +50 -92
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +50 -92
- 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.service.d.ts +0 -1
- package/lib/core/payment/status/save-payment-method-status/save-payment-method-status.service.d.ts +1 -11
- package/lib/core/payment/status/status-request/status-request-params.interface.d.ts +1 -1
- package/lib/core/payment/status/status-request/status-search-param.enum.d.ts +1 -1
- package/lib/core/payment/status/status.interface.d.ts +0 -1
- package/lib/core/payment/submit/response/submit-response.class.d.ts +1 -0
- package/lib/core/payment-methods/payment-methods-request-params.interface.d.ts +1 -1
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.1.14-test4.tgz +0 -0
- package/xsolla-payment-client-core-0.1.14-test22.tgz +0 -0
|
@@ -250,9 +250,7 @@ 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
|
|
254
|
-
? "1" /* XpsBoolean.true */
|
|
255
|
-
: "0" /* XpsBoolean.false */,
|
|
253
|
+
save_payment_account_only: isSaveMethodMode ? "1" /* XpsBoolean.true */ : "0" /* XpsBoolean.false */
|
|
256
254
|
};
|
|
257
255
|
const cacheKey = JSON.stringify(requestParams);
|
|
258
256
|
if (!this.cache.has(cacheKey)) {
|
|
@@ -456,16 +454,16 @@ class PaymentConfigService {
|
|
|
456
454
|
}
|
|
457
455
|
return {
|
|
458
456
|
...config,
|
|
459
|
-
returnUrl: this.enrichReturnUrl(config.returnUrl, !!config.savePaymentMethod)
|
|
457
|
+
returnUrl: this.enrichReturnUrl(config.returnUrl, !!config.savePaymentMethod)
|
|
460
458
|
};
|
|
461
459
|
}
|
|
462
460
|
enrichReturnUrl(returnUrl, savePaymentMethod) {
|
|
463
461
|
let enrichedUrl = this.urlService.addSearchParams(returnUrl, {
|
|
464
|
-
token: this.settingsService.token
|
|
462
|
+
token: this.settingsService.token
|
|
465
463
|
});
|
|
466
464
|
if (savePaymentMethod) {
|
|
467
465
|
enrichedUrl = this.urlService.addSearchParams(returnUrl, {
|
|
468
|
-
isSavePaymentAccount: "1" /* XpsBoolean.true
|
|
466
|
+
isSavePaymentAccount: "1" /* XpsBoolean.true */
|
|
469
467
|
});
|
|
470
468
|
}
|
|
471
469
|
return enrichedUrl;
|
|
@@ -476,7 +474,7 @@ PaymentConfigService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0",
|
|
|
476
474
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: PaymentConfigService, decorators: [{
|
|
477
475
|
type: Injectable,
|
|
478
476
|
args: [{
|
|
479
|
-
providedIn: 'root'
|
|
477
|
+
providedIn: 'root'
|
|
480
478
|
}]
|
|
481
479
|
}], ctorParameters: function () { return [{ type: UrlService }, { type: SettingsService }]; } });
|
|
482
480
|
|
|
@@ -557,9 +555,15 @@ var FieldNames;
|
|
|
557
555
|
class SubmitResponse {
|
|
558
556
|
constructor(parameters, responseNumber = 0) {
|
|
559
557
|
this.responseNumber = responseNumber;
|
|
558
|
+
this.isSavingMethodMode = false;
|
|
560
559
|
/* Todo split into properties */
|
|
561
560
|
this.parameters = parameters;
|
|
562
|
-
this.fields = Object.keys(parameters.form).map((key) =>
|
|
561
|
+
this.fields = Object.keys(parameters.form).map((key) => {
|
|
562
|
+
if (key === 'save_payment_account_only') {
|
|
563
|
+
this.isSavingMethodMode = parameters.form[key].value === "1" /* XpsBoolean.true */;
|
|
564
|
+
}
|
|
565
|
+
return parameters.form[key];
|
|
566
|
+
});
|
|
563
567
|
if (parameters.onlineBanking) {
|
|
564
568
|
this.onlineBanking = {
|
|
565
569
|
url: parameters.onlineBanking.value,
|
|
@@ -926,7 +930,7 @@ class StatusUpdatedAction {
|
|
|
926
930
|
isCanceled: status.isCanceled,
|
|
927
931
|
group: status.group,
|
|
928
932
|
isSavePaymentMethodMode,
|
|
929
|
-
savePaymentMethodStatus
|
|
933
|
+
savePaymentMethodStatus
|
|
930
934
|
};
|
|
931
935
|
}
|
|
932
936
|
}
|
|
@@ -1572,9 +1576,7 @@ class InitializeService {
|
|
|
1572
1576
|
? "1" /* XpsBoolean.true */
|
|
1573
1577
|
: "0" /* XpsBoolean.false */,
|
|
1574
1578
|
saved_method_id: config.savedMethodId,
|
|
1575
|
-
save_payment_account_only: !!config.savePaymentMethod
|
|
1576
|
-
? "1" /* XpsBoolean.true */
|
|
1577
|
-
: "0" /* XpsBoolean.false */,
|
|
1579
|
+
save_payment_account_only: !!config.savePaymentMethod ? "1" /* XpsBoolean.true */ : "0" /* XpsBoolean.false */
|
|
1578
1580
|
};
|
|
1579
1581
|
return this.xpsApiService
|
|
1580
1582
|
.directPaymentRequest(requestParams)
|
|
@@ -1606,7 +1608,7 @@ InitializeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", ve
|
|
|
1606
1608
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: InitializeService, decorators: [{
|
|
1607
1609
|
type: Injectable,
|
|
1608
1610
|
args: [{
|
|
1609
|
-
providedIn: 'root'
|
|
1611
|
+
providedIn: 'root'
|
|
1610
1612
|
}]
|
|
1611
1613
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
1612
1614
|
type: Inject,
|
|
@@ -2964,7 +2966,7 @@ var StatusSearchParam;
|
|
|
2964
2966
|
StatusSearchParam["testPs"] = "fix_testPs";
|
|
2965
2967
|
StatusSearchParam["testXsolla"] = "fix_testXsolla";
|
|
2966
2968
|
StatusSearchParam["userReturnStatus"] = "fix_userReturnStatus";
|
|
2967
|
-
StatusSearchParam["
|
|
2969
|
+
StatusSearchParam["savePaymentMethod"] = "savePaymentMethod";
|
|
2968
2970
|
})(StatusSearchParam || (StatusSearchParam = {}));
|
|
2969
2971
|
|
|
2970
2972
|
const requiredStatusSearchParams = [
|
|
@@ -3045,9 +3047,9 @@ const statusSearchParamsMap = new Map([
|
|
|
3045
3047
|
},
|
|
3046
3048
|
],
|
|
3047
3049
|
[
|
|
3048
|
-
StatusSearchParam.
|
|
3050
|
+
StatusSearchParam.savePaymentMethod,
|
|
3049
3051
|
{
|
|
3050
|
-
key: '
|
|
3052
|
+
key: 'savePaymentMethod',
|
|
3051
3053
|
converter: numberConverter,
|
|
3052
3054
|
},
|
|
3053
3055
|
],
|
|
@@ -4623,109 +4625,65 @@ SavedPaymentAccountChangesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersi
|
|
|
4623
4625
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, decorators: [{
|
|
4624
4626
|
type: Injectable,
|
|
4625
4627
|
args: [{
|
|
4626
|
-
providedIn: 'root'
|
|
4628
|
+
providedIn: 'root'
|
|
4627
4629
|
}]
|
|
4628
4630
|
}], ctorParameters: function () { return [{ type: SettingsService }, { type: SecureApiClient }]; } });
|
|
4629
4631
|
|
|
4630
4632
|
class SavePaymentMethodStatusService {
|
|
4631
|
-
constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService
|
|
4633
|
+
constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService) {
|
|
4632
4634
|
this.statusRequestService = statusRequestService;
|
|
4633
4635
|
this.listenStatusService = listenStatusService;
|
|
4634
4636
|
this.savedPaymentAccountChangesService = savedPaymentAccountChangesService;
|
|
4635
4637
|
this.nextActionService = nextActionService;
|
|
4636
|
-
this.checkStatusService = checkStatusService;
|
|
4637
|
-
this.statusChecked = false;
|
|
4638
4638
|
}
|
|
4639
4639
|
async getStatus(params) {
|
|
4640
|
-
|
|
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;
|
|
4651
|
-
}
|
|
4652
|
-
if (!this.statusChecked) {
|
|
4653
|
-
this.checkStatus(params);
|
|
4654
|
-
this.status.statusState = StatusEnum.processing;
|
|
4655
|
-
return this.status;
|
|
4656
|
-
}
|
|
4657
|
-
this.statusChecked = false;
|
|
4658
|
-
this.status.statusState = StatusEnum.error;
|
|
4659
|
-
const outStatus = { ...this.status };
|
|
4660
|
-
this.status = null;
|
|
4661
|
-
return outStatus;
|
|
4662
|
-
}
|
|
4663
|
-
checkStatus(params) {
|
|
4664
|
-
if (!this.statusChecked) {
|
|
4665
|
-
this.statusChecked = true;
|
|
4666
|
-
}
|
|
4640
|
+
this.statusRequestService.setRequestParams(params);
|
|
4667
4641
|
this.startWaitingStatusUpdates(params.invoice);
|
|
4668
4642
|
this.statusRequestService.request();
|
|
4669
|
-
|
|
4670
|
-
|
|
4671
|
-
|
|
4672
|
-
|
|
4673
|
-
|
|
4674
|
-
savingSuccessful(accountData, status, checkStatus) {
|
|
4675
|
-
return !!(status?.titleClass === TitleClass.done &&
|
|
4676
|
-
(accountData?.new_account || checkStatus?.isPaymentAccountAttached));
|
|
4677
|
-
}
|
|
4678
|
-
getPaymentAccountData(invoice) {
|
|
4679
|
-
return this.savedPaymentAccountChangesService.request(invoice);
|
|
4643
|
+
const statusResponse = await firstValueFrom(this.statusRequestService.response$);
|
|
4644
|
+
if (!this.savePaymentMethodStatus) {
|
|
4645
|
+
statusResponse.status.statusState = StatusEnum.processing;
|
|
4646
|
+
}
|
|
4647
|
+
return statusResponse.status;
|
|
4680
4648
|
}
|
|
4681
4649
|
startWaitingStatusUpdates(invoice) {
|
|
4682
|
-
if (this.listenStatusSubscription) {
|
|
4683
|
-
this.listenStatusSubscription.unsubscribe();
|
|
4684
|
-
this.listenStatusService.stopListening();
|
|
4685
|
-
}
|
|
4686
4650
|
this.listenStatusService.listen(invoice);
|
|
4687
|
-
this.
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
});
|
|
4695
|
-
});
|
|
4651
|
+
this.listenStatusService.statusUpdated$
|
|
4652
|
+
.pipe(skip(1))
|
|
4653
|
+
.subscribe(({ statusResponse }) => {
|
|
4654
|
+
if (statusResponse.status) {
|
|
4655
|
+
this.loadNewPaymentAccountData(statusResponse.status);
|
|
4656
|
+
}
|
|
4657
|
+
});
|
|
4696
4658
|
}
|
|
4697
|
-
loadNewPaymentAccountData(status
|
|
4659
|
+
loadNewPaymentAccountData(status) {
|
|
4698
4660
|
if (!status.invoice) {
|
|
4699
4661
|
return;
|
|
4700
4662
|
}
|
|
4701
|
-
void this.
|
|
4663
|
+
void this.savedPaymentAccountChangesService
|
|
4664
|
+
.request(status.invoice)
|
|
4665
|
+
.then((accountChanges) => {
|
|
4702
4666
|
if (accountChanges) {
|
|
4703
|
-
this.
|
|
4704
|
-
this.handleSavingStatus(status, accountChanges, checkStatus);
|
|
4667
|
+
this.handleSavingStatus(status, accountChanges.new_account);
|
|
4705
4668
|
}
|
|
4706
4669
|
});
|
|
4707
4670
|
}
|
|
4708
|
-
handleSavingStatus(status, account
|
|
4709
|
-
if (this.savingSuccessful(account, status, checkStatus)) {
|
|
4710
|
-
this.savePaymentMethodStatus = SavePaymentMethodStatus.success;
|
|
4711
|
-
}
|
|
4712
|
-
else {
|
|
4713
|
-
this.savePaymentMethodStatus = SavePaymentMethodStatus.failed;
|
|
4714
|
-
}
|
|
4671
|
+
handleSavingStatus(status, account) {
|
|
4715
4672
|
this.listenStatusService.stopListening();
|
|
4716
|
-
|
|
4673
|
+
const paymentAccountWasSaved = status?.titleClass === TitleClass.done && account !== null;
|
|
4717
4674
|
const isSavePaymentMethod = true;
|
|
4675
|
+
this.savePaymentMethodStatus = paymentAccountWasSaved ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
|
|
4718
4676
|
this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
|
|
4719
4677
|
}
|
|
4720
4678
|
}
|
|
4721
|
-
SavePaymentMethodStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, deps: [{ token: StatusRequestService }, { token: ListenStatusService }, { token: SavedPaymentAccountChangesService }, { token: NextActionService }
|
|
4679
|
+
SavePaymentMethodStatusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, deps: [{ token: StatusRequestService }, { token: ListenStatusService }, { token: SavedPaymentAccountChangesService }, { token: NextActionService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4722
4680
|
SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, providedIn: 'root' });
|
|
4723
4681
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
|
|
4724
4682
|
type: Injectable,
|
|
4725
4683
|
args: [{
|
|
4726
|
-
providedIn: 'root'
|
|
4684
|
+
providedIn: 'root'
|
|
4727
4685
|
}]
|
|
4728
|
-
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }
|
|
4686
|
+
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }]; } });
|
|
4729
4687
|
|
|
4730
4688
|
class StatusService {
|
|
4731
4689
|
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService) {
|
|
@@ -4737,9 +4695,11 @@ class StatusService {
|
|
|
4737
4695
|
this.savePaymentMethodStatusService = savePaymentMethodStatusService;
|
|
4738
4696
|
}
|
|
4739
4697
|
async getStatus(params) {
|
|
4740
|
-
|
|
4698
|
+
// todo: если params.savePaymentMethod, то надо выполнить логику для
|
|
4699
|
+
// account status
|
|
4700
|
+
const isSavePaymentMethodMode = !!params?.savePaymentMethod;
|
|
4741
4701
|
if (isSavePaymentMethodMode) {
|
|
4742
|
-
return this.savePaymentMethodStatusService.getStatus(params);
|
|
4702
|
+
return this.savePaymentMethodStatusService.getStatus(params); // todo: saveMethodStatus.getStatus();
|
|
4743
4703
|
}
|
|
4744
4704
|
this.statusRequestService.setRequestParams(params);
|
|
4745
4705
|
this.startWaitingStatusUpdates(params.invoice);
|
|
@@ -5256,7 +5216,6 @@ class PaymentService {
|
|
|
5256
5216
|
this.destroy$ = new Subject();
|
|
5257
5217
|
this.formDestroy$ = new Subject();
|
|
5258
5218
|
this.formFieldsStatusSubject = new BehaviorSubject(null);
|
|
5259
|
-
this.isSavingMethodMode = false;
|
|
5260
5219
|
}
|
|
5261
5220
|
async initialize(config) {
|
|
5262
5221
|
this.destroy$ = new Subject();
|
|
@@ -5282,10 +5241,9 @@ class PaymentService {
|
|
|
5282
5241
|
this.emitFormFieldsStatus(this.form);
|
|
5283
5242
|
return;
|
|
5284
5243
|
}
|
|
5285
|
-
this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
|
|
5286
5244
|
const submitResponse = await this.submitService.request(this.fields, this.form);
|
|
5287
5245
|
this.data = submitResponse;
|
|
5288
|
-
if (!
|
|
5246
|
+
if (!submitResponse.isSavingMethodMode) {
|
|
5289
5247
|
this.emitFinanceDetails(submitResponse.summary);
|
|
5290
5248
|
}
|
|
5291
5249
|
this.emitFormMessages(submitResponse.messages);
|
|
@@ -5336,7 +5294,7 @@ class PaymentService {
|
|
|
5336
5294
|
signature: this.data.signature ?? '',
|
|
5337
5295
|
locale: this.data.fields.find((field) => field.name === 'locale')?.value ??
|
|
5338
5296
|
'en',
|
|
5339
|
-
|
|
5297
|
+
savePaymentMethod: this.data.isSavingMethodMode ? 1 : 0,
|
|
5340
5298
|
};
|
|
5341
5299
|
return this.statusService.getStatus(params);
|
|
5342
5300
|
}
|