Base solution for your next web application
BLACK FRIDAY
From Nov 21
To Dec 1
XXDAYS : XXHRS : XXMIN : XXSEC
SAVE UP TO$3K
Also valid for the
existing customers!
Open Closed

Angular - BUG in compoment StripePaymentResultComponent #8682


1
denis.karovic created

Hello,

There is an error with this component. If getting payment result is not succesfull after the first attempt and the method controlAgain() needs to be called, there is en error with loosing scope.

Wrong implementation:

  controlAgain() {
        if (this.maxControlCount === 0) {
          return;
        }

        setTimeout(this.getPaymentResult, this.controlTimeout);                         // this makes it looses scope
        this.controlTimeout *= 2;
        this.maxControlCount--;
  }
  

Appropriate Implementation:

controlAgain() {
        if (this.maxControlCount === 0) {
          return;
        }

        setTimeout( () => {
            this.getPaymentResult();
        }, this.controlTimeout);                                                                    // this way scope is perserved
        this.controlTimeout *= 2;
        this.maxControlCount--;
  }

2 Answer(s)