@xsolla/payment-client-core 0.3.5 → 0.3.7

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.
@@ -6269,6 +6269,9 @@ class NchanWebSocketService {
6269
6269
  if (url === this.url) {
6270
6270
  this.close();
6271
6271
  }
6272
+ if (this.openPromise && this.url && url !== this.url && !this.isClosed()) {
6273
+ this.close();
6274
+ }
6272
6275
  if (this.openPromise && !this.isClosed()) {
6273
6276
  return this.openPromise;
6274
6277
  }
@@ -6302,6 +6305,9 @@ class NchanWebSocketService {
6302
6305
  .asObservable()
6303
6306
  .subscribe(next);
6304
6307
  }
6308
+ isOpened() {
6309
+ return !this.isClosed();
6310
+ }
6305
6311
  isClosed() {
6306
6312
  if (!this.connection) {
6307
6313
  return true;
@@ -6430,6 +6436,9 @@ class CentrifugoWebSocketService {
6430
6436
  this.url = '';
6431
6437
  this.channel = '';
6432
6438
  }
6439
+ isOpened() {
6440
+ return this.isConnectionOpen || this.isConnecting;
6441
+ }
6433
6442
  get messages$() {
6434
6443
  return (this.incomingMessages$
6435
6444
  .asObservable()
@@ -6616,6 +6625,9 @@ class WebsocketStatusService {
6616
6625
  get statusChanged$() {
6617
6626
  return this.statusChangedSubject.asObservable();
6618
6627
  }
6628
+ get isOpened() {
6629
+ return this.webSocketClient?.isOpened() ?? false;
6630
+ }
6619
6631
  constructor(webSocketFactory) {
6620
6632
  this.webSocketFactory = webSocketFactory;
6621
6633
  this.reinsuranceCheckStatus = {
@@ -6697,6 +6709,8 @@ class ListenStatusService {
6697
6709
  this.statusUpdatedSubject = new Subject();
6698
6710
  this.statusDoneSubject = new Subject();
6699
6711
  this.destroy$ = new Subject();
6712
+ this.listenInvoice = null;
6713
+ this.websocketInvoice = null;
6700
6714
  }
6701
6715
  listen(invoice) {
6702
6716
  if (this.isListening) {
@@ -6704,6 +6718,7 @@ class ListenStatusService {
6704
6718
  }
6705
6719
  this.destroy$ = new Subject();
6706
6720
  this.isListening = true;
6721
+ this.listenInvoice = invoice;
6707
6722
  this.subscribeStatusUpdate(invoice);
6708
6723
  this.subscribeCheckStatusUpdate();
6709
6724
  this.subscribeWebsocketEvent();
@@ -6716,6 +6731,9 @@ class ListenStatusService {
6716
6731
  this.destroy$.next();
6717
6732
  this.destroy$.complete();
6718
6733
  }
6734
+ isListeningInvoice(invoice) {
6735
+ return this.isListening && this.listenInvoice === invoice;
6736
+ }
6719
6737
  subscribeStatusUpdate(invoice) {
6720
6738
  this.statusService.response$
6721
6739
  .pipe(filter$1((statusResponse) => {
@@ -6752,7 +6770,11 @@ class ListenStatusService {
6752
6770
  });
6753
6771
  }
6754
6772
  if (statusSettings.needWebSocket) {
6755
- this.openWebsocket(statusSettings);
6773
+ if (!this.websocketStatusService.isOpened ||
6774
+ this.websocketInvoice !== invoice) {
6775
+ this.websocketInvoice = invoice;
6776
+ this.openWebsocket(statusSettings);
6777
+ }
6756
6778
  return;
6757
6779
  }
6758
6780
  this.stopListening();
@@ -6974,6 +6996,7 @@ class StatusService {
6974
6996
  this.nextActionService = nextActionService;
6975
6997
  this.savePaymentMethodStatusService = savePaymentMethodStatusService;
6976
6998
  this.statusUpdatedActionCreator = statusUpdatedActionCreator;
6999
+ this.listenStatusSubscription = null;
6977
7000
  }
6978
7001
  async getStatus(params) {
6979
7002
  const isSavePaymentMethodMode = params?.isSavePaymentAccount === "1" /* XpsBoolean.true */;
@@ -7010,8 +7033,12 @@ class StatusService {
7010
7033
  return params;
7011
7034
  }
7012
7035
  startWaitingStatusUpdates(invoice) {
7036
+ if (this.listenStatusService.isListeningInvoice(invoice)) {
7037
+ return;
7038
+ }
7013
7039
  this.listenStatusService.listen(invoice);
7014
- this.listenStatusService.statusUpdated$
7040
+ this.listenStatusSubscription?.unsubscribe();
7041
+ this.listenStatusSubscription = this.listenStatusService.statusUpdated$
7015
7042
  .pipe(skip(1))
7016
7043
  .subscribe(({ statusResponse }) => {
7017
7044
  this.financeDetailsService.emitWithStatus(statusResponse.status);
@@ -7289,11 +7316,10 @@ class DfpCollectService {
7289
7316
  * This method create invisible iframe with required params and after that it submit form in iframe
7290
7317
  * */
7291
7318
  openIframeWithPostRequest(threeDsForm, isNeedNotifyAfterLoad) {
7292
- const iFrameElement = this.window.document.getElementById(this.iframeName);
7293
- if (!iFrameElement) {
7294
- this.createIframe(isNeedNotifyAfterLoad, threeDsForm.threeDSTrXid);
7295
- this.postFormToIframe(threeDsForm.threeDSMethod, threeDsForm.threeDSMethodData);
7296
- }
7319
+ this.window.document.getElementById(this.iframeName)?.remove();
7320
+ this.window.document.getElementById(this.formName)?.remove();
7321
+ this.createIframe(isNeedNotifyAfterLoad, threeDsForm.threeDSTrXid);
7322
+ this.postFormToIframe(threeDsForm.threeDSMethod, threeDsForm.threeDSMethodData);
7297
7323
  }
7298
7324
  /*
7299
7325
  * isNeedNotifyAfterLoad is need to send notification of dft to server
@@ -7320,14 +7346,11 @@ class DfpCollectService {
7320
7346
  }
7321
7347
  }
7322
7348
  /*
7323
- * This method will submit form in our iframe. Form will be created, if it's don't exist
7349
+ * This method will submit form in our iframe
7324
7350
  * */
7325
7351
  postFormToIframe(url, threeDsMethod) {
7326
- let form = this.window.document.getElementById(this.formName);
7327
- if (!form) {
7328
- form = this.createForm();
7329
- this.window.document.body.appendChild(form);
7330
- }
7352
+ const form = this.createForm();
7353
+ this.window.document.body.appendChild(form);
7331
7354
  form.setAttribute('action', url);
7332
7355
  form.setAttribute('target', this.iframeName);
7333
7356
  form.appendChild(this.createInput('threeDSMethodData', threeDsMethod));
@@ -10895,5 +10918,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.12", ngImpo
10895
10918
  * Generated bundle index. Do not edit.
10896
10919
  */
10897
10920
 
10898
- export { ApplePayCartService, ApplePayService, CoreLibraryModule, CoreLibraryService, CreditCardTypes, ErrorTags, FieldNames, GooglePayService, LoggerService, MessageTags, PaymentSystemProcessingService, TaggedError, TaggedMessage, userBehaviourEventTypes };
10921
+ export { ApplePayCartService, ApplePayService, CoreLibraryModule, CoreLibraryService, CreditCardTypes, ErrorTags, FieldNames, GooglePayService, LoggerService, MessageTags, PaymentSystemProcessingService, TaggedError, TaggedMessage, americanExpressMethodId, cardsWith3ds, creditCardPaymentMethodId, isCreditCardSettingsGuard, maestroPaymentMethodId, masterCardAndVisaPaymentMethodId, specialCards, userBehaviourEventTypes };
10899
10922
  //# sourceMappingURL=xsolla-payment-client-core.mjs.map