Skip to content

Instantly share code, notes, and snippets.

@heymartinadams
Last active March 8, 2017 20:10
Show Gist options
  • Save heymartinadams/a4d1d218407714f761363668743c40d3 to your computer and use it in GitHub Desktop.
Save heymartinadams/a4d1d218407714f761363668743c40d3 to your computer and use it in GitHub Desktop.
onToken(token) {
// This is where token is received, as described in Logic #1
const userId = this.props.data.user.id
const stripeToken = token.id
// Hide or remove button to prevent duplicate purchases
this.setState({ buttonStyle: 'button hidden' })
// Logic #2
this.props.createCard({ variables: { stripeToken, userId } })
.then(() => {
console.log('Customer created...')
this.setState({ status: 'Customer created...' })
})
.catch((e) => { console.error(e) })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment