@xsolla/payment-client-core 0.5.2 → 0.5.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.
@@ -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.5.2';
16
+ const PAYMENT_CLIENT_CORE_VERSION = '0.5.4';
17
17
 
18
18
  class TranslateHelper {
19
19
  static init(service) {
@@ -7434,30 +7434,29 @@ class DfpCollectService {
7434
7434
  this.formName = 'formDFP';
7435
7435
  }
7436
7436
  collectDfpStatus(threeDsForm) {
7437
- if (threeDsForm.waitCallback) {
7438
- this.openIframeWithPostRequest(threeDsForm, false);
7439
- }
7440
- else {
7441
- this.openIframeWithPostRequest(threeDsForm, true);
7442
- }
7443
- }
7444
- /*
7445
- * This method create invisible iframe with required params and after that it submit form in iframe
7446
- * */
7447
- openIframeWithPostRequest(threeDsForm, isNeedNotifyAfterLoad) {
7448
7437
  this.window.document.getElementById(this.iframeName)?.remove();
7449
7438
  this.window.document.getElementById(this.formName)?.remove();
7450
- this.createIframe(isNeedNotifyAfterLoad, threeDsForm.threeDSTrXid);
7439
+ /*
7440
+ * With waitCallback (e.g. GPayments) the DFP URL is loaded directly into the
7441
+ * iframe as its src, and the result is delivered back via the websocket
7442
+ * callback instead of an onload notification. The legacy EMV 3DS Method flow
7443
+ * posts threeDSMethodData to a blank iframe and notifies on load.
7444
+ */
7445
+ if (threeDsForm.waitCallback) {
7446
+ this.createIframe(false, threeDsForm.threeDSTrXid, threeDsForm.threeDSMethod);
7447
+ return;
7448
+ }
7449
+ this.createIframe(true, threeDsForm.threeDSTrXid);
7451
7450
  this.postFormToIframe(threeDsForm.threeDSMethod, threeDsForm.threeDSMethodData);
7452
7451
  }
7453
7452
  /*
7454
7453
  * isNeedNotifyAfterLoad is need to send notification of dft to server
7455
7454
  * */
7456
- createIframe(isNeedNotifyAfterLoad, threeDsTrXid) {
7455
+ createIframe(isNeedNotifyAfterLoad, threeDsTrXid, src = 'about:blank') {
7457
7456
  const attributes = {
7458
7457
  name: this.iframeName,
7459
7458
  id: this.iframeName,
7460
- src: 'about:blank',
7459
+ src,
7461
7460
  style: 'display:none',
7462
7461
  };
7463
7462
  const iFrame = this.window.document.createElement('iframe');
@@ -7583,6 +7582,7 @@ class ThreeDs20Service {
7583
7582
  this.latestDfpParameters = null;
7584
7583
  this.notifyDfpTimerId = 'notify-dfp';
7585
7584
  this.notifyDfpTimeoutMs = 10000;
7585
+ this.waitCallbackNotifyDfpTimeoutMs = 20000;
7586
7586
  this.statusThreeDsTimerId = 'status-three-ds';
7587
7587
  this.statusThreeDsTimeoutMs = 180000;
7588
7588
  }
@@ -7593,7 +7593,9 @@ class ThreeDs20Service {
7593
7593
  this.clearLatestDfpParameters();
7594
7594
  this.reinsuranceCheckService.addTimer({
7595
7595
  id: this.notifyDfpTimerId,
7596
- timeoutMs: this.notifyDfpTimeoutMs,
7596
+ timeoutMs: threeDsForm.waitCallback
7597
+ ? this.waitCallbackNotifyDfpTimeoutMs
7598
+ : this.notifyDfpTimeoutMs,
7597
7599
  callback: () => {
7598
7600
  const threeDsTransactionId = this.latestDfpParameters?.threeDSTrXid ?? threeDsForm.threeDSTrXid;
7599
7601
  this.notifyDfpStatusService.request(threeDsTransactionId, false);
@@ -10140,7 +10142,11 @@ class GooglePayCheckoutPaymentService {
10140
10142
  const checkoutData = this.checkout.request.form.fields;
10141
10143
  const paymentDataRequest = JSON.parse(checkoutData.paymentDataRequest);
10142
10144
  const isReadyToPayRequest = JSON.parse(checkoutData.isReadyToPayRequest);
10143
- const result = { paymentDataRequest, isReadyToPayRequest };
10145
+ const result = {
10146
+ paymentDataRequest,
10147
+ isReadyToPayRequest,
10148
+ environment: checkoutData.environment,
10149
+ };
10144
10150
  if (checkoutData.amexCardNotification) {
10145
10151
  result.amexCardNotification = JSON.parse(checkoutData.amexCardNotification);
10146
10152
  }
@@ -10353,6 +10359,8 @@ class GooglePayService {
10353
10359
  this.analyticsEvent = new Subject();
10354
10360
  this.paymentInProgress = false;
10355
10361
  this.googlePaymentClient = null;
10362
+ this.googlePayClientEnvironment = null;
10363
+ this.serverEnvironment = null;
10356
10364
  this.paymentService = null;
10357
10365
  }
10358
10366
  get readyToPay$() {
@@ -10405,6 +10413,8 @@ class GooglePayService {
10405
10413
  this.loggerService.error(new TaggedError('No initialization data', [ErrorTags.GOOGLEPAY]));
10406
10414
  throw new AppError('Google Pay: no initialization data');
10407
10415
  }
10416
+ this.serverEnvironment = initData.environment ?? null;
10417
+ this.setupGooglePayClient();
10408
10418
  this.googlePaymentClient
10409
10419
  .isReadyToPay(initData.isReadyToPayRequest)
10410
10420
  .then((response) => {
@@ -10429,6 +10439,7 @@ class GooglePayService {
10429
10439
  });
10430
10440
  }
10431
10441
  async proceedCheckout() {
10442
+ this.setupGooglePayClient();
10432
10443
  if (!this.googlePaymentClient) {
10433
10444
  this.loggerService.error(new TaggedError('Google payment client is not initialized to proceed checkout', [ErrorTags.GOOGLEPAY]));
10434
10445
  throw new AppError(`Google Pay. proceedCheckout: no google payment client`);
@@ -10503,6 +10514,12 @@ class GooglePayService {
10503
10514
  buttonLocale: this.getLocaleForButton(configuration.locale),
10504
10515
  });
10505
10516
  }
10517
+ resolveGooglePayEnvironment() {
10518
+ if (this.serverEnvironment) {
10519
+ return this.serverEnvironment;
10520
+ }
10521
+ return this.initParams.isSandbox ? 'TEST' : 'PRODUCTION';
10522
+ }
10506
10523
  setupGooglePayClient() {
10507
10524
  if (!this.window.google) {
10508
10525
  this.loggerService.error(new TaggedError('Google Pay library is not available on window', [
@@ -10510,7 +10527,11 @@ class GooglePayService {
10510
10527
  ]));
10511
10528
  return;
10512
10529
  }
10513
- const environment = this.initParams.isSandbox ? 'TEST' : 'PRODUCTION';
10530
+ const environment = this.resolveGooglePayEnvironment();
10531
+ if (this.googlePaymentClient &&
10532
+ this.googlePayClientEnvironment === environment) {
10533
+ return;
10534
+ }
10514
10535
  const googlePaymentClientData = {
10515
10536
  environment,
10516
10537
  };
@@ -10522,6 +10543,7 @@ class GooglePayService {
10522
10543
  }
10523
10544
  this.googlePaymentClient =
10524
10545
  new this.window.google.payments.api.PaymentsClient(googlePaymentClientData);
10546
+ this.googlePayClientEnvironment = environment;
10525
10547
  }
10526
10548
  onLoadScript() {
10527
10549
  if (!this.window.google) {