@xsolla/payment-client-core 0.2.91 → 0.2.92

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 (30) hide show
  1. package/esm2022/lib/core/payment/actions/next-actions.mjs +3 -1
  2. package/esm2022/lib/core/payment/actions/redirect/google-three-ds-redirect.action.class.mjs +20 -0
  3. package/esm2022/lib/core/payment/actions/redirect/redirect.action.class.mjs +16 -8
  4. package/esm2022/lib/core/payment/actions/redirect/redirect.action.type.mjs +1 -1
  5. package/esm2022/lib/core/payment/field-names.enum.mjs +2 -1
  6. package/esm2022/lib/core/payment/form/validators/required/required.validator.mjs +1 -2
  7. package/esm2022/lib/core/payment/payment-configuration.interface.mjs +1 -1
  8. package/esm2022/lib/core/payment/payment-configurations/types/google-pay-form-configuration.interface.mjs +2 -0
  9. package/esm2022/lib/core/payment/payment-configurations/types/is-credit-card-settings.guard.mjs +5 -0
  10. package/esm2022/lib/core/payment/payment-configurations/types/is-google-pay-settings.guard.mjs +5 -0
  11. package/esm2022/lib/core/payment/payment-settings/payment-settings.service.mjs +8 -5
  12. package/esm2022/lib/core/payment/payment.service.mjs +13 -5
  13. package/esm2022/lib/core/sdk-payment-systems/sdk-payment-systems-initial-data.interface.mjs +1 -1
  14. package/esm2022/lib/core-library.service.mjs +1 -1
  15. package/fesm2022/xsolla-payment-client-core.mjs +59 -17
  16. package/fesm2022/xsolla-payment-client-core.mjs.map +1 -1
  17. package/lib/core/payment/actions/redirect/google-three-ds-redirect.action.class.d.ts +9 -0
  18. package/lib/core/payment/actions/redirect/redirect.action.class.d.ts +2 -1
  19. package/lib/core/payment/actions/redirect/redirect.action.type.d.ts +1 -0
  20. package/lib/core/payment/field-names.enum.d.ts +1 -0
  21. package/lib/core/payment/payment-configuration.interface.d.ts +4 -2
  22. package/lib/core/payment/payment-configurations/types/google-pay-form-configuration.interface.d.ts +8 -0
  23. package/lib/core/payment/payment-configurations/types/is-credit-card-settings.guard.d.ts +3 -0
  24. package/lib/core/payment/payment-configurations/types/is-google-pay-settings.guard.d.ts +3 -0
  25. package/lib/core/payment/payment.service.d.ts +4 -1
  26. package/lib/core/sdk-payment-systems/sdk-payment-systems-initial-data.interface.d.ts +1 -0
  27. package/lib/core-library.service.d.ts +4 -1
  28. package/package.json +1 -1
  29. package/xsolla-payment-client-core-0.2.92.tgz +0 -0
  30. package/xsolla-payment-client-core-0.2.91.tgz +0 -0
@@ -1353,6 +1353,7 @@ var FieldNames;
1353
1353
  FieldNames["payViaCheckoutUrl"] = "payViaCheckoutUrl";
1354
1354
  FieldNames["googlePayInitData"] = "googlePayInitData";
1355
1355
  FieldNames["googlePayPaymentData"] = "googlePayPaymentData";
1356
+ FieldNames["googlePay3dsRedirect"] = "googlePay3DSRedirect";
1356
1357
  FieldNames["externalCardIssuerCountry"] = "externalCardIssuerCountry";
1357
1358
  FieldNames["pmId"] = "pm_id";
1358
1359
  })(FieldNames || (FieldNames = {}));
@@ -1592,6 +1593,12 @@ const fieldsAllowedToExternalChange = new Set([
1592
1593
  FieldNames.pmId,
1593
1594
  ]);
1594
1595
 
1596
+ const googlePayPid = 3431;
1597
+
1598
+ const isGooglePaySettingsGuard = (settings) => {
1599
+ return settings.paymentMethodId === googlePayPid;
1600
+ };
1601
+
1595
1602
  const masterCardAndVisaPaymentMethodId = 26;
1596
1603
  const maestroPaymentMethodId = 490;
1597
1604
  // eslint-disable-next-line @typescript-eslint/no-magic-numbers
@@ -1608,6 +1615,10 @@ const cardsWith3ds = new Set([
1608
1615
  creditCardPaymentMethodId,
1609
1616
  ]);
1610
1617
 
1618
+ const isCreditCardSettingsGuard = (settings) => {
1619
+ return settings.paymentMethodId === creditCardPaymentMethodId;
1620
+ };
1621
+
1611
1622
  const initializeResponseFactoryToken = new InjectionToken('InitializeResponse');
1612
1623
  const initializeResponseFactoryProvider = {
1613
1624
  provide: initializeResponseFactoryToken,
@@ -1734,13 +1745,6 @@ class RedirectActionCreator {
1734
1745
  return (response.currentCommand === XpsCommand.checkout &&
1735
1746
  Boolean(response.parameters.checkout));
1736
1747
  }
1737
- getRedirect(submitResponse) {
1738
- return {
1739
- redirectUrl: this.getRedirectUrl(submitResponse),
1740
- isNewWindowRequired: this.getIsNewWindowRequired(submitResponse),
1741
- data: submitResponse.parameters.checkout.data,
1742
- };
1743
- }
1744
1748
  getRedirectUrl(submitResponse) {
1745
1749
  const responseRedirectUrl = submitResponse.parameters.checkout.action;
1746
1750
  const pid = submitResponse?.fields?.find(({ name }) => name === 'fix_pid')?.value;
@@ -1753,6 +1757,14 @@ class RedirectActionCreator {
1753
1757
  }
1754
1758
  return this.preparePagesUrl(pagesPath);
1755
1759
  }
1760
+ getRedirect(submitResponse) {
1761
+ return {
1762
+ redirectUrl: this.getRedirectUrl(submitResponse),
1763
+ isNewWindowRequired: this.getIsNewWindowRequired(submitResponse),
1764
+ isSameWindowRequired: this.getIsSameWindowRequired(submitResponse),
1765
+ data: submitResponse.parameters.checkout?.data ?? {},
1766
+ };
1767
+ }
1756
1768
  getIsNewWindowRequired(submitResponse) {
1757
1769
  if (!cardsWith3ds.has(submitResponse?.parameters?.pid)) {
1758
1770
  return false;
@@ -1763,6 +1775,13 @@ class RedirectActionCreator {
1763
1775
  const isJapanCard = cardBinCountry === 'JP';
1764
1776
  return isAcquirerWithRedirectInNewWindow || isJapanCard;
1765
1777
  }
1778
+ getIsSameWindowRequired(submitResponse) {
1779
+ if (this.getIsNewWindowRequired(submitResponse)) {
1780
+ return false;
1781
+ }
1782
+ // 3DS with redirect case
1783
+ return cardsWith3ds.has(submitResponse?.parameters?.pid);
1784
+ }
1766
1785
  preparePagesUrl(pagesPath) {
1767
1786
  const isSandbox = this.settingsService.isSandboxMode();
1768
1787
  const token = this.settingsService.token;
@@ -2027,8 +2046,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
2027
2046
  type: Injectable
2028
2047
  }] });
2029
2048
 
2030
- const googlePayPid = 3431;
2031
-
2032
2049
  class SpecialButtonActionCreator {
2033
2050
  constructor() {
2034
2051
  this.type = 'special_button';
@@ -2168,8 +2185,25 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImpor
2168
2185
  type: Injectable
2169
2186
  }] });
2170
2187
 
2188
+ class GoogleThreeDsRedirectActionCreator extends RedirectActionCreator {
2189
+ isSuitable(response) {
2190
+ return (response.currentCommand === XpsCommand.checkout &&
2191
+ !response.parameters.checkout &&
2192
+ Boolean(response.parameters.form?.googlePay3DSRedirect?.value));
2193
+ }
2194
+ getRedirectUrl(submitResponse) {
2195
+ return (String(submitResponse.parameters.form?.googlePay3DSRedirect?.value) ?? '');
2196
+ }
2197
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GoogleThreeDsRedirectActionCreator, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
2198
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GoogleThreeDsRedirectActionCreator }); }
2199
+ }
2200
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.3", ngImport: i0, type: GoogleThreeDsRedirectActionCreator, decorators: [{
2201
+ type: Injectable
2202
+ }] });
2203
+
2171
2204
  const nextActionsToken = new InjectionToken('Action');
2172
2205
  const nextActions = [
2206
+ GoogleThreeDsRedirectActionCreator,
2173
2207
  ShowFieldsActionCreator,
2174
2208
  CheckStatusActionCreator,
2175
2209
  SpecialButtonActionCreator,
@@ -3011,11 +3045,13 @@ class PaymentSettingsService {
3011
3045
  if (!config?.paymentMethodSettings) {
3012
3046
  return {};
3013
3047
  }
3014
- const settings = config.paymentMethodSettings;
3015
3048
  const params = {};
3016
- params.useSingleExpirationDateField = this.toXps(settings.useSingleExpirationDateField);
3017
- params.useExternalVault = this.toXps(settings.useExternalVault);
3018
- params.isPaymentViaSavedMethod = this.toXps(settings.isPaymentViaSavedMethod);
3049
+ if (isCreditCardSettingsGuard(config)) {
3050
+ const settings = config.paymentMethodSettings;
3051
+ params.useSingleExpirationDateField = this.toXps(settings.useSingleExpirationDateField);
3052
+ params.useExternalVault = this.toXps(settings.useExternalVault);
3053
+ params.isPaymentViaSavedMethod = this.toXps(settings.isPaymentViaSavedMethod);
3054
+ }
3019
3055
  return params;
3020
3056
  }
3021
3057
  toXps(value) {
@@ -3632,7 +3668,6 @@ function convertedEmailValidator() {
3632
3668
  }
3633
3669
 
3634
3670
  function convertedRequiredValidator() {
3635
- console.log();
3636
3671
  return convert(Validators.required, TranslateHelper.t('errors.validation.required', 'Required'));
3637
3672
  }
3638
3673
 
@@ -7488,7 +7523,10 @@ class PaymentService {
7488
7523
  this.fields = this.getFields();
7489
7524
  this.form = this.formService.createForm(this.fields);
7490
7525
  this.syncService.setup(this.form, this.fields, this.config);
7491
- return submitResponse;
7526
+ return {
7527
+ response: submitResponse,
7528
+ nextAction: this.nextActionService.getNextAction(submitResponse),
7529
+ };
7492
7530
  }
7493
7531
  setupInitialFieldValues() {
7494
7532
  const fieldsToOverride = this.config.overrideFormFields;
@@ -7530,6 +7568,9 @@ class PaymentService {
7530
7568
  throw new Error('Should submit form first');
7531
7569
  }
7532
7570
  const sdkPaymentData = this.getSdkPaymentDataFromResponse(this.data);
7571
+ const shouldHandleUserBackRedirectOnSdkSide = isGooglePaySettingsGuard(this.config)
7572
+ ? !!this.config.paymentMethodSettings?.useSdkHandlerForUserBackRedirect
7573
+ : false;
7533
7574
  return Promise.resolve({
7534
7575
  data: sdkPaymentData.checkoutData,
7535
7576
  sandbox: this.settingsService.isSandboxMode()
@@ -7540,6 +7581,7 @@ class PaymentService {
7540
7581
  submitResponse: isSubmitResponse(this.data) ? this.data : null,
7541
7582
  summary: sdkPaymentData.summary,
7542
7583
  locale: this.translateService.getCurrentLang(),
7584
+ shouldHandleUserBackRedirectOnSdkSide,
7543
7585
  });
7544
7586
  }
7545
7587
  getQrCode() {
@@ -7646,8 +7688,8 @@ class PaymentService {
7646
7688
  }
7647
7689
  externalChangeFieldValue(name, value) {
7648
7690
  const isFieldAllowedForExternalChange = fieldsAllowedToExternalChange.has(name);
7649
- const isExternalVault = this.config.paymentMethodSettings?.useExternalVault &&
7650
- this.config.paymentMethodId === creditCardPaymentMethodId;
7691
+ const isExternalVault = isCreditCardSettingsGuard(this.config) &&
7692
+ this.config.paymentMethodSettings?.useExternalVault;
7651
7693
  if (!isFieldAllowedForExternalChange || !isExternalVault)
7652
7694
  return;
7653
7695
  const formControl = this.form?.get(name);