Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dima@dima-Aspire-ES1-512:~/rails_project/accountdock-rails-master$ git diff
- diff --git a/app/controllers/team/home_controller.rb b/app/controllers/team/home_controller.rb
- index 06eb213..d7e064d 100644
- --- a/app/controllers/team/home_controller.rb
- +++ b/app/controllers/team/home_controller.rb
- @@ -5,7 +5,7 @@ class Team::HomeController < Team::BaseController
- @stripeCustomers = current_account.stripe_customers_estimate
- @setting = current_account.setting
- - @connection = current_account.connections.first
- + @connections = current_account.connections
- # Graphs
- @customer_delinquents = current_account.customers.delinquent.group_by_month("customers.updated_at", last: 12, format: "%b %Y").count
- diff --git a/app/helpers/team_helper.rb b/app/helpers/team_helper.rb
- index 362225e..4754cdf 100644
- --- a/app/helpers/team_helper.rb
- +++ b/app/helpers/team_helper.rb
- @@ -33,7 +33,7 @@ module TeamHelper
- disputes_count
- end
- - def vendor_name
- - current_account.connections.first.vendor.capitalize
- + def vendor_name(connection)
- + connection.vendor.capitalize
- end
- end
- diff --git a/app/models/account.rb b/app/models/account.rb
- index 5e79c52..4de1172 100644
- --- a/app/models/account.rb
- +++ b/app/models/account.rb
- @@ -131,13 +131,13 @@ class Account < ActiveRecord::Base
- # Add a Stripe connection
- def add_connection(params)
- - if self.connections.blank?
- + if self.connections.find_by(type: params[BraintreeConnection]).blank?
- self.connections.create(params)
- # Queue an initial sync of Stripe data to our local DB so Customers, etc show in
- # our UI and can be used for queries on expiry, etc.
- AccountSyncJob.perform_later(self) unless self.connections.first.try(:synced)
- else
- - self.connection.update_attributes!(params)
- + self.connections.first.update_attributes!(params)
- end
- end
- diff --git a/app/services/braintree_services/sync_service.rb b/app/services/braintree_services/sync_service.rb
- index ccd1e6f..9e1ee2d 100644
- --- a/app/services/braintree_services/sync_service.rb
- +++ b/app/services/braintree_services/sync_service.rb
- @@ -1,5 +1,7 @@
- class BraintreeServices::SyncService < SharedServices::BaseSyncService
- +
- private
- +
- def sync_customers
- sync_message('Customers')
- diff --git a/app/views/team/home/index.html.haml b/app/views/team/home/index.html.haml
- index ff2b82a..fff9f7b 100644
- --- a/app/views/team/home/index.html.haml
- +++ b/app/views/team/home/index.html.haml
- @@ -24,202 +24,209 @@
- .progress.progress-striped.active
- .progress-bar.progress-bar-success{'role' => 'progressbar', 'aria-valuenow' => "#{@percentage}", 'aria-valuemin' => '0', 'aria-v
- = "#{@percentage} % Complete"
- +
- %section.setup-steps
- .row
- - .col-lg-9
- - .panel.panel-default
- - %a.panel-body
- - %i.fa.fa-check.step-complete
- - Connect #{vendor_name} account
- - %span.label.label-primary
- - Authenticated as:
- - %strong
- - = @setting.display_name
- - on #{vendor_name}
- - %a.btn.btn-grey.btn-sm.pull-right.step-expand{'data-original' => 'Details'} Details
- - .step-content
- - %ul.stripe-connected-details
- - %li
- - %i.fa.fa-eye
- - You have granted AccountDock
- - %strong #{@connection.scope_in_words}
- - access
- -
- - %li
- - %i.fa.fa-users
- - Detected
- + - @connections.each do |connection|
- + .col-lg-9
- + .panel.panel-default
- + %a.panel-body
- + %i.fa.fa-check.step-complete
- + Connect #{vendor_name(connection)} account
- + %span.label.label-primary
- + Authenticated as:
- %strong
- - = @stripeCustomers
- - customers
- + = @setting.display_name
- + on #{vendor_name(connection)}
- + %a.btn.btn-grey.btn-sm.pull-right.step-expand{'data-original' => 'Details'} Details
- + .step-content
- + %ul.stripe-connected-details
- + %li
- + %i.fa.fa-eye
- + You have granted AccountDock
- + %strong #{connection.scope_in_words}
- + access
- +
- + %li
- + %i.fa.fa-users
- + Detected
- + %strong
- + = @stripeCustomers
- + customers
- +
- .row
- - .col-lg-9
- - .panel.panel-default
- - %a.panel-body
- - - if current_account.synced?
- - %i.fa.fa-check.step-complete
- - - else
- - %i.fa.fa-refresh.step-incomplete
- - Synchronizing with #{vendor_name}...
- - %a.btn.btn-grey.btn-sm.pull-right.step-expand{'data-original' => 'Details'} Details
- - .step-content
- - %ul.stripe-connected-details
- - %li
- - %i.fa.fa-warning
- - AccountDock is synchronizing with #{vendor_name} to generate pre-dunning, dunning and dispute notifications. These are confi
- + - @connections.each do |connection|
- + .col-lg-9
- + .panel.panel-default
- + %a.panel-body
- + - if current_account.synced?
- + %i.fa.fa-check.step-complete
- + - else
- + %i.fa.fa-refresh.step-incomplete
- + Synchronizing with #{vendor_name(connection)}...
- + %a.btn.btn-grey.btn-sm.pull-right.step-expand{'data-original' => 'Details'} Details
- + .step-content
- + %ul.stripe-connected-details
- + %li
- + %i.fa.fa-warning
- + AccountDock is synchronizing with #{vendor_name(connection)} to generate pre-dunning, dunning and dispute notifications. T
- +
- .row
- - .col-lg-9
- - .panel.panel-default
- - %a.panel-body
- - - if current_account.installed?
- - %i.fa.fa-check.step-complete
- - - else
- - %i.fa.fa-warning.step-incomplete
- - Place embed code in your application
- - %a.btn.btn-grey.btn-sm.pull-right.step-expand{'data-original' => 'Instructions'} Instructions
- + - @connections.each do |connection|
- + .col-lg-9
- + .panel.panel-default
- + %a.panel-body
- + - if current_account.installed?
- + %i.fa.fa-check.step-complete
- + - else
- + %i.fa.fa-warning.step-incomplete
- + Place embed code in your application
- + %a.btn.btn-grey.btn-sm.pull-right.step-expand{'data-original' => 'Instructions'} Instructions
- - .step-content.embed-step-content
- - %ul.nav.nav-tabs
- - %li.active{:role => 'presentation'}
- - = link_to 'Modal/Window Button', '#modal-window-embed', {'aria-controls' => 'home', :role => 'tab', 'data-toggle' => 'tab'}
- - %li{:role => 'presentation'}
- - = link_to 'Inline', '#inline-embed', {'aria-controls' => 'profile', :role => 'tab', 'data-toggle' => 'tab'}
- - .tab-content
- - .tab-pane.active#modal-window-embed{:role => 'tabpanel'}
- - %h3
- - Modal/Window Button
- - = link_to team_customization_path, class: 'customize-link' do
- - %i.fa.fa-paint-brush
- - Customize
- - %ol.quick-setup-steps.circles-list
- - %li
- - Place the AccountDock script after jQuery is loaded on your page.
- - .highlight
- - %pre
- - %code.language-html{'data-lang' => "html"}
- - = preserve do
- - :escaped
- - <script src="https://static.accountdock.com/app.min.js"></script>
- - %li
- - Place the following code into your javascript file or on the page where you'd like the AccountDock button to appear. (No
- - .highlight
- - %pre
- - %code.language-html{'data-lang' => "html"}
- - = preserve do
- - :escaped
- - <script type="text/javascript">
- - var handler = AccountDock.configure({
- - key: '#{current_account.public_key}',
- - customer: 'YOUR_STRIPE_CUSTOMER_ID'
- - });
- - $(function(){
- - $('#billing').on(
- - 'click',
- - function(event) {
- - event.preventDefault();
- - handler.open();
- - }
- - );
- - });
- - </script>
- + .step-content.embed-step-content
- + %ul.nav.nav-tabs
- + %li.active{:role => 'presentation'}
- + = link_to 'Modal/Window Button', '#modal-window-embed', {'aria-controls' => 'home', :role => 'tab', 'data-toggle' => 'tab'
- + %li{:role => 'presentation'}
- + = link_to 'Inline', '#inline-embed', {'aria-controls' => 'profile', :role => 'tab', 'data-toggle' => 'tab'}
- + .tab-content
- + .tab-pane.active#modal-window-embed{:role => 'tabpanel'}
- + %h3
- + Modal/Window Button
- + = link_to team_customization_path, class: 'customize-link' do
- + %i.fa.fa-paint-brush
- + Customize
- + %ol.quick-setup-steps.circles-list
- %li
- - Wherever you want the billing history button to appear on the page, add the markup that will trigger AccountDock to ap
- + Place the AccountDock script after jQuery is loaded on your page.
- .highlight
- %pre
- %code.language-html{'data-lang' => "html"}
- = preserve do
- :escaped
- - <button id="billing">View Billing</button>
- + <script src="https://static.accountdock.com/app.min.js"></script>
- + %li
- + Place the following code into your javascript file or on the page where you'd like the AccountDock button to appear. (
- + .highlight
- + %pre
- + %code.language-html{'data-lang' => "html"}
- + = preserve do
- + :escaped
- + <script type="text/javascript">
- + var handler = AccountDock.configure({
- + key: '#{current_account.public_key}',
- + customer: 'YOUR_STRIPE_CUSTOMER_ID'
- + });
- + $(function(){
- + $('#billing').on(
- + 'click',
- + function(event) {
- + event.preventDefault();
- + handler.open();
- + }
- + );
- + });
- + </script>
- + %li
- + Wherever you want the billing history button to appear on the page, add the markup that will trigger AccountDock to
- + .highlight
- + %pre
- + %code.language-html{'data-lang' => "html"}
- + = preserve do
- + :escaped
- + <button id="billing">View Billing</button>
- +
- + %p{style: "color: #74c274;"}
- + %strong>Note:</strong>
- + Email receipt notifications are off by default. To enable them, visit the customizations area
- + .tab-pane#inline-embed{:role => 'tabpanel'}
- + %h3
- + Inline Embed
- + = link_to team_customization_path, class: 'customize-link' do
- + %i.fa.fa-paint-brush
- + Customize
- + %ol.quick-setup-steps.circles-list
- + %li
- + Place the AccountDock script after jQuery is loaded on your page.
- + .highlight
- + %pre
- + %code.language-html{'data-lang' => "html"}
- + = preserve do
- + :escaped
- + <script src="https://static.accountdock.com/app.min.js"></script>
- + %li
- + Place the following code into your javascript file or on the page where you'd like the AccountDock button to appear. (
- + .highlight
- + %pre
- + %code.language-html{'data-lang' => "html"}
- + =preserve do
- + :escaped
- + <script type="text/javascript">
- + var handler = AccountDock.configure({
- + key: '#{current_account.public_key}',
- + customer: 'YOUR_STRIPE_CUSTOMER_ID'
- + });
- + $(function() {
- + handler.open({
- + container: '#inlineBillingWrapper'
- + });
- + });
- + </script>
- + %li
- + Wherever you want the billing history widget to appear on the page, add a container with the appropriate ID.
- + .highlight
- + %pre
- + %code.language-html{'data-lang' => "html"}
- + =preserve do
- + :escaped
- + <div id="inlineBillingWrapper"></div>
- + %br
- + %em Optionally
- + , add in default styles for the container while the application loads:
- + .highlight
- + %pre
- + %code.language-html{'data-lang' => "html"}
- + =preserve do
- + :escaped
- + #inlineBillingWrapper {
- + border: 1px solid #e0e0e0;
- + max-width: 940px;
- + box-sizing: content-box;
- + background-image: url('//i.imgur.com/uM2gq.gif');
- + background-position: center center;
- + background-repeat: no-repeat;
- + min-height: 100px;
- + background-color: #fff;
- + }
- %p{style: "color: #74c274;"}
- %strong>Note:</strong>
- Email receipt notifications are off by default. To enable them, visit the customizations area
- - .tab-pane#inline-embed{:role => 'tabpanel'}
- - %h3
- - Inline Embed
- - = link_to team_customization_path, class: 'customize-link' do
- - %i.fa.fa-paint-brush
- - Customize
- - %ol.quick-setup-steps.circles-list
- - %li
- - Place the AccountDock script after jQuery is loaded on your page.
- - .highlight
- - %pre
- - %code.language-html{'data-lang' => "html"}
- - = preserve do
- - :escaped
- - <script src="https://static.accountdock.com/app.min.js"></script>
- - %li
- - Place the following code into your javascript file or on the page where you'd like the AccountDock button to appear. (No
- - .highlight
- - %pre
- - %code.language-html{'data-lang' => "html"}
- - =preserve do
- - :escaped
- - <script type="text/javascript">
- - var handler = AccountDock.configure({
- - key: '#{current_account.public_key}',
- - customer: 'YOUR_STRIPE_CUSTOMER_ID'
- - });
- - $(function() {
- - handler.open({
- - container: '#inlineBillingWrapper'
- - });
- - });
- - </script>
- - %li
- - Wherever you want the billing history widget to appear on the page, add a container with the appropriate ID.
- - .highlight
- - %pre
- - %code.language-html{'data-lang' => "html"}
- - =preserve do
- - :escaped
- - <div id="inlineBillingWrapper"></div>
- - %br
- - %em Optionally
- - , add in default styles for the container while the application loads:
- - .highlight
- - %pre
- - %code.language-html{'data-lang' => "html"}
- - =preserve do
- - :escaped
- - #inlineBillingWrapper {
- - border: 1px solid #e0e0e0;
- - max-width: 940px;
- - box-sizing: content-box;
- - background-image: url('//i.imgur.com/uM2gq.gif');
- - background-position: center center;
- - background-repeat: no-repeat;
- - min-height: 100px;
- - background-color: #fff;
- - }
- -
- - %p{style: "color: #74c274;"}
- - %strong>Note:</strong>
- - Email receipt notifications are off by default. To enable them, visit the customizations area
- %p
- %strong Not quite ready to embed in your application?
- Check out the #{link_to 'customers', team_customers_path} page to see what your customers will see.
- %section.action-items
- .row
- - .col-lg-9
- - .panel.panel-default
- - %i.fa.fa-warning.step-incomplete
- - %div
- - %p These items require your attention:
- - %ul
- - - if current_account.customers.delinquent.count > 0
- - %li You have #{link_to "#{current_account.customers.delinquent.count} / #{current_account.customers.count} customers", team_
- - - if current_account.customers.missing_email.count > 0
- - %li You have #{link_to "#{current_account.customers.missing_email.count} / #{current_account.customers.count} customers", te
- - - if current_account.disputes.opened.count > 0
- - %li
- - You have #{link_to "#{current_account.disputes.opened.count} / #{current_account.disputes_count} disputes", team_disputes_
- - - if current_account.disputes_count > 0
- - %p
- - - group_disputes_for_count(current_account).each do |status, count|
- - -if count > 0
- - %span.label.label-primary #{status} : #{count}
- + - @connections.each do |connection|
- + .col-lg-9
- + .panel.panel-default
- + %i.fa.fa-warning.step-incomplete
- + %div
- + %p These items require your attention:
- + %ul
- + - if current_account.customers.delinquent.count > 0
- + %li You have #{link_to "#{current_account.customers.delinquent.count} / #{current_account.customers.count} customers", tea
- + - if current_account.customers.missing_email.count > 0
- + %li You have #{link_to "#{current_account.customers.missing_email.count} / #{current_account.customers.count} customers",
- + - if current_account.disputes.opened.count > 0
- + %li
- + You have #{link_to "#{current_account.disputes.opened.count} / #{current_account.disputes_count} disputes", team_dispute
- + - if current_account.disputes_count > 0
- + %p
- + - group_disputes_for_count(current_account).each do |status, count|
- + -if count > 0
- + %span.label.label-primary #{status} : #{count}
- %section.charts
- .row
- .col-lg-9
- diff --git a/lib/stripe_client.rb b/lib/stripe_client.rb
- index 5d20dac..82014f3 100644
- --- a/lib/stripe_client.rb
- +++ b/lib/stripe_client.rb
- @@ -83,7 +83,7 @@ class StripeClient
- customer.save
- end
- - def create_subscription_for_plan (customer_id, plan_id)
- + def create_subscription_for_plan(customer_id, plan_id)
- customer = self.customer(customer_id)
- customer.subscriptions.create({plan: plan_id})
- end
- @@ -95,7 +95,8 @@ class StripeClient
- end
- private
- - def client
- +
- + def self.client
- @client ||= OAuth2::Client.new(
- config[:stripe_client_id],
- config[:stripe_api_key],
- @@ -107,7 +108,7 @@ class StripeClient
- ).auth_code
- end
- - def self.config(name)
- - Rails.application.secrets[name]
- + def self.config
- + Rails.application.secrets
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment