Merge branch 'spinner' into staging
This commit is contained in:
commit
2318b42b49
|
@ -28,26 +28,24 @@ export default Ember.Component.extend({
|
|||
submitStripeCard() {
|
||||
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);
|
||||
|
||||
if (result.error) {
|
||||
console.log(result.error);
|
||||
if (data.error) {
|
||||
self.set('result', data.error.message);
|
||||
}
|
||||
else {
|
||||
self.set('transactionInProgress', true);
|
||||
|
||||
var params = {
|
||||
stripeToken: result.token.id,
|
||||
stripeToken: data.token.id,
|
||||
amount: self.get('amount') * 100
|
||||
};
|
||||
|
||||
ajax('/charges', { data: params, method: 'post' }).then(data => {
|
||||
self.set('transactionInProgress', false);
|
||||
self.set('result', (data.status == 'succeeded' ? true : null));
|
||||
}).catch((data) => {
|
||||
console.log('catch', data);
|
||||
self.set('result', data.outcome.seller_message);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
<div class="control-group save-button">
|
||||
<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'}}
|
||||
{{/d-button}}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
|||
{{/if}}
|
||||
|
||||
{{#if result}}
|
||||
<span>{{i18n 'discourse_donations.success'}}</span>
|
||||
<span>{{result}}</span>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue