@xsolla/payment-client-core 0.2.106 → 0.2.108

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.
Files changed (35) hide show
  1. package/esm2022/lib/core/exceptions-handling/common-log-attributes/common-log-attributes.interface.mjs +1 -1
  2. package/esm2022/lib/core/exceptions-handling/common-log-attributes/common-log-attributes.service.mjs +2 -2
  3. package/esm2022/lib/core/exceptions-handling/elk/elk-logger.service.mjs +1 -1
  4. package/esm2022/lib/core/exceptions-handling/logger/index.mjs +2 -1
  5. package/esm2022/lib/core/exceptions-handling/logger/log-handler.interface.mjs +1 -1
  6. package/esm2022/lib/core/exceptions-handling/logger/logger.service.mjs +5 -1
  7. package/esm2022/lib/core/exceptions-handling/messages/index.mjs +3 -0
  8. package/esm2022/lib/core/exceptions-handling/messages/message-tags.enum.mjs +6 -0
  9. package/esm2022/lib/core/exceptions-handling/messages/tagged-message.class.mjs +16 -0
  10. package/esm2022/lib/core/payment/actions/next-action.service.mjs +3 -2
  11. package/esm2022/lib/core/performance/performance.service.mjs +8 -5
  12. package/esm2022/lib/core/sdk-payment-systems/google-pay/google-pay.service.mjs +16 -5
  13. package/esm2022/lib/core/sdk-payment-systems/google-pay/payment/google-pay-checkout-payment.service.mjs +16 -6
  14. package/esm2022/lib/core/sdk-payment-systems/google-pay/payment/google-pay-instant-payment.service.mjs +17 -6
  15. package/esm2022/lib/core/web-socket/centrifugo-web-socket.service.mjs +3 -4
  16. package/esm2022/lib/core/web-socket/nchan-web-socket.service.mjs +19 -10
  17. package/esm2022/public-api.mjs +2 -1
  18. package/fesm2022/xsolla-payment-client-core.mjs +91 -32
  19. package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
  20. package/lib/core/exceptions-handling/common-log-attributes/common-log-attributes.interface.d.ts +2 -1
  21. package/lib/core/exceptions-handling/elk/elk-logger.service.d.ts +4 -1
  22. package/lib/core/exceptions-handling/logger/index.d.ts +1 -0
  23. package/lib/core/exceptions-handling/logger/log-handler.interface.d.ts +2 -0
  24. package/lib/core/exceptions-handling/logger/logger.service.d.ts +2 -0
  25. package/lib/core/exceptions-handling/messages/index.d.ts +2 -0
  26. package/lib/core/exceptions-handling/messages/message-tags.enum.d.ts +4 -0
  27. package/lib/core/exceptions-handling/messages/tagged-message.class.d.ts +9 -0
  28. package/lib/core/performance/performance.service.d.ts +1 -1
  29. package/lib/core/sdk-payment-systems/google-pay/payment/google-pay-checkout-payment.service.d.ts +3 -1
  30. package/lib/core/sdk-payment-systems/google-pay/payment/google-pay-instant-payment.service.d.ts +3 -1
  31. package/lib/core/web-socket/nchan-web-socket.service.d.ts +3 -0
  32. package/package.json +1 -1
  33. package/public-api.d.ts +1 -0
  34. package/xsolla-payment-client-core-0.2.108.tgz +0 -0
  35. package/xsolla-payment-client-core-0.2.106.tgz +0 -0
@@ -792,7 +792,7 @@ class CommonLogAttributesService {
792
792
  : 'none',
793
793
  country: user?.country?.value,
794
794
  local: user?.country?.localized_name,
795
- browserInfo: JSON.stringify(this.userAgentService.browserInfo),
795
+ browserInfo: this.userAgentService.browserInfo,
796
796
  };
797
797
  }
798
798
  extractUrlHost(url) {
@@ -929,6 +929,10 @@ class LoggerService {
929
929
  this.elkLoggerService.handleError(error);
930
930
  this.handlers.forEach((handler) => handler.handleError(error));
931
931
  }
932
+ info(info) {
933
+ this.elkLoggerService.log(info.message, info.tags, info.extra);
934
+ this.handlers.forEach((handler) => handler.handleInfo?.(info));
935
+ }
932
936
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LoggerService, deps: [{ token: ElkLoggerService }], target: i0.ɵɵFactoryTarget.Injectable }); }
933
937
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: LoggerService, providedIn: 'root' }); }
934
938
  }
@@ -2699,7 +2703,7 @@ class NextActionService {
2699
2703
  this.logNextAction(nextAction);
2700
2704
  return nextAction;
2701
2705
  }
2702
- throw new Error('Next action is undefined.');
2706
+ throw new TaggedError('Next action is undefined.', [ErrorTags.APP], submitResponse);
2703
2707
  }
2704
2708
  emitFlowUpdates(action) {
2705
2709
  this.flowUpdatesSubject.next(action);
@@ -6085,19 +6089,41 @@ var WebSocketClientType;
6085
6089
  WebSocketClientType["centrifugo"] = "centrifugo";
6086
6090
  })(WebSocketClientType || (WebSocketClientType = {}));
6087
6091
 
6092
+ var MessageTags;
6093
+ (function (MessageTags) {
6094
+ MessageTags["WS"] = "webSocket";
6095
+ MessageTags["HEADLESS_UI"] = "headlessUi";
6096
+ })(MessageTags || (MessageTags = {}));
6097
+
6098
+ class TaggedMessage {
6099
+ constructor(message, tags, extra) {
6100
+ this.name = 'TaggedMessage';
6101
+ this.tags = [];
6102
+ this.parentTag = MessageTags.HEADLESS_UI;
6103
+ this.message = message;
6104
+ this.tags = [this.parentTag];
6105
+ if (tags) {
6106
+ const newTags = tags.filter((t, i, arr) => !this.tags.includes(t) && arr.indexOf(t) === i);
6107
+ this.tags = [...this.tags, ...newTags];
6108
+ }
6109
+ this.extra = extra || {};
6110
+ }
6111
+ }
6112
+
6088
6113
  class NchanWebSocketService {
6089
- constructor() {
6114
+ static { this.reconnectionTimeoutIncrementFactor = 2; }
6115
+ static { this.timeoutsMs = {
6116
+ reconnection: 1500,
6117
+ reconnectionMaxDeviation: 1500,
6118
+ }; }
6119
+ constructor(loggerService) {
6120
+ this.loggerService = loggerService;
6090
6121
  this.type = WebSocketClientType.nchan;
6091
6122
  this.openPromise = null;
6092
6123
  this.reconnectionTimerId = null;
6093
6124
  this.incomingMessages$ = new Subject();
6094
6125
  this.successfulReconnectionEventsProxy$ = new Subject();
6095
6126
  }
6096
- static { this.reconnectionTimeoutIncrementFactor = 2; }
6097
- static { this.timeoutsMs = {
6098
- reconnection: 1500,
6099
- reconnectionMaxDeviation: 1500,
6100
- }; }
6101
6127
  async open(url) {
6102
6128
  if (url === this.url) {
6103
6129
  this.close();
@@ -6166,7 +6192,13 @@ class NchanWebSocketService {
6166
6192
  /* istanbul ignore next */
6167
6193
  async createConnection() {
6168
6194
  this.connection = new WebSocket(this.url);
6169
- this.connection.onmessage = this.incomingMessages$.next.bind(this.incomingMessages$);
6195
+ this.connection.onmessage = (event) => {
6196
+ const message = event.data;
6197
+ this.loggerService.info(new TaggedMessage(`websocket message received: ${message}`, [
6198
+ MessageTags.WS,
6199
+ ]));
6200
+ this.incomingMessages$.next(event);
6201
+ };
6170
6202
  return new Promise((resolve, reject) => {
6171
6203
  this.connection.onopen = () => {
6172
6204
  clearTimeout(this.openConnectionTimerId);
@@ -6199,7 +6231,7 @@ class NchanWebSocketService {
6199
6231
  }
6200
6232
  this.successfulReconnectionEventsProxy$.next();
6201
6233
  }
6202
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NchanWebSocketService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
6234
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NchanWebSocketService, deps: [{ token: LoggerService }], target: i0.ɵɵFactoryTarget.Injectable }); }
6203
6235
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NchanWebSocketService, providedIn: 'root' }); }
6204
6236
  }
6205
6237
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: NchanWebSocketService, decorators: [{
@@ -6207,7 +6239,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
6207
6239
  args: [{
6208
6240
  providedIn: 'root',
6209
6241
  }]
6210
- }] });
6242
+ }], ctorParameters: () => [{ type: LoggerService }] });
6211
6243
 
6212
6244
  class WsError extends TaggedError {
6213
6245
  constructor(message, channelName, tags) {
@@ -6337,9 +6369,7 @@ class CentrifugoWebSocketService {
6337
6369
  })
6338
6370
  .on('publication', (ctx) => {
6339
6371
  const message = ctx.data;
6340
- this.loggerService.error(new TaggedError(`websocket message received: ${message}`, [ErrorTags.WS], {
6341
- channel: websocketChannel,
6342
- }));
6372
+ this.loggerService.info(new TaggedMessage(`websocket message received: ${message}`, [MessageTags.WS], { channel: websocketChannel }));
6343
6373
  this.incomingMessages$.next(ctx);
6344
6374
  })
6345
6375
  .on('error', (ctx) => {
@@ -8442,6 +8472,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
8442
8472
  }] }] });
8443
8473
 
8444
8474
  class PerformanceService {
8475
+ get resourcesPerformance() {
8476
+ return this.window.performance?.getEntriesByType('resource');
8477
+ }
8445
8478
  get network() {
8446
8479
  return this.navigationPerformance?.responseEnd;
8447
8480
  }
@@ -8458,7 +8491,6 @@ class PerformanceService {
8458
8491
  this.window = window;
8459
8492
  this.zone = zone;
8460
8493
  this.navigationPerformance = this.window.performance?.getEntriesByType('navigation')?.[0];
8461
- this.resourcesPerformance = this.window.performance?.getEntriesByType('resource');
8462
8494
  }
8463
8495
  init() {
8464
8496
  if (!this.window?.performance) {
@@ -8473,12 +8505,13 @@ class PerformanceService {
8473
8505
  if (!this.navigationPerformance || !this.resourcesPerformance) {
8474
8506
  return null;
8475
8507
  }
8476
- const utilsTiming = this.resourcesPerformance.find((performance) => performance.name.includes(`${defaultApiUrl}utils`));
8508
+ const utilsTiming = this.resourcesPerformance.find((performance) => performance.name.includes(`${defaultApiUrl}utils`) ||
8509
+ performance.name.includes(`${sandboxApiUrl}utils`));
8477
8510
  if (!utilsTiming) {
8478
8511
  return null;
8479
8512
  }
8480
8513
  return {
8481
- duration: utilsTiming.fetchStart - utilsTiming.responseEnd,
8514
+ duration: utilsTiming.responseEnd - utilsTiming.fetchStart,
8482
8515
  timeReserve: this.navigationPerformance.domComplete - utilsTiming.responseEnd,
8483
8516
  utilsDuration: utilsTiming.duration,
8484
8517
  };
@@ -9675,19 +9708,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9675
9708
  }] }] });
9676
9709
 
9677
9710
  class GooglePayCheckoutPaymentService {
9678
- constructor(paymentSystemProcessingService, userBehaviourAnalyticsService) {
9711
+ constructor(paymentSystemProcessingService, userBehaviourAnalyticsService, loggerService) {
9679
9712
  this.paymentSystemProcessingService = paymentSystemProcessingService;
9680
9713
  this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9714
+ this.loggerService = loggerService;
9681
9715
  this.checkout = null;
9682
9716
  }
9683
9717
  preparePayment({ initParams, checkDeviceData, }) {
9684
- if (!initParams || !checkDeviceData.base64checkoutData)
9718
+ if (!initParams || !checkDeviceData.base64checkoutData) {
9719
+ this.loggerService.error(new TaggedError('Google Pay checkout: missing initParams or base64checkoutData', [ErrorTags.GOOGLEPAY]));
9685
9720
  return null;
9721
+ }
9686
9722
  this.initParams = initParams;
9687
9723
  this.checkout =
9688
9724
  this.paymentSystemProcessingService.getDecodedCheckout(checkDeviceData.base64checkoutData);
9689
- if (!this.checkout)
9725
+ if (!this.checkout) {
9726
+ this.loggerService.error(new TaggedError('Google Pay checkout: failed to decode checkout data', [
9727
+ ErrorTags.GOOGLEPAY,
9728
+ ]));
9690
9729
  return null;
9730
+ }
9691
9731
  const checkoutData = this.checkout.request.form.fields;
9692
9732
  const paymentDataRequest = JSON.parse(checkoutData.paymentDataRequest);
9693
9733
  const isReadyToPayRequest = JSON.parse(checkoutData.isReadyToPayRequest);
@@ -9739,7 +9779,7 @@ class GooglePayCheckoutPaymentService {
9739
9779
  isCancelledStatus(statusCode) {
9740
9780
  return statusCode.toLowerCase() === 'canceled';
9741
9781
  }
9742
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, deps: [{ token: PaymentSystemProcessingService }, { token: UserBehaviourAnalyticsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9782
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, deps: [{ token: PaymentSystemProcessingService }, { token: UserBehaviourAnalyticsService }, { token: LoggerService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9743
9783
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, providedIn: 'root' }); }
9744
9784
  }
9745
9785
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, decorators: [{
@@ -9747,20 +9787,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9747
9787
  args: [{
9748
9788
  providedIn: 'root',
9749
9789
  }]
9750
- }], ctorParameters: () => [{ type: PaymentSystemProcessingService }, { type: UserBehaviourAnalyticsService }] });
9790
+ }], ctorParameters: () => [{ type: PaymentSystemProcessingService }, { type: UserBehaviourAnalyticsService }, { type: LoggerService }] });
9751
9791
 
9752
9792
  class GooglePayInstantPaymentService {
9753
- constructor(summaryFinanceDetailsAdapterService) {
9793
+ constructor(summaryFinanceDetailsAdapterService, loggerService) {
9754
9794
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
9795
+ this.loggerService = loggerService;
9755
9796
  this.googleInitData = null;
9756
9797
  }
9757
9798
  preparePayment({ initParams, checkDeviceData, }) {
9758
- if (!initParams)
9799
+ if (!initParams) {
9800
+ this.loggerService.error(new TaggedError('Google Pay instant: missing initParams', [
9801
+ ErrorTags.GOOGLEPAY,
9802
+ ]));
9759
9803
  return null;
9804
+ }
9760
9805
  this.initParams = initParams;
9761
9806
  this.googleInitData = this.extractGoogleInitData(initParams.fields);
9762
- if (!this.googleInitData)
9807
+ if (!this.googleInitData) {
9808
+ this.loggerService.error(new TaggedError('Google Pay instant: failed to extract google init data from fields', [ErrorTags.GOOGLEPAY]));
9763
9809
  return null;
9810
+ }
9764
9811
  const displayItems = checkDeviceData.summary
9765
9812
  ? this.getItemsTaxes(checkDeviceData.summary)
9766
9813
  : [];
@@ -9809,6 +9856,7 @@ class GooglePayInstantPaymentService {
9809
9856
  return data;
9810
9857
  }
9811
9858
  catch (error) {
9859
+ this.loggerService.error(new TaggedError(`Google Pay instant: failed to parse googlePayInitData, ${error.message}`, [ErrorTags.GOOGLEPAY]));
9812
9860
  return null;
9813
9861
  }
9814
9862
  }
@@ -9856,7 +9904,7 @@ class GooglePayInstantPaymentService {
9856
9904
  getTotalAmount(finance) {
9857
9905
  return finance?.grand_total?.amount ?? finance?.total?.amount;
9858
9906
  }
9859
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayInstantPaymentService, deps: [{ token: SummaryFinanceDetailsAdapterService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9907
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayInstantPaymentService, deps: [{ token: SummaryFinanceDetailsAdapterService }, { token: LoggerService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9860
9908
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayInstantPaymentService, providedIn: 'root' }); }
9861
9909
  }
9862
9910
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayInstantPaymentService, decorators: [{
@@ -9864,7 +9912,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9864
9912
  args: [{
9865
9913
  providedIn: 'root',
9866
9914
  }]
9867
- }], ctorParameters: () => [{ type: SummaryFinanceDetailsAdapterService }] });
9915
+ }], ctorParameters: () => [{ type: SummaryFinanceDetailsAdapterService }, { type: LoggerService }] });
9868
9916
 
9869
9917
  class GooglePayService {
9870
9918
  get libraryWasInitialized() {
@@ -9945,7 +9993,8 @@ class GooglePayService {
9945
9993
  this.readyToPay.next(false);
9946
9994
  const result = response.result?.toString() ?? '';
9947
9995
  const isHavePaymentClient = Boolean(this.googlePaymentClient).toString();
9948
- throw new AppError(`Google Pay: possibly no response.result or googlePaymentClient is missing, result - ${result}, isHavePaymentClient - ${isHavePaymentClient}`);
9996
+ const message = `Google Pay: possibly no response.result or googlePaymentClient is missing, result - ${result}, isHavePaymentClient - ${isHavePaymentClient}`;
9997
+ this.loggerService.error(new TaggedError(message, [ErrorTags.GOOGLEPAY]));
9949
9998
  })
9950
9999
  .catch((error) => {
9951
10000
  this.readyToPay.next(false);
@@ -9953,7 +10002,7 @@ class GooglePayService {
9953
10002
  if (error instanceof Error) {
9954
10003
  message = error.message;
9955
10004
  }
9956
- throw new AppError(`Google Pay: device is not ready to pay, ${message}`);
10005
+ this.loggerService.error(new TaggedError(`Google Pay: device is not ready to pay, ${message}`, [ErrorTags.GOOGLEPAY]));
9957
10006
  });
9958
10007
  });
9959
10008
  }
@@ -9991,15 +10040,21 @@ class GooglePayService {
9991
10040
  this.paymentService.handleFailedPayment?.(error);
9992
10041
  this.paymentWindowIsClose.next();
9993
10042
  this.error.next(error);
9994
- const isClosedByUser = this.isClosedByUser(error?.message ?? '');
9995
- const isCanceledStatus = this.isCanceledStatus(error.statusCode ?? '');
10043
+ const errorMessage = error?.message ?? '';
10044
+ const errorStatusCode = error?.statusCode ?? '';
10045
+ const isClosedByUser = this.isClosedByUser(errorMessage);
10046
+ const isCanceledStatus = this.isCanceledStatus(errorStatusCode);
9996
10047
  if (isClosedByUser || isCanceledStatus)
9997
10048
  return null;
10049
+ this.loggerService.error(new TaggedError(`Google Pay: proceedCheckout failed, ${errorMessage}`, [
10050
+ ErrorTags.GOOGLEPAY,
10051
+ ]));
9998
10052
  return checkStatusAction;
9999
10053
  }
10000
10054
  }
10001
10055
  createButton(onClickHandler, configuration) {
10002
10056
  if (!this.googlePaymentClient) {
10057
+ this.loggerService.error(new TaggedError('Google payment client is not initialized to create button', [ErrorTags.GOOGLEPAY]));
10003
10058
  return null;
10004
10059
  }
10005
10060
  const allowedPaymentMethods = this.paymentService?.getAllowedPaymentMethods() || [];
@@ -10014,6 +10069,9 @@ class GooglePayService {
10014
10069
  }
10015
10070
  setupGooglePayClient() {
10016
10071
  if (!this.window.google) {
10072
+ this.loggerService.error(new TaggedError('Google Pay library is not available on window', [
10073
+ ErrorTags.GOOGLEPAY,
10074
+ ]));
10017
10075
  return;
10018
10076
  }
10019
10077
  const environment = this.initParams.isSandbox ? 'TEST' : 'PRODUCTION';
@@ -10032,6 +10090,7 @@ class GooglePayService {
10032
10090
  onLoadScript() {
10033
10091
  if (!this.window.google) {
10034
10092
  const retryTimeout = 1000;
10093
+ this.loggerService.error(new TaggedError('Google Pay: library not available after script load, retrying', [ErrorTags.GOOGLEPAY]));
10035
10094
  setTimeout(() => {
10036
10095
  const isAvailableGoogleClient = !!this.window.google;
10037
10096
  if (isAvailableGoogleClient) {
@@ -10673,5 +10732,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10673
10732
  * Generated bundle index. Do not edit.
10674
10733
  */
10675
10734
 
10676
- export { ApplePayCartService, ApplePayService, CoreLibraryModule, CoreLibraryService, CreditCardTypes, ErrorTags, FieldNames, GooglePayService, PaymentSystemProcessingService, TaggedError, userBehaviourEventTypes };
10735
+ export { ApplePayCartService, ApplePayService, CoreLibraryModule, CoreLibraryService, CreditCardTypes, ErrorTags, FieldNames, GooglePayService, LoggerService, MessageTags, PaymentSystemProcessingService, TaggedError, TaggedMessage, userBehaviourEventTypes };
10677
10736
  //# sourceMappingURL=xsolla-payment-client-core.mjs.map