class Iugu::HandleCallbacks::Referrals::BankVerification

Public Instance Methods

call() click to toggle source
# File lib/jera_payment/services/iugu/handle_callbacks/referrals/bank_verification.rb, line 5
def call
  super

  @sub_account = SubAccount.find_by(account_id: @params["data"]["account_id"])

  return 404 unless @sub_account.present?

  if @params["data"]["status"] == "accepted"
    change_current_household
  else
    delete_household(@sub_account.households.last)
  end

  return 200
end

Private Instance Methods

change_current_household() click to toggle source
# File lib/jera_payment/services/iugu/handle_callbacks/referrals/bank_verification.rb, line 23
def change_current_household
  last_household = @sub_account.households.last
  first_household = @sub_account.households.first

  @sub_account.update(current_household: last_household)

  delete_household(first_household)
end
delete_household(household) click to toggle source
# File lib/jera_payment/services/iugu/handle_callbacks/referrals/bank_verification.rb, line 32
def delete_household(household)
  household.destroy
end