Funding source in transfer request body


(Arsen Ugliar) #1

I’m trying to implement money transactions by user’s email in my rails application using DwollaV2. The problem is I don’t really understand from the documentation what has to be a funding source in the request body and always getting error “Funding source not found”.

Steps I’m performing:

  1. Create Dwolla client with key & secret
  2. Get code from Auth
  3. Exchange code for a token, here’s how it looks:

#<DwollaV2::Token client=#<DwollaV2::Client id=“gjk6…” secret=“8XF…” environment=:sandbox> access_token="LQPX…"refresh_token=“jjLS…” expires_in=3590 scope=“send|fundings” account_id=“3481…”>

  1. Create request body:

     id = token.account_id
     email = test@gmail.com
    
     request_body = {
     _links: {
       destination: {
         email: "mailto:#{email}"
       },
       source: {
         href: "https://api.dwolla.com/funding-sources/#{id}"
       }
     },
     amount: {
       currency: 'USD',
       value: amount.to_s
     }
     }
    
  2. Perform POST request:
    Everything is done with sandbox Dwolla account

     token.post 'transfers', request_body
    

Would be grateful for any help or suggestions.


(Arsen Ugliar) #2

Problem solved


(Spencer Hunter) #3

@Arsen_Ugliar, Glad you were able to get your issue resolved! Your request body looks good to me with the exception of your key value you have specified as your destination. “email” should be “href”. i.e.

 destination: {
    href: "mailto:#{email}"
  }

(Arsen Ugliar) #4

Thanks, @spencer. I figured it but forgot to post the solution. Sorry :slight_smile: