Skip to content

Instantly share code, notes, and snippets.

@finbarr
Last active December 18, 2015 03:08
Show Gist options
  • Save finbarr/5715934 to your computer and use it in GitHub Desktop.
Save finbarr/5715934 to your computer and use it in GitHub Desktop.
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