title: Not able to call custom function/service inside razorPaySuccessHandler in Angular
body: <p>I am trying to call an API after payment success. So I was calling Function inside razorPaySuccessHandler function but it is throwing error as below:</p>
  <pre><code>constructor(
    private userService: UserService
  ) { }
  
    paymentProcess() {
      let creditDialogRef = this.dialog.open(CreditFormComponent);
      creditDialogRef.afterClosed().subscribe(result =&gt; {
        this.userService.createOrder(this.id).subscribe(res =&gt; {
  
          // this.RAZORPAY_OPTIONS.amount = result.data.amount;
          this.RAZORPAY_OPTIONS.amount = '100';
          this.RAZORPAY_OPTIONS.order_id = '';
  
          // binding this object to both success and dismiss handler
          this.RAZORPAY_OPTIONS[&quot;handler&quot;] = this.razorPaySuccessHandler.bind(this);
  
          let razorpay = new Razorpay(this.RAZORPAY_OPTIONS);
          razorpay.open();
        });
      });
    }
  
  public razorPaySuccessHandler(response) {
          console.log(&quot;razorpay&quot;,response)
          if (response.razorpay_payment_id) {
            console.log(response, &quot;Order Placed&quot;);
            this.razorpayResponse = `Razorpay Response`;
            this.userService.verifyOrder(this.orderId).subscribe(res=&gt;{
                console.log(res)
            })
          }
          else {
            console.log(&quot;Payment failed&quot;)
          }
        }
  </code></pre>
  <p>I am getting error:</p>
  <pre><code>Uncaught TypeError: Cannot read property 'verifyOrder' of undefined
      at Ui.push../src/app/views/marketing/home-page/home-page.component.ts.HomePageComponent.razorPaySuccessHandler (home-page.component.ts:214)
      at checkout.js:1
      at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
      at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
  </code></pre>
  <p>How do I call my own function or service inside it?</p>