Skip to content

Commit 13e3be0

Browse files
authored
Merge pull request #1678 from CodeNow/SAN-4781-payments-integration-v3
SAN-4781 Payments Integration
2 parents 008ee6f + 0ad367f commit 13e3be0

File tree

45 files changed

+382
-232
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+382
-232
lines changed

Gruntfile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ module.exports = function(grunt) {
437437
configObj.socketHost = process.env.API_SOCK_URL || configObj.host;
438438
configObj.userContentDomain = process.env.USER_CONTENT_DOMAIN || 'runnableapp.com';
439439
configObj.corporateUrl = process.env.MARKETING_URL || 'https://runnable.io';
440+
configObj.stripeToken = process.env.STRIPE_TOKEN || 'pk_test_sHr5tQaPtgwiE2cpW6dQkzi8';
440441

441442
if (configObj.host.charAt(configObj.host.length - 1) === '/') {
442443
configObj.host = configObj.host.substr(0, configObj.host.length - 1);

client/assets/styles/scss/forms/forms-billing.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979

8080
// date
8181
&:last-child {
82-
max-width: 105px;
82+
max-width: 125px;
8383
}
8484
}
8585
}

client/assets/styles/scss/forms/forms-plan.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,11 @@
224224
}
225225

226226
&:hover,
227-
&:active,
227+
&:active {
228+
border-color: $gray-lighter;
229+
cursor: default;
230+
}
231+
228232
&.active {
229233
background: $white;
230234
border-color: $gray-lighter;

client/config/routes.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,12 @@ module.exports = [
6464
grantedOrgs: function (fetchGrantedGithubOrgs) {
6565
return fetchGrantedGithubOrgs();
6666
},
67-
user: function (fetchUser) {
68-
return fetchUser();
67+
user: function (fetchUser, $rootScope, keypather) {
68+
return fetchUser()
69+
.then(function (user) {
70+
keypather.set($rootScope, 'dataApp.data.user', user);
71+
return user;
72+
});
6973
},
7074
whitelistedOrgs: function (fetchWhitelistForDockCreated) {
7175
return fetchWhitelistForDockCreated();
@@ -79,8 +83,12 @@ module.exports = [
7983
controller: 'WelcomeBackController',
8084
controllerAs: 'WBC',
8185
resolve: {
82-
user: function (fetchUser) {
83-
return fetchUser();
86+
user: function (fetchUser, $rootScope, keypather) {
87+
return fetchUser()
88+
.then(function (user) {
89+
keypather.set($rootScope, 'dataApp.data.user', user);
90+
return user;
91+
});
8492
},
8593
booted: function (eventTracking, user) {
8694
return eventTracking.boot(user);
@@ -161,7 +169,7 @@ module.exports = [
161169
return $q.reject(new Error('User Unauthorized for Organization'));
162170
});
163171
}
164-
if (!activeOrg.attrs.allowed) {
172+
if (!activeOrg.attrs.isActive) {
165173
// There is a bug in ui-router and a timeout is the workaround
166174
return $timeout(function () {
167175
$state.go('paused');

client/directives/accountsSelect/directiveAccountsSelect.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ function accountsSelect (
105105
return '';
106106
}
107107
if (currentOrg.poppa.isInTrial() && !currentOrg.poppa.attrs.hasPaymentMethod) {
108-
return currentOrg.poppa.trialDaysRemaining();
108+
var trialRemaining = currentOrg.poppa.trialDaysRemaining();
109+
if (trialRemaining <= 3) {
110+
return trialRemaining;
111+
}
109112
}
110113
return '';
111114
};
@@ -114,9 +117,10 @@ function accountsSelect (
114117
if (!$rootScope.featureFlags.billing) {
115118
return {};
116119
}
120+
var showBadge = currentOrg.poppa.isInTrial() && !currentOrg.poppa.attrs.hasPaymentMethod && currentOrg.poppa.trialDaysRemaining() <= 3;
117121
return {
118-
badge: currentOrg.poppa.isInTrial() && !currentOrg.poppa.attrs.hasPaymentMethod,
119-
'badge-orange': currentOrg.poppa.isInTrial() && !currentOrg.poppa.attrs.hasPaymentMethod
122+
badge: showBadge,
123+
'badge-orange': showBadge
120124
};
121125
};
122126
}

client/directives/animatedPanels/animatedPanelContainerDirective.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,35 @@ function animatedPanelContainer(
2323
}
2424

2525
var isAnimatingForwards = true;
26-
var animateOut = false;
26+
var isAnimatingOut = false;
2727
var leavingPanel = null;
2828
var activelyAnimatingTimeout = false;
29-
var activelyAnimating = false;
29+
var isActivelyAnimating = false;
3030

3131
var panels = [];
3232
var panelElements = {};
3333
$scope.activePanel = null;
3434

3535
$scope.goToPanel = function (panelName, style) {
3636
if (panels.includes(panelName)) {
37-
activelyAnimating = true;
38-
$timeout(function () {
39-
isAnimatingForwards = style !== 'back';
40-
animateOut = false;
41-
leavingPanel = $scope.activePanel;
37+
isActivelyAnimating = style !== 'immediate';
38+
isAnimatingForwards = style !== 'back';
39+
isAnimatingOut = false;
40+
leavingPanel = $scope.activePanel;
4241

43-
// Quick move our elements to the right spot, then let them animate into place
44-
$timeout(function () {
45-
if (style !== 'immediate') {
46-
animateOut = true;
47-
$timeout.cancel(activelyAnimatingTimeout);
48-
activelyAnimatingTimeout = $timeout(function () {
49-
activelyAnimating = false;
50-
}, 300);
51-
}
52-
$scope.activePanel = panelName;
53-
}, 0);
42+
// Quick move our elements to the right spot, then let them animate into place
43+
$timeout(function () {
44+
if (style !== 'immediate') {
45+
isAnimatingOut = true;
46+
$timeout.cancel(activelyAnimatingTimeout);
47+
activelyAnimatingTimeout = $timeout(function () {
48+
isActivelyAnimating = false;
49+
}, 300);
50+
}
51+
$scope.activePanel = panelName;
5452
}, 0);
5553
} else {
56-
activelyAnimating = false;
54+
isActivelyAnimating = false;
5755
console.error('Tried going to panel that doesn\'t exist', panelName);
5856
}
5957
};
@@ -72,7 +70,7 @@ function animatedPanelContainer(
7270

7371
$scope.getAnimatedPanelStyle = function () {
7472
var inElement = panelElements[$scope.activePanel];
75-
if (!inElement || !activelyAnimating) {
73+
if (!inElement || !isActivelyAnimating) {
7674
return;
7775
}
7876
return {
@@ -91,8 +89,8 @@ function animatedPanelContainer(
9189
out: panelName !== $scope.activePanel,
9290
in: panelName === $scope.activePanel,
9391
back: !goingForwards,
94-
animated: animateOut,
95-
animating: activelyAnimating
92+
animated: isAnimatingOut,
93+
animating: isActivelyAnimating
9694
};
9795
};
9896

client/directives/modals/gracePeriodModal/forms/trialEndView.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@
3434
)
3535
.grid-block.justify-center.modal-outer-footer(
3636
grace-period-footer
37-
close = "WBC.close"
37+
close = "EAC.close"
3838
)

client/directives/modals/gracePeriodModal/welcomeBackController.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ function WelcomeBackController(
77
$rootScope
88
) {
99
var WBC = this;
10+
WBC.close = angular.noop;
1011

11-
$rootScope.dataApp = {
12-
gracePeriod: true
13-
};
12+
$rootScope.dataApp.gracePeriod = true;
1413
WBC.openIntercom = function () {
1514
window.Intercom(
1615
'showNewMessage',

client/directives/modals/settingsModal/forms/billingForm/billingForm.jade

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.modal-form.form-billing
2-
32
.spinner-wrapper.spinner-md.spinner-gray.in(
43
ng-include = "'spinner'"
54
ng-if = "$root.isLoading.billingForm"
@@ -27,7 +26,7 @@
2726

2827
.grid-block.vertical.form-plan.label.padding-sm.fade(
2928
ng-class = "{'in': isActivePanel()}"
30-
ng-include = "'showPlanForm'"
29+
show-plan-form
3130
ng-if = "!currentOrg.poppa.isInTrial() || (currentOrg.poppa.isInTrial() && currentOrg.poppa.attrs.hasPaymentMethod)"
3231
)
3332
.grid-block.vertical.label.padding-sm.fade(

client/directives/modals/settingsModal/forms/billingForm/billingFormDirective.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,35 @@
33
require('app').directive('billingForm', billingForm);
44

55
function billingForm(
6-
currentOrg
6+
currentOrg,
7+
keypather,
8+
fetchPaymentMethod,
9+
fetchPlan,
10+
fetchInvoices
711
) {
812
return {
913
restrict: 'A',
1014
templateUrl: 'billingForm',
11-
link: function ($scope, element) {
15+
link: function ($scope) {
1216
$scope.$on('$destroy', function () {
1317
$scope.SEMC.showFooter = true;
18+
fetchPaymentMethod.cache.clear();
19+
fetchPlan.cache.clear();
20+
fetchInvoices.cache.clear();
1421
});
1522
$scope.$on('changed-animated-panel', function (event, panelName) {
1623
$scope.SEMC.showFooter = panelName === 'billingForm';
1724
});
1825
$scope.$broadcast('go-to-panel', $scope.SEMC.subTab || 'billingForm', 'immediate');
1926
$scope.currentOrg = currentOrg;
27+
var startedWithPaymentMethod = keypather.get(currentOrg, 'poppa.attrs.hasPaymentMethod');
2028
$scope.actions = {
2129
save: function () {
22-
$scope.$broadcast('go-to-panel', 'confirmationForm');
30+
if (startedWithPaymentMethod) {
31+
$scope.$broadcast('go-to-panel', 'billingForm', 'back');
32+
} else {
33+
$scope.$broadcast('go-to-panel', 'confirmationForm');
34+
}
2335
},
2436
cancel: function () {
2537
$scope.$broadcast('go-to-panel', 'billingForm', 'back');

0 commit comments

Comments
 (0)