2020-06-11 12:05:40 +03:00
|
|
|
import Service from '@ember/service';
|
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
|
|
|
|
export default class MembersUtilsService extends Service {
|
|
|
|
@service settings;
|
|
|
|
|
2020-06-11 15:46:04 +03:00
|
|
|
get isStripeEnabled() {
|
2020-06-11 17:45:45 +03:00
|
|
|
let stripeConnectIntegration;
|
|
|
|
|
|
|
|
try {
|
|
|
|
stripeConnectIntegration = JSON.parse(this.settings.get('stripeConnectIntegration'));
|
|
|
|
} catch (err) {
|
|
|
|
stripeConnectIntegration = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
let stripeConnectEnabled = stripeConnectIntegration && stripeConnectIntegration.account_id;
|
|
|
|
|
2020-06-11 15:46:04 +03:00
|
|
|
let membersSubscriptionSettings = this.settings.parseSubscriptionSettings(this.settings.get('membersSubscriptionSettings'));
|
2020-06-11 12:05:40 +03:00
|
|
|
let stripeEnabled = membersSubscriptionSettings && !!(membersSubscriptionSettings.paymentProcessors[0].config.secret_token) && !!(membersSubscriptionSettings.paymentProcessors[0].config.public_token);
|
2020-06-11 17:45:45 +03:00
|
|
|
|
|
|
|
return stripeEnabled || stripeConnectEnabled;
|
2020-06-11 12:05:40 +03:00
|
|
|
}
|
|
|
|
}
|