@xsolla/payment-client-core 0.1.14-test22 → 0.1.14-test3
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 +3 -6
- 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 +51 -96
- package/fesm2015/xsolla-payment-client-core.mjs.map +1 -1
- package/fesm2020/xsolla-payment-client-core.mjs +51 -96
- 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-test3.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
|
],
|
|
@@ -4619,113 +4621,66 @@ class SavedPaymentAccountChangesService {
|
|
|
4619
4621
|
}
|
|
4620
4622
|
}
|
|
4621
4623
|
SavedPaymentAccountChangesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, deps: [{ token: SettingsService }, { token: SecureApiClient }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4622
|
-
SavedPaymentAccountChangesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService
|
|
4624
|
+
SavedPaymentAccountChangesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService });
|
|
4623
4625
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavedPaymentAccountChangesService, decorators: [{
|
|
4624
|
-
type: Injectable
|
|
4625
|
-
args: [{
|
|
4626
|
-
providedIn: 'root',
|
|
4627
|
-
}]
|
|
4626
|
+
type: Injectable
|
|
4628
4627
|
}], ctorParameters: function () { return [{ type: SettingsService }, { type: SecureApiClient }]; } });
|
|
4629
4628
|
|
|
4630
4629
|
class SavePaymentMethodStatusService {
|
|
4631
|
-
constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService
|
|
4630
|
+
constructor(statusRequestService, listenStatusService, savedPaymentAccountChangesService, nextActionService) {
|
|
4632
4631
|
this.statusRequestService = statusRequestService;
|
|
4633
4632
|
this.listenStatusService = listenStatusService;
|
|
4634
4633
|
this.savedPaymentAccountChangesService = savedPaymentAccountChangesService;
|
|
4635
4634
|
this.nextActionService = nextActionService;
|
|
4636
|
-
this.checkStatusService = checkStatusService;
|
|
4637
|
-
this.statusChecked = false;
|
|
4638
4635
|
}
|
|
4639
4636
|
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
|
-
}
|
|
4637
|
+
this.statusRequestService.setRequestParams(params);
|
|
4667
4638
|
this.startWaitingStatusUpdates(params.invoice);
|
|
4668
4639
|
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);
|
|
4640
|
+
const statusResponse = await firstValueFrom(this.statusRequestService.response$);
|
|
4641
|
+
if (!this.savePaymentMethodStatus) {
|
|
4642
|
+
statusResponse.status.statusState = StatusEnum.processing;
|
|
4643
|
+
}
|
|
4644
|
+
return statusResponse.status;
|
|
4680
4645
|
}
|
|
4681
4646
|
startWaitingStatusUpdates(invoice) {
|
|
4682
|
-
if (this.listenStatusSubscription) {
|
|
4683
|
-
this.listenStatusSubscription.unsubscribe();
|
|
4684
|
-
this.listenStatusService.stopListening();
|
|
4685
|
-
}
|
|
4686
4647
|
this.listenStatusService.listen(invoice);
|
|
4687
|
-
this.
|
|
4688
|
-
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
});
|
|
4695
|
-
});
|
|
4648
|
+
this.listenStatusService.statusUpdated$
|
|
4649
|
+
.pipe(skip(1))
|
|
4650
|
+
.subscribe(({ statusResponse }) => {
|
|
4651
|
+
if (statusResponse.status) {
|
|
4652
|
+
this.loadNewPaymentAccountData(statusResponse.status);
|
|
4653
|
+
}
|
|
4654
|
+
});
|
|
4696
4655
|
}
|
|
4697
|
-
loadNewPaymentAccountData(status
|
|
4656
|
+
loadNewPaymentAccountData(status) {
|
|
4698
4657
|
if (!status.invoice) {
|
|
4699
4658
|
return;
|
|
4700
4659
|
}
|
|
4701
|
-
void this.
|
|
4660
|
+
void this.savedPaymentAccountChangesService
|
|
4661
|
+
.request(status.invoice)
|
|
4662
|
+
.then((accountChanges) => {
|
|
4702
4663
|
if (accountChanges) {
|
|
4703
|
-
this.
|
|
4704
|
-
this.handleSavingStatus(status, accountChanges, checkStatus);
|
|
4664
|
+
this.handleSavingStatus(status, accountChanges.new_account);
|
|
4705
4665
|
}
|
|
4706
4666
|
});
|
|
4707
4667
|
}
|
|
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
|
-
}
|
|
4668
|
+
handleSavingStatus(status, account) {
|
|
4715
4669
|
this.listenStatusService.stopListening();
|
|
4716
|
-
|
|
4670
|
+
const paymentAccountWasSaved = status?.titleClass === TitleClass.done && account !== null;
|
|
4717
4671
|
const isSavePaymentMethod = true;
|
|
4672
|
+
this.savePaymentMethodStatus = paymentAccountWasSaved ? SavePaymentMethodStatus.success : SavePaymentMethodStatus.failed;
|
|
4718
4673
|
this.nextActionService.emitFlowUpdates(new StatusUpdatedAction(status, isSavePaymentMethod, this.savePaymentMethodStatus));
|
|
4719
4674
|
}
|
|
4720
4675
|
}
|
|
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 }
|
|
4676
|
+
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
4677
|
SavePaymentMethodStatusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, providedIn: 'root' });
|
|
4723
4678
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.7", ngImport: i0, type: SavePaymentMethodStatusService, decorators: [{
|
|
4724
4679
|
type: Injectable,
|
|
4725
4680
|
args: [{
|
|
4726
|
-
providedIn: 'root'
|
|
4681
|
+
providedIn: 'root'
|
|
4727
4682
|
}]
|
|
4728
|
-
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }
|
|
4683
|
+
}], ctorParameters: function () { return [{ type: StatusRequestService }, { type: ListenStatusService }, { type: SavedPaymentAccountChangesService }, { type: NextActionService }]; } });
|
|
4729
4684
|
|
|
4730
4685
|
class StatusService {
|
|
4731
4686
|
constructor(urlService, statusRequestService, financeDetailsService, listenStatusService, nextActionService, savePaymentMethodStatusService) {
|
|
@@ -4737,9 +4692,11 @@ class StatusService {
|
|
|
4737
4692
|
this.savePaymentMethodStatusService = savePaymentMethodStatusService;
|
|
4738
4693
|
}
|
|
4739
4694
|
async getStatus(params) {
|
|
4740
|
-
|
|
4695
|
+
// todo: если params.savePaymentMethod, то надо выполнить логику для
|
|
4696
|
+
// account status
|
|
4697
|
+
const isSavePaymentMethodMode = !!params?.savePaymentMethod;
|
|
4741
4698
|
if (isSavePaymentMethodMode) {
|
|
4742
|
-
return this.savePaymentMethodStatusService.getStatus(params);
|
|
4699
|
+
return this.savePaymentMethodStatusService.getStatus(params); // todo: saveMethodStatus.getStatus();
|
|
4743
4700
|
}
|
|
4744
4701
|
this.statusRequestService.setRequestParams(params);
|
|
4745
4702
|
this.startWaitingStatusUpdates(params.invoice);
|
|
@@ -5256,7 +5213,6 @@ class PaymentService {
|
|
|
5256
5213
|
this.destroy$ = new Subject();
|
|
5257
5214
|
this.formDestroy$ = new Subject();
|
|
5258
5215
|
this.formFieldsStatusSubject = new BehaviorSubject(null);
|
|
5259
|
-
this.isSavingMethodMode = false;
|
|
5260
5216
|
}
|
|
5261
5217
|
async initialize(config) {
|
|
5262
5218
|
this.destroy$ = new Subject();
|
|
@@ -5282,10 +5238,9 @@ class PaymentService {
|
|
|
5282
5238
|
this.emitFormFieldsStatus(this.form);
|
|
5283
5239
|
return;
|
|
5284
5240
|
}
|
|
5285
|
-
this.isSavingMethodMode = this.fields.some(({ name, value }) => name === 'savePsAccountOnly' && value === "1" /* XpsBoolean.true */);
|
|
5286
5241
|
const submitResponse = await this.submitService.request(this.fields, this.form);
|
|
5287
5242
|
this.data = submitResponse;
|
|
5288
|
-
if (!
|
|
5243
|
+
if (!submitResponse.isSavingMethodMode) {
|
|
5289
5244
|
this.emitFinanceDetails(submitResponse.summary);
|
|
5290
5245
|
}
|
|
5291
5246
|
this.emitFormMessages(submitResponse.messages);
|
|
@@ -5336,7 +5291,7 @@ class PaymentService {
|
|
|
5336
5291
|
signature: this.data.signature ?? '',
|
|
5337
5292
|
locale: this.data.fields.find((field) => field.name === 'locale')?.value ??
|
|
5338
5293
|
'en',
|
|
5339
|
-
|
|
5294
|
+
savePaymentMethod: this.data.isSavingMethodMode ? 1 : 0,
|
|
5340
5295
|
};
|
|
5341
5296
|
return this.statusService.getStatus(params);
|
|
5342
5297
|
}
|