fc74bed72a
no-issue This is now the central place for checking if stripe is configured for members and we want to make sure that the Stripe Connect correctly affects this value
24 lines
937 B
JavaScript
24 lines
937 B
JavaScript
import Service from '@ember/service';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default class MembersUtilsService extends Service {
|
|
@service settings;
|
|
|
|
get isStripeEnabled() {
|
|
let stripeConnectIntegration;
|
|
|
|
try {
|
|
stripeConnectIntegration = JSON.parse(this.settings.get('stripeConnectIntegration'));
|
|
} catch (err) {
|
|
stripeConnectIntegration = null;
|
|
}
|
|
|
|
let stripeConnectEnabled = stripeConnectIntegration && stripeConnectIntegration.account_id;
|
|
|
|
let membersSubscriptionSettings = this.settings.parseSubscriptionSettings(this.settings.get('membersSubscriptionSettings'));
|
|
let stripeEnabled = membersSubscriptionSettings && !!(membersSubscriptionSettings.paymentProcessors[0].config.secret_token) && !!(membersSubscriptionSettings.paymentProcessors[0].config.public_token);
|
|
|
|
return stripeEnabled || stripeConnectEnabled;
|
|
}
|
|
}
|