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
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