Class: PlaidRails::AccountsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- PlaidRails::AccountsController
- Defined in:
- app/controllers/plaid_rails/accounts_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
create new bank account and return all the accounts for the owner.
- #destroy ⇒ Object
- #index ⇒ Object
-
#new ⇒ Object
display list of accounts for authenticated user.
-
#stripe_token ⇒ Object
retreive the stripe token /accounts/:account_id/stripe_token.
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
create new bank account and return all the accounts for the owner
23 24 25 |
# File 'app/controllers/plaid_rails/accounts_controller.rb', line 23 def create @plaid_accounts = PlaidRails::CreateAccountService.call(account_params) end |
#destroy ⇒ Object
31 32 33 34 |
# File 'app/controllers/plaid_rails/accounts_controller.rb', line 31 def destroy @plaid_account = PlaidRails::Account.find(params[:id]) @plaid_account.destroy end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/plaid_rails/accounts_controller.rb', line 6 def index @plaid_accounts =PlaidRails::Account.where(owner_id: account_params[:owner_id]) end |
#new ⇒ Object
display list of accounts for authenticated user
11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/plaid_rails/accounts_controller.rb', line 11 def new client = Plaid::Client.new(env: PlaidRails.env, client_id: PlaidRails.client_id, secret: PlaidRails.secret, public_key: PlaidRails.public_key) response = client.accounts.get(account_params["access_token"]) @plaid_accounts = response.accounts end |
#stripe_token ⇒ Object
retreive the stripe token /accounts/:account_id/stripe_token
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/plaid_rails/accounts_controller.rb', line 38 def stripe_token plaid_account = PlaidRails::Account.find(params[:id]) client = Plaid::Client.new(env: PlaidRails.env, client_id: PlaidRails.client_id, secret: PlaidRails.secret, public_key: PlaidRails.public_key) stripe_response = client.processor.stripe.bank_account_token. create(plaid_account.access_token, plaid_account.plaid_id) bank_account_token = stripe_response['stripe_bank_account_token'] render json: {id: bank_account_token} end |
#update ⇒ Object
27 28 29 |
# File 'app/controllers/plaid_rails/accounts_controller.rb', line 27 def update end |