swell-js icon indicating copy to clipboard operation
swell-js copied to clipboard

fix: bind stripe element instance to their events

Open stafyniaksacha opened this issue 2 years ago • 0 comments

This allows us to have the element in stripe events:

swell.payment.createElements({
  card: {
    onReady: function() { // context requires function (not arrow functions)
      console.log('card element ready')
      this.focus() // this is the element instance
    }
  }
})

Also work with separateElements: true

swell.payment.createElements({
  card: {
    separateElements: true,
    cardNumber: {
      onReady: function() { // context requires function (not arrow functions)
        console.log('card number element ready')
        this.focus() // this is the element instance
      }
    },
    cardExpiry: {
      onReady: function() { // context requires function (not arrow functions)
        console.log('card expiry element ready')
        // this is the element instance
        this.on('networkschange', () => { })
      }
    },
  }
})

stafyniaksacha avatar Aug 30 '22 17:08 stafyniaksacha