Created
January 22, 2017 13:27
-
-
Save ChadTaljaardt/d91332682b0cd80c5b840614dbcad7fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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