Last active
December 18, 2015 03:08
-
-
Save finbarr/5715934 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BankDetailsController < ApplicationController | |
before_filter :set_recipient | |
def show | |
end | |
def update | |
if @recipient.present? && @recipient.verified | |
update_bank_account | |
else | |
update_recipient | |
end | |
end | |
private | |
def set_recipient | |
@recipient = current_contractor.stripe_recipient | |
end | |
def update_bank_account | |
@recipient.bank_account = params.slice(:account_number, :routing_number).merge(:country => 'US') | |
@recipient.save | |
end | |
def update_recipient | |
if @recipient.nil? | |
@recipient = Stripe::Recipient.create( | |
params.slice(:name, :tax_id).merge(:type => 'individual') | |
) | |
current_contractor.stripe_recipient_id = @recipient.id | |
current_contractor.save! | |
else | |
@recipient.tax_id = params[:tax_id] | |
@recipient.name = params[:name] | |
@recipient.save | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment