@xsolla/payment-client-core 0.3.11 → 0.3.13
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/http/secure-api/secure-api.service.mjs +20 -6
- package/esm2022/lib/core/http/secure-api/token-prefix.const.mjs +3 -0
- package/esm2022/lib/core/payment/payment.service.mjs +3 -1
- package/esm2022/lib/core/payment/status/listen-status/listen-status.service.mjs +3 -1
- package/esm2022/lib/core/payment/status/status.service.mjs +24 -8
- package/esm2022/lib/core/sdk-payment-systems/apple-pay/apple-pay.errors.enum.mjs +2 -1
- package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/braintree.handler.mjs +14 -2
- package/esm2022/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.mjs +23 -7
- package/esm2022/lib/core/sdk-payment-systems/google-pay/google-pay.service.mjs +12 -4
- package/esm2022/lib/core/settings/settings.service.mjs +2 -1
- package/esm2022/lib/core-library.module.mjs +2 -2
- package/esm2022/lib/version.mjs +2 -2
- package/fesm2022/xsolla-payment-client-core.mjs +87 -21
- package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
- package/lib/core/http/secure-api/secure-api.service.d.ts +3 -0
- package/lib/core/http/secure-api/token-prefix.const.d.ts +2 -0
- package/lib/core/payment/status/status.service.d.ts +1 -0
- package/lib/core/sdk-payment-systems/apple-pay/apple-pay.errors.enum.d.ts +2 -1
- package/lib/core/sdk-payment-systems/apple-pay/session-handlers/checkout.handler.d.ts +3 -1
- package/lib/core/sdk-payment-systems/google-pay/google-pay.service.d.ts +3 -1
- package/lib/version.d.ts +1 -1
- package/package.json +1 -1
- package/xsolla-payment-client-core-0.3.11.tgz +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { InjectionToken, Inject, Injectable, isDevMode, Pipe, NgModule } from '@angular/core';
|
|
3
|
-
import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil,
|
|
3
|
+
import { firstValueFrom, lastValueFrom, map, Subject, BehaviorSubject, filter as filter$1, takeUntil, take, of, interval, throwError, share } from 'rxjs';
|
|
4
4
|
import * as i1 from '@angular/common/http';
|
|
5
5
|
import { HttpParams, HttpHeaders, HttpClientModule, HTTP_INTERCEPTORS, provideHttpClient } from '@angular/common/http';
|
|
6
6
|
import { UntypedFormGroup, Validators, UntypedFormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
|
@@ -13,7 +13,7 @@ import { CommonModule } from '@angular/common';
|
|
|
13
13
|
import { provideTranslateHttpLoader } from '@ngx-translate/http-loader';
|
|
14
14
|
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
16
|
-
const PAYMENT_CLIENT_CORE_VERSION = '0.3.
|
|
16
|
+
const PAYMENT_CLIENT_CORE_VERSION = '0.3.13';
|
|
17
17
|
|
|
18
18
|
class TranslateHelper {
|
|
19
19
|
static init(service) {
|
|
@@ -54,29 +54,45 @@ const windowToken = new InjectionToken('window');
|
|
|
54
54
|
const defaultApiUrl = 'https://secure.xsolla.com/paystation2/api/';
|
|
55
55
|
const sandboxApiUrl = 'https://sandbox-secure.xsolla.com/paystation2/api/';
|
|
56
56
|
|
|
57
|
+
const tokenPrefixParamName = 'rlp';
|
|
58
|
+
const tokenPrefixLength = 4;
|
|
59
|
+
|
|
57
60
|
class SecureApiClient {
|
|
58
61
|
constructor(httpClient, window) {
|
|
59
62
|
this.httpClient = httpClient;
|
|
60
63
|
this.window = window;
|
|
61
64
|
this.isSandboxMode = false;
|
|
65
|
+
this.token = '';
|
|
62
66
|
}
|
|
63
67
|
setSandboxMode(isSandboxMode) {
|
|
64
68
|
this.isSandboxMode = isSandboxMode;
|
|
65
69
|
}
|
|
70
|
+
setToken(token) {
|
|
71
|
+
this.token = token;
|
|
72
|
+
}
|
|
66
73
|
get(url, options) {
|
|
67
|
-
return this.httpClient.get(
|
|
74
|
+
return this.httpClient.get(this.buildUrl(url), options);
|
|
68
75
|
}
|
|
69
76
|
post(url, body, options) {
|
|
70
|
-
return this.httpClient.post(
|
|
77
|
+
return this.httpClient.post(this.buildUrl(url), body, options);
|
|
71
78
|
}
|
|
72
79
|
patch(url, body, options) {
|
|
73
|
-
return this.httpClient.patch(
|
|
80
|
+
return this.httpClient.patch(this.buildUrl(url), body, options);
|
|
74
81
|
}
|
|
75
82
|
put(url, body, options) {
|
|
76
|
-
return this.httpClient.put(
|
|
83
|
+
return this.httpClient.put(this.buildUrl(url), body, options);
|
|
77
84
|
}
|
|
78
85
|
delete(url, options) {
|
|
79
|
-
return this.httpClient.delete(
|
|
86
|
+
return this.httpClient.delete(this.buildUrl(url), options);
|
|
87
|
+
}
|
|
88
|
+
buildUrl(url) {
|
|
89
|
+
const fullUrl = `${this.baseUrl}${url}`;
|
|
90
|
+
const tokenPrefix = this.token.slice(0, tokenPrefixLength);
|
|
91
|
+
if (!tokenPrefix) {
|
|
92
|
+
return fullUrl;
|
|
93
|
+
}
|
|
94
|
+
const separator = fullUrl.includes('?') ? '&' : '?';
|
|
95
|
+
return `${fullUrl}${separator}${tokenPrefixParamName}=${tokenPrefix}`;
|
|
80
96
|
}
|
|
81
97
|
get baseUrl() {
|
|
82
98
|
let predefinedBaseUrl = null;
|
|
@@ -218,6 +234,7 @@ class SettingsService {
|
|
|
218
234
|
async sendRequest(token) {
|
|
219
235
|
const params = new HttpParams().set('access_token', token);
|
|
220
236
|
this.secureApi.setSandboxMode(this.isSandboxMode());
|
|
237
|
+
this.secureApi.setToken(token);
|
|
221
238
|
this.response = await firstValueFrom(this.secureApi.get('utils', { params }));
|
|
222
239
|
}
|
|
223
240
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: SettingsService, deps: [{ token: SecureApiClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
@@ -6732,6 +6749,8 @@ class ListenStatusService {
|
|
|
6732
6749
|
}
|
|
6733
6750
|
stopListening() {
|
|
6734
6751
|
this.isListening = false;
|
|
6752
|
+
this.listenInvoice = null;
|
|
6753
|
+
this.websocketInvoice = null;
|
|
6735
6754
|
this.websocketStatusService.closeWebSocket();
|
|
6736
6755
|
this.destroy$.next();
|
|
6737
6756
|
this.destroy$.complete();
|
|
@@ -7025,6 +7044,11 @@ class StatusService {
|
|
|
7025
7044
|
listenFinalStatus(invoice) {
|
|
7026
7045
|
return this.listenStatusService.listen(invoice);
|
|
7027
7046
|
}
|
|
7047
|
+
stopWaitingStatusUpdates() {
|
|
7048
|
+
this.listenStatusSubscription?.unsubscribe();
|
|
7049
|
+
this.listenStatusSubscription = null;
|
|
7050
|
+
this.listenStatusService.stopListening();
|
|
7051
|
+
}
|
|
7028
7052
|
getRequestParamsFromUrl(url) {
|
|
7029
7053
|
const searchParams = this.urlService.getSearchParams(url ?? '');
|
|
7030
7054
|
const keys = new Set(Object.keys(searchParams));
|
|
@@ -7042,13 +7066,23 @@ class StatusService {
|
|
|
7042
7066
|
return;
|
|
7043
7067
|
}
|
|
7044
7068
|
this.listenStatusService.listen(invoice);
|
|
7069
|
+
let isFirstStatus = true;
|
|
7045
7070
|
this.listenStatusSubscription?.unsubscribe();
|
|
7046
|
-
this.listenStatusSubscription =
|
|
7047
|
-
.
|
|
7048
|
-
|
|
7049
|
-
|
|
7050
|
-
|
|
7051
|
-
|
|
7071
|
+
this.listenStatusSubscription =
|
|
7072
|
+
this.listenStatusService.statusUpdated$.subscribe(({ statusResponse }) => {
|
|
7073
|
+
const isTerminalStatus = [
|
|
7074
|
+
StatusEnum.done,
|
|
7075
|
+
StatusEnum.error,
|
|
7076
|
+
StatusEnum.canceled,
|
|
7077
|
+
].includes(statusResponse.status.statusState);
|
|
7078
|
+
if (isFirstStatus && !isTerminalStatus) {
|
|
7079
|
+
isFirstStatus = false;
|
|
7080
|
+
return;
|
|
7081
|
+
}
|
|
7082
|
+
isFirstStatus = false;
|
|
7083
|
+
this.financeDetailsService.emitWithStatus(statusResponse.status);
|
|
7084
|
+
this.nextActionService.emitFlowUpdates(this.statusUpdatedActionCreator.getActionData({ statusResponse }));
|
|
7085
|
+
});
|
|
7052
7086
|
}
|
|
7053
7087
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: StatusService, deps: [{ token: UrlService }, { token: StatusRequestService }, { token: FinanceDetailsService }, { token: ListenStatusService }, { token: NextActionService }, { token: SavePaymentMethodStatusService }, { token: StatusUpdatedActionCreator }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
7054
7088
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: StatusService, providedIn: 'root' }); }
|
|
@@ -7893,6 +7927,8 @@ class PaymentService {
|
|
|
7893
7927
|
this.isSavingMethodMode = false;
|
|
7894
7928
|
}
|
|
7895
7929
|
async initialize(config) {
|
|
7930
|
+
this.threeDsService.stopChecking();
|
|
7931
|
+
this.statusService.stopWaitingStatusUpdates();
|
|
7896
7932
|
this.destroy$ = new Subject();
|
|
7897
7933
|
this.formDestroy$ = new Subject();
|
|
7898
7934
|
this.isSubmitAttempted = false;
|
|
@@ -9337,6 +9373,7 @@ var ApplePayErrors;
|
|
|
9337
9373
|
ApplePayErrors["cancelled"] = "Apple Pay: payment cancelled";
|
|
9338
9374
|
ApplePayErrors["merchantValidationError"] = "Apple Pay: merchant validation error";
|
|
9339
9375
|
ApplePayErrors["braintreeInitializeError"] = "Apple Pay: Braintree library is not initialized";
|
|
9376
|
+
ApplePayErrors["createPaySessionError"] = "Apple Pay: Could not create pay session";
|
|
9340
9377
|
})(ApplePayErrors || (ApplePayErrors = {}));
|
|
9341
9378
|
|
|
9342
9379
|
class ApplePaySessionHandlerAbstract {
|
|
@@ -9492,7 +9529,19 @@ class BraintreeHandler extends ApplePaySessionHandlerAbstract {
|
|
|
9492
9529
|
}
|
|
9493
9530
|
const request = this.buildPaymentRequest(params);
|
|
9494
9531
|
const applePayRequest = this.paymentClient.createPaymentRequest(request);
|
|
9495
|
-
|
|
9532
|
+
let session = null;
|
|
9533
|
+
try {
|
|
9534
|
+
session = new this.window.ApplePaySession(applePayVersion, applePayRequest);
|
|
9535
|
+
}
|
|
9536
|
+
catch (error) {
|
|
9537
|
+
const errorMessage = typeof error === 'string'
|
|
9538
|
+
? error
|
|
9539
|
+
: ApplePayErrors.createPaySessionError;
|
|
9540
|
+
console.error(errorMessage);
|
|
9541
|
+
this.loggerService.error(new TaggedError(errorMessage, [ErrorTags.APPLEPAY]));
|
|
9542
|
+
}
|
|
9543
|
+
if (!session)
|
|
9544
|
+
return;
|
|
9496
9545
|
const { isApplePayInstantFlowEnabled, topLevelDomain } = additionalParams;
|
|
9497
9546
|
this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayBraintreeStartSession, 'manual');
|
|
9498
9547
|
session.onshippingcontactselected = (event) => {
|
|
@@ -9581,16 +9630,29 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
9581
9630
|
}] }, { type: LoggerService }, { type: ApplePayCartService }, { type: UserBehaviourAnalyticsService }] });
|
|
9582
9631
|
|
|
9583
9632
|
class CheckoutHandler extends ApplePaySessionHandlerAbstract {
|
|
9584
|
-
constructor(window, http, applePayCartService, userBehaviourAnalyticsService) {
|
|
9633
|
+
constructor(window, http, loggerService, applePayCartService, userBehaviourAnalyticsService) {
|
|
9585
9634
|
super();
|
|
9586
9635
|
this.window = window;
|
|
9587
9636
|
this.http = http;
|
|
9637
|
+
this.loggerService = loggerService;
|
|
9588
9638
|
this.applePayCartService = applePayCartService;
|
|
9589
9639
|
this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
|
|
9590
9640
|
}
|
|
9591
9641
|
startSession(params, additionalParams, applePayFinallyCallback) {
|
|
9592
9642
|
const request = this.buildPaymentRequest(params);
|
|
9593
|
-
|
|
9643
|
+
let session = null;
|
|
9644
|
+
try {
|
|
9645
|
+
session = new this.window.ApplePaySession(applePayVersion, request);
|
|
9646
|
+
}
|
|
9647
|
+
catch (error) {
|
|
9648
|
+
const errorMessage = typeof error === 'string'
|
|
9649
|
+
? error
|
|
9650
|
+
: ApplePayErrors.createPaySessionError;
|
|
9651
|
+
console.error(errorMessage);
|
|
9652
|
+
this.loggerService.error(new TaggedError(errorMessage, [ErrorTags.APPLEPAY]));
|
|
9653
|
+
}
|
|
9654
|
+
if (!session)
|
|
9655
|
+
return;
|
|
9594
9656
|
session.onshippingcontactselected = (event) => {
|
|
9595
9657
|
this.userBehaviourAnalyticsService.send(UserBehaviourEventName.applePayCheckoutSelectShipping, 'manual');
|
|
9596
9658
|
this.applePayCartService.cartSuccessfulRecalculated$
|
|
@@ -9662,7 +9724,7 @@ class CheckoutHandler extends ApplePaySessionHandlerAbstract {
|
|
|
9662
9724
|
};
|
|
9663
9725
|
session.begin();
|
|
9664
9726
|
}
|
|
9665
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckoutHandler, deps: [{ token: windowToken }, { token: i1.HttpClient }, { token: ApplePayCartService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
9727
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckoutHandler, deps: [{ token: windowToken }, { token: i1.HttpClient }, { token: LoggerService }, { token: ApplePayCartService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
9666
9728
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckoutHandler }); }
|
|
9667
9729
|
}
|
|
9668
9730
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: CheckoutHandler, decorators: [{
|
|
@@ -9670,7 +9732,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
9670
9732
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
9671
9733
|
type: Inject,
|
|
9672
9734
|
args: [windowToken]
|
|
9673
|
-
}] }, { type: i1.HttpClient }, { type: ApplePayCartService }, { type: UserBehaviourAnalyticsService }] });
|
|
9735
|
+
}] }, { type: i1.HttpClient }, { type: LoggerService }, { type: ApplePayCartService }, { type: UserBehaviourAnalyticsService }] });
|
|
9674
9736
|
|
|
9675
9737
|
class PaymentBehaviourModule {
|
|
9676
9738
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: PaymentBehaviourModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
@@ -10109,13 +10171,14 @@ class GooglePayService {
|
|
|
10109
10171
|
get googlePaymentClientWasInitialized() {
|
|
10110
10172
|
return !!this.googlePaymentClient;
|
|
10111
10173
|
}
|
|
10112
|
-
constructor(window, loggerService, paymentSystemProcessingService, googlePayCheckoutPaymentService, googlePayInstantPaymentService, injector) {
|
|
10174
|
+
constructor(window, loggerService, paymentSystemProcessingService, googlePayCheckoutPaymentService, googlePayInstantPaymentService, injector, userBehaviourAnalyticsService) {
|
|
10113
10175
|
this.window = window;
|
|
10114
10176
|
this.loggerService = loggerService;
|
|
10115
10177
|
this.paymentSystemProcessingService = paymentSystemProcessingService;
|
|
10116
10178
|
this.googlePayCheckoutPaymentService = googlePayCheckoutPaymentService;
|
|
10117
10179
|
this.googlePayInstantPaymentService = googlePayInstantPaymentService;
|
|
10118
10180
|
this.injector = injector;
|
|
10181
|
+
this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
|
|
10119
10182
|
this.googlePayScriptUrl = 'https://pay.google.com/gp/p/js/pay.js';
|
|
10120
10183
|
this.readyToPay = new BehaviorSubject(null);
|
|
10121
10184
|
this.paymentWindowIsReady = new Subject();
|
|
@@ -10208,6 +10271,9 @@ class GooglePayService {
|
|
|
10208
10271
|
if (this.paymentInProgress) {
|
|
10209
10272
|
return Promise.resolve(null);
|
|
10210
10273
|
}
|
|
10274
|
+
if (this.initParams.isInstantPayFlow) {
|
|
10275
|
+
this.userBehaviourAnalyticsService.send(UserBehaviourEventName.sysInstantFlowOpen, userBehaviourEventTypes.open, { instanceId: googlePay });
|
|
10276
|
+
}
|
|
10211
10277
|
const paymentDataRequest = this.paymentService.getPaymentRequest();
|
|
10212
10278
|
if (!paymentDataRequest) {
|
|
10213
10279
|
this.loggerService.error(new TaggedError('No data for payment data request', [
|
|
@@ -10354,7 +10420,7 @@ class GooglePayService {
|
|
|
10354
10420
|
}
|
|
10355
10421
|
return allowedLocales.find((locale) => locale === userLocale) ?? 'en';
|
|
10356
10422
|
}
|
|
10357
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayService, deps: [{ token: windowToken }, { token: LoggerService }, { token: PaymentSystemProcessingService }, { token: GooglePayCheckoutPaymentService }, { token: GooglePayInstantPaymentService }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
10423
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayService, deps: [{ token: windowToken }, { token: LoggerService }, { token: PaymentSystemProcessingService }, { token: GooglePayCheckoutPaymentService }, { token: GooglePayInstantPaymentService }, { token: i0.Injector }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
10358
10424
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayService, providedIn: 'root' }); }
|
|
10359
10425
|
}
|
|
10360
10426
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayService, decorators: [{
|
|
@@ -10365,7 +10431,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
|
|
|
10365
10431
|
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
10366
10432
|
type: Inject,
|
|
10367
10433
|
args: [windowToken]
|
|
10368
|
-
}] }, { type: LoggerService }, { type: PaymentSystemProcessingService }, { type: GooglePayCheckoutPaymentService }, { type: GooglePayInstantPaymentService }, { type: i0.Injector }] });
|
|
10434
|
+
}] }, { type: LoggerService }, { type: PaymentSystemProcessingService }, { type: GooglePayCheckoutPaymentService }, { type: GooglePayInstantPaymentService }, { type: i0.Injector }, { type: UserBehaviourAnalyticsService }] });
|
|
10369
10435
|
|
|
10370
10436
|
var ApplePayIntegrationType;
|
|
10371
10437
|
(function (ApplePayIntegrationType) {
|