@xsolla/payment-client-core 0.2.107 → 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.
@@ -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) {
@@ -2703,7 +2703,7 @@ class NextActionService {
2703
2703
  this.logNextAction(nextAction);
2704
2704
  return nextAction;
2705
2705
  }
2706
- throw new Error('Next action is undefined.');
2706
+ throw new TaggedError('Next action is undefined.', [ErrorTags.APP], submitResponse);
2707
2707
  }
2708
2708
  emitFlowUpdates(action) {
2709
2709
  this.flowUpdatesSubject.next(action);
@@ -9708,19 +9708,26 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9708
9708
  }] }] });
9709
9709
 
9710
9710
  class GooglePayCheckoutPaymentService {
9711
- constructor(paymentSystemProcessingService, userBehaviourAnalyticsService) {
9711
+ constructor(paymentSystemProcessingService, userBehaviourAnalyticsService, loggerService) {
9712
9712
  this.paymentSystemProcessingService = paymentSystemProcessingService;
9713
9713
  this.userBehaviourAnalyticsService = userBehaviourAnalyticsService;
9714
+ this.loggerService = loggerService;
9714
9715
  this.checkout = null;
9715
9716
  }
9716
9717
  preparePayment({ initParams, checkDeviceData, }) {
9717
- if (!initParams || !checkDeviceData.base64checkoutData)
9718
+ if (!initParams || !checkDeviceData.base64checkoutData) {
9719
+ this.loggerService.error(new TaggedError('Google Pay checkout: missing initParams or base64checkoutData', [ErrorTags.GOOGLEPAY]));
9718
9720
  return null;
9721
+ }
9719
9722
  this.initParams = initParams;
9720
9723
  this.checkout =
9721
9724
  this.paymentSystemProcessingService.getDecodedCheckout(checkDeviceData.base64checkoutData);
9722
- 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
+ ]));
9723
9729
  return null;
9730
+ }
9724
9731
  const checkoutData = this.checkout.request.form.fields;
9725
9732
  const paymentDataRequest = JSON.parse(checkoutData.paymentDataRequest);
9726
9733
  const isReadyToPayRequest = JSON.parse(checkoutData.isReadyToPayRequest);
@@ -9772,7 +9779,7 @@ class GooglePayCheckoutPaymentService {
9772
9779
  isCancelledStatus(statusCode) {
9773
9780
  return statusCode.toLowerCase() === 'canceled';
9774
9781
  }
9775
- 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 }); }
9776
9783
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, providedIn: 'root' }); }
9777
9784
  }
9778
9785
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayCheckoutPaymentService, decorators: [{
@@ -9780,20 +9787,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9780
9787
  args: [{
9781
9788
  providedIn: 'root',
9782
9789
  }]
9783
- }], ctorParameters: () => [{ type: PaymentSystemProcessingService }, { type: UserBehaviourAnalyticsService }] });
9790
+ }], ctorParameters: () => [{ type: PaymentSystemProcessingService }, { type: UserBehaviourAnalyticsService }, { type: LoggerService }] });
9784
9791
 
9785
9792
  class GooglePayInstantPaymentService {
9786
- constructor(summaryFinanceDetailsAdapterService) {
9793
+ constructor(summaryFinanceDetailsAdapterService, loggerService) {
9787
9794
  this.summaryFinanceDetailsAdapterService = summaryFinanceDetailsAdapterService;
9795
+ this.loggerService = loggerService;
9788
9796
  this.googleInitData = null;
9789
9797
  }
9790
9798
  preparePayment({ initParams, checkDeviceData, }) {
9791
- if (!initParams)
9799
+ if (!initParams) {
9800
+ this.loggerService.error(new TaggedError('Google Pay instant: missing initParams', [
9801
+ ErrorTags.GOOGLEPAY,
9802
+ ]));
9792
9803
  return null;
9804
+ }
9793
9805
  this.initParams = initParams;
9794
9806
  this.googleInitData = this.extractGoogleInitData(initParams.fields);
9795
- 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]));
9796
9809
  return null;
9810
+ }
9797
9811
  const displayItems = checkDeviceData.summary
9798
9812
  ? this.getItemsTaxes(checkDeviceData.summary)
9799
9813
  : [];
@@ -9842,6 +9856,7 @@ class GooglePayInstantPaymentService {
9842
9856
  return data;
9843
9857
  }
9844
9858
  catch (error) {
9859
+ this.loggerService.error(new TaggedError(`Google Pay instant: failed to parse googlePayInitData, ${error.message}`, [ErrorTags.GOOGLEPAY]));
9845
9860
  return null;
9846
9861
  }
9847
9862
  }
@@ -9889,7 +9904,7 @@ class GooglePayInstantPaymentService {
9889
9904
  getTotalAmount(finance) {
9890
9905
  return finance?.grand_total?.amount ?? finance?.total?.amount;
9891
9906
  }
9892
- 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 }); }
9893
9908
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayInstantPaymentService, providedIn: 'root' }); }
9894
9909
  }
9895
9910
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImport: i0, type: GooglePayInstantPaymentService, decorators: [{
@@ -9897,7 +9912,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
9897
9912
  args: [{
9898
9913
  providedIn: 'root',
9899
9914
  }]
9900
- }], ctorParameters: () => [{ type: SummaryFinanceDetailsAdapterService }] });
9915
+ }], ctorParameters: () => [{ type: SummaryFinanceDetailsAdapterService }, { type: LoggerService }] });
9901
9916
 
9902
9917
  class GooglePayService {
9903
9918
  get libraryWasInitialized() {
@@ -9978,7 +9993,8 @@ class GooglePayService {
9978
9993
  this.readyToPay.next(false);
9979
9994
  const result = response.result?.toString() ?? '';
9980
9995
  const isHavePaymentClient = Boolean(this.googlePaymentClient).toString();
9981
- 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]));
9982
9998
  })
9983
9999
  .catch((error) => {
9984
10000
  this.readyToPay.next(false);
@@ -9986,7 +10002,7 @@ class GooglePayService {
9986
10002
  if (error instanceof Error) {
9987
10003
  message = error.message;
9988
10004
  }
9989
- 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]));
9990
10006
  });
9991
10007
  });
9992
10008
  }
@@ -10024,15 +10040,21 @@ class GooglePayService {
10024
10040
  this.paymentService.handleFailedPayment?.(error);
10025
10041
  this.paymentWindowIsClose.next();
10026
10042
  this.error.next(error);
10027
- const isClosedByUser = this.isClosedByUser(error?.message ?? '');
10028
- 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);
10029
10047
  if (isClosedByUser || isCanceledStatus)
10030
10048
  return null;
10049
+ this.loggerService.error(new TaggedError(`Google Pay: proceedCheckout failed, ${errorMessage}`, [
10050
+ ErrorTags.GOOGLEPAY,
10051
+ ]));
10031
10052
  return checkStatusAction;
10032
10053
  }
10033
10054
  }
10034
10055
  createButton(onClickHandler, configuration) {
10035
10056
  if (!this.googlePaymentClient) {
10057
+ this.loggerService.error(new TaggedError('Google payment client is not initialized to create button', [ErrorTags.GOOGLEPAY]));
10036
10058
  return null;
10037
10059
  }
10038
10060
  const allowedPaymentMethods = this.paymentService?.getAllowedPaymentMethods() || [];
@@ -10047,6 +10069,9 @@ class GooglePayService {
10047
10069
  }
10048
10070
  setupGooglePayClient() {
10049
10071
  if (!this.window.google) {
10072
+ this.loggerService.error(new TaggedError('Google Pay library is not available on window', [
10073
+ ErrorTags.GOOGLEPAY,
10074
+ ]));
10050
10075
  return;
10051
10076
  }
10052
10077
  const environment = this.initParams.isSandbox ? 'TEST' : 'PRODUCTION';
@@ -10065,6 +10090,7 @@ class GooglePayService {
10065
10090
  onLoadScript() {
10066
10091
  if (!this.window.google) {
10067
10092
  const retryTimeout = 1000;
10093
+ this.loggerService.error(new TaggedError('Google Pay: library not available after script load, retrying', [ErrorTags.GOOGLEPAY]));
10068
10094
  setTimeout(() => {
10069
10095
  const isAvailableGoogleClient = !!this.window.google;
10070
10096
  if (isAvailableGoogleClient) {
@@ -10706,5 +10732,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10706
10732
  * Generated bundle index. Do not edit.
10707
10733
  */
10708
10734
 
10709
- export { ApplePayCartService, ApplePayService, CoreLibraryModule, CoreLibraryService, CreditCardTypes, ErrorTags, FieldNames, GooglePayService, MessageTags, PaymentSystemProcessingService, TaggedError, TaggedMessage, userBehaviourEventTypes };
10735
+ export { ApplePayCartService, ApplePayService, CoreLibraryModule, CoreLibraryService, CreditCardTypes, ErrorTags, FieldNames, GooglePayService, LoggerService, MessageTags, PaymentSystemProcessingService, TaggedError, TaggedMessage, userBehaviourEventTypes };
10710
10736
  //# sourceMappingURL=xsolla-payment-client-core.mjs.map