Dwolla / dwolla-v2-ruby

Official Ruby Wrapper for Dwolla's API v2
https://developers.dwolla.com/
MIT License
22 stars 17 forks source link

DateOfBirth value not allowed #22

Closed gentle-noah closed 6 years ago

gentle-noah commented 7 years ago

I am testing this on heroku in my staging env which matches key for key with production. I am running everything using sandbox for Dwolla, but keep getting this same issue.

Here is there service class I am using, the error is getting triggered by this line: customer = @access_token.post 'customers', request_body

Any clue as to why this might be happening?

# Service for managing Dwolla customers
class DwollaCustomer
  def initialize(params)
    @dwolla = set_dwolla_instance
    @user = params[:user]
    @access_token = @dwolla.auths.client
  end

  def create
    customer = @access_token.post 'customers', request_body
    @user.update_attributes(dwolla_url: customer.headers[:location])
  end

  def funding_sources
    return unless @user.merchant? || @user.dwolla_url.nil?
    sources = @access_token.get "#{@user.dwolla_url}/funding-sources"
    sources._embedded['funding-sources']
  end

  private

  def request_body
    {
      firstName: @user.first_name,
      lastName: @user.last_name,
      businessName: @user.business_name,
      email: @user.email,
      type: 'personal',
      address1: @user.street_address,
      city: @user.city,
      state: @user.state,
      postalCode: @user.zipcode,
      dateOfBirth: @user.dob.strftime('%Y-%m-%d').to_s,
      ssn: @user.ssn.last(4)
    }
  end

  def set_dwolla_instance
    @dwolla = DwollaV2::Client.new(key: ENV['dwolla_key'], secret: ENV['dwolla_secret']) do |config|
      config.environment = ENV['dwolla_env'].to_sym
    end
  end
end

Here is the entire error produced:

DwollaV2::ValidationError: {"code"=>"ValidationError", "message"=>"Validation error(s) present. See embedded errors list for more details.", "_embedded"=>{"errors"=>[{"code"=>"NotAllowed", "message"=>"DateOfBirth value not allowed.", "path"=>"/dateOfBirth", "_links"=>{}}]}}

ajbraus commented 2 years ago

What was the solution to this? I'm getting the same error.

spencerhunter commented 2 years ago

Hi @ajbraus , do you have your account ID for your Dwolla Account? We can take a look in our logs to see what value is getting sent to us.