Ionic 2 Cookbook - Second Edition by Hoc Phan

Ionic 2 Cookbook - Second Edition by Hoc Phan

Author:Hoc Phan [Phan, Hoc]
Language: eng
Format: azw3
Publisher: Packt Publishing
Published: 2016-11-29T16:00:00+00:00


Once Stripe returns your token ID, it will call the following arrow function:

(status, response) => this.stripeResponseHandler(status, response)

The reason for using the arrow function here is because your code within the stripeResponseHandler method needs the this context of the HomePage class. This is a nice way to access the token variable. Observe the following code:

stripeResponseHandler(status, response) { if (response.error) { // Show the errors on the form console.log('error'); console.log(response.error.message); } else { // response contains id and card, which contains additional card details this.token = response.id; // Insert the token into the form so it gets submitted to the server console.log('success'); console.log('Sending token param:'); console.log(this.token); this.nav.push(ThankyouPage, {token: this.token}); } }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.