mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 09:03:12 +03:00
Hidden subscriptions section on member profile when no connected Stripe
no issue - There is no way to turn on "Complimentary" subscription when Stripe is not connected - There is no constructiove information that can be shown about subscriptions
This commit is contained in:
parent
7f465278c6
commit
ed14ffed02
@ -5,6 +5,7 @@ import {gt} from '@ember/object/computed';
|
||||
import {inject as service} from '@ember/service';
|
||||
|
||||
export default Component.extend({
|
||||
settings: service(),
|
||||
feature: service(),
|
||||
config: service(),
|
||||
mediaQueries: service(),
|
||||
@ -13,6 +14,16 @@ export default Component.extend({
|
||||
setProperty: () => {},
|
||||
|
||||
hasMultipleSubscriptions: gt('member.stripe', 1),
|
||||
canShowStripeInfo: computed('member.isNew', 'settings.membersSubscriptionSettings', function () {
|
||||
let membersSubscriptionSettings = this.settings.parseSubscriptionSettings(this.get('settings.membersSubscriptionSettings'));
|
||||
let stripeEnabled = membersSubscriptionSettings && !!(membersSubscriptionSettings.paymentProcessors[0].config.secret_token) && !!(membersSubscriptionSettings.paymentProcessors[0].config.public_token);
|
||||
|
||||
if (this.member.isNew || !stripeEnabled) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}),
|
||||
|
||||
subscriptions: computed('member.stripe', function () {
|
||||
let subscriptions = this.member.get('stripe');
|
||||
|
@ -31,7 +31,7 @@ export default Component.extend({
|
||||
}),
|
||||
|
||||
subscriptionSettings: computed('settings.membersSubscriptionSettings', function () {
|
||||
let subscriptionSettings = this.parseSubscriptionSettings(this.get('settings.membersSubscriptionSettings'));
|
||||
let subscriptionSettings = this.settings.parseSubscriptionSettings(this.get('settings.membersSubscriptionSettings'));
|
||||
let stripeProcessor = subscriptionSettings.paymentProcessors.find((proc) => {
|
||||
return (proc.adapter === 'stripe');
|
||||
});
|
||||
@ -84,7 +84,7 @@ export default Component.extend({
|
||||
this.setBulkEmailSettings(bulkEmailSettings);
|
||||
},
|
||||
setSubscriptionSettings(key, event) {
|
||||
let subscriptionSettings = this.parseSubscriptionSettings(this.get('settings.membersSubscriptionSettings'));
|
||||
let subscriptionSettings = this.settings.parseSubscriptionSettings(this.get('settings.membersSubscriptionSettings'));
|
||||
let stripeProcessor = subscriptionSettings.paymentProcessors.find((proc) => {
|
||||
return (proc.adapter === 'stripe');
|
||||
});
|
||||
@ -115,42 +115,5 @@ export default Component.extend({
|
||||
}
|
||||
this.setMembersSubscriptionSettings(subscriptionSettings);
|
||||
}
|
||||
},
|
||||
|
||||
parseSubscriptionSettings(settingsString) {
|
||||
try {
|
||||
return JSON.parse(settingsString);
|
||||
} catch (e) {
|
||||
return {
|
||||
isPaid: false,
|
||||
allowSelfSignup: true,
|
||||
fromAddress: 'noreply',
|
||||
paymentProcessors: [{
|
||||
adapter: 'stripe',
|
||||
config: {
|
||||
secret_token: '',
|
||||
public_token: '',
|
||||
product: {
|
||||
name: this.settings.get('title')
|
||||
},
|
||||
plans: [
|
||||
{
|
||||
name: 'Monthly',
|
||||
currency: 'usd',
|
||||
interval: 'month',
|
||||
amount: ''
|
||||
},
|
||||
{
|
||||
name: 'Yearly',
|
||||
currency: 'usd',
|
||||
interval: 'year',
|
||||
amount: ''
|
||||
}
|
||||
]
|
||||
}
|
||||
}]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -69,8 +69,44 @@ export default Service.extend(_ProxyMixin, ValidationEngine, {
|
||||
rollbackAttributes() {
|
||||
return this.content.rollbackAttributes();
|
||||
},
|
||||
|
||||
|
||||
changedAttributes() {
|
||||
return this.content.changedAttributes();
|
||||
},
|
||||
|
||||
parseSubscriptionSettings(settingsString) {
|
||||
try {
|
||||
return JSON.parse(settingsString);
|
||||
} catch (e) {
|
||||
return {
|
||||
isPaid: false,
|
||||
allowSelfSignup: true,
|
||||
fromAddress: 'noreply',
|
||||
paymentProcessors: [{
|
||||
adapter: 'stripe',
|
||||
config: {
|
||||
secret_token: '',
|
||||
public_token: '',
|
||||
product: {
|
||||
name: this.settings.get('title')
|
||||
},
|
||||
plans: [
|
||||
{
|
||||
name: 'Monthly',
|
||||
currency: 'usd',
|
||||
interval: 'month',
|
||||
amount: ''
|
||||
},
|
||||
{
|
||||
name: 'Yearly',
|
||||
currency: 'usd',
|
||||
interval: 'year',
|
||||
amount: ''
|
||||
}
|
||||
]
|
||||
}
|
||||
}]
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -52,7 +52,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#unless this.member.isNew}}
|
||||
{{#if canShowStripeInfo}}
|
||||
<h4 class="midlightgrey f-small fw5 ttu mt12">Stripe info</h4>
|
||||
|
||||
{{#if this.isLoading}}
|
||||
@ -185,4 +185,4 @@
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
{{/if}}
|
||||
|
Loading…
Reference in New Issue
Block a user