arrow_backward Back to blog

Dwolla, An Alternative Payment Processor

At Intridea, we enjoy helping our customers create secure and functional marketplaces. From investigating and research to testing out the product, finding the best payment solution for our client is top priority.

Recently when looking for a replacement ACH payment processor we had an opportunity to do a deep dive into Dwolla and were pleasantly surprised! We worked through an initial integration with one of our Rails apps, and in this post I’ll share how you can do the same.

What is Dwolla?

According to their site:

Dwolla is a payment network that allows any business or person to send, request, and accept money. Unlike the big payment companies that rely on plastic cards and charge hefty fees, Dwolla built their own network that securely connects to your bank account and allows you to move money…

We chose to go with their OAuth + REST API method for integration, but this was one of many possible scenarios. Not only does Dwolla have multiple options for connecting and delivering payment requests, but (as is attractive to any developer) their documentation is clear and concise.

One aspect we’ve avoided in the past with systems like Dwolla, is forcing users to create full accounts prior to gaining access. Dwolla’s new “direct” offering allows users to proceed with an email address, password, and their bank’s website credentials only; saving time, effort and eliminating errors. You can see an example of their form builder here.

Connecting Dwolla to your rails app

Hundreds of people are leveraging the advantages of super simple, secure authentication with OmniAuth in their applications. This authentication route helps simplify login and allows you necessary access to Dwolla permissions.

First, let’s add the two gems in your Gemfile. Note: If you want to handle payments as well as incoming funds, add dwolla-ruby too.

gem 'omniauth-dwolla' gem 'dwolla-ruby'  

Next, configure omniauth-dwolla by adding the middleware to config/initializers/omniauth.rb and getting a token with scope permissions for full user info access and sending and requesting transactions:

Rails.application.config.middleware.use OmniAuth::Builder do   provider :dwolla, ENV['DWOLLA_KEY'], ENV['DWOLLA_SECRET'],    :scope => 'accountinfofull|send|request',   :client_options => {         :site => 'https://uat.dwolla.com',         :authorize_url => '/oauth/v2/authenticate',         :token_url => '/oauth/v2/token'       } end 

Finally, visit https://uat.dwolla.com (Dwolla’s sandbox which mirrors production) to create a testing account. The sandbox is full-featured, with everything you need in testing; transactions, activity logs, adding funds to test accounts, etc. Once you’ve registered for this test account, you’ll be able to retrieve user information from the Dwolla site when users create an account on the marketplace app. See below:

    "raw_info": {         "City": "New York",         "Id": "123-456-7890",         "Latitude": 41.584546,         "Longitude": -93.634167,         "Name": "Test User",         "State": "NY",         "Type": "Personal"     } 

Before we play with some functions, let’s set the secret and key for the app, located in your registered application panel. Remember to record your pin (shown below) for your reference. The pin ensures security for purchases both from your application and for individual purchasers.

# Dwolla Secret Stuff @api_key = 'ztRqeAYvw0B6KFezOuw161bbxWdrmEDPbWVWgETN086Mmj809y' @api_secret = 'knZgUVDlmqWLcao2e64xU+X/L+YMMMaeZQz8JjcFyA+aQgtyXt' @token = 'Bx3bmKWClyUZdLi3KnnQwXkAcOtJy7c/qAzV6oNaHdB0nXobCC' @pin = '1234' 

Using the Dwolla API

You should initiate a new Dwolla User client and seed a previously generated access token (see below) every time you want to call the API.

Dwolla::token = @token Dwolla::api_key = @api_key Dwolla::api_secret = @api_secret 

In order to handle transactions (you can try in rails console):

##### Send money ($1.00) to a Dwolla ID transactionId = Dwolla::Transactions.send({:destinationId => '812-626-8794', :amount => 1.00, :pin => @pin})  ##### Send money ($1.00) to an email address, with a note transactionId = Dwolla::Transactions.send({:destinationId => '812-626-8794', :destinationType => 'Email', :amount => 1.00, :pin => @pin, :notes => 'Everyone loves getting money'})  ##### Get details about a certain Transaction pp Dwolla::Transactions.get(transactionId)  

Handle funding sources.

Keep in mind, as the seller you can affect funding sources in Dwolla’s admin panel. We’ve found that you often need this to let the buyer update/add their bank information to Dwolla via your marketplace.

##### Fetch detailed information for the funding source with a specific ID pp Dwolla::FundingSources.get('some_funding_source_id')  ##### Deposit funds from a bank account into the Dwolla account balance. pp Dwolla::FundingSources.deposit('some_funding_source_id', {:amount => 30.05, :pin => @pin})  ##### Withdraw funds from a Dwolla account balance into bank account pp Dwolla::FundingSources.withdraw('some_funding_source_id', {:amount => 30.05, :pin => @pin})  ##### Add a new bank account. Possible values for account_type: "Checking" and "Savings" pp Dwolla::FundingSources.add({:routing_number => 1111111, :account_number => 1111111, :account_type => "Checking", :name => "Owner Name"})  

There are a multitude of ways to interact with the Dwolla API, and their documentation breaks it down for both developers and non-developers. There are tons more samples like I posted above, but what’s more important is to apply the functions correctly to your marketplace use case. Additional features can be found in their labs, click here for more surprises.

If you are looking for a payment gateway, I strongly recommend you use Dwolla. From all angles, it’s a complete and smoothly implemented choice. Got any questions? Let us know!

arrow_backBack

New Project Request













Top