Skip to content

Instantly share code, notes, and snippets.

@ChadTaljaardt
Created January 22, 2017 13:27
Show Gist options
  • Save ChadTaljaardt/d91332682b0cd80c5b840614dbcad7fb to your computer and use it in GitHub Desktop.
Save ChadTaljaardt/d91332682b0cd80c5b840614dbcad7fb to your computer and use it in GitHub Desktop.
<template>
<form action="/subscriptions" method="POST">
<input type="hidden" name="stripeToken" v-model="stripeToken">
<input type="hidden" name="stripeEmail" v-model="stripeEmail">
<button id="customButton" @click.prevent="subscribe">Purchase</button>
</form>
</template>
<script>
export default {
data() {
return {
stripeEmail: '',
stripeToken: ''
}
},
created() {
this.stripe = StripeCheckout.configure({
key: Laravel.stripeKey,
image: 'https://stripe.com/img/documentation/checkout/marketplace.png',
locale: 'auto',
token: function(token) {
this.stripeToken = token.id;
this.stripeEmail = token.email;
this.$http.post('subscriptions', this.$data)
.then(response => alert("Complete! Thanks for your subscription"));
}
});
},
methods: {
buy() {
this.stripe.open({
name: 'Stripe.com',
description: '2 widgets',
zipCode: true,
amount: 2000
});
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment