From cc3f60d8b03d82566bbf52684cf76b174f84965d Mon Sep 17 00:00:00 2001 From: wishinghand Date: Wed, 26 Oct 2016 01:01:29 -0700 Subject: [PATCH 1/2] some progress on integrating Stripe --- index.html | 5 +++-- src/components/Profile.vue | 1 - src/components/add-goal.vue | 39 +++++++++++++++++++++++++++++++++++++ src/main.js | 1 - 4 files changed, 42 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index e9b0396..448db52 100644 --- a/index.html +++ b/index.html @@ -4,12 +4,13 @@ Incentify + -
+
\ No newline at end of file diff --git a/src/components/Profile.vue b/src/components/Profile.vue index 8b74250..4341f07 100644 --- a/src/components/Profile.vue +++ b/src/components/Profile.vue @@ -74,7 +74,6 @@ export default { }); }, logout() { - console.log("hi") localStorage.removeItem('token') this.$router.go('/'); } diff --git a/src/components/add-goal.vue b/src/components/add-goal.vue index 69f4904..37da97e 100644 --- a/src/components/add-goal.vue +++ b/src/components/add-goal.vue @@ -16,6 +16,7 @@

+ @@ -27,6 +28,10 @@ ], data() { return { + stripe_token: {}, + price: 1000, + stripe_instance: {}, + order_status: 'READY', showIntegration$Input: true, activeTab: { tab: 1, @@ -41,6 +46,19 @@ } }; }, + ready() { + this.stripe_instance = StripeCheckout.configure({ + key: 'pk_test_t5EdiYNBA1LOp7En1xhBOYVp', //put your own publishable key here + image: 'https://stripe.com/img/documentation/checkout/marketplace.png', + locale: 'auto', + token: function(token) { + console.log(token); + // console.log('got a token. sending data to localhost'); + this.stripe_token= token; + this.sendData2Server(); + } + }); + }, methods: { commit() { var shortname = this.integrationShortName.toLowerCase(); @@ -52,6 +70,27 @@ // error callback this.failure = !this.failure; }); + }, + purchaseStuff() { + this.stripe_instance.open({ + name: 'Incentify', + description: 'New Commitment', + amount: this.price + }) + // console.log('attempting to get a token'); + }, + sendData2Server() { + console.log("data 2 server"); + this.order_status= "PENDING"; + this.$http.post(process.env.API_URL + '/stripe/process_payment', {token_id: this.stripe_token.id, price: this.price}) + .then((response) => { + // console.log(response.body); + this.order_status= "Successfully Completed"; + },(response) => { + // error callback + // console.log(response.body); + this.order_status= "Failed"; + }); } } }; diff --git a/src/main.js b/src/main.js index 59e2622..55c9ed3 100644 --- a/src/main.js +++ b/src/main.js @@ -24,7 +24,6 @@ const router = new VueRouter(); // get rid of 300ms tap delay FastClick.attach(document.body); -console.log(process.env.API_URL); router.map({ '/': { From 86ca48399d9ddb429d34cbc7eac330c1b6ea0bfc Mon Sep 17 00:00:00 2001 From: wishinghand Date: Wed, 26 Oct 2016 10:18:07 -0700 Subject: [PATCH 2/2] more stripe attempts --- src/App.vue | 2 +- src/components/Profile.vue | 1 - src/components/add-goal.vue | 4 +--- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/App.vue b/src/App.vue index 49e149e..d7ebbf5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -2,7 +2,7 @@
- +
diff --git a/src/components/Profile.vue b/src/components/Profile.vue index 4341f07..d2deefe 100644 --- a/src/components/Profile.vue +++ b/src/components/Profile.vue @@ -81,7 +81,6 @@ export default { created() { this.$http.get(process.env.API_URL + '/users').then((response) => { // success callback - console.log(response); this.profileData.email = response.body[0].email; }, (response) => { // error callback diff --git a/src/components/add-goal.vue b/src/components/add-goal.vue index 37da97e..f45fbf9 100644 --- a/src/components/add-goal.vue +++ b/src/components/add-goal.vue @@ -52,8 +52,6 @@ image: 'https://stripe.com/img/documentation/checkout/marketplace.png', locale: 'auto', token: function(token) { - console.log(token); - // console.log('got a token. sending data to localhost'); this.stripe_token= token; this.sendData2Server(); } @@ -91,7 +89,7 @@ // console.log(response.body); this.order_status= "Failed"; }); - } + }, } };