0

"This question is repeated on stack but not getting solution" .

loadStripe() { 
  if(!window.document.getElementById('stripe-script')) {
    var s = window.document.createElement("script");
    s.id = "stripe-script";
    s.type = "text/javascript";
    s.src = "https://checkout.stripe.com/checkout.js";
    window.document.body.appendChild(s);
  } 

pay(amount: any) {
    const handler = (<any>window).StripeCheckout.configure({
      key: 'pk_test_51IRXdhksd',
      locale: 'auto',
      token(token: any) {
        this.updateStatus(token.id);
         //IN HERE i try to put function ("this.updateStatus"), but it will give error. 
      }
    }); 
    handler.open({
      name: 'Test Site',
      description: '2 widgets',
      amount: amount * 100
    });
  }

If any one know solution then please share with us, Thanks.

AMAR MAGAR
  • 137
  • 2
  • 13

1 Answers1

0

This appears to be structured using the legacy version of Checkout which has been deprecated for several years, with a recommendation to migrate to new Checkout (migration guide). Building a new integration with this legacy approach is not recommended.

Within the legacy product, inside configure it appears that token should be a function:

token: function(token, args) { ... }

It's possible that you are encountering an issue with scoping this in the callback, though without the details of the error I can only speculate. You should take a look at this great answer to see multiple strategies for accessing the this you expect.

Nolan H
  • 6,205
  • 1
  • 5
  • 19