class CashOut::Connect::Account::Create
Public Instance Methods
execute()
click to toggle source
# File lib/cash_out/connect/account/create.rb, line 23 def execute account = create_stripe_account user.stripe_id = account["id"] if account.is_a?(Stripe::Account) validate_and_save(user) end
Private Instance Methods
create_stripe_account()
click to toggle source
# File lib/cash_out/connect/account/create.rb, line 31 def create_stripe_account Stripe::Account.create(stripe_account_params) rescue *STRIPE_ERRORS => e errors.add(:stripe, e.to_s) end
legal_entity_must_be_present()
click to toggle source
# File lib/cash_out/connect/account/create.rb, line 81 def legal_entity_must_be_present missing_fields.each { |mf| errors.add(mf, I18n.t('cash_out.connect.is_required')) } end
legal_entity_params()
click to toggle source
# File lib/cash_out/connect/account/create.rb, line 55 def legal_entity_params { type: legal_entity_type, first_name: user.first_name, last_name: user.last_name, ssn_last_4: ssn_last_4, dob: { day: user.date_of_birth.day, month: user.date_of_birth.month, year: user.date_of_birth.year, }, address: { line1: legal_entity_address[:line1], line2: legal_entity_address[:line2], city: legal_entity_address[:city], state: legal_entity_address[:state], country: legal_entity_address[:country], postal_code: legal_entity_address[:postal_code] } } end
missing_fields()
click to toggle source
# File lib/cash_out/connect/account/create.rb, line 85 def missing_fields legal_entity_address.except(:line2).map do |key, value| key.to_sym if value.empty? end.compact end
no_existing_stripe_account()
click to toggle source
# File lib/cash_out/connect/account/create.rb, line 77 def no_existing_stripe_account errors.add(:stripe, I18n.t('cash_out.connect.account_already_exists')) if user.stripe_id.present? end
stripe_account_params()
click to toggle source
# File lib/cash_out/connect/account/create.rb, line 37 def stripe_account_params { type: "custom", country: "US", tos_acceptance: { date: Time.current.to_i, ip: ip_address, }, payout_schedule: { delay_days: 2, interval: "daily" }, debit_negative_balances: true, legal_entity: legal_entity_params, external_account: external_account_token } end