@xsolla/payment-client-core 0.3.2 → 0.3.4
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/esm2022/lib/core/capabilities/capabilities.service.mjs +25 -0
- package/esm2022/lib/core/capabilities/capability.const.mjs +8 -0
- package/esm2022/lib/core/payment/actions/next-action.interface.mjs +1 -1
- package/esm2022/lib/core/payment/actions/next-actions.mjs +3 -1
- package/esm2022/lib/core/payment/actions/show-init-form/show-init-form.action.class.mjs +56 -0
- package/esm2022/lib/core/payment/actions/show-init-form/show-init-form.action.type.mjs +2 -0
- package/esm2022/lib/core/payment/config/config.service.mjs +8 -1
- package/esm2022/lib/core/sdk-payment-systems/google-pay/google-pay.service.mjs +9 -1
- package/esm2022/lib/core/settings/configuration.interface.mjs +1 -1
- package/esm2022/lib/core-library.service.mjs +9 -4
- package/fesm2022/xsolla-payment-client-core.mjs +102 -3
- package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/capabilities/capabilities.service.d.ts +9 -0
- package/lib/core/capabilities/capability.const.d.ts +6 -0
- package/lib/core/payment/actions/next-action.interface.d.ts +2 -1
- package/lib/core/payment/actions/show-init-form/show-init-form.action.class.d.ts +17 -0
- package/lib/core/payment/actions/show-init-form/show-init-form.action.type.d.ts +11 -0
- package/lib/core/payment/config/config.service.d.ts +3 -0
- package/lib/core/sdk-payment-systems/google-pay/google-pay.service.d.ts +1 -0
- package/lib/core/settings/configuration.interface.d.ts +7 -0
- package/lib/core-library.service.d.ts +3 -1
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.3.4.tgz +0 -0
- package/xsolla-payment-client-core-0.3.2.tgz +0 -0
|
@@ -1280,6 +1280,13 @@ class PaymentConfigService {
|
|
|
1280
1280
|
constructor(urlService, settingsService) {
|
|
1281
1281
|
this.urlService = urlService;
|
|
1282
1282
|
this.settingsService = settingsService;
|
|
1283
|
+
this._activeConfig = null;
|
|
1284
|
+
}
|
|
1285
|
+
get activeConfig() {
|
|
1286
|
+
return this._activeConfig;
|
|
1287
|
+
}
|
|
1288
|
+
setActiveConfig(config) {
|
|
1289
|
+
this._activeConfig = config;
|
|
1283
1290
|
}
|
|
1284
1291
|
enrich(config) {
|
|
1285
1292
|
if (!config.returnUrl) {
|
|
@@ -1985,6 +1992,85 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
1985
1992
|
type: Injectable
|
|
1986
1993
|
}] });
|
|
1987
1994
|
|
|
1995
|
+
/**
|
|
1996
|
+
* Known capability identifiers. Values mirror the SDK-side
|
|
1997
|
+
* {@link Capability} enum but are kept as plain strings because
|
|
1998
|
+
* payment-client-core must not depend on pay-station-sdk.
|
|
1999
|
+
*/
|
|
2000
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2001
|
+
const SHOW_INIT_FORM_CAPABILITY = 'show_init_form_action';
|
|
2002
|
+
|
|
2003
|
+
class CapabilitiesService {
|
|
2004
|
+
constructor() {
|
|
2005
|
+
this.capabilities = new Set();
|
|
2006
|
+
}
|
|
2007
|
+
set(list = []) {
|
|
2008
|
+
this.capabilities = new Set(list);
|
|
2009
|
+
}
|
|
2010
|
+
has(capability) {
|
|
2011
|
+
return this.capabilities.has(capability);
|
|
2012
|
+
}
|
|
2013
|
+
clear() {
|
|
2014
|
+
this.capabilities.clear();
|
|
2015
|
+
}
|
|
2016
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CapabilitiesService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2017
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CapabilitiesService, providedIn: 'root' }); }
|
|
2018
|
+
}
|
|
2019
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CapabilitiesService, decorators: [{
|
|
2020
|
+
type: Injectable,
|
|
2021
|
+
args: [{
|
|
2022
|
+
providedIn: 'root',
|
|
2023
|
+
}]
|
|
2024
|
+
}] });
|
|
2025
|
+
|
|
2026
|
+
class ShowInitFormActionCreator {
|
|
2027
|
+
constructor(paymentConfigService, capabilitiesService) {
|
|
2028
|
+
this.paymentConfigService = paymentConfigService;
|
|
2029
|
+
this.capabilitiesService = capabilitiesService;
|
|
2030
|
+
this.type = 'show_init_form';
|
|
2031
|
+
}
|
|
2032
|
+
getActionData(submitResponse) {
|
|
2033
|
+
const data = {
|
|
2034
|
+
fields: submitResponse.fields.filter((field) => field?.isVisible === "1" /* XpsBoolean.true */),
|
|
2035
|
+
errors: submitResponse.errors,
|
|
2036
|
+
messages: submitResponse.messages,
|
|
2037
|
+
};
|
|
2038
|
+
return {
|
|
2039
|
+
type: this.type,
|
|
2040
|
+
data,
|
|
2041
|
+
};
|
|
2042
|
+
}
|
|
2043
|
+
isSuitable(response) {
|
|
2044
|
+
if (!this.capabilitiesService.has(SHOW_INIT_FORM_CAPABILITY)) {
|
|
2045
|
+
return false;
|
|
2046
|
+
}
|
|
2047
|
+
if (!this.isExternalVaultActive()) {
|
|
2048
|
+
return false;
|
|
2049
|
+
}
|
|
2050
|
+
if (response.pid !== creditCardPaymentMethodId) {
|
|
2051
|
+
return false;
|
|
2052
|
+
}
|
|
2053
|
+
if (response.currentCommand !== XpsCommand.form) {
|
|
2054
|
+
return false;
|
|
2055
|
+
}
|
|
2056
|
+
if (!response.errors?.length) {
|
|
2057
|
+
return false;
|
|
2058
|
+
}
|
|
2059
|
+
return true;
|
|
2060
|
+
}
|
|
2061
|
+
isExternalVaultActive() {
|
|
2062
|
+
const config = this.paymentConfigService.activeConfig;
|
|
2063
|
+
return Boolean(config &&
|
|
2064
|
+
isCreditCardSettingsGuard(config) &&
|
|
2065
|
+
config.paymentMethodSettings?.useExternalVault);
|
|
2066
|
+
}
|
|
2067
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ShowInitFormActionCreator, deps: [{ token: PaymentConfigService }, { token: CapabilitiesService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2068
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ShowInitFormActionCreator }); }
|
|
2069
|
+
}
|
|
2070
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: ShowInitFormActionCreator, decorators: [{
|
|
2071
|
+
type: Injectable
|
|
2072
|
+
}], ctorParameters: () => [{ type: PaymentConfigService }, { type: CapabilitiesService }] });
|
|
2073
|
+
|
|
1988
2074
|
class TerminalError extends AppError {
|
|
1989
2075
|
constructor(message, code) {
|
|
1990
2076
|
super(message);
|
|
@@ -2397,6 +2483,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
2397
2483
|
|
|
2398
2484
|
const nextActionsToken = new InjectionToken('Action');
|
|
2399
2485
|
const nextActions = [
|
|
2486
|
+
ShowInitFormActionCreator,
|
|
2400
2487
|
GoogleThreeDsRedirectActionCreator,
|
|
2401
2488
|
ShowFieldsActionCreator,
|
|
2402
2489
|
CheckStatusActionCreator,
|
|
@@ -8891,7 +8978,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
8891
8978
|
}] }] });
|
|
8892
8979
|
|
|
8893
8980
|
class CoreLibraryService {
|
|
8894
|
-
constructor(settingsService, loggerService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService, creditCardService, creditCardStateService, formMessagesService, editSavedMethodsService, userBehaviourAnalyticsService, performanceService, combinedPaymentMethodsService, countriesApiService, sendInstructionService, scriptTrackerService, translateService, commonLogAttributesService) {
|
|
8981
|
+
constructor(settingsService, loggerService, countryService, paymentMethodsService, savedMethodsService, userBalanceService, paymentConfigService, paymentService, deviceFingerPrintService, financeDetailsService, legalService, statusService, nextActionService, creditCardService, creditCardStateService, formMessagesService, editSavedMethodsService, userBehaviourAnalyticsService, performanceService, combinedPaymentMethodsService, countriesApiService, sendInstructionService, scriptTrackerService, translateService, commonLogAttributesService, capabilitiesService) {
|
|
8895
8982
|
this.settingsService = settingsService;
|
|
8896
8983
|
this.loggerService = loggerService;
|
|
8897
8984
|
this.countryService = countryService;
|
|
@@ -8917,6 +9004,7 @@ class CoreLibraryService {
|
|
|
8917
9004
|
this.scriptTrackerService = scriptTrackerService;
|
|
8918
9005
|
this.translateService = translateService;
|
|
8919
9006
|
this.commonLogAttributesService = commonLogAttributesService;
|
|
9007
|
+
this.capabilitiesService = capabilitiesService;
|
|
8920
9008
|
this.paymentMethods = {
|
|
8921
9009
|
getList: async (isSaveMethodMode) => this.paymentMethodsService.getList(isSaveMethodMode),
|
|
8922
9010
|
getQuickMethods: async () => this.paymentMethodsService.getQuickMethods(),
|
|
@@ -8936,6 +9024,8 @@ class CoreLibraryService {
|
|
|
8936
9024
|
}
|
|
8937
9025
|
async init(configuration) {
|
|
8938
9026
|
await this.settingsService.init(configuration);
|
|
9027
|
+
this.capabilitiesService.set(configuration.capabilities);
|
|
9028
|
+
this.paymentConfigService.setActiveConfig(null);
|
|
8939
9029
|
this.performanceService.init();
|
|
8940
9030
|
this.userBehaviourAnalyticsService.init();
|
|
8941
9031
|
this.deviceFingerPrintService.init();
|
|
@@ -8982,6 +9072,7 @@ class CoreLibraryService {
|
|
|
8982
9072
|
createPayment(config) {
|
|
8983
9073
|
const enrichedConfig = this.paymentConfigService.enrich(config);
|
|
8984
9074
|
this.paymentConfigService.updateReferByPaymentConfiguration(enrichedConfig);
|
|
9075
|
+
this.paymentConfigService.setActiveConfig(enrichedConfig);
|
|
8985
9076
|
return {
|
|
8986
9077
|
initialize: async () => this.paymentService.initialize(enrichedConfig),
|
|
8987
9078
|
submit: async () => this.paymentService.submit(),
|
|
@@ -9059,7 +9150,7 @@ class CoreLibraryService {
|
|
|
9059
9150
|
get commonLogAttributes() {
|
|
9060
9151
|
return this.commonLogAttributesService.getAttributes();
|
|
9061
9152
|
}
|
|
9062
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CoreLibraryService, deps: [{ token: SettingsService }, { token: LoggerService }, { token: CountryService }, { token: PaymentMethodsService }, { token: SavedMethodsService }, { token: UserBalanceService }, { token: PaymentConfigService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: FinanceDetailsService }, { token: LegalService }, { token: StatusService }, { token: NextActionService }, { token: CreditCardService }, { token: CreditCardStateService }, { token: FormMessagesService }, { token: EditSavedMethodsService }, { token: UserBehaviourAnalyticsService }, { token: PerformanceService }, { token: CombinedPaymentMethodsService }, { token: CountriesApiService }, { token: SendInstructionService }, { token: ScriptTrackerService }, { token: i19.TranslateService }, { token: CommonLogAttributesService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
9153
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CoreLibraryService, deps: [{ token: SettingsService }, { token: LoggerService }, { token: CountryService }, { token: PaymentMethodsService }, { token: SavedMethodsService }, { token: UserBalanceService }, { token: PaymentConfigService }, { token: PaymentService }, { token: DeviceFingerPrintService }, { token: FinanceDetailsService }, { token: LegalService }, { token: StatusService }, { token: NextActionService }, { token: CreditCardService }, { token: CreditCardStateService }, { token: FormMessagesService }, { token: EditSavedMethodsService }, { token: UserBehaviourAnalyticsService }, { token: PerformanceService }, { token: CombinedPaymentMethodsService }, { token: CountriesApiService }, { token: SendInstructionService }, { token: ScriptTrackerService }, { token: i19.TranslateService }, { token: CommonLogAttributesService }, { token: CapabilitiesService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
9063
9154
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CoreLibraryService, providedIn: 'root' }); }
|
|
9064
9155
|
}
|
|
9065
9156
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CoreLibraryService, decorators: [{
|
|
@@ -9067,7 +9158,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
9067
9158
|
args: [{
|
|
9068
9159
|
providedIn: 'root',
|
|
9069
9160
|
}]
|
|
9070
|
-
}], ctorParameters: () => [{ type: SettingsService }, { type: LoggerService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentConfigService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: StatusService }, { type: NextActionService }, { type: CreditCardService }, { type: CreditCardStateService }, { type: FormMessagesService }, { type: EditSavedMethodsService }, { type: UserBehaviourAnalyticsService }, { type: PerformanceService }, { type: CombinedPaymentMethodsService }, { type: CountriesApiService }, { type: SendInstructionService }, { type: ScriptTrackerService }, { type: i19.TranslateService }, { type: CommonLogAttributesService }] });
|
|
9161
|
+
}], ctorParameters: () => [{ type: SettingsService }, { type: LoggerService }, { type: CountryService }, { type: PaymentMethodsService }, { type: SavedMethodsService }, { type: UserBalanceService }, { type: PaymentConfigService }, { type: PaymentService }, { type: DeviceFingerPrintService }, { type: FinanceDetailsService }, { type: LegalService }, { type: StatusService }, { type: NextActionService }, { type: CreditCardService }, { type: CreditCardStateService }, { type: FormMessagesService }, { type: EditSavedMethodsService }, { type: UserBehaviourAnalyticsService }, { type: PerformanceService }, { type: CombinedPaymentMethodsService }, { type: CountriesApiService }, { type: SendInstructionService }, { type: ScriptTrackerService }, { type: i19.TranslateService }, { type: CommonLogAttributesService }, { type: CapabilitiesService }] });
|
|
9071
9162
|
|
|
9072
9163
|
class HttpExceptionsInterceptor {
|
|
9073
9164
|
constructor(router) {
|
|
@@ -9977,6 +10068,7 @@ class GooglePayService {
|
|
|
9977
10068
|
this.paymentWindowIsReady = new Subject();
|
|
9978
10069
|
this.paymentWindowIsClose = new Subject();
|
|
9979
10070
|
this.error = new Subject();
|
|
10071
|
+
this.paymentInProgress = false;
|
|
9980
10072
|
this.googlePaymentClient = null;
|
|
9981
10073
|
this.paymentService = null;
|
|
9982
10074
|
}
|
|
@@ -10059,6 +10151,10 @@ class GooglePayService {
|
|
|
10059
10151
|
this.loggerService.error(new TaggedError('Google payment service is not initialized to proceed checkout', [ErrorTags.GOOGLEPAY]));
|
|
10060
10152
|
throw new AppError(`Google Pay. proceedCheckout: no google payment service`);
|
|
10061
10153
|
}
|
|
10154
|
+
// google support only one payment in time
|
|
10155
|
+
if (this.paymentInProgress) {
|
|
10156
|
+
return Promise.resolve(null);
|
|
10157
|
+
}
|
|
10062
10158
|
const paymentDataRequest = this.paymentService.getPaymentRequest();
|
|
10063
10159
|
if (!paymentDataRequest) {
|
|
10064
10160
|
this.loggerService.error(new TaggedError('No data for payment data request', [
|
|
@@ -10070,6 +10166,7 @@ class GooglePayService {
|
|
|
10070
10166
|
.get(CheckStatusActionCreator)
|
|
10071
10167
|
.getActionData();
|
|
10072
10168
|
try {
|
|
10169
|
+
this.paymentInProgress = true;
|
|
10073
10170
|
this.paymentWindowIsReady.next();
|
|
10074
10171
|
const paymentData = await this.googlePaymentClient.loadPaymentData(paymentDataRequest);
|
|
10075
10172
|
if (!paymentData?.paymentMethodData?.tokenizationData?.token) {
|
|
@@ -10078,9 +10175,11 @@ class GooglePayService {
|
|
|
10078
10175
|
}
|
|
10079
10176
|
this.paymentService.handleSuccessfulPayment?.(paymentData);
|
|
10080
10177
|
this.paymentWindowIsClose.next();
|
|
10178
|
+
this.paymentInProgress = false;
|
|
10081
10179
|
return checkStatusAction;
|
|
10082
10180
|
}
|
|
10083
10181
|
catch (error) {
|
|
10182
|
+
this.paymentInProgress = false;
|
|
10084
10183
|
this.paymentService.handleFailedPayment?.(error);
|
|
10085
10184
|
this.paymentWindowIsClose.next();
|
|
10086
10185
|
this.error.next(error);
|