From 13fe7ab7d52b4d2bf33485fde60ebe4d70c6c387 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Wed, 10 May 2017 14:17:28 +1000 Subject: [PATCH] remove second request to create user --- README.md | 5 ++- .../discourse/components/stripe-card.js.es6 | 38 +------------------ 2 files changed, 5 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 89e3eb1..2f2c2de 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ Accept donations in Discourse! Integrates with [Stripe](https://stripe.com). Note: Stripe requires HTTPS. +## Creating new user accounts + +This is an experimental feature. A user can create a new account if there is a donation. + ## Installation * Follow the install instructions here: https://meta.discourse.org/t/install-a-plugin/19157 @@ -30,6 +34,5 @@ Visit `/admin/customize/site_texts` and search for 'discourse_donations'. You'll ## TODO -* Donate when creating account * Handle custom fields * Handle fails from stripe diff --git a/assets/javascripts/discourse/components/stripe-card.js.es6 b/assets/javascripts/discourse/components/stripe-card.js.es6 index e3a1063..da0737f 100644 --- a/assets/javascripts/discourse/components/stripe-card.js.es6 +++ b/assets/javascripts/discourse/components/stripe-card.js.es6 @@ -48,26 +48,6 @@ export default Ember.Component.extend({ this.set('result', this.get('result').concat(messages)); }, - createUser() { - let self = this; - ajax('/users/hp', { method: 'get' }).then(data => { - let params = { - email: self.get('email'), - username: self.get('username'), - name: self.get('name'), - password: self.get('password'), - password_confirmation: data.value, - challenge: data.challenge.split('').reverse().join(''), - }; - - ajax('/users', { data: params, method: 'post' }).then(data => { - self.setSuccess(); - self.concatMessages(data.messages); - self.endTranscation(); - }); - }); - }, - actions: { submitStripeCard() { let self = this; @@ -93,25 +73,9 @@ export default Ember.Component.extend({ if(!self.get('paymentSuccess')) { ajax('/charges', { data: params, method: 'post' }).then(data => { self.concatMessages(data.messages); - - if(!this.get('create_accounts')) { - if(data.status == 'succeeded') { this.setSuccess() }; - self.endTranscation(); - } - else { - if(data.status == 'succeeded') { - this.createUser(); - } - else { - self.endTranscation(); - } - } + self.endTranscation(); }); } - else if (this.get('create_accounts')) { - self.set('result', []); - self.createUser(); - } } }); }