Merge pull request #10 from chrisbeach/amount_setting

Make donation amounts a customisable setting
This commit is contained in:
Chris Beach 2018-02-02 12:28:19 +00:00 committed by GitHub
commit 76c5641041
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 8 deletions

View File

@ -3,14 +3,6 @@ import { getRegister } from 'discourse-common/lib/get-owner';
import { default as computed } from 'ember-addons/ember-computed-decorators'; import { default as computed } from 'ember-addons/ember-computed-decorators';
export default Ember.Component.extend({ export default Ember.Component.extend({
donateAmounts: [
{ value: 1, name: '1.00'},
{ value: 2, name: '2.00'},
{ value: 5, name: '5.00'},
{ value: 10, name: '10.00'},
{ value: 20, name: '20.00'},
{ value: 50, name: '50.00'}
],
result: [], result: [],
amount: 1, amount: 1,
stripe: null, stripe: null,
@ -26,6 +18,21 @@ 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));
}, },
@computed
donateAmounts() {
const setting = Discourse.SiteSettings.discourse_donations_amounts.split('|');
if (setting.length) {
return setting.map((amount) => {
return {
value: parseInt(amount, 10),
name: `${amount}.00`
};
});
} else {
return [];
}
},
@computed('stripe') @computed('stripe')
card(stripe) { card(stripe) {
let elements = stripe.elements(); let elements = stripe.elements();

View File

@ -15,6 +15,10 @@ 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_custom_amount: "Allow custom donation amount"
errors:
discourse_donations_amount_must_be_number: "Amounts must be numbers"
js: js:
discourse_donations: discourse_donations:

View File

@ -44,3 +44,9 @@ plugins:
discourse_donations_transaction_fee_percent: discourse_donations_transaction_fee_percent:
client: true client: true
default: 0.029 default: 0.029
discourse_donations_amounts:
client: true
type: list
default: '1|2|5|10|20|50'
regex: "^[0-9\\|]+$"
regex_error: "site_settings.errors.discourse_donations_amount_must_be_number"