diff --git a/app/controllers/discourse_donations/charges_controller.rb b/app/controllers/discourse_donations/charges_controller.rb
index c712d19..ba30895 100644
--- a/app/controllers/discourse_donations/charges_controller.rb
+++ b/app/controllers/discourse_donations/charges_controller.rb
@@ -40,10 +40,10 @@ module DiscourseDonations
}
if user_params[:type] === 'once'
- charge = payment.charge(@user, opts)
+ result = payment.charge(@user, opts)
else
opts[:type] = user_params[:type]
- charge = payment.subscribe(@user, opts)
+ result = payment.subscribe(@user, opts)
end
rescue ::Stripe::CardError => e
@@ -57,7 +57,7 @@ module DiscourseDonations
render(json: output) && (return)
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['rewards'] << { type: :group, name: group_name } if group_name
diff --git a/assets/javascripts/discourse/components/stripe-card.js.es6 b/assets/javascripts/discourse/components/stripe-card.js.es6
index add4db7..ca4bc3c 100644
--- a/assets/javascripts/discourse/components/stripe-card.js.es6
+++ b/assets/javascripts/discourse/components/stripe-card.js.es6
@@ -4,7 +4,6 @@ import { default as computed } from 'ember-addons/ember-computed-decorators';
export default Ember.Component.extend({
result: [],
- amount: 1,
stripe: null,
transactionInProgress: null,
settings: null,
@@ -18,8 +17,13 @@ export default Ember.Component.extend({
this.set('stripe', Stripe(this.get('settings').discourse_donations_public_key));
const types = Discourse.SiteSettings.discourse_donations_types.split('|') || [];
- this.set('types', types);
- this.set('type', types[0]);
+ const amounts = this.get('donateAmounts');
+
+ this.setProperties({
+ types,
+ type: types[0],
+ amount: amounts[0].value
+ });
},
@computed('types')
@@ -91,6 +95,20 @@ export default Ember.Component.extend({
didInsertElement() {
this._super();
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() {
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 26cef77..e85a01a 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -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_transaction_fee_fixed: "Fixed part of Stripe transaction fee (changes per region). See Stripe's pricing for your region and Stripe's explaination of passing fees onto customers."
discourse_donations_transaction_fee_percent: "Percent part of Stripe transaction fee (changes per region). See Stripe's pricing for your region and Stripe's explaination of passing fees onto customers."
- 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_types: "Donation types. First listed will be the default."
errors:
@@ -31,7 +31,7 @@ en:
submit_with_create_account: Make Payment and Create Account
transaction_fee:
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"
messages:
success: Thank you for your donation!