Small fixes

This commit is contained in:
Angus McLeod 2018-06-22 11:55:16 +10:00
parent d55d149d7d
commit 90f5083fb6
3 changed files with 26 additions and 8 deletions

View File

@ -40,10 +40,10 @@ module DiscourseDonations
} }
if user_params[:type] === 'once' if user_params[:type] === 'once'
charge = payment.charge(@user, opts) result = payment.charge(@user, opts)
else else
opts[:type] = user_params[:type] opts[:type] = user_params[:type]
charge = payment.subscribe(@user, opts) result = payment.subscribe(@user, opts)
end end
rescue ::Stripe::CardError => e rescue ::Stripe::CardError => e
@ -57,7 +57,7 @@ module DiscourseDonations
render(json: output) && (return) render(json: output) && (return)
end end
if charge['paid'] == true if result['paid'] == true || result['status'] === 'active'
output['messages'] << I18n.l(Time.now(), format: :long) + ': ' + I18n.t('donations.payment.success') output['messages'] << I18n.l(Time.now(), format: :long) + ': ' + I18n.t('donations.payment.success')
output['rewards'] << { type: :group, name: group_name } if group_name output['rewards'] << { type: :group, name: group_name } if group_name

View File

@ -4,7 +4,6 @@ import { default as computed } from 'ember-addons/ember-computed-decorators';
export default Ember.Component.extend({ export default Ember.Component.extend({
result: [], result: [],
amount: 1,
stripe: null, stripe: null,
transactionInProgress: null, transactionInProgress: null,
settings: null, settings: null,
@ -18,8 +17,13 @@ export default Ember.Component.extend({
this.set('stripe', Stripe(this.get('settings').discourse_donations_public_key)); this.set('stripe', Stripe(this.get('settings').discourse_donations_public_key));
const types = Discourse.SiteSettings.discourse_donations_types.split('|') || []; const types = Discourse.SiteSettings.discourse_donations_types.split('|') || [];
this.set('types', types); const amounts = this.get('donateAmounts');
this.set('type', types[0]);
this.setProperties({
types,
type: types[0],
amount: amounts[0].value
});
}, },
@computed('types') @computed('types')
@ -91,6 +95,20 @@ export default Ember.Component.extend({
didInsertElement() { didInsertElement() {
this._super(); this._super();
this.get('card').mount('#card-element'); this.get('card').mount('#card-element');
Ember.$(document).on('click', Ember.run.bind(this, this.documentClick));
},
willDestroyElement() {
Ember.$(document).off('click', Ember.run.bind(this, this.documentClick));
},
documentClick(e) {
let $element = this.$('.transaction-fee-description');
let $target = $(e.target);
if ($target.closest($element).length < 1 &&
this._state !== 'destroying') {
this.set('showTransactionFeeDescription', false);
}
}, },
setSuccess() { setSuccess() {

View File

@ -15,7 +15,7 @@ en:
discourse_donations_enable_transaction_fee: "Give the user the option of including the Stripe transaction fee in their donation." discourse_donations_enable_transaction_fee: "Give the user the option of including the Stripe transaction fee in their donation."
discourse_donations_transaction_fee_fixed: "Fixed part of Stripe transaction fee (changes per region). See <a href='https://stripe.com/pricing'>Stripe's pricing for your region</a> and <a href='https://support.stripe.com/questions/can-i-charge-my-stripe-fees-to-my-customers'>Stripe's explaination of passing fees onto customers</a>." discourse_donations_transaction_fee_fixed: "Fixed part of Stripe transaction fee (changes per region). See <a href='https://stripe.com/pricing'>Stripe's pricing for your region</a> and <a href='https://support.stripe.com/questions/can-i-charge-my-stripe-fees-to-my-customers'>Stripe's explaination of passing fees onto customers</a>."
discourse_donations_transaction_fee_percent: "Percent part of Stripe transaction fee (changes per region). See <a href='https://stripe.com/pricing'>Stripe's pricing for your region</a> and <a href='https://support.stripe.com/questions/can-i-charge-my-stripe-fees-to-my-customers'>Stripe's explaination of passing fees onto customers</a>." discourse_donations_transaction_fee_percent: "Percent part of Stripe transaction fee (changes per region). See <a href='https://stripe.com/pricing'>Stripe's pricing for your region</a> and <a href='https://support.stripe.com/questions/can-i-charge-my-stripe-fees-to-my-customers'>Stripe's explaination of passing fees onto customers</a>."
discourse_donations_amounts: "Donation amounts available to user" discourse_donations_amounts: "Donation amounts available to user. First listed will be the default."
discourse_donations_custom_amount: "Allow custom donation amount" discourse_donations_custom_amount: "Allow custom donation amount"
discourse_donations_types: "Donation types. First listed will be the default." discourse_donations_types: "Donation types. First listed will be the default."
errors: errors:
@ -31,7 +31,7 @@ en:
submit_with_create_account: Make Payment and Create Account submit_with_create_account: Make Payment and Create Account
transaction_fee: transaction_fee:
label: "Include transaction fee of {{currency}} {{transactionFee}}" label: "Include transaction fee of {{currency}} {{transactionFee}}"
description: "When you make a donation we get charged a transaciton fee. If you would like to help us out with this fee, check this box and it will be included in your donation." description: "When you make a donation we get charged a transaction fee. If you would like to help us out with this fee, check this box and it will be included in your donation."
total: "Total" total: "Total"
messages: messages:
success: Thank you for your donation! success: Thank you for your donation!