From 226c20192524fb6b4f53d92f4e96d142fec5eb12 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 14 Aug 2017 10:21:08 -0400 Subject: [PATCH] bank account payment method for orgs --- ...anizationBillingChangePaymentController.js | 23 +- .../organizationBillingController.js | 15 +- ...organizationBillingVerifyBankController.js | 25 + .../views/organizationBilling.html | 9 + .../views/organizationBillingVerifyBank.html | 43 ++ src/app/services/apiService.js | 1 + .../settingsBillingChangePaymentController.js | 1 + .../settingsCreateOrganizationController.js | 20 +- src/app/settings/settingsPremiumController.js | 3 +- .../views/settingsBillingChangePayment.html | 57 +- .../views/settingsCreateOrganization.html | 727 ++++++++++-------- src/app/settings/views/settingsPremium.html | 4 +- src/index.html | 1 + 13 files changed, 587 insertions(+), 342 deletions(-) create mode 100644 src/app/organization/organizationBillingVerifyBankController.js create mode 100644 src/app/organization/views/organizationBillingVerifyBank.html diff --git a/src/app/organization/organizationBillingChangePaymentController.js b/src/app/organization/organizationBillingChangePaymentController.js index 7893ac308d..3f40c3dc57 100644 --- a/src/app/organization/organizationBillingChangePaymentController.js +++ b/src/app/organization/organizationBillingChangePaymentController.js @@ -6,11 +6,30 @@ $analytics.eventTrack('organizationBillingChangePaymentController', { category: 'Modal' }); $scope.existingPaymentMethod = existingPaymentMethod; $scope.paymentMethod = 'card'; - $scope.showPaymentOptions = false; + $scope.showPaymentOptions = true; + $scope.hidePaypal = true; $scope.card = {}; + $scope.bank = {}; + + $scope.changePaymentMethod = function (val) { + $scope.paymentMethod = val; + }; $scope.submit = function () { - $scope.submitPromise = stripe.card.createToken($scope.card).then(function (response) { + var stripeReq = null; + if ($scope.paymentMethod === 'card') { + stripeReq = stripe.card.createToken($scope.card); + } + else if ($scope.paymentMethod === 'bank') { + $scope.bank.currency = 'USD'; + $scope.bank.country = 'US'; + stripeReq = stripe.bankAccount.createToken($scope.bank); + } + else { + return; + } + + $scope.submitPromise = stripeReq.then(function (response) { var request = { paymentToken: response.id }; diff --git a/src/app/organization/organizationBillingController.js b/src/app/organization/organizationBillingController.js index c44d6b34d0..2eb06dd07c 100644 --- a/src/app/organization/organizationBillingController.js +++ b/src/app/organization/organizationBillingController.js @@ -80,6 +80,18 @@ }); }; + $scope.verifyBank = function () { + var modal = $uibModal.open({ + animation: true, + templateUrl: 'app/organization/views/organizationBillingVerifyBank.html', + controller: 'organizationBillingVerifyBankController' + }); + + modal.result.then(function () { + load(); + }); + }; + $scope.cancel = function () { if (!confirm('Are you sure you want to cancel? All users will lose access to the organization ' + 'at the end of this billing cycle.')) { @@ -167,7 +179,8 @@ $scope.paymentSource = { type: org.PaymentSource.Type, description: org.PaymentSource.Description, - cardBrand: org.PaymentSource.CardBrand + cardBrand: org.PaymentSource.CardBrand, + needsVerification: org.PaymentSource.NeedsVerification }; } diff --git a/src/app/organization/organizationBillingVerifyBankController.js b/src/app/organization/organizationBillingVerifyBankController.js new file mode 100644 index 0000000000..9489ebbc58 --- /dev/null +++ b/src/app/organization/organizationBillingVerifyBankController.js @@ -0,0 +1,25 @@ +angular + .module('bit.organization') + + .controller('organizationBillingVerifyBankController', function ($scope, $state, $uibModalInstance, apiService, + $analytics, toastr) { + $analytics.eventTrack('organizationBillingVerifyBankController', { category: 'Modal' }); + + $scope.submit = function () { + var request = { + amount1: $scope.amount1, + amount2: $scope.amount2 + }; + + $scope.submitPromise = apiService.organizations.postVerifyBank({ id: $state.params.orgId }, request) + .$promise.then(function (response) { + $analytics.eventTrack('Verified Bank Account'); + toastr.success('You have successfully verified your bank account.'); + $uibModalInstance.close(); + }); + }; + + $scope.close = function () { + $uibModalInstance.dismiss('cancel'); + }; + }); diff --git a/src/app/organization/views/organizationBilling.html b/src/app/organization/views/organizationBilling.html index 843111ea5f..81f7803a84 100644 --- a/src/app/organization/views/organizationBilling.html +++ b/src/app/organization/views/organizationBilling.html @@ -140,6 +140,15 @@ No payment method on file.
+
+

You must verify your bank account

+

+ We have made two micro-deposits to your bank account (it may take 1-2 business days to show up). + Enter these amounts to verify the bank account. Failure to verify the bank account will result in a + missed payment and your organization being disabled. +

+ +
{{paymentSource.description}} diff --git a/src/app/organization/views/organizationBillingVerifyBank.html b/src/app/organization/views/organizationBillingVerifyBank.html new file mode 100644 index 0000000000..7ee01a3ffd --- /dev/null +++ b/src/app/organization/views/organizationBillingVerifyBank.html @@ -0,0 +1,43 @@ + +
+ + +
diff --git a/src/app/services/apiService.js b/src/app/services/apiService.js index 4cba765e61..9bbb961ecb 100644 --- a/src/app/services/apiService.js +++ b/src/app/services/apiService.js @@ -69,6 +69,7 @@ putCancel: { url: _apiUri + '/organizations/:id/cancel', method: 'POST', params: { id: '@id' } }, putReinstate: { url: _apiUri + '/organizations/:id/reinstate', method: 'POST', params: { id: '@id' } }, postLeave: { url: _apiUri + '/organizations/:id/leave', method: 'POST', params: { id: '@id' } }, + postVerifyBank: { url: _apiUri + '/organizations/:id/verify-bank', method: 'POST', params: { id: '@id' } }, del: { url: _apiUri + '/organizations/:id/delete', method: 'POST', params: { id: '@id' } } }); diff --git a/src/app/settings/settingsBillingChangePaymentController.js b/src/app/settings/settingsBillingChangePaymentController.js index 0fa6419ef4..62a8d8bb0b 100644 --- a/src/app/settings/settingsBillingChangePaymentController.js +++ b/src/app/settings/settingsBillingChangePaymentController.js @@ -8,6 +8,7 @@ $scope.paymentMethod = 'card'; $scope.dropinLoaded = false; $scope.showPaymentOptions = false; + $scope.hideBank = true; $scope.card = {}; var btInstance = null; diff --git a/src/app/settings/settingsCreateOrganizationController.js b/src/app/settings/settingsCreateOrganizationController.js index 42f7bcf240..42d4c5c4ce 100644 --- a/src/app/settings/settingsCreateOrganizationController.js +++ b/src/app/settings/settingsCreateOrganizationController.js @@ -5,6 +5,7 @@ toastr, $analytics, authService, stripe, constants) { $scope.plans = constants.plans; $scope.storageGb = constants.storageGb; + $scope.paymentMethod = 'card'; $scope.model = { plan: 'free', @@ -27,6 +28,10 @@ } }; + $scope.changePaymentMethod = function (val) { + $scope.paymentMethod = val; + }; + $scope.changedPlan = function () { if ($scope.plans[$scope.model.plan].hasOwnProperty('monthPlanType')) { $scope.model.interval = 'year'; @@ -61,7 +66,20 @@ $scope.submitPromise = apiService.organizations.post(freeRequest).$promise.then(finalizeCreate); } else { - $scope.submitPromise = stripe.card.createToken(model.card).then(function (response) { + var stripeReq = null; + if ($scope.paymentMethod === 'card') { + stripeReq = stripe.card.createToken(model.card); + } + else if ($scope.paymentMethod === 'bank') { + model.bank.currency = 'USD'; + model.bank.country = 'US'; + stripeReq = stripe.bankAccount.createToken(model.bank); + } + else { + return; + } + + $scope.submitPromise = stripeReq.then(function (response) { var paidRequest = { name: model.name, planType: model.interval === 'month' ? $scope.plans[model.plan].monthPlanType : diff --git a/src/app/settings/settingsPremiumController.js b/src/app/settings/settingsPremiumController.js index 9305521bc5..a24c52a191 100644 --- a/src/app/settings/settingsPremiumController.js +++ b/src/app/settings/settingsPremiumController.js @@ -21,7 +21,8 @@ additionalStorageGb: null }; - $scope.changePaymentMethod = function () { + $scope.changePaymentMethod = function (val) { + $scope.paymentMethod = val; if ($scope.paymentMethod !== 'paypal') { return; } diff --git a/src/app/settings/views/settingsBillingChangePayment.html b/src/app/settings/views/settingsBillingChangePayment.html index c2c907ef51..df496cfb57 100644 --- a/src/app/settings/views/settingsBillingChangePayment.html +++ b/src/app/settings/views/settingsBillingChangePayment.html @@ -14,19 +14,72 @@
-
+
+
+

You must verify your bank account

+

+ Payment with a bank account is only available to customers in the United States. + You will be required to verify your bank account. We will make two micro-deposits within the next + 1-2 business days. Enter these amounts in the organization's billing area to verify the bank account. + Failure to verify the bank account will result in a missed payment and your organization being + disabled. +

+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
+
+
+
diff --git a/src/app/settings/views/settingsCreateOrganization.html b/src/app/settings/views/settingsCreateOrganization.html index 260d0295f0..62091eb963 100644 --- a/src/app/settings/views/settingsCreateOrganization.html +++ b/src/app/settings/views/settingsCreateOrganization.html @@ -256,347 +256,408 @@

Payment Information

-
-
-
- - + + +
+
+
+

You must verify your bank account

+

+ Payment with a bank account is only available to customers in the United States. + You will be required to verify your bank account. We will make two micro-deposits within the next + 1-2 business days. Enter these amounts in the organization's billing area to verify the bank account. + Failure to verify the bank account will result in a missed payment and your organization being + disabled. +

+
+
+
+
+ + +
+
+
+
+ + +
-
- -
    -
  • -
  • -
  • -
  • -
  • -
  • -
-
-
-
-
-
- - +
+
+
+ + +
-
-
-
- - -
-
-
-
- - +
+
+ + +
-
-
-
- - +
+
+
+
+ + +
+
+
+ +
    +
  • +
  • +
  • +
  • +
  • +
  • +
-
-
- - +
+
+
+ + +
+
+
+
+ + +
+
+
+
+ + +
+
+
+
+
+
+ + +
+
+
+
+ + +
diff --git a/src/app/settings/views/settingsPremium.html b/src/app/settings/views/settingsPremium.html index fa2fed96b1..cef7af7c19 100644 --- a/src/app/settings/views/settingsPremium.html +++ b/src/app/settings/views/settingsPremium.html @@ -114,11 +114,11 @@

diff --git a/src/index.html b/src/index.html index b422c5ca68..ba7e63ffb9 100644 --- a/src/index.html +++ b/src/index.html @@ -204,6 +204,7 @@ +