-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbilling_client.js
53 lines (41 loc) · 1.42 KB
/
billing_client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var helpers = {
hasFeature: function(feature) {
var subscriber = Billing.subscriber()
, comma = (feature || '').indexOf(','),
features
if (!subscriber || !subscriber.subscription) return false;
if (!Match.test(feature, String)) return false;
if (comma !== -1) {
features = _.reduce(feature.split(','), function (memo, f) {
if (!f || !f.trim()) {
return memo;
}
memo.push(f.trim());
return memo;
}, []);
} else {
features = [feature];
}
return Billing.hasFeatures(subscriber.subscription, features);
},
priceForFeature: function(feature) {
var subscriber = Billing.subscriber();
if (!subscriber || !subscriber.subscription) return false;
return accounting.formatMoney(Billing.priceForFeature(subscriber.subscription, feature));
},
unitPriceForFeature: function(feature) {
var subscriber = Billing.subscriber();
if (!subscriber || !subscriber.subscription) return false;
return accounting.formatMoney(Billing.unitPriceForFeature(org, feature));
},
hasSubscription: function() {
var subscriber = Billing.subscriber();
if (!subscriber || !subscriber.subscription) return false;
return Billing.getSubscription(subscriber.subscription) ? true : false;
}
}
if(Package.ui) {
_.each(helpers, function(helper, name) {
Package.ui.Handlebars.registerHelper(name, helper);
});
}