Merge branch 'spinner' into staging

This commit is contained in:
Rimian Perkins 2017-03-06 12:34:18 +11:00
commit 2318b42b49
3 changed files with 8 additions and 10 deletions

View File

@ -28,26 +28,24 @@ export default Ember.Component.extend({
submitStripeCard() { submitStripeCard() {
var self = this; var self = this;
this.get('stripe').createToken(this.get('card')).then(function(result) { this.get('stripe').createToken(this.get('card')).then(data => {
self.set('result', null); self.set('result', null);
if (result.error) { if (data.error) {
console.log(result.error); self.set('result', data.error.message);
} }
else { else {
self.set('transactionInProgress', true); self.set('transactionInProgress', true);
var params = { var params = {
stripeToken: result.token.id, stripeToken: data.token.id,
amount: self.get('amount') * 100 amount: self.get('amount') * 100
}; };
ajax('/charges', { data: params, method: 'post' }).then(data => { ajax('/charges', { data: params, method: 'post' }).then(data => {
self.set('transactionInProgress', false); self.set('transactionInProgress', false);
self.set('result', (data.status == 'succeeded' ? true : null)); self.set('result', data.outcome.seller_message);
}).catch((data) => {
console.log('catch', data);
}); });
} }
}); });

View File

@ -14,7 +14,7 @@
<div class="control-group save-button"> <div class="control-group save-button">
<div class="controls"> <div class="controls">
{{#d-button action="submitStripeCard" class="btn btn-primary btn-payment"}} {{#d-button action="submitStripeCard" disabled=transactionInProgress class="btn btn-primary btn-payment"}}
{{i18n 'discourse_donations.submit'}} {{i18n 'discourse_donations.submit'}}
{{/d-button}} {{/d-button}}
@ -23,7 +23,7 @@
{{/if}} {{/if}}
{{#if result}} {{#if result}}
<span>{{i18n 'discourse_donations.success'}}</span> <span>{{result}}</span>
{{/if}} {{/if}}
</div> </div>
</div> </div>

View File

@ -1,6 +1,6 @@
# name: discourse-donations # name: discourse-donations
# about: Integrating Discourse with Stripe for donations # about: Integrating Discourse with Stripe for donations
# version: 1.7.2 # version: 1.7.3
# url: https://github.com/choiceaustralia/discourse-donations # url: https://github.com/choiceaustralia/discourse-donations
# authors: Rimian Perkins # authors: Rimian Perkins