diff --git a/assets/javascripts/discourse/components/stripe-card.js.es6 b/assets/javascripts/discourse/components/stripe-card.js.es6 new file mode 100644 index 0000000..3018383 --- /dev/null +++ b/assets/javascripts/discourse/components/stripe-card.js.es6 @@ -0,0 +1,29 @@ +export default Ember.Component.extend({ + stripe: Stripe('pk_test_b8RmhzlL8QPizJRqOrKF3JEV'), + card: function() { + var elements = this.get('stripe').elements(); + return elements.create('card', { hidePostalCode: true }); + }.property('stripe'), + + didInsertElement() { + this.get('card').mount('#stripe-card'); + }, + + actions: { + submitStripeCard() { + this.get('stripe').createToken(this.get('card')).then(function(result) { + if (result.error) { + console.log('error yo'); + } + else { + var form = document.getElementById('stripe-card'); + var hiddenInput = document.createElement('input'); + // hiddenInput.setAttribute('type', 'hidden'); + hiddenInput.setAttribute('name', 'stripeToken'); + hiddenInput.setAttribute('value', result.token.id); + form.appendChild(hiddenInput); + } + }); + } + } +}); diff --git a/assets/javascripts/discourse/templates/components/stripe-card.hbs b/assets/javascripts/discourse/templates/components/stripe-card.hbs new file mode 100644 index 0000000..5f76857 --- /dev/null +++ b/assets/javascripts/discourse/templates/components/stripe-card.hbs @@ -0,0 +1,5 @@ +
+ + diff --git a/assets/javascripts/discourse/templates/user/payments.hbs b/assets/javascripts/discourse/templates/user/payments.hbs index 2f56863..e4ea8d7 100644 --- a/assets/javascripts/discourse/templates/user/payments.hbs +++ b/assets/javascripts/discourse/templates/user/payments.hbs @@ -1,83 +1,5 @@ - - -
-
- -
+

Payments

-
- - -
- - - +{{stripe-card}}